minerender 2.1.0-alpha.31 → 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 +185 -154
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +73 -42
- package/dist/browser/index.mjs.map +1 -1
- package/dist/bundle.js +119 -88
- 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 +185 -154
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +73 -42
- package/dist/node/index.mjs.map +1 -1
- package/package.json +2 -1
package/dist/browser/index.js
CHANGED
|
@@ -483,19 +483,19 @@ function isDisposable(obj) {
|
|
|
483
483
|
var import_three2 = require("three");
|
|
484
484
|
|
|
485
485
|
// src/util/util.ts
|
|
486
|
-
var
|
|
486
|
+
var import_crypto_js = __toESM(require("crypto-js"));
|
|
487
487
|
var changeEvent = { type: "change" };
|
|
488
488
|
function md5(str) {
|
|
489
|
-
return
|
|
489
|
+
return import_crypto_js.default.MD5(str).toString(import_crypto_js.default.enc.Hex);
|
|
490
490
|
}
|
|
491
491
|
function sha1(str) {
|
|
492
|
-
return
|
|
492
|
+
return import_crypto_js.default.SHA1(str).toString(import_crypto_js.default.enc.Hex);
|
|
493
493
|
}
|
|
494
494
|
function sha256(str) {
|
|
495
|
-
return
|
|
495
|
+
return import_crypto_js.default.SHA256(str).toString(import_crypto_js.default.enc.Hex);
|
|
496
496
|
}
|
|
497
497
|
function sha512(str) {
|
|
498
|
-
return
|
|
498
|
+
return import_crypto_js.default.SHA512(str).toString(import_crypto_js.default.enc.Hex);
|
|
499
499
|
}
|
|
500
500
|
function base64encode(str) {
|
|
501
501
|
if (typeof btoa !== "undefined") {
|
|
@@ -2879,26 +2879,40 @@ var Entities = class {
|
|
|
2879
2879
|
};
|
|
2880
2880
|
return collect("");
|
|
2881
2881
|
}
|
|
2882
|
-
static async
|
|
2882
|
+
static async getModelFile(modelKey) {
|
|
2883
2883
|
const path = isAssetKey(modelKey) ? modelKey.getFullPath() : modelKey.path;
|
|
2884
2884
|
const key = new AssetKey(modelKey.namespace, path, void 0, void 0, "entity-models", ".json");
|
|
2885
|
-
|
|
2885
|
+
return Caching.entityModelCache.get(key.serialize(), () => AssetLoader.get(key, "json" /* JSON */));
|
|
2886
|
+
}
|
|
2887
|
+
static async getLayerList(modelKey) {
|
|
2888
|
+
return Object.keys((await this.getModelFile(modelKey))?.layers ?? {});
|
|
2889
|
+
}
|
|
2890
|
+
static async getEntity(modelKey, textureKey, options) {
|
|
2891
|
+
const model = await this.getModelFile(modelKey);
|
|
2886
2892
|
if (!model) return void 0;
|
|
2887
|
-
const
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2893
|
+
const names = [...new Set(options?.layers ?? [options?.layer ?? "main"])];
|
|
2894
|
+
if (names.length === 0) throw new MineRenderError(`Entity ${model.id} requires at least one layer`);
|
|
2895
|
+
const selected = names.map((name) => {
|
|
2896
|
+
const layer = model.layers[name];
|
|
2897
|
+
if (!layer) {
|
|
2898
|
+
throw new MineRenderError(`Entity ${model.id} has no layer "${name}". Available layers: ${Object.keys(model.layers).join(", ")}`);
|
|
2899
|
+
}
|
|
2900
|
+
return { name, layer };
|
|
2901
|
+
});
|
|
2902
|
+
const layers = Object.fromEntries(await Promise.all(selected.map(async ({ name, layer }, index) => {
|
|
2903
|
+
const override = options?.textures?.[name] ?? (index === 0 ? textureKey : void 0);
|
|
2904
|
+
let texture;
|
|
2905
|
+
if (override) {
|
|
2906
|
+
const path = isAssetKey(override) ? override.getFullPath() : override.path;
|
|
2907
|
+
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);
|
|
2908
|
+
} else if (layer.textureLocation !== void 0) {
|
|
2909
|
+
texture = AssetKey.parse("textures", layer.textureLocation.replace(/^([^:]+:)?textures\//, "$1"));
|
|
2910
|
+
} else {
|
|
2911
|
+
texture = await this.resolveTexture(modelKey);
|
|
2912
|
+
}
|
|
2913
|
+
return [name, { key: override ?? modelKey, texture, layer }];
|
|
2914
|
+
})));
|
|
2915
|
+
return { ...layers[names[0]], id: model.id, layers };
|
|
2902
2916
|
}
|
|
2903
2917
|
static async resolveTexture(modelKey) {
|
|
2904
2918
|
const path = isAssetKey(modelKey) ? modelKey.getFullPath() : modelKey.path;
|
|
@@ -3363,9 +3377,21 @@ var _EntityObject = class _EntityObject extends SceneObject {
|
|
|
3363
3377
|
dispose() {
|
|
3364
3378
|
super.dispose();
|
|
3365
3379
|
}
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3380
|
+
getLayerGroup(name) {
|
|
3381
|
+
return super.getGroupByName(`layer:${name}`);
|
|
3382
|
+
}
|
|
3383
|
+
getGroupByName(name, layerName) {
|
|
3384
|
+
return layerName === void 0 ? super.getGroupByName(name) : this.getLayerGroup(layerName)?.getObjectByName(`group:${name}`);
|
|
3385
|
+
}
|
|
3386
|
+
getMeshByName(name, layerName) {
|
|
3387
|
+
return layerName === void 0 ? super.getMeshByName(name) : this.getLayerGroup(layerName)?.getObjectByName(`mesh:${name}`);
|
|
3388
|
+
}
|
|
3389
|
+
get entityLayers() {
|
|
3390
|
+
return this.entity.layers ?? { main: this.entity };
|
|
3391
|
+
}
|
|
3392
|
+
getTextureKey(layer) {
|
|
3393
|
+
if (layer.texture) return layer.texture;
|
|
3394
|
+
const key = layer.key;
|
|
3369
3395
|
return new AssetKey(
|
|
3370
3396
|
key.namespace,
|
|
3371
3397
|
isAssetKey(key) ? key.getFullPath() : key.path,
|
|
@@ -3375,18 +3401,22 @@ var _EntityObject = class _EntityObject extends SceneObject {
|
|
|
3375
3401
|
".png"
|
|
3376
3402
|
);
|
|
3377
3403
|
}
|
|
3378
|
-
async loadTextures() {
|
|
3379
|
-
|
|
3404
|
+
async loadTextures(layer = this.entity) {
|
|
3405
|
+
return ModelTextures.get(this.getTextureKey(layer));
|
|
3380
3406
|
}
|
|
3381
3407
|
createMeshes(force = false) {
|
|
3382
3408
|
if (this.meshesCreated && !force) return;
|
|
3383
3409
|
const modelRoot = new import_three12.Object3D();
|
|
3384
3410
|
if (this.options.flip) modelRoot.scale.set(-1, -1, 1);
|
|
3385
3411
|
this.add(modelRoot);
|
|
3386
|
-
|
|
3412
|
+
Object.entries(this.entityLayers).forEach(([name, layer], index) => {
|
|
3413
|
+
const group = this.createGroup(`layer:${name}`);
|
|
3414
|
+
modelRoot.add(group);
|
|
3415
|
+
this.createPart("root", layer.layer.root, group, layer.layer.texture, Materials.MISSING_TEXTURE, index);
|
|
3416
|
+
});
|
|
3387
3417
|
this.meshesCreated = true;
|
|
3388
3418
|
}
|
|
3389
|
-
createPart(name, part, parent, textureSize, material) {
|
|
3419
|
+
createPart(name, part, parent, textureSize, material, renderOrder) {
|
|
3390
3420
|
const anchor = this.createGroup(name);
|
|
3391
3421
|
anchor.position.fromArray(part.pose.offset);
|
|
3392
3422
|
anchor.rotation.set(...part.pose.rotation, "ZYX");
|
|
@@ -3406,30 +3436,31 @@ var _EntityObject = class _EntityObject extends SceneObject {
|
|
|
3406
3436
|
).clone();
|
|
3407
3437
|
geometry.translate(cube.origin[0] + width / 2, cube.origin[1] + height / 2, cube.origin[2] + depth / 2);
|
|
3408
3438
|
const mesh = this.createMesh(name, geometry, material);
|
|
3439
|
+
mesh.renderOrder = renderOrder;
|
|
3409
3440
|
anchor.add(mesh);
|
|
3410
3441
|
if (this.options.wireframe) addWireframeToMesh(geometry, mesh);
|
|
3411
3442
|
}
|
|
3412
3443
|
for (const [childName, child] of Object.entries(part.children)) {
|
|
3413
|
-
this.createPart(childName, child, anchor, size, material);
|
|
3444
|
+
this.createPart(childName, child, anchor, size, material, renderOrder);
|
|
3414
3445
|
}
|
|
3415
3446
|
}
|
|
3416
3447
|
async applyTextures() {
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
});
|
|
3448
|
+
await Promise.all(Object.entries(this.entityLayers).map(async ([name, layer]) => {
|
|
3449
|
+
const assetKeyStr = this.getTextureKey(layer).serialize();
|
|
3450
|
+
const keyStr = `entity:${assetKeyStr}`;
|
|
3451
|
+
let mat = Caching.materialCache.getIfPresent(keyStr);
|
|
3452
|
+
if (!mat) {
|
|
3453
|
+
const cachedAsset = Caching.textureAssetCache.getIfPresent(assetKeyStr);
|
|
3454
|
+
const imageData = await this.loadTextures(layer);
|
|
3455
|
+
if (!imageData) return;
|
|
3456
|
+
const canvas = imageData.data.canvas;
|
|
3457
|
+
const createMaterial = () => Materials.createBasicCanvasMaterial(canvas);
|
|
3458
|
+
mat = cachedAsset && Caching.textureAssetCache.getIfPresent(assetKeyStr) === cachedAsset ? Caching.materialCache.get(keyStr, createMaterial) : createMaterial();
|
|
3459
|
+
}
|
|
3460
|
+
this.getLayerGroup(name)?.traverse((object) => {
|
|
3461
|
+
if (isMesh(object)) object.material = mat;
|
|
3462
|
+
});
|
|
3463
|
+
}));
|
|
3433
3464
|
this.notifyDirty();
|
|
3434
3465
|
}
|
|
3435
3466
|
};
|
|
@@ -3445,16 +3476,16 @@ var GuiObject = class extends SceneObject {
|
|
|
3445
3476
|
};
|
|
3446
3477
|
|
|
3447
3478
|
// src/inspector/SceneInspector.ts
|
|
3448
|
-
var
|
|
3479
|
+
var import_three14 = require("three");
|
|
3449
3480
|
var p7 = prefix("SceneInspector");
|
|
3450
3481
|
var help = "<span>Ctrl+Click to Select<br/></span><br/>";
|
|
3451
3482
|
var SceneInspector = class {
|
|
3452
3483
|
constructor(renderer) {
|
|
3453
3484
|
this.renderer = renderer;
|
|
3454
|
-
this.mouse = new
|
|
3485
|
+
this.mouse = new import_three14.Vector2();
|
|
3455
3486
|
this.objectInfoContainer = document.createElement("div");
|
|
3456
3487
|
this.objectControlsContainer = document.createElement("div");
|
|
3457
|
-
this.raycaster = new
|
|
3488
|
+
this.raycaster = new import_three14.Raycaster();
|
|
3458
3489
|
this.init();
|
|
3459
3490
|
}
|
|
3460
3491
|
init() {
|
|
@@ -3965,10 +3996,10 @@ var BlockTints = class {
|
|
|
3965
3996
|
};
|
|
3966
3997
|
|
|
3967
3998
|
// src/model/scene/ModelObject.ts
|
|
3968
|
-
var
|
|
3999
|
+
var import_three17 = require("three");
|
|
3969
4000
|
|
|
3970
4001
|
// src/three/BufferGeometryUtils.js
|
|
3971
|
-
var
|
|
4002
|
+
var import_three16 = require("three");
|
|
3972
4003
|
function computeTangents(geometry) {
|
|
3973
4004
|
geometry.computeTangents();
|
|
3974
4005
|
console.warn("THREE.BufferGeometryUtils: .computeTangents() has been removed. Use BufferGeometry.computeTangents() instead.");
|
|
@@ -3980,7 +4011,7 @@ function mergeBufferGeometries(geometries, useGroups = false) {
|
|
|
3980
4011
|
const attributes = {};
|
|
3981
4012
|
const morphAttributes = {};
|
|
3982
4013
|
const morphTargetsRelative = geometries[0].morphTargetsRelative;
|
|
3983
|
-
const mergedGeometry = new
|
|
4014
|
+
const mergedGeometry = new import_three16.BufferGeometry();
|
|
3984
4015
|
let offset = 0;
|
|
3985
4016
|
for (let i = 0; i < geometries.length; ++i) {
|
|
3986
4017
|
const geometry = geometries[i];
|
|
@@ -4104,7 +4135,7 @@ function mergeBufferAttributes(attributes) {
|
|
|
4104
4135
|
array.set(attributes[i].array, offset);
|
|
4105
4136
|
offset += attributes[i].array.length;
|
|
4106
4137
|
}
|
|
4107
|
-
return new
|
|
4138
|
+
return new import_three16.BufferAttribute(array, itemSize, normalized);
|
|
4108
4139
|
}
|
|
4109
4140
|
function interleaveAttributes(attributes) {
|
|
4110
4141
|
let TypedArray;
|
|
@@ -4120,7 +4151,7 @@ function interleaveAttributes(attributes) {
|
|
|
4120
4151
|
arrayLength += attribute.array.length;
|
|
4121
4152
|
stride += attribute.itemSize;
|
|
4122
4153
|
}
|
|
4123
|
-
const interleavedBuffer = new
|
|
4154
|
+
const interleavedBuffer = new import_three16.InterleavedBuffer(new TypedArray(arrayLength), stride);
|
|
4124
4155
|
let offset = 0;
|
|
4125
4156
|
const res = [];
|
|
4126
4157
|
const getters = ["getX", "getY", "getZ", "getW"];
|
|
@@ -4129,7 +4160,7 @@ function interleaveAttributes(attributes) {
|
|
|
4129
4160
|
const attribute = attributes[j];
|
|
4130
4161
|
const itemSize = attribute.itemSize;
|
|
4131
4162
|
const count = attribute.count;
|
|
4132
|
-
const iba = new
|
|
4163
|
+
const iba = new import_three16.InterleavedBufferAttribute(interleavedBuffer, itemSize, offset, attribute.normalized);
|
|
4133
4164
|
res.push(iba);
|
|
4134
4165
|
offset += itemSize;
|
|
4135
4166
|
for (let c = 0; c < count; c++) {
|
|
@@ -4213,13 +4244,13 @@ function mergeVertices(geometry, tolerance = 1e-4) {
|
|
|
4213
4244
|
const name = attributeNames[i];
|
|
4214
4245
|
const oldAttribute = geometry.getAttribute(name);
|
|
4215
4246
|
const buffer = new oldAttribute.array.constructor(attrArrays[name]);
|
|
4216
|
-
const attribute = new
|
|
4247
|
+
const attribute = new import_three16.BufferAttribute(buffer, oldAttribute.itemSize, oldAttribute.normalized);
|
|
4217
4248
|
result.setAttribute(name, attribute);
|
|
4218
4249
|
if (name in morphAttrsArrays) {
|
|
4219
4250
|
for (let j = 0; j < morphAttrsArrays[name].length; j++) {
|
|
4220
4251
|
const oldMorphAttribute = geometry.morphAttributes[name][j];
|
|
4221
4252
|
const buffer2 = new oldMorphAttribute.array.constructor(morphAttrsArrays[name][j]);
|
|
4222
|
-
const morphAttribute = new
|
|
4253
|
+
const morphAttribute = new import_three16.BufferAttribute(buffer2, oldMorphAttribute.itemSize, oldMorphAttribute.normalized);
|
|
4223
4254
|
result.morphAttributes[name][j] = morphAttribute;
|
|
4224
4255
|
}
|
|
4225
4256
|
}
|
|
@@ -4228,11 +4259,11 @@ function mergeVertices(geometry, tolerance = 1e-4) {
|
|
|
4228
4259
|
return result;
|
|
4229
4260
|
}
|
|
4230
4261
|
function toTrianglesDrawMode(geometry, drawMode) {
|
|
4231
|
-
if (drawMode ===
|
|
4262
|
+
if (drawMode === import_three16.TrianglesDrawMode) {
|
|
4232
4263
|
console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles.");
|
|
4233
4264
|
return geometry;
|
|
4234
4265
|
}
|
|
4235
|
-
if (drawMode ===
|
|
4266
|
+
if (drawMode === import_three16.TriangleFanDrawMode || drawMode === import_three16.TriangleStripDrawMode) {
|
|
4236
4267
|
let index = geometry.getIndex();
|
|
4237
4268
|
if (index === null) {
|
|
4238
4269
|
const indices = [];
|
|
@@ -4250,7 +4281,7 @@ function toTrianglesDrawMode(geometry, drawMode) {
|
|
|
4250
4281
|
}
|
|
4251
4282
|
const numberOfTriangles = index.count - 2;
|
|
4252
4283
|
const newIndices = [];
|
|
4253
|
-
if (drawMode ===
|
|
4284
|
+
if (drawMode === import_three16.TriangleFanDrawMode) {
|
|
4254
4285
|
for (let i = 1; i <= numberOfTriangles; i++) {
|
|
4255
4286
|
newIndices.push(index.getX(0));
|
|
4256
4287
|
newIndices.push(index.getX(i));
|
|
@@ -4286,15 +4317,15 @@ function computeMorphedAttributes(object) {
|
|
|
4286
4317
|
console.error("THREE.BufferGeometryUtils: Geometry is not of type BufferGeometry.");
|
|
4287
4318
|
return null;
|
|
4288
4319
|
}
|
|
4289
|
-
const _vA = new
|
|
4290
|
-
const _vB = new
|
|
4291
|
-
const _vC = new
|
|
4292
|
-
const _tempA = new
|
|
4293
|
-
const _tempB = new
|
|
4294
|
-
const _tempC = new
|
|
4295
|
-
const _morphA = new
|
|
4296
|
-
const _morphB = new
|
|
4297
|
-
const _morphC = new
|
|
4320
|
+
const _vA = new import_three16.Vector3();
|
|
4321
|
+
const _vB = new import_three16.Vector3();
|
|
4322
|
+
const _vC = new import_three16.Vector3();
|
|
4323
|
+
const _tempA = new import_three16.Vector3();
|
|
4324
|
+
const _tempB = new import_three16.Vector3();
|
|
4325
|
+
const _tempC = new import_three16.Vector3();
|
|
4326
|
+
const _morphA = new import_three16.Vector3();
|
|
4327
|
+
const _morphB = new import_three16.Vector3();
|
|
4328
|
+
const _morphC = new import_three16.Vector3();
|
|
4298
4329
|
function _calculateMorphedAttributeData(object2, material2, attribute, morphAttribute, morphTargetsRelative2, a2, b2, c2, modifiedAttributeArray) {
|
|
4299
4330
|
_vA.fromBufferAttribute(attribute, a2);
|
|
4300
4331
|
_vB.fromBufferAttribute(attribute, b2);
|
|
@@ -4489,8 +4520,8 @@ function computeMorphedAttributes(object) {
|
|
|
4489
4520
|
}
|
|
4490
4521
|
}
|
|
4491
4522
|
}
|
|
4492
|
-
const morphedPositionAttribute = new
|
|
4493
|
-
const morphedNormalAttribute = new
|
|
4523
|
+
const morphedPositionAttribute = new import_three16.Float32BufferAttribute(modifiedPosition, 3);
|
|
4524
|
+
const morphedNormalAttribute = new import_three16.Float32BufferAttribute(modifiedNormal, 3);
|
|
4494
4525
|
return {
|
|
4495
4526
|
positionAttribute,
|
|
4496
4527
|
normalAttribute,
|
|
@@ -4538,7 +4569,7 @@ var _ModelObject = class _ModelObject extends SceneObject {
|
|
|
4538
4569
|
this.atlas.model.elements?.forEach((el) => {
|
|
4539
4570
|
const elGeo = this._getBoxGeometryFromElement(el).clone();
|
|
4540
4571
|
if (this.options.uvLockRotation) {
|
|
4541
|
-
UVMapper.lockUvs(elGeo, el.faces, this.atlas, new
|
|
4572
|
+
UVMapper.lockUvs(elGeo, el.faces, this.atlas, new import_three17.Euler(...this.options.uvLockRotation));
|
|
4542
4573
|
}
|
|
4543
4574
|
if (this.options.tints) {
|
|
4544
4575
|
const colors = new Float32Array(elGeo.getAttribute("position").count * 3).fill(1);
|
|
@@ -4547,19 +4578,19 @@ var _ModelObject = class _ModelObject extends SceneObject {
|
|
|
4547
4578
|
if (tintIndex === void 0 || tintIndex < 0) continue;
|
|
4548
4579
|
const tint = this.options.tints[tintIndex];
|
|
4549
4580
|
if (tint === void 0) continue;
|
|
4550
|
-
const color = new
|
|
4581
|
+
const color = new import_three17.Color(tint);
|
|
4551
4582
|
for (let vertex = 0; vertex < 4; vertex++) {
|
|
4552
4583
|
color.toArray(colors, (faceIndex * 4 + vertex) * 3);
|
|
4553
4584
|
}
|
|
4554
4585
|
}
|
|
4555
|
-
elGeo.setAttribute("color", new
|
|
4586
|
+
elGeo.setAttribute("color", new import_three17.BufferAttribute(colors, 3));
|
|
4556
4587
|
}
|
|
4557
|
-
elGeo.applyMatrix4(new
|
|
4558
|
-
elGeo.applyMatrix4(new
|
|
4588
|
+
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));
|
|
4589
|
+
elGeo.applyMatrix4(new import_three17.Matrix4().makeTranslation(el.from[0], el.from[1], el.from[2]));
|
|
4559
4590
|
if (el.rotation) {
|
|
4560
4591
|
applyElementRotation(el.rotation, elGeo);
|
|
4561
4592
|
}
|
|
4562
|
-
elGeo.applyMatrix4(new
|
|
4593
|
+
elGeo.applyMatrix4(new import_three17.Matrix4().makeTranslation(-8, -8, -8));
|
|
4563
4594
|
if (displayTransform) DisplayTransforms.apply(elGeo, displayTransform);
|
|
4564
4595
|
if (this.options.mergeMeshes) {
|
|
4565
4596
|
allGeos.push(elGeo);
|
|
@@ -4581,7 +4612,7 @@ var _ModelObject = class _ModelObject extends SceneObject {
|
|
|
4581
4612
|
if (allGeos.length > 0) {
|
|
4582
4613
|
combinedGeo = mergeBufferGeometries(allGeos);
|
|
4583
4614
|
} else {
|
|
4584
|
-
combinedGeo = new
|
|
4615
|
+
combinedGeo = new import_three17.BoxGeometry(16, 16, 16);
|
|
4585
4616
|
if (displayTransform) DisplayTransforms.apply(combinedGeo, displayTransform);
|
|
4586
4617
|
}
|
|
4587
4618
|
combinedGeo.computeBoundingBox();
|
|
@@ -4636,7 +4667,7 @@ function isModelObject(obj) {
|
|
|
4636
4667
|
|
|
4637
4668
|
// src/model/block/scene/BlockObject.ts
|
|
4638
4669
|
var import_ts_deepmerge6 = __toESM(require_dist());
|
|
4639
|
-
var
|
|
4670
|
+
var import_three18 = require("three");
|
|
4640
4671
|
var p10 = prefix("BlockObject");
|
|
4641
4672
|
function matchesCondition(condition, state) {
|
|
4642
4673
|
return Object.entries(condition).every(([key, value]) => {
|
|
@@ -4693,7 +4724,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
4693
4724
|
if (isModelObject(model)) {
|
|
4694
4725
|
model.removeFromScene();
|
|
4695
4726
|
} else if (isInstanceReference(model)) {
|
|
4696
|
-
model.setScale(new
|
|
4727
|
+
model.setScale(new import_three18.Vector3(0, 0, 0));
|
|
4697
4728
|
}
|
|
4698
4729
|
}
|
|
4699
4730
|
super.removeFromScene();
|
|
@@ -4754,7 +4785,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
4754
4785
|
}
|
|
4755
4786
|
for (let model of this._models) {
|
|
4756
4787
|
if (isInstanceReference(model)) {
|
|
4757
|
-
model.setScale(new
|
|
4788
|
+
model.setScale(new import_three18.Vector3(0, 0, 0));
|
|
4758
4789
|
} else {
|
|
4759
4790
|
model.dispose();
|
|
4760
4791
|
}
|
|
@@ -4791,7 +4822,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
4791
4822
|
await this.createVariant(variant);
|
|
4792
4823
|
}
|
|
4793
4824
|
async createVariant(variant) {
|
|
4794
|
-
const rotation = new
|
|
4825
|
+
const rotation = new import_three18.Euler();
|
|
4795
4826
|
if (typeof variant.x !== "undefined") {
|
|
4796
4827
|
rotation.x = toRadians(clampRotationDegrees(variant.x));
|
|
4797
4828
|
}
|
|
@@ -4880,7 +4911,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
4880
4911
|
setPositionRotationScaleAt(index, position, rotation, scale) {
|
|
4881
4912
|
super.setPositionRotationScaleAt(index, position, rotation, scale);
|
|
4882
4913
|
}
|
|
4883
|
-
getMatrixAt(index, matrix = new
|
|
4914
|
+
getMatrixAt(index, matrix = new import_three18.Matrix4()) {
|
|
4884
4915
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
4885
4916
|
const child = this._models[0];
|
|
4886
4917
|
if (child && isModelObject(child)) {
|
|
@@ -4959,7 +4990,7 @@ var StructureParser = class {
|
|
|
4959
4990
|
};
|
|
4960
4991
|
|
|
4961
4992
|
// src/renderer/MineRenderScene.ts
|
|
4962
|
-
var
|
|
4993
|
+
var import_three20 = require("three");
|
|
4963
4994
|
var import_ts_deepmerge8 = __toESM(require_dist());
|
|
4964
4995
|
|
|
4965
4996
|
// src/skin/SkinPart.ts
|
|
@@ -5684,7 +5715,7 @@ var slimSkinGeometries = {
|
|
|
5684
5715
|
var import_ts_deepmerge7 = __toESM(require_dist());
|
|
5685
5716
|
|
|
5686
5717
|
// src/skin/SkinTextures.ts
|
|
5687
|
-
var
|
|
5718
|
+
var import_three19 = require("three");
|
|
5688
5719
|
|
|
5689
5720
|
// src/skin/SkinImage.ts
|
|
5690
5721
|
var SkinImage = class {
|
|
@@ -5761,11 +5792,11 @@ var SkinTextures = class {
|
|
|
5761
5792
|
});
|
|
5762
5793
|
}
|
|
5763
5794
|
static createMaterial(pixels, width, height, transparent = true) {
|
|
5764
|
-
const texture = Textures.initTextureProps(new
|
|
5765
|
-
texture.colorSpace =
|
|
5795
|
+
const texture = Textures.initTextureProps(new import_three19.DataTexture(pixels, width, height));
|
|
5796
|
+
texture.colorSpace = import_three19.SRGBColorSpace;
|
|
5766
5797
|
texture.flipY = true;
|
|
5767
5798
|
texture.needsUpdate = true;
|
|
5768
|
-
return new
|
|
5799
|
+
return new import_three19.MeshBasicMaterial({ map: texture, transparent, side: transparent ? import_three19.DoubleSide : import_three19.FrontSide, alphaTest: transparent ? 0.1 : 0 });
|
|
5769
5800
|
}
|
|
5770
5801
|
static isSlim(image, scale) {
|
|
5771
5802
|
for (const [x, y] of [[46, 52], [54, 20]]) {
|
|
@@ -5992,7 +6023,7 @@ var SkinObject = class extends SceneObject {
|
|
|
5992
6023
|
};
|
|
5993
6024
|
|
|
5994
6025
|
// src/renderer/MineRenderScene.ts
|
|
5995
|
-
var _MineRenderScene = class _MineRenderScene extends
|
|
6026
|
+
var _MineRenderScene = class _MineRenderScene extends import_three20.Scene {
|
|
5996
6027
|
constructor(options) {
|
|
5997
6028
|
super();
|
|
5998
6029
|
this.isMineRenderScene = true;
|
|
@@ -6115,17 +6146,17 @@ function isMineRenderScene(obj) {
|
|
|
6115
6146
|
}
|
|
6116
6147
|
|
|
6117
6148
|
// src/renderer/Renderer.ts
|
|
6118
|
-
var
|
|
6149
|
+
var import_three22 = require("three");
|
|
6119
6150
|
var import_ts_deepmerge9 = __toESM(require_dist());
|
|
6120
6151
|
var import_stats = __toESM(require("stats.js"));
|
|
6121
6152
|
var import_postprocessing = require("postprocessing");
|
|
6122
6153
|
|
|
6123
6154
|
// src/three/OrbitControls.js
|
|
6124
|
-
var
|
|
6155
|
+
var import_three21 = require("three");
|
|
6125
6156
|
var _changeEvent = { type: "change" };
|
|
6126
6157
|
var _startEvent = { type: "start" };
|
|
6127
6158
|
var _endEvent = { type: "end" };
|
|
6128
|
-
var OrbitControls = class extends
|
|
6159
|
+
var OrbitControls = class extends import_three21.EventDispatcher {
|
|
6129
6160
|
constructor(object, domElement) {
|
|
6130
6161
|
super();
|
|
6131
6162
|
if (domElement === void 0) console.warn('THREE.OrbitControls: The second parameter "domElement" is now mandatory.');
|
|
@@ -6134,7 +6165,7 @@ var OrbitControls = class extends import_three20.EventDispatcher {
|
|
|
6134
6165
|
this.domElement = domElement;
|
|
6135
6166
|
this.domElement.style.touchAction = "none";
|
|
6136
6167
|
this.enabled = true;
|
|
6137
|
-
this.target = new
|
|
6168
|
+
this.target = new import_three21.Vector3();
|
|
6138
6169
|
this.minDistance = 0;
|
|
6139
6170
|
this.maxDistance = Infinity;
|
|
6140
6171
|
this.minZoom = 0;
|
|
@@ -6156,8 +6187,8 @@ var OrbitControls = class extends import_three20.EventDispatcher {
|
|
|
6156
6187
|
this.autoRotate = false;
|
|
6157
6188
|
this.autoRotateSpeed = 2;
|
|
6158
6189
|
this.keys = { LEFT: "ArrowLeft", UP: "ArrowUp", RIGHT: "ArrowRight", BOTTOM: "ArrowDown" };
|
|
6159
|
-
this.mouseButtons = { LEFT:
|
|
6160
|
-
this.touches = { ONE:
|
|
6190
|
+
this.mouseButtons = { LEFT: import_three21.MOUSE.ROTATE, MIDDLE: import_three21.MOUSE.DOLLY, RIGHT: import_three21.MOUSE.PAN };
|
|
6191
|
+
this.touches = { ONE: import_three21.TOUCH.ROTATE, TWO: import_three21.TOUCH.DOLLY_PAN };
|
|
6161
6192
|
this.target0 = this.target.clone();
|
|
6162
6193
|
this.position0 = this.object.position.clone();
|
|
6163
6194
|
this.zoom0 = this.object.zoom;
|
|
@@ -6186,11 +6217,11 @@ var OrbitControls = class extends import_three20.EventDispatcher {
|
|
|
6186
6217
|
state = STATE.NONE;
|
|
6187
6218
|
};
|
|
6188
6219
|
this.update = function() {
|
|
6189
|
-
const offset = new
|
|
6190
|
-
const quat = new
|
|
6220
|
+
const offset = new import_three21.Vector3();
|
|
6221
|
+
const quat = new import_three21.Quaternion().setFromUnitVectors(object.up, new import_three21.Vector3(0, 1, 0));
|
|
6191
6222
|
const quatInverse = quat.clone().invert();
|
|
6192
|
-
const lastPosition = new
|
|
6193
|
-
const lastQuaternion = new
|
|
6223
|
+
const lastPosition = new import_three21.Vector3();
|
|
6224
|
+
const lastQuaternion = new import_three21.Quaternion();
|
|
6194
6225
|
const twoPI = 2 * Math.PI;
|
|
6195
6226
|
return function update() {
|
|
6196
6227
|
const position = scope.object.position;
|
|
@@ -6276,20 +6307,20 @@ var OrbitControls = class extends import_three20.EventDispatcher {
|
|
|
6276
6307
|
};
|
|
6277
6308
|
let state = STATE.NONE;
|
|
6278
6309
|
const EPS = 1e-6;
|
|
6279
|
-
const spherical = new
|
|
6280
|
-
const sphericalDelta = new
|
|
6310
|
+
const spherical = new import_three21.Spherical();
|
|
6311
|
+
const sphericalDelta = new import_three21.Spherical();
|
|
6281
6312
|
let scale = 1;
|
|
6282
|
-
const panOffset = new
|
|
6313
|
+
const panOffset = new import_three21.Vector3();
|
|
6283
6314
|
let zoomChanged = false;
|
|
6284
|
-
const rotateStart = new
|
|
6285
|
-
const rotateEnd = new
|
|
6286
|
-
const rotateDelta = new
|
|
6287
|
-
const panStart = new
|
|
6288
|
-
const panEnd = new
|
|
6289
|
-
const panDelta = new
|
|
6290
|
-
const dollyStart = new
|
|
6291
|
-
const dollyEnd = new
|
|
6292
|
-
const dollyDelta = new
|
|
6315
|
+
const rotateStart = new import_three21.Vector2();
|
|
6316
|
+
const rotateEnd = new import_three21.Vector2();
|
|
6317
|
+
const rotateDelta = new import_three21.Vector2();
|
|
6318
|
+
const panStart = new import_three21.Vector2();
|
|
6319
|
+
const panEnd = new import_three21.Vector2();
|
|
6320
|
+
const panDelta = new import_three21.Vector2();
|
|
6321
|
+
const dollyStart = new import_three21.Vector2();
|
|
6322
|
+
const dollyEnd = new import_three21.Vector2();
|
|
6323
|
+
const dollyDelta = new import_three21.Vector2();
|
|
6293
6324
|
const pointers = [];
|
|
6294
6325
|
const pointerPositions = {};
|
|
6295
6326
|
function getAutoRotationAngle() {
|
|
@@ -6305,7 +6336,7 @@ var OrbitControls = class extends import_three20.EventDispatcher {
|
|
|
6305
6336
|
sphericalDelta.phi -= angle;
|
|
6306
6337
|
}
|
|
6307
6338
|
const panLeft = function() {
|
|
6308
|
-
const v = new
|
|
6339
|
+
const v = new import_three21.Vector3();
|
|
6309
6340
|
return function panLeft2(distance, objectMatrix) {
|
|
6310
6341
|
v.setFromMatrixColumn(objectMatrix, 0);
|
|
6311
6342
|
v.multiplyScalar(-distance);
|
|
@@ -6313,7 +6344,7 @@ var OrbitControls = class extends import_three20.EventDispatcher {
|
|
|
6313
6344
|
};
|
|
6314
6345
|
}();
|
|
6315
6346
|
const panUp = function() {
|
|
6316
|
-
const v = new
|
|
6347
|
+
const v = new import_three21.Vector3();
|
|
6317
6348
|
return function panUp2(distance, objectMatrix) {
|
|
6318
6349
|
if (scope.screenSpacePanning === true) {
|
|
6319
6350
|
v.setFromMatrixColumn(objectMatrix, 1);
|
|
@@ -6326,7 +6357,7 @@ var OrbitControls = class extends import_three20.EventDispatcher {
|
|
|
6326
6357
|
};
|
|
6327
6358
|
}();
|
|
6328
6359
|
const pan = function() {
|
|
6329
|
-
const offset = new
|
|
6360
|
+
const offset = new import_three21.Vector3();
|
|
6330
6361
|
return function pan2(deltaX, deltaY) {
|
|
6331
6362
|
const element = scope.domElement;
|
|
6332
6363
|
if (scope.object.isPerspectiveCamera) {
|
|
@@ -6575,12 +6606,12 @@ var OrbitControls = class extends import_three20.EventDispatcher {
|
|
|
6575
6606
|
mouseAction = -1;
|
|
6576
6607
|
}
|
|
6577
6608
|
switch (mouseAction) {
|
|
6578
|
-
case
|
|
6609
|
+
case import_three21.MOUSE.DOLLY:
|
|
6579
6610
|
if (scope.enableZoom === false) return;
|
|
6580
6611
|
handleMouseDownDolly(event);
|
|
6581
6612
|
state = STATE.DOLLY;
|
|
6582
6613
|
break;
|
|
6583
|
-
case
|
|
6614
|
+
case import_three21.MOUSE.ROTATE:
|
|
6584
6615
|
if (event.ctrlKey || event.metaKey || event.shiftKey) {
|
|
6585
6616
|
if (scope.enablePan === false) return;
|
|
6586
6617
|
handleMouseDownPan(event);
|
|
@@ -6591,7 +6622,7 @@ var OrbitControls = class extends import_three20.EventDispatcher {
|
|
|
6591
6622
|
state = STATE.ROTATE;
|
|
6592
6623
|
}
|
|
6593
6624
|
break;
|
|
6594
|
-
case
|
|
6625
|
+
case import_three21.MOUSE.PAN:
|
|
6595
6626
|
if (event.ctrlKey || event.metaKey || event.shiftKey) {
|
|
6596
6627
|
if (scope.enableRotate === false) return;
|
|
6597
6628
|
handleMouseDownRotate(event);
|
|
@@ -6647,12 +6678,12 @@ var OrbitControls = class extends import_three20.EventDispatcher {
|
|
|
6647
6678
|
switch (pointers.length) {
|
|
6648
6679
|
case 1:
|
|
6649
6680
|
switch (scope.touches.ONE) {
|
|
6650
|
-
case
|
|
6681
|
+
case import_three21.TOUCH.ROTATE:
|
|
6651
6682
|
if (scope.enableRotate === false) return;
|
|
6652
6683
|
handleTouchStartRotate();
|
|
6653
6684
|
state = STATE.TOUCH_ROTATE;
|
|
6654
6685
|
break;
|
|
6655
|
-
case
|
|
6686
|
+
case import_three21.TOUCH.PAN:
|
|
6656
6687
|
if (scope.enablePan === false) return;
|
|
6657
6688
|
handleTouchStartPan();
|
|
6658
6689
|
state = STATE.TOUCH_PAN;
|
|
@@ -6663,12 +6694,12 @@ var OrbitControls = class extends import_three20.EventDispatcher {
|
|
|
6663
6694
|
break;
|
|
6664
6695
|
case 2:
|
|
6665
6696
|
switch (scope.touches.TWO) {
|
|
6666
|
-
case
|
|
6697
|
+
case import_three21.TOUCH.DOLLY_PAN:
|
|
6667
6698
|
if (scope.enableZoom === false && scope.enablePan === false) return;
|
|
6668
6699
|
handleTouchStartDollyPan();
|
|
6669
6700
|
state = STATE.TOUCH_DOLLY_PAN;
|
|
6670
6701
|
break;
|
|
6671
|
-
case
|
|
6702
|
+
case import_three21.TOUCH.DOLLY_ROTATE:
|
|
6672
6703
|
if (scope.enableZoom === false && scope.enableRotate === false) return;
|
|
6673
6704
|
handleTouchStartDollyRotate();
|
|
6674
6705
|
state = STATE.TOUCH_DOLLY_ROTATE;
|
|
@@ -6735,7 +6766,7 @@ var OrbitControls = class extends import_three20.EventDispatcher {
|
|
|
6735
6766
|
function trackPointer(event) {
|
|
6736
6767
|
let position = pointerPositions[event.pointerId];
|
|
6737
6768
|
if (position === void 0) {
|
|
6738
|
-
position = new
|
|
6769
|
+
position = new import_three21.Vector2();
|
|
6739
6770
|
pointerPositions[event.pointerId] = position;
|
|
6740
6771
|
}
|
|
6741
6772
|
position.set(event.pageX, event.pageY);
|
|
@@ -6755,10 +6786,10 @@ var MapControls = class extends OrbitControls {
|
|
|
6755
6786
|
constructor(object, domElement) {
|
|
6756
6787
|
super(object, domElement);
|
|
6757
6788
|
this.screenSpacePanning = false;
|
|
6758
|
-
this.mouseButtons.LEFT =
|
|
6759
|
-
this.mouseButtons.RIGHT =
|
|
6760
|
-
this.touches.ONE =
|
|
6761
|
-
this.touches.TWO =
|
|
6789
|
+
this.mouseButtons.LEFT = import_three21.MOUSE.PAN;
|
|
6790
|
+
this.mouseButtons.RIGHT = import_three21.MOUSE.ROTATE;
|
|
6791
|
+
this.touches.ONE = import_three21.TOUCH.PAN;
|
|
6792
|
+
this.touches.TWO = import_three21.TOUCH.DOLLY_ROTATE;
|
|
6762
6793
|
}
|
|
6763
6794
|
};
|
|
6764
6795
|
|
|
@@ -6795,14 +6826,14 @@ var _Renderer = class _Renderer {
|
|
|
6795
6826
|
switch (this.options.camera.type) {
|
|
6796
6827
|
case "perspective":
|
|
6797
6828
|
default:
|
|
6798
|
-
return new
|
|
6829
|
+
return new import_three22.PerspectiveCamera(
|
|
6799
6830
|
this.options.camera.perspective.fov,
|
|
6800
6831
|
this.options.camera.perspective.aspect ?? this.viewWidth / this.viewHeight,
|
|
6801
6832
|
this.options.camera.near,
|
|
6802
6833
|
this.options.camera.far
|
|
6803
6834
|
);
|
|
6804
6835
|
case "orthographic":
|
|
6805
|
-
return new
|
|
6836
|
+
return new import_three22.OrthographicCamera(
|
|
6806
6837
|
this.options.camera.orthographic.left ?? this.viewWidth / -2,
|
|
6807
6838
|
this.options.camera.orthographic.right ?? this.viewWidth / 2,
|
|
6808
6839
|
this.options.camera.orthographic.top ?? this.viewHeight / 2,
|
|
@@ -6813,7 +6844,7 @@ var _Renderer = class _Renderer {
|
|
|
6813
6844
|
}
|
|
6814
6845
|
}
|
|
6815
6846
|
createRenderer() {
|
|
6816
|
-
const renderer = new
|
|
6847
|
+
const renderer = new import_three22.WebGLRenderer({
|
|
6817
6848
|
antialias: this.options.render.antialias,
|
|
6818
6849
|
alpha: true,
|
|
6819
6850
|
powerPreference: "high-performance",
|
|
@@ -6821,8 +6852,8 @@ var _Renderer = class _Renderer {
|
|
|
6821
6852
|
});
|
|
6822
6853
|
renderer.setClearColor(0, 0);
|
|
6823
6854
|
renderer.shadowMap.enabled = true;
|
|
6824
|
-
renderer.shadowMap.type =
|
|
6825
|
-
renderer.outputColorSpace =
|
|
6855
|
+
renderer.shadowMap.type = import_three22.PCFSoftShadowMap;
|
|
6856
|
+
renderer.outputColorSpace = import_three22.SRGBColorSpace;
|
|
6826
6857
|
renderer.setSize(this.viewWidth, this.viewHeight);
|
|
6827
6858
|
return renderer;
|
|
6828
6859
|
}
|
|
@@ -6856,20 +6887,20 @@ var _Renderer = class _Renderer {
|
|
|
6856
6887
|
window["__THREE_DEVTOOLS__"].dispatchEvent(new CustomEvent("observe", { detail: this.scene }));
|
|
6857
6888
|
}
|
|
6858
6889
|
if (this.options.debug.grid) {
|
|
6859
|
-
const gridHelper = new
|
|
6890
|
+
const gridHelper = new import_three22.GridHelper(128, 16);
|
|
6860
6891
|
this._debugHelpers.push(gridHelper);
|
|
6861
6892
|
this.scene.add(gridHelper);
|
|
6862
|
-
const gridHelper2 = new
|
|
6893
|
+
const gridHelper2 = new import_three22.GridHelper(128, 16);
|
|
6863
6894
|
this._debugHelpers.push(gridHelper2);
|
|
6864
6895
|
gridHelper2.rotation.x = 90 * (Math.PI / 180);
|
|
6865
6896
|
this.scene.add(gridHelper2);
|
|
6866
|
-
const gridHelper3 = new
|
|
6897
|
+
const gridHelper3 = new import_three22.GridHelper(128, 16);
|
|
6867
6898
|
this._debugHelpers.push(gridHelper3);
|
|
6868
6899
|
gridHelper3.rotation.z = 90 * (Math.PI / 180);
|
|
6869
6900
|
this.scene.add(gridHelper3);
|
|
6870
6901
|
}
|
|
6871
6902
|
if (this.options.debug.axes) {
|
|
6872
|
-
const axesHelper = new
|
|
6903
|
+
const axesHelper = new import_three22.AxesHelper(64);
|
|
6873
6904
|
this._debugHelpers.push(axesHelper);
|
|
6874
6905
|
this.scene.add(axesHelper);
|
|
6875
6906
|
}
|
|
@@ -7073,8 +7104,8 @@ _Renderer.DEFAULT_OPTIONS = (0, import_ts_deepmerge9.default)({}, {
|
|
|
7073
7104
|
top: void 0,
|
|
7074
7105
|
bottom: void 0
|
|
7075
7106
|
},
|
|
7076
|
-
position: new
|
|
7077
|
-
lookingAt: new
|
|
7107
|
+
position: new import_three22.Vector3(50, 50, 50),
|
|
7108
|
+
lookingAt: new import_three22.Vector3(0, 0, 0)
|
|
7078
7109
|
},
|
|
7079
7110
|
render: {
|
|
7080
7111
|
fpsLimit: 60,
|
|
@@ -7262,10 +7293,10 @@ var Skins = class {
|
|
|
7262
7293
|
};
|
|
7263
7294
|
|
|
7264
7295
|
// src/world/Chunk.ts
|
|
7265
|
-
var
|
|
7296
|
+
var import_three25 = require("three");
|
|
7266
7297
|
|
|
7267
7298
|
// src/world/MineRenderWorld.ts
|
|
7268
|
-
var
|
|
7299
|
+
var import_three24 = require("three");
|
|
7269
7300
|
var MineRenderWorld = class {
|
|
7270
7301
|
constructor(scene) {
|
|
7271
7302
|
this._size = 4;
|
|
@@ -7276,10 +7307,10 @@ var MineRenderWorld = class {
|
|
|
7276
7307
|
}
|
|
7277
7308
|
getBlockAt(posOrX, y, z) {
|
|
7278
7309
|
if (typeof posOrX == "number") {
|
|
7279
|
-
return this.getBlockAt(new
|
|
7310
|
+
return this.getBlockAt(new import_three24.Vector3(posOrX, y, z));
|
|
7280
7311
|
}
|
|
7281
7312
|
if (isTripleArray(posOrX)) {
|
|
7282
|
-
return this.getBlockAt(new
|
|
7313
|
+
return this.getBlockAt(new import_three24.Vector3(posOrX[0], posOrX[1], posOrX[2]));
|
|
7283
7314
|
}
|
|
7284
7315
|
const chunk = this.getChunkAt(posOrX);
|
|
7285
7316
|
if (typeof chunk === "undefined") {
|
|
@@ -7290,10 +7321,10 @@ var MineRenderWorld = class {
|
|
|
7290
7321
|
}
|
|
7291
7322
|
async setBlockAt(posOrX, yOrBlock, z, block) {
|
|
7292
7323
|
if (typeof posOrX == "number") {
|
|
7293
|
-
return this.setBlockAt(new
|
|
7324
|
+
return this.setBlockAt(new import_three24.Vector3(posOrX, yOrBlock, z), block);
|
|
7294
7325
|
}
|
|
7295
7326
|
if (isTripleArray(posOrX)) {
|
|
7296
|
-
return this.setBlockAt(new
|
|
7327
|
+
return this.setBlockAt(new import_three24.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
|
|
7297
7328
|
}
|
|
7298
7329
|
this.validatePosBounds(posOrX);
|
|
7299
7330
|
const chunk = this.getOrCreateChunkAt(posOrX);
|
|
@@ -7339,14 +7370,14 @@ var MineRenderWorld = class {
|
|
|
7339
7370
|
return this._chunks[index];
|
|
7340
7371
|
}
|
|
7341
7372
|
static worldToScenePosition(pos) {
|
|
7342
|
-
return new
|
|
7373
|
+
return new import_three24.Vector3(
|
|
7343
7374
|
pos.x * 16,
|
|
7344
7375
|
pos.y * 16,
|
|
7345
7376
|
pos.z * 16
|
|
7346
7377
|
);
|
|
7347
7378
|
}
|
|
7348
7379
|
static sceneToWorldPosition(pos) {
|
|
7349
|
-
return new
|
|
7380
|
+
return new import_three24.Vector3(
|
|
7350
7381
|
pos.x / 16,
|
|
7351
7382
|
pos.y / 16,
|
|
7352
7383
|
pos.z / 16
|
|
@@ -7383,12 +7414,12 @@ var Chunk = class _Chunk {
|
|
|
7383
7414
|
this.x = x;
|
|
7384
7415
|
this.y = y;
|
|
7385
7416
|
this.z = z;
|
|
7386
|
-
let anchor = new
|
|
7417
|
+
let anchor = new import_three25.Object3D();
|
|
7387
7418
|
this._anchor = anchor;
|
|
7388
7419
|
scene.add(anchor);
|
|
7389
7420
|
anchor.position.set(this.x * 256 + 128 - 8, this.y * 256 + 128 - 8, this.z * 256 + 128 - 8);
|
|
7390
7421
|
addBox3WireframeToObject(
|
|
7391
|
-
new
|
|
7422
|
+
new import_three25.Box3(new import_three25.Vector3(0, 0, 0), new import_three25.Vector3(256, 256, 256)),
|
|
7392
7423
|
anchor,
|
|
7393
7424
|
16776960,
|
|
7394
7425
|
4
|
|
@@ -7396,10 +7427,10 @@ var Chunk = class _Chunk {
|
|
|
7396
7427
|
}
|
|
7397
7428
|
getBlockAt(posOrX, y, z) {
|
|
7398
7429
|
if (typeof posOrX == "number") {
|
|
7399
|
-
return this.getBlockAt(new
|
|
7430
|
+
return this.getBlockAt(new import_three25.Vector3(posOrX, y, z));
|
|
7400
7431
|
}
|
|
7401
7432
|
if (isTripleArray(posOrX)) {
|
|
7402
|
-
return this.getBlockAt(new
|
|
7433
|
+
return this.getBlockAt(new import_three25.Vector3(posOrX[0], posOrX[1], posOrX[2]));
|
|
7403
7434
|
}
|
|
7404
7435
|
const pos = this.worldPosToChunkPos(posOrX);
|
|
7405
7436
|
const index = _Chunk.chunkPosToBlockIndex(pos);
|
|
@@ -7407,10 +7438,10 @@ var Chunk = class _Chunk {
|
|
|
7407
7438
|
}
|
|
7408
7439
|
async setBlockAt(posOrX, yOrBlock, z, block) {
|
|
7409
7440
|
if (typeof posOrX == "number") {
|
|
7410
|
-
return this.setBlockAt(new
|
|
7441
|
+
return this.setBlockAt(new import_three25.Vector3(posOrX, yOrBlock, z), block);
|
|
7411
7442
|
}
|
|
7412
7443
|
if (isTripleArray(posOrX)) {
|
|
7413
|
-
return this.setBlockAt(new
|
|
7444
|
+
return this.setBlockAt(new import_three25.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
|
|
7414
7445
|
}
|
|
7415
7446
|
const worldPos = posOrX;
|
|
7416
7447
|
const pos = this.worldPosToChunkPos(worldPos);
|
|
@@ -7456,7 +7487,7 @@ var Chunk = class _Chunk {
|
|
|
7456
7487
|
}
|
|
7457
7488
|
async clear() {
|
|
7458
7489
|
let promises = [];
|
|
7459
|
-
let pos = new
|
|
7490
|
+
let pos = new import_three25.Vector3();
|
|
7460
7491
|
for (let x = 0; x < 16; x++) {
|
|
7461
7492
|
for (let z = 0; z < 16; z++) {
|
|
7462
7493
|
for (let y = 0; y < 16; y++) {
|
|
@@ -7475,14 +7506,14 @@ var Chunk = class _Chunk {
|
|
|
7475
7506
|
return pos.y * 16 * 16 + pos.z * 16 + pos.x;
|
|
7476
7507
|
}
|
|
7477
7508
|
worldPosToChunkPos(pos) {
|
|
7478
|
-
return new
|
|
7509
|
+
return new import_three25.Vector3(
|
|
7479
7510
|
pos.x - this.x * 16,
|
|
7480
7511
|
pos.y - this.y * 16,
|
|
7481
7512
|
pos.z - this.z * 16
|
|
7482
7513
|
);
|
|
7483
7514
|
}
|
|
7484
7515
|
chunkPosToWorldPos(pos) {
|
|
7485
|
-
return new
|
|
7516
|
+
return new import_three25.Vector3(
|
|
7486
7517
|
this.x * 16 + pos.x,
|
|
7487
7518
|
this.y * 16 + pos.y,
|
|
7488
7519
|
this.z * 16 + pos.z
|