minerender 2.1.0-alpha.54 → 2.1.0-alpha.55
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 +159 -1
- package/dist/browser/index.d.ts +159 -1
- package/dist/browser/index.js +546 -261
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +310 -25
- package/dist/browser/index.mjs.map +1 -1
- package/dist/bundle.js +296 -2
- package/dist/bundle.js.map +1 -1
- package/dist/node/index.d.mts +159 -1
- package/dist/node/index.d.ts +159 -1
- package/dist/node/index.js +556 -261
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +314 -25
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/node/index.js
CHANGED
|
@@ -291,6 +291,12 @@ var init_Caching = __esm({
|
|
|
291
291
|
static {
|
|
292
292
|
this.entityTextureCache = _Caching.createAssetCache();
|
|
293
293
|
}
|
|
294
|
+
static {
|
|
295
|
+
this.entityAnimationCache = _Caching.createAssetCache();
|
|
296
|
+
}
|
|
297
|
+
static {
|
|
298
|
+
this.blockEntityIndexCache = _Caching.createAssetCache();
|
|
299
|
+
}
|
|
294
300
|
static createAssetCache() {
|
|
295
301
|
return import_loading_cache.Caches.builder().expireAfterWrite(import_time.Time.minutes(10)).expireAfterAccess(import_time.Time.minutes(5)).expirationInterval(import_time.Time.seconds(30)).buildAsync();
|
|
296
302
|
}
|
|
@@ -315,7 +321,9 @@ var init_Caching = __esm({
|
|
|
315
321
|
this.defaultBlockStatesCache,
|
|
316
322
|
this.blockTintCache,
|
|
317
323
|
this.entityModelCache,
|
|
318
|
-
this.entityTextureCache
|
|
324
|
+
this.entityTextureCache,
|
|
325
|
+
this.entityAnimationCache,
|
|
326
|
+
this.blockEntityIndexCache
|
|
319
327
|
];
|
|
320
328
|
}
|
|
321
329
|
static clear() {
|
|
@@ -3166,10 +3174,10 @@ var init_InstanceReference = __esm({
|
|
|
3166
3174
|
function isSceneObject(obj) {
|
|
3167
3175
|
return obj.isSceneObject;
|
|
3168
3176
|
}
|
|
3169
|
-
var
|
|
3177
|
+
var import_three11, import_ts_deepmerge3, p6, SceneObject;
|
|
3170
3178
|
var init_SceneObject = __esm({
|
|
3171
3179
|
"src/renderer/SceneObject.ts"() {
|
|
3172
|
-
|
|
3180
|
+
import_three11 = require("three");
|
|
3173
3181
|
init_Geometries();
|
|
3174
3182
|
init_UVMapper();
|
|
3175
3183
|
init_Axis();
|
|
@@ -3181,7 +3189,7 @@ var init_SceneObject = __esm({
|
|
|
3181
3189
|
import_ts_deepmerge3 = __toESM(require_dist());
|
|
3182
3190
|
init_log();
|
|
3183
3191
|
p6 = prefix("SceneObject");
|
|
3184
|
-
SceneObject = class _SceneObject extends
|
|
3192
|
+
SceneObject = class _SceneObject extends import_three11.Object3D {
|
|
3185
3193
|
constructor(options) {
|
|
3186
3194
|
super();
|
|
3187
3195
|
this.isSceneObject = true;
|
|
@@ -3233,7 +3241,7 @@ var init_SceneObject = __esm({
|
|
|
3233
3241
|
return group;
|
|
3234
3242
|
}
|
|
3235
3243
|
createGroup(name, x = 0, y = 0, z = 0, offsetAxis, offset = 0) {
|
|
3236
|
-
const obj = new
|
|
3244
|
+
const obj = new import_three11.Object3D();
|
|
3237
3245
|
if (name) {
|
|
3238
3246
|
obj.name = `group:${name}`;
|
|
3239
3247
|
}
|
|
@@ -3283,7 +3291,7 @@ var init_SceneObject = __esm({
|
|
|
3283
3291
|
return mesh;
|
|
3284
3292
|
}
|
|
3285
3293
|
createMesh(name, geometry, material, offsetAxis, offset = 0) {
|
|
3286
|
-
const mesh = new
|
|
3294
|
+
const mesh = new import_three11.Mesh(geometry, material);
|
|
3287
3295
|
if (name) {
|
|
3288
3296
|
mesh.name = `mesh:${name}`;
|
|
3289
3297
|
}
|
|
@@ -3295,7 +3303,7 @@ var init_SceneObject = __esm({
|
|
|
3295
3303
|
return mesh;
|
|
3296
3304
|
}
|
|
3297
3305
|
createInstancedMesh(name, geometry, material, count) {
|
|
3298
|
-
const mesh = new
|
|
3306
|
+
const mesh = new import_three11.InstancedMesh(geometry, material, count);
|
|
3299
3307
|
mesh.count = 0;
|
|
3300
3308
|
this.instanceMesh = mesh;
|
|
3301
3309
|
this._isInstanced = true;
|
|
@@ -3375,11 +3383,11 @@ var init_SceneObject = __esm({
|
|
|
3375
3383
|
this._instanceCounter = this.instanceReferences.size;
|
|
3376
3384
|
mesh.count = Math.max(mesh.count, index + 1);
|
|
3377
3385
|
if (mesh.instanceColor) {
|
|
3378
|
-
mesh.setColorAt(index, new
|
|
3386
|
+
mesh.setColorAt(index, new import_three11.Color(16777215));
|
|
3379
3387
|
mesh.instanceColor.needsUpdate = true;
|
|
3380
3388
|
}
|
|
3381
3389
|
if (this._scene) this._scene.stats.instanceCount++;
|
|
3382
|
-
this.setMatrixAt(index, new
|
|
3390
|
+
this.setMatrixAt(index, new import_three11.Matrix4());
|
|
3383
3391
|
return reference;
|
|
3384
3392
|
}
|
|
3385
3393
|
/** Returns the live reference for a raycast hit on this object's instance mesh. */
|
|
@@ -3392,7 +3400,7 @@ var init_SceneObject = __esm({
|
|
|
3392
3400
|
removeInstanceAt(index) {
|
|
3393
3401
|
if (!this.instanceReferences.has(index)) return;
|
|
3394
3402
|
const mesh = this.instanceMesh;
|
|
3395
|
-
this.setMatrixAt(index, new
|
|
3403
|
+
this.setMatrixAt(index, new import_three11.Matrix4().makeScale(0, 0, 0));
|
|
3396
3404
|
this.instanceReferences.delete(index);
|
|
3397
3405
|
this.freeInstanceIndices.push(index);
|
|
3398
3406
|
this._instanceCounter = this.instanceReferences.size;
|
|
@@ -3405,7 +3413,7 @@ var init_SceneObject = __esm({
|
|
|
3405
3413
|
const grow = (attribute, fill) => {
|
|
3406
3414
|
const array = new Float32Array(capacity * attribute.itemSize).fill(fill);
|
|
3407
3415
|
array.set(attribute.array);
|
|
3408
|
-
return new
|
|
3416
|
+
return new import_three11.InstancedBufferAttribute(array, attribute.itemSize, attribute.normalized, attribute.meshPerAttribute).setUsage(attribute.usage);
|
|
3409
3417
|
};
|
|
3410
3418
|
const matrix = grow(mesh.instanceMatrix, 0);
|
|
3411
3419
|
const color = mesh.instanceColor ? grow(mesh.instanceColor, 1) : null;
|
|
@@ -3422,7 +3430,7 @@ var init_SceneObject = __esm({
|
|
|
3422
3430
|
}
|
|
3423
3431
|
//</editor-fold>
|
|
3424
3432
|
//<editor-fold desc="TRANSFORMATION">
|
|
3425
|
-
getMatrixAt(index, matrix = new
|
|
3433
|
+
getMatrixAt(index, matrix = new import_three11.Matrix4()) {
|
|
3426
3434
|
if (!this.instanceReferences.has(index)) throw new MineRenderError("Instance is not active");
|
|
3427
3435
|
this.instanceMesh.getMatrixAt(index, matrix);
|
|
3428
3436
|
return matrix;
|
|
@@ -3438,16 +3446,16 @@ var init_SceneObject = __esm({
|
|
|
3438
3446
|
}
|
|
3439
3447
|
setPositionRotationScaleAt(index, position, rotation, scale) {
|
|
3440
3448
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3441
|
-
const oldPosition = new
|
|
3442
|
-
const oldRotation = new
|
|
3443
|
-
const oldScale = new
|
|
3444
|
-
const matrix = new
|
|
3449
|
+
const oldPosition = new import_three11.Vector3();
|
|
3450
|
+
const oldRotation = new import_three11.Quaternion();
|
|
3451
|
+
const oldScale = new import_three11.Vector3();
|
|
3452
|
+
const matrix = new import_three11.Matrix4();
|
|
3445
3453
|
if (!scale || !rotation || !position) {
|
|
3446
3454
|
this.getMatrixAt(index, matrix).decompose(oldPosition, oldRotation, oldScale);
|
|
3447
3455
|
}
|
|
3448
3456
|
matrix.compose(
|
|
3449
3457
|
position ? position : oldPosition,
|
|
3450
|
-
rotation ? new
|
|
3458
|
+
rotation ? new import_three11.Quaternion().setFromEuler(rotation) : oldRotation,
|
|
3451
3459
|
scale ? scale : oldScale
|
|
3452
3460
|
);
|
|
3453
3461
|
this.setMatrixAt(index, matrix);
|
|
@@ -3456,7 +3464,7 @@ var init_SceneObject = __esm({
|
|
|
3456
3464
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3457
3465
|
this.setPositionRotationScaleAt(index, position);
|
|
3458
3466
|
}
|
|
3459
|
-
getPositionAt(index, vector = new
|
|
3467
|
+
getPositionAt(index, vector = new import_three11.Vector3()) {
|
|
3460
3468
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3461
3469
|
const matrix = this.getMatrixAt(index);
|
|
3462
3470
|
vector.setFromMatrixPosition(matrix);
|
|
@@ -3466,17 +3474,17 @@ var init_SceneObject = __esm({
|
|
|
3466
3474
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3467
3475
|
this.setPositionRotationScaleAt(index, void 0, rotation, void 0);
|
|
3468
3476
|
}
|
|
3469
|
-
getRotationAt(index, euler = new
|
|
3477
|
+
getRotationAt(index, euler = new import_three11.Euler()) {
|
|
3470
3478
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3471
|
-
const rotation = new
|
|
3472
|
-
this.getMatrixAt(index).decompose(new
|
|
3479
|
+
const rotation = new import_three11.Quaternion();
|
|
3480
|
+
this.getMatrixAt(index).decompose(new import_three11.Vector3(), rotation, new import_three11.Vector3());
|
|
3473
3481
|
return euler.setFromQuaternion(rotation);
|
|
3474
3482
|
}
|
|
3475
3483
|
setScaleAt(index, scale) {
|
|
3476
3484
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3477
3485
|
this.setPositionRotationScaleAt(index, void 0, void 0, scale);
|
|
3478
3486
|
}
|
|
3479
|
-
getScaleAt(index, vector = new
|
|
3487
|
+
getScaleAt(index, vector = new import_three11.Vector3()) {
|
|
3480
3488
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3481
3489
|
const matrix = this.getMatrixAt(index);
|
|
3482
3490
|
vector.setFromMatrixScale(matrix);
|
|
@@ -3612,7 +3620,7 @@ function mergeBufferGeometries(geometries, useGroups = false) {
|
|
|
3612
3620
|
const attributes = {};
|
|
3613
3621
|
const morphAttributes = {};
|
|
3614
3622
|
const morphTargetsRelative = geometries[0].morphTargetsRelative;
|
|
3615
|
-
const mergedGeometry = new
|
|
3623
|
+
const mergedGeometry = new import_three20.BufferGeometry();
|
|
3616
3624
|
let offset = 0;
|
|
3617
3625
|
for (let i = 0; i < geometries.length; ++i) {
|
|
3618
3626
|
const geometry = geometries[i];
|
|
@@ -3736,7 +3744,7 @@ function mergeBufferAttributes(attributes) {
|
|
|
3736
3744
|
array.set(attributes[i].array, offset);
|
|
3737
3745
|
offset += attributes[i].array.length;
|
|
3738
3746
|
}
|
|
3739
|
-
return new
|
|
3747
|
+
return new import_three20.BufferAttribute(array, itemSize, normalized);
|
|
3740
3748
|
}
|
|
3741
3749
|
function interleaveAttributes(attributes) {
|
|
3742
3750
|
let TypedArray;
|
|
@@ -3752,7 +3760,7 @@ function interleaveAttributes(attributes) {
|
|
|
3752
3760
|
arrayLength += attribute.array.length;
|
|
3753
3761
|
stride += attribute.itemSize;
|
|
3754
3762
|
}
|
|
3755
|
-
const interleavedBuffer = new
|
|
3763
|
+
const interleavedBuffer = new import_three20.InterleavedBuffer(new TypedArray(arrayLength), stride);
|
|
3756
3764
|
let offset = 0;
|
|
3757
3765
|
const res = [];
|
|
3758
3766
|
const getters = ["getX", "getY", "getZ", "getW"];
|
|
@@ -3761,7 +3769,7 @@ function interleaveAttributes(attributes) {
|
|
|
3761
3769
|
const attribute = attributes[j];
|
|
3762
3770
|
const itemSize = attribute.itemSize;
|
|
3763
3771
|
const count = attribute.count;
|
|
3764
|
-
const iba = new
|
|
3772
|
+
const iba = new import_three20.InterleavedBufferAttribute(interleavedBuffer, itemSize, offset, attribute.normalized);
|
|
3765
3773
|
res.push(iba);
|
|
3766
3774
|
offset += itemSize;
|
|
3767
3775
|
for (let c = 0; c < count; c++) {
|
|
@@ -3845,13 +3853,13 @@ function mergeVertices(geometry, tolerance = 1e-4) {
|
|
|
3845
3853
|
const name = attributeNames[i];
|
|
3846
3854
|
const oldAttribute = geometry.getAttribute(name);
|
|
3847
3855
|
const buffer = new oldAttribute.array.constructor(attrArrays[name]);
|
|
3848
|
-
const attribute = new
|
|
3856
|
+
const attribute = new import_three20.BufferAttribute(buffer, oldAttribute.itemSize, oldAttribute.normalized);
|
|
3849
3857
|
result.setAttribute(name, attribute);
|
|
3850
3858
|
if (name in morphAttrsArrays) {
|
|
3851
3859
|
for (let j = 0; j < morphAttrsArrays[name].length; j++) {
|
|
3852
3860
|
const oldMorphAttribute = geometry.morphAttributes[name][j];
|
|
3853
3861
|
const buffer2 = new oldMorphAttribute.array.constructor(morphAttrsArrays[name][j]);
|
|
3854
|
-
const morphAttribute = new
|
|
3862
|
+
const morphAttribute = new import_three20.BufferAttribute(buffer2, oldMorphAttribute.itemSize, oldMorphAttribute.normalized);
|
|
3855
3863
|
result.morphAttributes[name][j] = morphAttribute;
|
|
3856
3864
|
}
|
|
3857
3865
|
}
|
|
@@ -3860,11 +3868,11 @@ function mergeVertices(geometry, tolerance = 1e-4) {
|
|
|
3860
3868
|
return result;
|
|
3861
3869
|
}
|
|
3862
3870
|
function toTrianglesDrawMode(geometry, drawMode) {
|
|
3863
|
-
if (drawMode ===
|
|
3871
|
+
if (drawMode === import_three20.TrianglesDrawMode) {
|
|
3864
3872
|
console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles.");
|
|
3865
3873
|
return geometry;
|
|
3866
3874
|
}
|
|
3867
|
-
if (drawMode ===
|
|
3875
|
+
if (drawMode === import_three20.TriangleFanDrawMode || drawMode === import_three20.TriangleStripDrawMode) {
|
|
3868
3876
|
let index = geometry.getIndex();
|
|
3869
3877
|
if (index === null) {
|
|
3870
3878
|
const indices = [];
|
|
@@ -3882,7 +3890,7 @@ function toTrianglesDrawMode(geometry, drawMode) {
|
|
|
3882
3890
|
}
|
|
3883
3891
|
const numberOfTriangles = index.count - 2;
|
|
3884
3892
|
const newIndices = [];
|
|
3885
|
-
if (drawMode ===
|
|
3893
|
+
if (drawMode === import_three20.TriangleFanDrawMode) {
|
|
3886
3894
|
for (let i = 1; i <= numberOfTriangles; i++) {
|
|
3887
3895
|
newIndices.push(index.getX(0));
|
|
3888
3896
|
newIndices.push(index.getX(i));
|
|
@@ -3918,15 +3926,15 @@ function computeMorphedAttributes(object) {
|
|
|
3918
3926
|
console.error("THREE.BufferGeometryUtils: Geometry is not of type BufferGeometry.");
|
|
3919
3927
|
return null;
|
|
3920
3928
|
}
|
|
3921
|
-
const _vA = new
|
|
3922
|
-
const _vB = new
|
|
3923
|
-
const _vC = new
|
|
3924
|
-
const _tempA = new
|
|
3925
|
-
const _tempB = new
|
|
3926
|
-
const _tempC = new
|
|
3927
|
-
const _morphA = new
|
|
3928
|
-
const _morphB = new
|
|
3929
|
-
const _morphC = new
|
|
3929
|
+
const _vA = new import_three20.Vector3();
|
|
3930
|
+
const _vB = new import_three20.Vector3();
|
|
3931
|
+
const _vC = new import_three20.Vector3();
|
|
3932
|
+
const _tempA = new import_three20.Vector3();
|
|
3933
|
+
const _tempB = new import_three20.Vector3();
|
|
3934
|
+
const _tempC = new import_three20.Vector3();
|
|
3935
|
+
const _morphA = new import_three20.Vector3();
|
|
3936
|
+
const _morphB = new import_three20.Vector3();
|
|
3937
|
+
const _morphC = new import_three20.Vector3();
|
|
3930
3938
|
function _calculateMorphedAttributeData(object2, material2, attribute, morphAttribute, morphTargetsRelative2, a2, b2, c2, modifiedAttributeArray) {
|
|
3931
3939
|
_vA.fromBufferAttribute(attribute, a2);
|
|
3932
3940
|
_vB.fromBufferAttribute(attribute, b2);
|
|
@@ -4121,8 +4129,8 @@ function computeMorphedAttributes(object) {
|
|
|
4121
4129
|
}
|
|
4122
4130
|
}
|
|
4123
4131
|
}
|
|
4124
|
-
const morphedPositionAttribute = new
|
|
4125
|
-
const morphedNormalAttribute = new
|
|
4132
|
+
const morphedPositionAttribute = new import_three20.Float32BufferAttribute(modifiedPosition, 3);
|
|
4133
|
+
const morphedNormalAttribute = new import_three20.Float32BufferAttribute(modifiedNormal, 3);
|
|
4126
4134
|
return {
|
|
4127
4135
|
positionAttribute,
|
|
4128
4136
|
normalAttribute,
|
|
@@ -4130,24 +4138,24 @@ function computeMorphedAttributes(object) {
|
|
|
4130
4138
|
morphedNormalAttribute
|
|
4131
4139
|
};
|
|
4132
4140
|
}
|
|
4133
|
-
var
|
|
4141
|
+
var import_three20;
|
|
4134
4142
|
var init_BufferGeometryUtils = __esm({
|
|
4135
4143
|
"src/three/BufferGeometryUtils.js"() {
|
|
4136
|
-
|
|
4144
|
+
import_three20 = require("three");
|
|
4137
4145
|
}
|
|
4138
4146
|
});
|
|
4139
4147
|
|
|
4140
4148
|
// src/model/ModelCulling.ts
|
|
4141
|
-
var
|
|
4149
|
+
var import_three21, ModelCulling;
|
|
4142
4150
|
var init_ModelCulling = __esm({
|
|
4143
4151
|
"src/model/ModelCulling.ts"() {
|
|
4144
|
-
|
|
4152
|
+
import_three21 = require("three");
|
|
4145
4153
|
init_CubeFace();
|
|
4146
4154
|
ModelCulling = class {
|
|
4147
4155
|
static toLocalMask(worldMask, rotation) {
|
|
4148
4156
|
let localMask = 0;
|
|
4149
4157
|
for (const [localFace, offset] of CUBE_FACE_OFFSETS.entries()) {
|
|
4150
|
-
const normal = new
|
|
4158
|
+
const normal = new import_three21.Vector3(...offset).applyEuler(rotation);
|
|
4151
4159
|
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);
|
|
4152
4160
|
if (worldFace < 0) return 0;
|
|
4153
4161
|
if (worldMask & 1 << worldFace) localMask |= 1 << localFace;
|
|
@@ -4183,13 +4191,13 @@ var init_ModelCulling = __esm({
|
|
|
4183
4191
|
function isModelObject(obj) {
|
|
4184
4192
|
return obj.isModelObject;
|
|
4185
4193
|
}
|
|
4186
|
-
var
|
|
4194
|
+
var import_three22, import_ts_deepmerge5, p7, ModelObject;
|
|
4187
4195
|
var init_ModelObject = __esm({
|
|
4188
4196
|
"src/model/scene/ModelObject.ts"() {
|
|
4189
4197
|
init_SceneObject();
|
|
4190
4198
|
init_Materials();
|
|
4191
4199
|
init_UVMapper();
|
|
4192
|
-
|
|
4200
|
+
import_three22 = require("three");
|
|
4193
4201
|
init_BufferGeometryUtils();
|
|
4194
4202
|
init_model();
|
|
4195
4203
|
import_ts_deepmerge5 = __toESM(require_dist());
|
|
@@ -4246,7 +4254,7 @@ var init_ModelObject = __esm({
|
|
|
4246
4254
|
elGeo.clearGroups();
|
|
4247
4255
|
}
|
|
4248
4256
|
if (this.options.uvLockRotation) {
|
|
4249
|
-
UVMapper.lockUvs(elGeo, el.faces, this.atlas, new
|
|
4257
|
+
UVMapper.lockUvs(elGeo, el.faces, this.atlas, new import_three22.Euler(...this.options.uvLockRotation));
|
|
4250
4258
|
}
|
|
4251
4259
|
if (this.options.tints) {
|
|
4252
4260
|
const colors = new Float32Array(elGeo.getAttribute("position").count * 3).fill(1);
|
|
@@ -4255,19 +4263,19 @@ var init_ModelObject = __esm({
|
|
|
4255
4263
|
if (tintIndex === void 0 || tintIndex < 0) continue;
|
|
4256
4264
|
const tint = this.options.tints[tintIndex];
|
|
4257
4265
|
if (tint === void 0) continue;
|
|
4258
|
-
const color = new
|
|
4266
|
+
const color = new import_three22.Color(tint);
|
|
4259
4267
|
for (let vertex = 0; vertex < 4; vertex++) {
|
|
4260
4268
|
color.toArray(colors, (faceIndex * 4 + vertex) * 3);
|
|
4261
4269
|
}
|
|
4262
4270
|
}
|
|
4263
|
-
elGeo.setAttribute("color", new
|
|
4271
|
+
elGeo.setAttribute("color", new import_three22.BufferAttribute(colors, 3));
|
|
4264
4272
|
}
|
|
4265
|
-
elGeo.applyMatrix4(new
|
|
4266
|
-
elGeo.applyMatrix4(new
|
|
4273
|
+
elGeo.applyMatrix4(new import_three22.Matrix4().makeTranslation((el.to[0] - el.from[0]) / 2, (el.to[1] - el.from[1]) / 2, (el.to[2] - el.from[2]) / 2));
|
|
4274
|
+
elGeo.applyMatrix4(new import_three22.Matrix4().makeTranslation(el.from[0], el.from[1], el.from[2]));
|
|
4267
4275
|
if (el.rotation) {
|
|
4268
4276
|
applyElementRotation(el.rotation, elGeo);
|
|
4269
4277
|
}
|
|
4270
|
-
elGeo.applyMatrix4(new
|
|
4278
|
+
elGeo.applyMatrix4(new import_three22.Matrix4().makeTranslation(-8, -8, -8));
|
|
4271
4279
|
if (displayTransform) DisplayTransforms.apply(elGeo, displayTransform);
|
|
4272
4280
|
if (this.options.mergeMeshes) {
|
|
4273
4281
|
allGeos.push(elGeo);
|
|
@@ -4289,7 +4297,7 @@ var init_ModelObject = __esm({
|
|
|
4289
4297
|
if (allGeos.length > 0) {
|
|
4290
4298
|
combinedGeo = mergeBufferGeometries(allGeos);
|
|
4291
4299
|
} else {
|
|
4292
|
-
combinedGeo = new
|
|
4300
|
+
combinedGeo = new import_three22.BoxGeometry(16, 16, 16);
|
|
4293
4301
|
if (displayTransform) DisplayTransforms.apply(combinedGeo, displayTransform);
|
|
4294
4302
|
}
|
|
4295
4303
|
combinedGeo.computeBoundingBox();
|
|
@@ -4397,7 +4405,7 @@ function ownHeight(sample) {
|
|
|
4397
4405
|
return (level === 0 || level >= 8 ? 8 : 8 - level) / 9;
|
|
4398
4406
|
}
|
|
4399
4407
|
function createFluidGeometry(kind, sample) {
|
|
4400
|
-
const geometry = new
|
|
4408
|
+
const geometry = new import_three27.BufferGeometry();
|
|
4401
4409
|
const positions = [], normals = [], uvs = [], indices = [];
|
|
4402
4410
|
const self = sample(0, 0, 0);
|
|
4403
4411
|
const height = (x, z) => {
|
|
@@ -4496,16 +4504,16 @@ function createFluidGeometry(kind, sample) {
|
|
|
4496
4504
|
1
|
|
4497
4505
|
);
|
|
4498
4506
|
}
|
|
4499
|
-
geometry.setAttribute("position", new
|
|
4500
|
-
geometry.setAttribute("normal", new
|
|
4501
|
-
geometry.setAttribute("uv", new
|
|
4507
|
+
geometry.setAttribute("position", new import_three27.Float32BufferAttribute(positions, 3));
|
|
4508
|
+
geometry.setAttribute("normal", new import_three27.Float32BufferAttribute(normals, 3));
|
|
4509
|
+
geometry.setAttribute("uv", new import_three27.Float32BufferAttribute(uvs, 2));
|
|
4502
4510
|
geometry.setIndex(indices);
|
|
4503
4511
|
return geometry;
|
|
4504
4512
|
}
|
|
4505
|
-
var
|
|
4513
|
+
var import_three27, fluidRules, HORIZONTAL, EPSILON;
|
|
4506
4514
|
var init_FluidGeometry = __esm({
|
|
4507
4515
|
"src/model/fluid/FluidGeometry.ts"() {
|
|
4508
|
-
|
|
4516
|
+
import_three27 = require("three");
|
|
4509
4517
|
init_fluidBlocks();
|
|
4510
4518
|
fluidRules = fluidBlocks_default;
|
|
4511
4519
|
HORIZONTAL = [[0, -1], [0, 1], [-1, 0], [1, 0]];
|
|
@@ -4534,10 +4542,10 @@ function sampleFluid(kind, sample) {
|
|
|
4534
4542
|
}
|
|
4535
4543
|
return { key: key.join(""), sample: (x, y, z) => cells[(y + 1) * 9 + (z + 1) * 3 + x + 1] };
|
|
4536
4544
|
}
|
|
4537
|
-
var
|
|
4545
|
+
var import_three28, FluidModelObject;
|
|
4538
4546
|
var init_FluidModelObject = __esm({
|
|
4539
4547
|
"src/model/fluid/FluidModelObject.ts"() {
|
|
4540
|
-
|
|
4548
|
+
import_three28 = require("three");
|
|
4541
4549
|
init_AssetKey();
|
|
4542
4550
|
init_Materials();
|
|
4543
4551
|
init_ModelObject();
|
|
@@ -4570,10 +4578,10 @@ var init_FluidModelObject = __esm({
|
|
|
4570
4578
|
}
|
|
4571
4579
|
}
|
|
4572
4580
|
geometry.clearGroups();
|
|
4573
|
-
const color = new
|
|
4581
|
+
const color = new import_three28.Color(this.options.tints?.[0] ?? (this.kind === "water" ? 4159204 : 16777215));
|
|
4574
4582
|
const colors = new Float32Array(geometry.getAttribute("position").count * 3);
|
|
4575
4583
|
for (let i = 0; i < colors.length; i += 3) color.toArray(colors, i);
|
|
4576
|
-
geometry.setAttribute("color", new
|
|
4584
|
+
geometry.setAttribute("color", new import_three28.BufferAttribute(colors, 3));
|
|
4577
4585
|
geometry.computeBoundingBox();
|
|
4578
4586
|
geometry.computeBoundingSphere();
|
|
4579
4587
|
if (this.options.instanceMeshes) {
|
|
@@ -4587,7 +4595,7 @@ var init_FluidModelObject = __esm({
|
|
|
4587
4595
|
super.applyTextures();
|
|
4588
4596
|
this.iterateAllMeshes((mesh) => {
|
|
4589
4597
|
const material = mesh.material;
|
|
4590
|
-
material.side =
|
|
4598
|
+
material.side = import_three28.DoubleSide;
|
|
4591
4599
|
material.forceSinglePass = true;
|
|
4592
4600
|
material.depthWrite = !material.transparent;
|
|
4593
4601
|
});
|
|
@@ -4618,6 +4626,7 @@ __export(index_node_exports, {
|
|
|
4618
4626
|
BUILTIN_GENERATED: () => BUILTIN_GENERATED,
|
|
4619
4627
|
BasicAssetKey: () => BasicAssetKey,
|
|
4620
4628
|
BatchedExecutor: () => BatchedExecutor,
|
|
4629
|
+
BlockEntities: () => BlockEntities,
|
|
4621
4630
|
BlockObject: () => BlockObject,
|
|
4622
4631
|
BlockStateResolver: () => BlockStateResolver,
|
|
4623
4632
|
BlockStates: () => BlockStates,
|
|
@@ -4639,7 +4648,9 @@ __export(index_node_exports, {
|
|
|
4639
4648
|
DefaultBlockStates: () => DefaultBlockStates,
|
|
4640
4649
|
DisplayPosition: () => DisplayPosition,
|
|
4641
4650
|
DisplayTransforms: () => DisplayTransforms,
|
|
4651
|
+
ENTITY_ANIMATION_CHANNELS: () => ENTITY_ANIMATION_CHANNELS,
|
|
4642
4652
|
Entities: () => Entities,
|
|
4653
|
+
EntityAnimationPlayer: () => EntityAnimationPlayer,
|
|
4643
4654
|
EntityObject: () => EntityObject,
|
|
4644
4655
|
Env: () => Env,
|
|
4645
4656
|
FluidModelObject: () => FluidModelObject,
|
|
@@ -4715,6 +4726,7 @@ __export(index_node_exports, {
|
|
|
4715
4726
|
createCanvas: () => createCanvas2,
|
|
4716
4727
|
createFluidGeometry: () => createFluidGeometry,
|
|
4717
4728
|
createImage: () => createImage,
|
|
4729
|
+
entityAnimationTime: () => entityAnimationTime,
|
|
4718
4730
|
estimateBytesUsed: () => estimateBytesUsed,
|
|
4719
4731
|
getBlockFluidState: () => getBlockFluidState,
|
|
4720
4732
|
getFluidKind: () => getFluidKind,
|
|
@@ -4747,6 +4759,8 @@ __export(index_node_exports, {
|
|
|
4747
4759
|
mergeVertices: () => mergeVertices,
|
|
4748
4760
|
prefix: () => prefix,
|
|
4749
4761
|
registerNodeEnv: () => registerNodeEnv,
|
|
4762
|
+
sampleEntityAnimation: () => sampleEntityAnimation,
|
|
4763
|
+
sampleEntityKeyframes: () => sampleEntityKeyframes,
|
|
4750
4764
|
sampleFluid: () => sampleFluid,
|
|
4751
4765
|
serializeBoxGeometryKey: () => serializeBoxGeometryKey,
|
|
4752
4766
|
serializeImageKey: () => serializeImageKey,
|
|
@@ -5004,6 +5018,59 @@ function shutdown() {
|
|
|
5004
5018
|
init_AssetKey();
|
|
5005
5019
|
init_AssetLoader();
|
|
5006
5020
|
init_Assets();
|
|
5021
|
+
|
|
5022
|
+
// src/assets/BlockEntities.ts
|
|
5023
|
+
var import_three10 = require("three");
|
|
5024
|
+
init_AssetKey();
|
|
5025
|
+
init_AssetLoader();
|
|
5026
|
+
init_source();
|
|
5027
|
+
init_Caching();
|
|
5028
|
+
var BlockEntities = class {
|
|
5029
|
+
/**
|
|
5030
|
+
* Loads the block index of a version. Versions and sources without one yield an empty index, and so does
|
|
5031
|
+
* a failed load: the index is optional, and blocks must not retry or fail with it one by one. The empty
|
|
5032
|
+
* result is cached like any other; `Caching.clear()` or `AssetLoader.setVersion()` forces a new attempt.
|
|
5033
|
+
*/
|
|
5034
|
+
static async getIndex(root) {
|
|
5035
|
+
const key = new AssetKey("entity-models", "blocks", void 0, void 0, void 0, ".json", root);
|
|
5036
|
+
key.rootType = void 0;
|
|
5037
|
+
const index = await Caching.blockEntityIndexCache.get(key.serialize(), async () => {
|
|
5038
|
+
try {
|
|
5039
|
+
return await AssetLoader.get(key, "json" /* JSON */) ?? {};
|
|
5040
|
+
} catch (error) {
|
|
5041
|
+
console.warn("Could not load the block entity index; block entities are drawn as plain block models", error);
|
|
5042
|
+
return {};
|
|
5043
|
+
}
|
|
5044
|
+
});
|
|
5045
|
+
return index ?? {};
|
|
5046
|
+
}
|
|
5047
|
+
/** The index entry of a block ID such as `minecraft:chest`. */
|
|
5048
|
+
static entry(index, block) {
|
|
5049
|
+
const entry = Object.prototype.hasOwnProperty.call(index, block) ? index[block] : void 0;
|
|
5050
|
+
return Array.isArray(entry?.parts) ? entry : void 0;
|
|
5051
|
+
}
|
|
5052
|
+
/** Selects the parts and placement for a block ID such as `minecraft:chest`; undefined when nothing is drawn. */
|
|
5053
|
+
static resolve(index, block, state = {}) {
|
|
5054
|
+
const entry = this.entry(index, block);
|
|
5055
|
+
if (!entry) return void 0;
|
|
5056
|
+
const value = (property) => String(state[property]).toLowerCase();
|
|
5057
|
+
const parts = entry.parts.filter((part) => Object.entries(part.when ?? {}).every(([property, values]) => String(values).split("|").includes(value(property))));
|
|
5058
|
+
if (!parts.length) return void 0;
|
|
5059
|
+
let rotation = 0;
|
|
5060
|
+
if (entry.rotation) {
|
|
5061
|
+
const selected = value(entry.rotation.property);
|
|
5062
|
+
rotation = "degrees" in entry.rotation ? entry.rotation.degrees[selected] : Number(selected) * entry.rotation.step;
|
|
5063
|
+
if (!Number.isFinite(rotation)) rotation = 0;
|
|
5064
|
+
}
|
|
5065
|
+
return { parts, rotation, translation: entry.translation ?? [0, 0, 0] };
|
|
5066
|
+
}
|
|
5067
|
+
/** Placement in block space (0..16 per axis), applied on top of the model's own transform. */
|
|
5068
|
+
static matrix(resolved, matrix = new import_three10.Matrix4()) {
|
|
5069
|
+
return matrix.makeTranslation(8, 0, 8).multiply(new import_three10.Matrix4().makeRotationY(resolved.rotation * Math.PI / 180)).multiply(new import_three10.Matrix4().makeTranslation(resolved.translation[0] - 8, resolved.translation[1], resolved.translation[2] - 8));
|
|
5070
|
+
}
|
|
5071
|
+
};
|
|
5072
|
+
|
|
5073
|
+
// src/assets/index.ts
|
|
5007
5074
|
init_BlockStates();
|
|
5008
5075
|
|
|
5009
5076
|
// src/assets/Entities.ts
|
|
@@ -5074,6 +5141,15 @@ var Entities = class {
|
|
|
5074
5141
|
})));
|
|
5075
5142
|
return { ...layers[names[0]], id: model.id, layers, ...model.transform && { transform: model.transform } };
|
|
5076
5143
|
}
|
|
5144
|
+
/**
|
|
5145
|
+
* Vanilla's keyframe animations of a model by name, or undefined when the model or the selected version has none.
|
|
5146
|
+
*/
|
|
5147
|
+
static async getAnimations(modelKey) {
|
|
5148
|
+
const path = isAssetKey(modelKey) ? modelKey.getFullPath() : modelKey.path;
|
|
5149
|
+
const key = new AssetKey(modelKey.namespace, path, void 0, void 0, "entity-models/animations", ".json");
|
|
5150
|
+
const file = await Caching.entityAnimationCache.get(key.serialize(), () => AssetLoader.get(key, "json" /* JSON */));
|
|
5151
|
+
return file?.animations;
|
|
5152
|
+
}
|
|
5077
5153
|
static async resolveTexture(modelKey) {
|
|
5078
5154
|
const path = isAssetKey(modelKey) ? modelKey.getFullPath() : modelKey.path;
|
|
5079
5155
|
const key = new AssetKey(modelKey.namespace, path, void 0, void 0, "entity-models", ".json");
|
|
@@ -5150,11 +5226,124 @@ function trimCanvas(source) {
|
|
|
5150
5226
|
return canvas;
|
|
5151
5227
|
}
|
|
5152
5228
|
|
|
5229
|
+
// src/entity/EntityAnimation.ts
|
|
5230
|
+
var ENTITY_ANIMATION_CHANNELS = ["position", "rotation", "scale"];
|
|
5231
|
+
function catmullRom(delta, p0, p1, p22, p32) {
|
|
5232
|
+
return 0.5 * (2 * p1 + (p22 - p0) * delta + (2 * p0 - 5 * p1 + 4 * p22 - p32) * delta * delta + (3 * p1 - p0 - 3 * p22 + p32) * delta * delta * delta);
|
|
5233
|
+
}
|
|
5234
|
+
function sampleEntityKeyframes(keyframes, time) {
|
|
5235
|
+
if (keyframes.length === 0) return [0, 0, 0];
|
|
5236
|
+
let low = 0, high = keyframes.length;
|
|
5237
|
+
while (low < high) {
|
|
5238
|
+
const middle = low + high >>> 1;
|
|
5239
|
+
if (time <= keyframes[middle].time) high = middle;
|
|
5240
|
+
else low = middle + 1;
|
|
5241
|
+
}
|
|
5242
|
+
const a = Math.max(0, low - 1);
|
|
5243
|
+
const b = Math.min(keyframes.length - 1, a + 1);
|
|
5244
|
+
const from = keyframes[a];
|
|
5245
|
+
const to = keyframes[b];
|
|
5246
|
+
const delta = a === b ? 0 : Math.min(1, Math.max(0, (time - from.time) / (to.time - from.time)));
|
|
5247
|
+
if (to.interpolation === "catmullrom") {
|
|
5248
|
+
const before = keyframes[Math.max(0, a - 1)].value;
|
|
5249
|
+
const after = keyframes[Math.min(keyframes.length - 1, b + 1)].value;
|
|
5250
|
+
return [0, 1, 2].map((i) => catmullRom(delta, before[i], from.value[i], to.value[i], after[i]));
|
|
5251
|
+
}
|
|
5252
|
+
const target = to.pre ?? to.value;
|
|
5253
|
+
return [0, 1, 2].map((i) => from.value[i] + (target[i] - from.value[i]) * delta);
|
|
5254
|
+
}
|
|
5255
|
+
function entityAnimationTime(animation, time, loop = animation.loop) {
|
|
5256
|
+
return loop && animation.length > 0 ? time % animation.length : time;
|
|
5257
|
+
}
|
|
5258
|
+
function sampleEntityAnimation(animation, time, loop = animation.loop) {
|
|
5259
|
+
const elapsed = entityAnimationTime(animation, time, loop);
|
|
5260
|
+
const pose = {};
|
|
5261
|
+
for (const [name, bone] of Object.entries(animation.bones)) {
|
|
5262
|
+
const sampled = pose[name] = {};
|
|
5263
|
+
for (const channel of ENTITY_ANIMATION_CHANNELS) {
|
|
5264
|
+
const keyframes = bone[channel];
|
|
5265
|
+
if (keyframes?.length) sampled[channel] = sampleEntityKeyframes(keyframes, elapsed);
|
|
5266
|
+
}
|
|
5267
|
+
}
|
|
5268
|
+
return pose;
|
|
5269
|
+
}
|
|
5270
|
+
|
|
5271
|
+
// src/entity/scene/EntityAnimationPlayer.ts
|
|
5272
|
+
var ZERO = [0, 0, 0];
|
|
5273
|
+
var EntityAnimationPlayer = class {
|
|
5274
|
+
constructor() {
|
|
5275
|
+
this.parts = [];
|
|
5276
|
+
this._time = 0;
|
|
5277
|
+
this.loop = false;
|
|
5278
|
+
this.speed = 1;
|
|
5279
|
+
}
|
|
5280
|
+
get animation() {
|
|
5281
|
+
return this._animation;
|
|
5282
|
+
}
|
|
5283
|
+
get time() {
|
|
5284
|
+
return this._time;
|
|
5285
|
+
}
|
|
5286
|
+
/**
|
|
5287
|
+
* Starts an animation on the named parts below each layer root. The current pose of a part becomes its default;
|
|
5288
|
+
* bones without a matching part are skipped.
|
|
5289
|
+
*/
|
|
5290
|
+
play(layers, animation, options = {}) {
|
|
5291
|
+
this.stop();
|
|
5292
|
+
this._animation = animation;
|
|
5293
|
+
this._time = options.time ?? 0;
|
|
5294
|
+
this.loop = options.loop ?? animation.loop;
|
|
5295
|
+
this.speed = options.speed ?? 1;
|
|
5296
|
+
for (const layer of layers) {
|
|
5297
|
+
for (const bone of Object.keys(animation.bones)) {
|
|
5298
|
+
const object = layer.getObjectByName(`group:${bone}`);
|
|
5299
|
+
if (!object) continue;
|
|
5300
|
+
this.parts.push({ bone, object, position: object.position.clone(), rotation: object.rotation.clone(), scale: object.scale.clone() });
|
|
5301
|
+
}
|
|
5302
|
+
}
|
|
5303
|
+
this.apply();
|
|
5304
|
+
}
|
|
5305
|
+
/** Restores the default poses. Returns whether an animation was active. */
|
|
5306
|
+
stop() {
|
|
5307
|
+
if (!this._animation) return false;
|
|
5308
|
+
for (const part of this.parts) {
|
|
5309
|
+
part.object.position.copy(part.position);
|
|
5310
|
+
part.object.rotation.copy(part.rotation);
|
|
5311
|
+
part.object.scale.copy(part.scale);
|
|
5312
|
+
}
|
|
5313
|
+
this.clear();
|
|
5314
|
+
return true;
|
|
5315
|
+
}
|
|
5316
|
+
/** Forgets the animation without touching the parts, for parts that no longer exist. */
|
|
5317
|
+
clear() {
|
|
5318
|
+
this.parts = [];
|
|
5319
|
+
this._animation = void 0;
|
|
5320
|
+
this._time = 0;
|
|
5321
|
+
}
|
|
5322
|
+
setTime(seconds) {
|
|
5323
|
+
if (!this._animation) return false;
|
|
5324
|
+
this._time = seconds;
|
|
5325
|
+
this.apply();
|
|
5326
|
+
return true;
|
|
5327
|
+
}
|
|
5328
|
+
advance(deltaSeconds) {
|
|
5329
|
+
return this.setTime(this._time + deltaSeconds * this.speed);
|
|
5330
|
+
}
|
|
5331
|
+
apply() {
|
|
5332
|
+
const pose = sampleEntityAnimation(this._animation, this._time, this.loop);
|
|
5333
|
+
for (const part of this.parts) {
|
|
5334
|
+
const { position = ZERO, rotation = ZERO, scale = ZERO } = pose[part.bone];
|
|
5335
|
+
part.object.position.set(part.position.x + position[0], part.position.y + position[1], part.position.z + position[2]);
|
|
5336
|
+
part.object.rotation.set(part.rotation.x + rotation[0], part.rotation.y + rotation[1], part.rotation.z + rotation[2], part.rotation.order);
|
|
5337
|
+
part.object.scale.set(part.scale.x + scale[0], part.scale.y + scale[1], part.scale.z + scale[2]);
|
|
5338
|
+
}
|
|
5339
|
+
}
|
|
5340
|
+
};
|
|
5341
|
+
|
|
5153
5342
|
// src/entity/scene/EntityObject.ts
|
|
5154
5343
|
init_SceneObject();
|
|
5155
5344
|
init_Caching();
|
|
5156
5345
|
var import_ts_deepmerge4 = __toESM(require_dist());
|
|
5157
|
-
var
|
|
5346
|
+
var import_three13 = require("three");
|
|
5158
5347
|
init_Ticker();
|
|
5159
5348
|
init_model();
|
|
5160
5349
|
init_ModelTextures();
|
|
@@ -5171,6 +5360,7 @@ var EntityObject = class _EntityObject extends SceneObject {
|
|
|
5171
5360
|
this.scrollMaterials = [];
|
|
5172
5361
|
/** Entity age in ticks, as vanilla's `ageInTicks`; drives the scrolling render modes. */
|
|
5173
5362
|
this.age = 0;
|
|
5363
|
+
this.animationPlayer = new EntityAnimationPlayer();
|
|
5174
5364
|
this.options = (0, import_ts_deepmerge4.default)({}, _EntityObject.DEFAULT_OPTIONS, options ?? {});
|
|
5175
5365
|
}
|
|
5176
5366
|
static {
|
|
@@ -5185,6 +5375,7 @@ var EntityObject = class _EntityObject extends SceneObject {
|
|
|
5185
5375
|
}
|
|
5186
5376
|
disposeAndRemoveAllChildren() {
|
|
5187
5377
|
this.clearScrollMaterials();
|
|
5378
|
+
this.animationPlayer.clear();
|
|
5188
5379
|
super.disposeAndRemoveAllChildren();
|
|
5189
5380
|
}
|
|
5190
5381
|
clearScrollMaterials() {
|
|
@@ -5202,6 +5393,39 @@ var EntityObject = class _EntityObject extends SceneObject {
|
|
|
5202
5393
|
}
|
|
5203
5394
|
this.notifyDirty();
|
|
5204
5395
|
}
|
|
5396
|
+
//<editor-fold desc="ANIMATION">
|
|
5397
|
+
/** The animation started by {@link playAnimation}, until {@link stopAnimation} or disposal. */
|
|
5398
|
+
get animation() {
|
|
5399
|
+
return this.animationPlayer.animation;
|
|
5400
|
+
}
|
|
5401
|
+
/** Seconds since the animation started, before looping. */
|
|
5402
|
+
get animationTime() {
|
|
5403
|
+
return this.animationPlayer.time;
|
|
5404
|
+
}
|
|
5405
|
+
/**
|
|
5406
|
+
* Poses the object from a keyframe animation of {@link Entities.getAnimations}, replacing the current one.
|
|
5407
|
+
* Parts of every layer are matched by name and their current pose is the default the offsets add to.
|
|
5408
|
+
* The object owns no clock: call {@link advanceAnimation} per frame, or {@link setAnimationTime}.
|
|
5409
|
+
*/
|
|
5410
|
+
playAnimation(animation, options) {
|
|
5411
|
+
this.createMeshes();
|
|
5412
|
+
const layers = Object.keys(this.entityLayers).map((name) => this.getLayerGroup(name)).filter((layer) => !!layer);
|
|
5413
|
+
this.animationPlayer.play(layers, animation, options);
|
|
5414
|
+
this.notifyDirty();
|
|
5415
|
+
}
|
|
5416
|
+
/** Stops the animation and restores the default pose. */
|
|
5417
|
+
stopAnimation() {
|
|
5418
|
+
if (this.animationPlayer.stop()) this.notifyDirty();
|
|
5419
|
+
}
|
|
5420
|
+
/** Poses the object at an explicit time in seconds. Has no effect without an animation. */
|
|
5421
|
+
setAnimationTime(seconds) {
|
|
5422
|
+
if (this.animationPlayer.setTime(seconds)) this.notifyDirty();
|
|
5423
|
+
}
|
|
5424
|
+
/** Advances the animation by a frame delta in seconds, scaled by its speed. Has no effect without an animation. */
|
|
5425
|
+
advanceAnimation(deltaSeconds) {
|
|
5426
|
+
if (this.animationPlayer.advance(deltaSeconds)) this.notifyDirty();
|
|
5427
|
+
}
|
|
5428
|
+
//</editor-fold>
|
|
5205
5429
|
getLayerGroup(name) {
|
|
5206
5430
|
return super.getGroupByName(`layer:${name}`);
|
|
5207
5431
|
}
|
|
@@ -5231,14 +5455,14 @@ var EntityObject = class _EntityObject extends SceneObject {
|
|
|
5231
5455
|
}
|
|
5232
5456
|
createMeshes(force = false) {
|
|
5233
5457
|
if (this.meshesCreated && !force) return;
|
|
5234
|
-
const modelRoot = new
|
|
5458
|
+
const modelRoot = new import_three13.Object3D();
|
|
5235
5459
|
const transform = this.options.flip === void 0 ? this.entity.transform : void 0;
|
|
5236
5460
|
if (transform) {
|
|
5237
5461
|
for (const op of transform) {
|
|
5238
|
-
const matrix = new
|
|
5462
|
+
const matrix = new import_three13.Matrix4();
|
|
5239
5463
|
if ("scale" in op) matrix.makeScale(...op.scale);
|
|
5240
5464
|
else if ("translate" in op) matrix.makeTranslation(...op.translate);
|
|
5241
|
-
else matrix.makeRotationFromEuler(new
|
|
5465
|
+
else matrix.makeRotationFromEuler(new import_three13.Euler(...op.rotate, "ZYX"));
|
|
5242
5466
|
modelRoot.matrix.multiply(matrix);
|
|
5243
5467
|
}
|
|
5244
5468
|
modelRoot.matrixAutoUpdate = false;
|
|
@@ -5293,7 +5517,7 @@ var EntityObject = class _EntityObject extends SceneObject {
|
|
|
5293
5517
|
const tint = layer.tint === void 0 ? void 0 : this.options.tints?.[layer.tint];
|
|
5294
5518
|
const scroll = Materials.entityModeScroll(mode);
|
|
5295
5519
|
const assetKeyStr = this.getTextureKey(layer).serialize();
|
|
5296
|
-
const keyStr = `entity:${mode}:${tint === void 0 ? "" : new
|
|
5520
|
+
const keyStr = `entity:${mode}:${tint === void 0 ? "" : new import_three13.Color(tint).getHexString()}:${assetKeyStr}`;
|
|
5297
5521
|
let mat = scroll ? void 0 : Caching.materialCache.getIfPresent(keyStr);
|
|
5298
5522
|
if (!mat) {
|
|
5299
5523
|
const cachedAsset = Caching.textureAssetCache.getIfPresent(assetKeyStr);
|
|
@@ -5330,27 +5554,27 @@ function isEntityObject(obj) {
|
|
|
5330
5554
|
init_MineRenderError();
|
|
5331
5555
|
|
|
5332
5556
|
// src/export/SceneExporter.ts
|
|
5333
|
-
var
|
|
5557
|
+
var import_three19 = require("three");
|
|
5334
5558
|
|
|
5335
5559
|
// ../../node_modules/three/examples/jsm/exporters/OBJExporter.js
|
|
5336
|
-
var
|
|
5560
|
+
var import_three15 = require("three");
|
|
5337
5561
|
var OBJExporter = class {
|
|
5338
5562
|
parse(object) {
|
|
5339
5563
|
let output = "";
|
|
5340
5564
|
let indexVertex = 0;
|
|
5341
5565
|
let indexVertexUvs = 0;
|
|
5342
5566
|
let indexNormals = 0;
|
|
5343
|
-
const vertex = new
|
|
5344
|
-
const color = new
|
|
5345
|
-
const normal = new
|
|
5346
|
-
const uv = new
|
|
5567
|
+
const vertex = new import_three15.Vector3();
|
|
5568
|
+
const color = new import_three15.Color();
|
|
5569
|
+
const normal = new import_three15.Vector3();
|
|
5570
|
+
const uv = new import_three15.Vector2();
|
|
5347
5571
|
const face = [];
|
|
5348
5572
|
function parseMesh(mesh) {
|
|
5349
5573
|
let nbVertex = 0;
|
|
5350
5574
|
let nbNormals = 0;
|
|
5351
5575
|
let nbVertexUvs = 0;
|
|
5352
5576
|
const geometry = mesh.geometry;
|
|
5353
|
-
const normalMatrixWorld = new
|
|
5577
|
+
const normalMatrixWorld = new import_three15.Matrix3();
|
|
5354
5578
|
const vertices = geometry.getAttribute("position");
|
|
5355
5579
|
const normals = geometry.getAttribute("normal");
|
|
5356
5580
|
const uvs = geometry.getAttribute("uv");
|
|
@@ -5469,7 +5693,7 @@ var OBJExporter = class {
|
|
|
5469
5693
|
};
|
|
5470
5694
|
|
|
5471
5695
|
// ../../node_modules/three/examples/jsm/exporters/PLYExporter.js
|
|
5472
|
-
var
|
|
5696
|
+
var import_three16 = require("three");
|
|
5473
5697
|
var PLYExporter = class {
|
|
5474
5698
|
parse(object, onDone, options = {}) {
|
|
5475
5699
|
function traverseMeshes(cb) {
|
|
@@ -5526,7 +5750,7 @@ var PLYExporter = class {
|
|
|
5526
5750
|
includeIndices = false;
|
|
5527
5751
|
}
|
|
5528
5752
|
});
|
|
5529
|
-
const tempColor = new
|
|
5753
|
+
const tempColor = new import_three16.Color();
|
|
5530
5754
|
includeIndices = includeIndices && excludeAttributes.indexOf("index") === -1;
|
|
5531
5755
|
includeNormals = includeNormals && excludeAttributes.indexOf("normal") === -1;
|
|
5532
5756
|
includeColors = includeColors && excludeAttributes.indexOf("color") === -1;
|
|
@@ -5560,8 +5784,8 @@ property list uchar int vertex_index
|
|
|
5560
5784
|
`;
|
|
5561
5785
|
}
|
|
5562
5786
|
header += "end_header\n";
|
|
5563
|
-
const vertex = new
|
|
5564
|
-
const normalMatrixWorld = new
|
|
5787
|
+
const vertex = new import_three16.Vector3();
|
|
5788
|
+
const normalMatrixWorld = new import_three16.Matrix3();
|
|
5565
5789
|
let result = null;
|
|
5566
5790
|
if (options.binary === true) {
|
|
5567
5791
|
const headerBin = new TextEncoder().encode(header);
|
|
@@ -5735,18 +5959,18 @@ property list uchar int vertex_index
|
|
|
5735
5959
|
};
|
|
5736
5960
|
|
|
5737
5961
|
// ../../node_modules/three/examples/jsm/exporters/GLTFExporter.js
|
|
5738
|
-
var
|
|
5962
|
+
var import_three18 = require("three");
|
|
5739
5963
|
|
|
5740
5964
|
// ../../node_modules/three/examples/jsm/utils/TextureUtils.js
|
|
5741
|
-
var
|
|
5965
|
+
var import_three17 = require("three");
|
|
5742
5966
|
var _renderer;
|
|
5743
5967
|
var fullscreenQuadGeometry;
|
|
5744
5968
|
var fullscreenQuadMaterial;
|
|
5745
5969
|
var fullscreenQuad;
|
|
5746
5970
|
function decompress(texture, maxTextureSize = Infinity, renderer = null) {
|
|
5747
|
-
if (!fullscreenQuadGeometry) fullscreenQuadGeometry = new
|
|
5748
|
-
if (!fullscreenQuadMaterial) fullscreenQuadMaterial = new
|
|
5749
|
-
uniforms: { blitTexture: new
|
|
5971
|
+
if (!fullscreenQuadGeometry) fullscreenQuadGeometry = new import_three17.PlaneGeometry(2, 2, 1, 1);
|
|
5972
|
+
if (!fullscreenQuadMaterial) fullscreenQuadMaterial = new import_three17.ShaderMaterial({
|
|
5973
|
+
uniforms: { blitTexture: new import_three17.Uniform(texture) },
|
|
5750
5974
|
vertexShader: `
|
|
5751
5975
|
varying vec2 vUv;
|
|
5752
5976
|
void main(){
|
|
@@ -5768,22 +5992,22 @@ function decompress(texture, maxTextureSize = Infinity, renderer = null) {
|
|
|
5768
5992
|
}`
|
|
5769
5993
|
});
|
|
5770
5994
|
fullscreenQuadMaterial.uniforms.blitTexture.value = texture;
|
|
5771
|
-
fullscreenQuadMaterial.defines.IS_SRGB = texture.colorSpace ==
|
|
5995
|
+
fullscreenQuadMaterial.defines.IS_SRGB = texture.colorSpace == import_three17.SRGBColorSpace;
|
|
5772
5996
|
fullscreenQuadMaterial.needsUpdate = true;
|
|
5773
5997
|
if (!fullscreenQuad) {
|
|
5774
|
-
fullscreenQuad = new
|
|
5998
|
+
fullscreenQuad = new import_three17.Mesh(fullscreenQuadGeometry, fullscreenQuadMaterial);
|
|
5775
5999
|
fullscreenQuad.frustrumCulled = false;
|
|
5776
6000
|
}
|
|
5777
|
-
const _camera = new
|
|
5778
|
-
const _scene = new
|
|
6001
|
+
const _camera = new import_three17.PerspectiveCamera();
|
|
6002
|
+
const _scene = new import_three17.Scene();
|
|
5779
6003
|
_scene.add(fullscreenQuad);
|
|
5780
6004
|
if (!renderer) {
|
|
5781
|
-
renderer = _renderer = new
|
|
6005
|
+
renderer = _renderer = new import_three17.WebGLRenderer({ antialias: false });
|
|
5782
6006
|
}
|
|
5783
6007
|
renderer.setSize(Math.min(texture.image.width, maxTextureSize), Math.min(texture.image.height, maxTextureSize));
|
|
5784
6008
|
renderer.clear();
|
|
5785
6009
|
renderer.render(_scene, _camera);
|
|
5786
|
-
const readableTexture = new
|
|
6010
|
+
const readableTexture = new import_three17.Texture(renderer.domElement);
|
|
5787
6011
|
readableTexture.minFilter = texture.minFilter;
|
|
5788
6012
|
readableTexture.magFilter = texture.magFilter;
|
|
5789
6013
|
readableTexture.wrapS = texture.wrapS;
|
|
@@ -5929,22 +6153,22 @@ var WEBGL_CONSTANTS = {
|
|
|
5929
6153
|
};
|
|
5930
6154
|
var KHR_MESH_QUANTIZATION = "KHR_mesh_quantization";
|
|
5931
6155
|
var THREE_TO_WEBGL = {};
|
|
5932
|
-
THREE_TO_WEBGL[
|
|
5933
|
-
THREE_TO_WEBGL[
|
|
5934
|
-
THREE_TO_WEBGL[
|
|
5935
|
-
THREE_TO_WEBGL[
|
|
5936
|
-
THREE_TO_WEBGL[
|
|
5937
|
-
THREE_TO_WEBGL[
|
|
5938
|
-
THREE_TO_WEBGL[
|
|
5939
|
-
THREE_TO_WEBGL[
|
|
5940
|
-
THREE_TO_WEBGL[
|
|
6156
|
+
THREE_TO_WEBGL[import_three18.NearestFilter] = WEBGL_CONSTANTS.NEAREST;
|
|
6157
|
+
THREE_TO_WEBGL[import_three18.NearestMipmapNearestFilter] = WEBGL_CONSTANTS.NEAREST_MIPMAP_NEAREST;
|
|
6158
|
+
THREE_TO_WEBGL[import_three18.NearestMipmapLinearFilter] = WEBGL_CONSTANTS.NEAREST_MIPMAP_LINEAR;
|
|
6159
|
+
THREE_TO_WEBGL[import_three18.LinearFilter] = WEBGL_CONSTANTS.LINEAR;
|
|
6160
|
+
THREE_TO_WEBGL[import_three18.LinearMipmapNearestFilter] = WEBGL_CONSTANTS.LINEAR_MIPMAP_NEAREST;
|
|
6161
|
+
THREE_TO_WEBGL[import_three18.LinearMipmapLinearFilter] = WEBGL_CONSTANTS.LINEAR_MIPMAP_LINEAR;
|
|
6162
|
+
THREE_TO_WEBGL[import_three18.ClampToEdgeWrapping] = WEBGL_CONSTANTS.CLAMP_TO_EDGE;
|
|
6163
|
+
THREE_TO_WEBGL[import_three18.RepeatWrapping] = WEBGL_CONSTANTS.REPEAT;
|
|
6164
|
+
THREE_TO_WEBGL[import_three18.MirroredRepeatWrapping] = WEBGL_CONSTANTS.MIRRORED_REPEAT;
|
|
5941
6165
|
var PATH_PROPERTIES = {
|
|
5942
6166
|
scale: "scale",
|
|
5943
6167
|
position: "translation",
|
|
5944
6168
|
quaternion: "rotation",
|
|
5945
6169
|
morphTargetInfluences: "weights"
|
|
5946
6170
|
};
|
|
5947
|
-
var DEFAULT_SPECULAR_COLOR = new
|
|
6171
|
+
var DEFAULT_SPECULAR_COLOR = new import_three18.Color();
|
|
5948
6172
|
var GLB_HEADER_BYTES = 12;
|
|
5949
6173
|
var GLB_HEADER_MAGIC = 1179937895;
|
|
5950
6174
|
var GLB_VERSION = 2;
|
|
@@ -5978,7 +6202,7 @@ function getMinMax(attribute, start, count) {
|
|
|
5978
6202
|
else if (a === 2) value = attribute.getZ(i);
|
|
5979
6203
|
else if (a === 3) value = attribute.getW(i);
|
|
5980
6204
|
if (attribute.normalized === true) {
|
|
5981
|
-
value =
|
|
6205
|
+
value = import_three18.MathUtils.normalize(value, attribute.array);
|
|
5982
6206
|
}
|
|
5983
6207
|
}
|
|
5984
6208
|
output.min[a] = Math.min(output.min[a], value);
|
|
@@ -6184,7 +6408,7 @@ var GLTFWriter = class {
|
|
|
6184
6408
|
isNormalizedNormalAttribute(normal) {
|
|
6185
6409
|
const cache = this.cache;
|
|
6186
6410
|
if (cache.attributesNormalized.has(normal)) return false;
|
|
6187
|
-
const v = new
|
|
6411
|
+
const v = new import_three18.Vector3();
|
|
6188
6412
|
for (let i = 0, il = normal.count; i < il; i++) {
|
|
6189
6413
|
if (Math.abs(v.fromBufferAttribute(normal, i).length() - 1) > 5e-4) return false;
|
|
6190
6414
|
}
|
|
@@ -6201,7 +6425,7 @@ var GLTFWriter = class {
|
|
|
6201
6425
|
const cache = this.cache;
|
|
6202
6426
|
if (cache.attributesNormalized.has(normal)) return cache.attributesNormalized.get(normal);
|
|
6203
6427
|
const attribute = normal.clone();
|
|
6204
|
-
const v = new
|
|
6428
|
+
const v = new import_three18.Vector3();
|
|
6205
6429
|
for (let i = 0, il = attribute.count; i < il; i++) {
|
|
6206
6430
|
v.fromBufferAttribute(attribute, i);
|
|
6207
6431
|
if (v.x === 0 && v.y === 0 && v.z === 0) {
|
|
@@ -6245,7 +6469,7 @@ var GLTFWriter = class {
|
|
|
6245
6469
|
buildMetalRoughTexture(metalnessMap, roughnessMap) {
|
|
6246
6470
|
if (metalnessMap === roughnessMap) return metalnessMap;
|
|
6247
6471
|
function getEncodingConversion(map) {
|
|
6248
|
-
if (map.colorSpace ===
|
|
6472
|
+
if (map.colorSpace === import_three18.SRGBColorSpace) {
|
|
6249
6473
|
return function SRGBToLinear(c) {
|
|
6250
6474
|
return c < 0.04045 ? c * 0.0773993808 : Math.pow(c * 0.9478672986 + 0.0521327014, 2.4);
|
|
6251
6475
|
};
|
|
@@ -6255,10 +6479,10 @@ var GLTFWriter = class {
|
|
|
6255
6479
|
};
|
|
6256
6480
|
}
|
|
6257
6481
|
console.warn("THREE.GLTFExporter: Merged metalnessMap and roughnessMap textures.");
|
|
6258
|
-
if (metalnessMap instanceof
|
|
6482
|
+
if (metalnessMap instanceof import_three18.CompressedTexture) {
|
|
6259
6483
|
metalnessMap = decompress(metalnessMap);
|
|
6260
6484
|
}
|
|
6261
|
-
if (roughnessMap instanceof
|
|
6485
|
+
if (roughnessMap instanceof import_three18.CompressedTexture) {
|
|
6262
6486
|
roughnessMap = decompress(roughnessMap);
|
|
6263
6487
|
}
|
|
6264
6488
|
const metalness = metalnessMap ? metalnessMap.image : null;
|
|
@@ -6291,8 +6515,8 @@ var GLTFWriter = class {
|
|
|
6291
6515
|
context.putImageData(composite, 0, 0);
|
|
6292
6516
|
const reference = metalnessMap || roughnessMap;
|
|
6293
6517
|
const texture = reference.clone();
|
|
6294
|
-
texture.source = new
|
|
6295
|
-
texture.colorSpace =
|
|
6518
|
+
texture.source = new import_three18.Source(canvas);
|
|
6519
|
+
texture.colorSpace = import_three18.NoColorSpace;
|
|
6296
6520
|
texture.channel = (metalnessMap || roughnessMap).channel;
|
|
6297
6521
|
if (metalnessMap && roughnessMap && metalnessMap.channel !== roughnessMap.channel) {
|
|
6298
6522
|
console.warn("THREE.GLTFExporter: UV channels for metalnessMap and roughnessMap textures must match.");
|
|
@@ -6350,7 +6574,7 @@ var GLTFWriter = class {
|
|
|
6350
6574
|
else if (a === 2) value = attribute.getZ(i);
|
|
6351
6575
|
else if (a === 3) value = attribute.getW(i);
|
|
6352
6576
|
if (attribute.normalized === true) {
|
|
6353
|
-
value =
|
|
6577
|
+
value = import_three18.MathUtils.normalize(value, attribute.array);
|
|
6354
6578
|
}
|
|
6355
6579
|
}
|
|
6356
6580
|
if (componentType === WEBGL_CONSTANTS.FLOAT) {
|
|
@@ -6500,7 +6724,7 @@ var GLTFWriter = class {
|
|
|
6500
6724
|
ctx.scale(1, -1);
|
|
6501
6725
|
}
|
|
6502
6726
|
if (image.data !== void 0) {
|
|
6503
|
-
if (format !==
|
|
6727
|
+
if (format !== import_three18.RGBAFormat) {
|
|
6504
6728
|
console.error("GLTFExporter: Only RGBAFormat is supported.", format);
|
|
6505
6729
|
}
|
|
6506
6730
|
if (image.width > options.maxTextureSize || image.height > options.maxTextureSize) {
|
|
@@ -6569,7 +6793,7 @@ var GLTFWriter = class {
|
|
|
6569
6793
|
const json = this.json;
|
|
6570
6794
|
if (cache.textures.has(map)) return cache.textures.get(map);
|
|
6571
6795
|
if (!json.textures) json.textures = [];
|
|
6572
|
-
if (map instanceof
|
|
6796
|
+
if (map instanceof import_three18.CompressedTexture) {
|
|
6573
6797
|
map = decompress(map, options.maxTextureSize);
|
|
6574
6798
|
}
|
|
6575
6799
|
let mimeType = map.userData.mimeType;
|
|
@@ -6677,7 +6901,7 @@ var GLTFWriter = class {
|
|
|
6677
6901
|
materialDef.alphaCutoff = material.alphaTest;
|
|
6678
6902
|
}
|
|
6679
6903
|
}
|
|
6680
|
-
if (material.side ===
|
|
6904
|
+
if (material.side === import_three18.DoubleSide) materialDef.doubleSided = true;
|
|
6681
6905
|
if (material.name !== "") materialDef.name = material.name;
|
|
6682
6906
|
this.serializeUserData(material, materialDef);
|
|
6683
6907
|
this._invokeAll(function(ext) {
|
|
@@ -6751,7 +6975,7 @@ var GLTFWriter = class {
|
|
|
6751
6975
|
const array = attribute.array;
|
|
6752
6976
|
if (attributeName === "JOINTS_0" && !(array instanceof Uint16Array) && !(array instanceof Uint8Array)) {
|
|
6753
6977
|
console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.');
|
|
6754
|
-
modifiedAttribute = new
|
|
6978
|
+
modifiedAttribute = new import_three18.BufferAttribute(new Uint16Array(array), attribute.itemSize, attribute.normalized);
|
|
6755
6979
|
}
|
|
6756
6980
|
const accessor = this.processAccessor(modifiedAttribute || attribute, geometry);
|
|
6757
6981
|
if (accessor !== null) {
|
|
@@ -6911,7 +7135,7 @@ var GLTFWriter = class {
|
|
|
6911
7135
|
} else {
|
|
6912
7136
|
cameraDef.perspective = {
|
|
6913
7137
|
aspectRatio: camera.aspect,
|
|
6914
|
-
yfov:
|
|
7138
|
+
yfov: import_three18.MathUtils.degToRad(camera.fov),
|
|
6915
7139
|
zfar: camera.far <= 0 ? 1e-3 : camera.far,
|
|
6916
7140
|
znear: camera.near < 0 ? 0 : camera.near
|
|
6917
7141
|
};
|
|
@@ -6939,8 +7163,8 @@ var GLTFWriter = class {
|
|
|
6939
7163
|
const samplers = [];
|
|
6940
7164
|
for (let i = 0; i < tracks.length; ++i) {
|
|
6941
7165
|
const track = tracks[i];
|
|
6942
|
-
const trackBinding =
|
|
6943
|
-
let trackNode =
|
|
7166
|
+
const trackBinding = import_three18.PropertyBinding.parseTrackName(track.name);
|
|
7167
|
+
let trackNode = import_three18.PropertyBinding.findNode(root, trackBinding.nodeName);
|
|
6944
7168
|
const trackProperty = PATH_PROPERTIES[trackBinding.propertyName];
|
|
6945
7169
|
if (trackBinding.objectName === "bones") {
|
|
6946
7170
|
if (trackNode.isSkinnedMesh === true) {
|
|
@@ -6962,14 +7186,14 @@ var GLTFWriter = class {
|
|
|
6962
7186
|
if (track.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline === true) {
|
|
6963
7187
|
interpolation = "CUBICSPLINE";
|
|
6964
7188
|
outputItemSize /= 3;
|
|
6965
|
-
} else if (track.getInterpolation() ===
|
|
7189
|
+
} else if (track.getInterpolation() === import_three18.InterpolateDiscrete) {
|
|
6966
7190
|
interpolation = "STEP";
|
|
6967
7191
|
} else {
|
|
6968
7192
|
interpolation = "LINEAR";
|
|
6969
7193
|
}
|
|
6970
7194
|
samplers.push({
|
|
6971
|
-
input: this.processAccessor(new
|
|
6972
|
-
output: this.processAccessor(new
|
|
7195
|
+
input: this.processAccessor(new import_three18.BufferAttribute(track.times, inputItemSize)),
|
|
7196
|
+
output: this.processAccessor(new import_three18.BufferAttribute(track.values, outputItemSize)),
|
|
6973
7197
|
interpolation
|
|
6974
7198
|
});
|
|
6975
7199
|
channels.push({
|
|
@@ -7001,7 +7225,7 @@ var GLTFWriter = class {
|
|
|
7001
7225
|
if (rootJoint === void 0) return null;
|
|
7002
7226
|
const joints = [];
|
|
7003
7227
|
const inverseBindMatrices = new Float32Array(skeleton.bones.length * 16);
|
|
7004
|
-
const temporaryBoneInverse = new
|
|
7228
|
+
const temporaryBoneInverse = new import_three18.Matrix4();
|
|
7005
7229
|
for (let i = 0; i < skeleton.bones.length; ++i) {
|
|
7006
7230
|
joints.push(nodeMap.get(skeleton.bones[i]));
|
|
7007
7231
|
temporaryBoneInverse.copy(skeleton.boneInverses[i]);
|
|
@@ -7009,7 +7233,7 @@ var GLTFWriter = class {
|
|
|
7009
7233
|
}
|
|
7010
7234
|
if (json.skins === void 0) json.skins = [];
|
|
7011
7235
|
json.skins.push({
|
|
7012
|
-
inverseBindMatrices: this.processAccessor(new
|
|
7236
|
+
inverseBindMatrices: this.processAccessor(new import_three18.BufferAttribute(inverseBindMatrices, 16)),
|
|
7013
7237
|
joints,
|
|
7014
7238
|
skeleton: nodeMap.get(rootJoint)
|
|
7015
7239
|
});
|
|
@@ -7105,7 +7329,7 @@ var GLTFWriter = class {
|
|
|
7105
7329
|
* @param {Array} objects List of objects to process
|
|
7106
7330
|
*/
|
|
7107
7331
|
processObjects(objects) {
|
|
7108
|
-
const scene = new
|
|
7332
|
+
const scene = new import_three18.Scene();
|
|
7109
7333
|
scene.name = "AuxScene";
|
|
7110
7334
|
for (let i = 0; i < objects.length; i++) {
|
|
7111
7335
|
scene.children.push(objects[i]);
|
|
@@ -7123,7 +7347,7 @@ var GLTFWriter = class {
|
|
|
7123
7347
|
});
|
|
7124
7348
|
const objectsWithoutScene = [];
|
|
7125
7349
|
for (let i = 0; i < input.length; i++) {
|
|
7126
|
-
if (input[i] instanceof
|
|
7350
|
+
if (input[i] instanceof import_three18.Scene) {
|
|
7127
7351
|
this.processScene(input[i]);
|
|
7128
7352
|
} else {
|
|
7129
7353
|
objectsWithoutScene.push(input[i]);
|
|
@@ -7467,10 +7691,10 @@ var GLTFMeshGpuInstancing = class {
|
|
|
7467
7691
|
const translationAttr = new Float32Array(mesh.count * 3);
|
|
7468
7692
|
const rotationAttr = new Float32Array(mesh.count * 4);
|
|
7469
7693
|
const scaleAttr = new Float32Array(mesh.count * 3);
|
|
7470
|
-
const matrix = new
|
|
7471
|
-
const position = new
|
|
7472
|
-
const quaternion = new
|
|
7473
|
-
const scale = new
|
|
7694
|
+
const matrix = new import_three18.Matrix4();
|
|
7695
|
+
const position = new import_three18.Vector3();
|
|
7696
|
+
const quaternion = new import_three18.Quaternion();
|
|
7697
|
+
const scale = new import_three18.Vector3();
|
|
7474
7698
|
for (let i = 0; i < mesh.count; i++) {
|
|
7475
7699
|
mesh.getMatrixAt(i, matrix);
|
|
7476
7700
|
matrix.decompose(position, quaternion, scale);
|
|
@@ -7479,9 +7703,9 @@ var GLTFMeshGpuInstancing = class {
|
|
|
7479
7703
|
scale.toArray(scaleAttr, i * 3);
|
|
7480
7704
|
}
|
|
7481
7705
|
const attributes = {
|
|
7482
|
-
TRANSLATION: writer.processAccessor(new
|
|
7483
|
-
ROTATION: writer.processAccessor(new
|
|
7484
|
-
SCALE: writer.processAccessor(new
|
|
7706
|
+
TRANSLATION: writer.processAccessor(new import_three18.BufferAttribute(translationAttr, 3)),
|
|
7707
|
+
ROTATION: writer.processAccessor(new import_three18.BufferAttribute(rotationAttr, 4)),
|
|
7708
|
+
SCALE: writer.processAccessor(new import_three18.BufferAttribute(scaleAttr, 3))
|
|
7485
7709
|
};
|
|
7486
7710
|
if (mesh.instanceColor)
|
|
7487
7711
|
attributes._COLOR_0 = writer.processAccessor(mesh.instanceColor);
|
|
@@ -7546,8 +7770,8 @@ GLTFExporter.Utils = {
|
|
|
7546
7770
|
const sourceTracks = clip.tracks;
|
|
7547
7771
|
for (let i = 0; i < sourceTracks.length; ++i) {
|
|
7548
7772
|
let sourceTrack = sourceTracks[i];
|
|
7549
|
-
const sourceTrackBinding =
|
|
7550
|
-
const sourceTrackNode =
|
|
7773
|
+
const sourceTrackBinding = import_three18.PropertyBinding.parseTrackName(sourceTrack.name);
|
|
7774
|
+
const sourceTrackNode = import_three18.PropertyBinding.findNode(root, sourceTrackBinding.nodeName);
|
|
7551
7775
|
if (sourceTrackBinding.propertyName !== "morphTargetInfluences" || sourceTrackBinding.propertyIndex === void 0) {
|
|
7552
7776
|
tracks.push(sourceTrack);
|
|
7553
7777
|
continue;
|
|
@@ -7558,7 +7782,7 @@ GLTFExporter.Utils = {
|
|
|
7558
7782
|
}
|
|
7559
7783
|
console.warn("THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead.");
|
|
7560
7784
|
sourceTrack = sourceTrack.clone();
|
|
7561
|
-
sourceTrack.setInterpolation(
|
|
7785
|
+
sourceTrack.setInterpolation(import_three18.InterpolateLinear);
|
|
7562
7786
|
}
|
|
7563
7787
|
const targetCount = sourceTrackNode.morphTargetInfluences.length;
|
|
7564
7788
|
const targetIndex = sourceTrackNode.morphTargetDictionary[sourceTrackBinding.propertyIndex];
|
|
@@ -7641,10 +7865,10 @@ var SceneExporter = class {
|
|
|
7641
7865
|
}
|
|
7642
7866
|
};
|
|
7643
7867
|
function localMatrix(object) {
|
|
7644
|
-
return object.matrixAutoUpdate ? new
|
|
7868
|
+
return object.matrixAutoUpdate ? new import_three19.Matrix4().compose(object.position, object.quaternion, object.scale) : object.matrix.clone();
|
|
7645
7869
|
}
|
|
7646
7870
|
function createSnapshot(root, gltf, bakeColors = false) {
|
|
7647
|
-
const scene = new
|
|
7871
|
+
const scene = new import_three19.Scene();
|
|
7648
7872
|
const geometries = [];
|
|
7649
7873
|
const materials = [];
|
|
7650
7874
|
const textures = [];
|
|
@@ -7662,7 +7886,7 @@ function createSnapshot(root, gltf, bakeColors = false) {
|
|
|
7662
7886
|
if (!uniforms.map?.value?.isTexture || !uniforms.SHADE || !uniforms.BRIGHTNESS || !uniforms.EMISSIVE) {
|
|
7663
7887
|
throw new MineRenderError("glTF export does not support this custom ShaderMaterial");
|
|
7664
7888
|
}
|
|
7665
|
-
material = new
|
|
7889
|
+
material = new import_three19.MeshBasicMaterial({
|
|
7666
7890
|
map: uniforms.map.value,
|
|
7667
7891
|
vertexColors: source.vertexColors,
|
|
7668
7892
|
transparent: source.transparent,
|
|
@@ -7672,7 +7896,7 @@ function createSnapshot(root, gltf, bakeColors = false) {
|
|
|
7672
7896
|
});
|
|
7673
7897
|
material.name = source.name;
|
|
7674
7898
|
} else if (shader.isShaderMaterial) {
|
|
7675
|
-
material = new
|
|
7899
|
+
material = new import_three19.MeshBasicMaterial({ vertexColors: source.vertexColors });
|
|
7676
7900
|
material.name = source.name;
|
|
7677
7901
|
} else {
|
|
7678
7902
|
const copySource = Object.create(source);
|
|
@@ -7726,11 +7950,11 @@ function createSnapshot(root, gltf, bakeColors = false) {
|
|
|
7726
7950
|
const material = copyMaterial(sourceMaterial, geometry);
|
|
7727
7951
|
if (!sourceMaterial.vertexColors) geometry.deleteAttribute("color");
|
|
7728
7952
|
if (bakeColors || instanceColor) {
|
|
7729
|
-
const tint = (material.color ?? new
|
|
7953
|
+
const tint = (material.color ?? new import_three19.Color()).clone();
|
|
7730
7954
|
if (instanceColor) tint.multiply(instanceColor);
|
|
7731
7955
|
if (bakeColors) {
|
|
7732
7956
|
const original = geometry.getAttribute("color");
|
|
7733
|
-
const colors = new
|
|
7957
|
+
const colors = new import_three19.Float32BufferAttribute(new Float32Array(geometry.getAttribute("position").count * 3), 3);
|
|
7734
7958
|
for (let i = 0; i < colors.count; i++) {
|
|
7735
7959
|
colors.setXYZ(i, (original?.getX(i) ?? 1) * tint.r, (original?.getY(i) ?? 1) * tint.g, (original?.getZ(i) ?? 1) * tint.b);
|
|
7736
7960
|
}
|
|
@@ -7739,7 +7963,7 @@ function createSnapshot(root, gltf, bakeColors = false) {
|
|
|
7739
7963
|
material.color.copy(tint);
|
|
7740
7964
|
}
|
|
7741
7965
|
}
|
|
7742
|
-
const copy = new
|
|
7966
|
+
const copy = new import_three19.Mesh(geometry, material);
|
|
7743
7967
|
copy.name = mesh.name;
|
|
7744
7968
|
copy.renderOrder = mesh.renderOrder;
|
|
7745
7969
|
scene.add(copy);
|
|
@@ -7753,9 +7977,9 @@ function createSnapshot(root, gltf, bakeColors = false) {
|
|
|
7753
7977
|
const instanced = mesh;
|
|
7754
7978
|
if (instanced.isInstancedMesh) {
|
|
7755
7979
|
for (let i = 0; i < instanced.count; i++) {
|
|
7756
|
-
const matrix = new
|
|
7980
|
+
const matrix = new import_three19.Matrix4();
|
|
7757
7981
|
instanced.getMatrixAt(i, matrix);
|
|
7758
|
-
const color = instanced.instanceColor ? new
|
|
7982
|
+
const color = instanced.instanceColor ? new import_three19.Color().fromBufferAttribute(instanced.instanceColor, i) : void 0;
|
|
7759
7983
|
addMesh(mesh, world.clone().multiply(matrix), color);
|
|
7760
7984
|
}
|
|
7761
7985
|
} else {
|
|
@@ -7767,7 +7991,7 @@ function createSnapshot(root, gltf, bakeColors = false) {
|
|
|
7767
7991
|
try {
|
|
7768
7992
|
const ancestors = [];
|
|
7769
7993
|
for (let parent = root.parent; parent; parent = parent.parent) ancestors.unshift(parent);
|
|
7770
|
-
const world = new
|
|
7994
|
+
const world = new import_three19.Matrix4();
|
|
7771
7995
|
for (const ancestor of ancestors) {
|
|
7772
7996
|
if (!ancestor.visible) return { scene, dispose };
|
|
7773
7997
|
world.multiply(localMatrix(ancestor));
|
|
@@ -7781,7 +8005,7 @@ function createSnapshot(root, gltf, bakeColors = false) {
|
|
|
7781
8005
|
}
|
|
7782
8006
|
function selectAlphaMode(material, geometry) {
|
|
7783
8007
|
const texture = material.map;
|
|
7784
|
-
if (material.type !== "MeshBasicMaterial" || !material.transparent || !material.depthWrite || material.opacity !== 1 || material.alphaMap || !texture?.isDataTexture || texture.format !==
|
|
8008
|
+
if (material.type !== "MeshBasicMaterial" || !material.transparent || !material.depthWrite || material.opacity !== 1 || material.alphaMap || !texture?.isDataTexture || texture.format !== import_three19.RGBAFormat || texture.type !== import_three19.UnsignedByteType || texture.wrapS !== import_three19.ClampToEdgeWrapping || texture.wrapT !== import_three19.ClampToEdgeWrapping || texture.magFilter !== import_three19.NearestFilter || texture.minFilter !== import_three19.NearestFilter || texture.anisotropy > 1 || texture.offset.x !== 0 || texture.offset.y !== 0 || texture.repeat.x !== 1 || texture.repeat.y !== 1 || texture.rotation !== 0 || !texture.matrixAutoUpdate && !texture.matrix.elements.every((value, i) => value === (i % 4 === 0 ? 1 : 0))) return;
|
|
7785
8009
|
const uv = geometry.getAttribute(texture.channel === 0 ? "uv" : `uv${texture.channel}`);
|
|
7786
8010
|
const colors = geometry.getAttribute("color");
|
|
7787
8011
|
if (!uv || material.vertexColors && colors?.itemSize === 4) return;
|
|
@@ -7818,7 +8042,7 @@ function selectAlphaMode(material, geometry) {
|
|
|
7818
8042
|
}
|
|
7819
8043
|
function copyDataTexture(source) {
|
|
7820
8044
|
const image = source.image;
|
|
7821
|
-
if (source.format !==
|
|
8045
|
+
if (source.format !== import_three19.RGBAFormat || source.type !== import_three19.UnsignedByteType) {
|
|
7822
8046
|
throw new MineRenderError("glTF export requires RGBA unsigned-byte data textures");
|
|
7823
8047
|
}
|
|
7824
8048
|
const canvas = createCanvas2(image.width, image.height);
|
|
@@ -7829,8 +8053,8 @@ function copyDataTexture(source) {
|
|
|
7829
8053
|
context.putImageData(pixels, 0, 0);
|
|
7830
8054
|
const copySource = Object.create(source);
|
|
7831
8055
|
copySource.userData = {};
|
|
7832
|
-
copySource.source = new
|
|
7833
|
-
return new
|
|
8056
|
+
copySource.source = new import_three19.Source(canvas);
|
|
8057
|
+
return new import_three19.Texture().copy(copySource);
|
|
7834
8058
|
}
|
|
7835
8059
|
|
|
7836
8060
|
// src/gui/GuiHelper.ts
|
|
@@ -7900,7 +8124,7 @@ var GuiHelper = class {
|
|
|
7900
8124
|
};
|
|
7901
8125
|
|
|
7902
8126
|
// src/gui/scene/GuiObject.ts
|
|
7903
|
-
var
|
|
8127
|
+
var import_three23 = require("three");
|
|
7904
8128
|
init_AssetKey();
|
|
7905
8129
|
init_ModelTextures();
|
|
7906
8130
|
init_Models();
|
|
@@ -7924,7 +8148,7 @@ var GuiObject = class extends SceneObject {
|
|
|
7924
8148
|
this.textureLayers = textureLayers;
|
|
7925
8149
|
this.isGuiObject = true;
|
|
7926
8150
|
/** Local bounds in GUI pixels, with y growing down from the origin. */
|
|
7927
|
-
this.bounds = new
|
|
8151
|
+
this.bounds = new import_three23.Box2();
|
|
7928
8152
|
this.geometries = /* @__PURE__ */ new Set();
|
|
7929
8153
|
this.ownedMaterials = /* @__PURE__ */ new Set();
|
|
7930
8154
|
this.initialized = false;
|
|
@@ -7941,7 +8165,7 @@ var GuiObject = class extends SceneObject {
|
|
|
7941
8165
|
item.position.set(x + width2 / 2, -y - height2 / 2, 0);
|
|
7942
8166
|
item.scale.set(width2 / 16, height2 / 16, width2 / 16);
|
|
7943
8167
|
item.updateMatrix();
|
|
7944
|
-
const bounds = new
|
|
8168
|
+
const bounds = new import_three23.Box3();
|
|
7945
8169
|
item.iterateAllMeshes((mesh2) => {
|
|
7946
8170
|
mesh2.geometry.computeBoundingBox();
|
|
7947
8171
|
bounds.union(mesh2.geometry.boundingBox);
|
|
@@ -7949,10 +8173,10 @@ var GuiObject = class extends SceneObject {
|
|
|
7949
8173
|
bounds.applyMatrix4(item.matrix);
|
|
7950
8174
|
item.position.z = depth - bounds.min.z;
|
|
7951
8175
|
depth += bounds.max.z - bounds.min.z + 0.01;
|
|
7952
|
-
this.bounds.expandByPoint(new
|
|
7953
|
-
this.bounds.expandByPoint(new
|
|
7954
|
-
this.bounds.expandByPoint(new
|
|
7955
|
-
this.bounds.expandByPoint(new
|
|
8176
|
+
this.bounds.expandByPoint(new import_three23.Vector2(x, y));
|
|
8177
|
+
this.bounds.expandByPoint(new import_three23.Vector2(x + width2, y + height2));
|
|
8178
|
+
this.bounds.expandByPoint(new import_three23.Vector2(bounds.min.x, -bounds.max.y));
|
|
8179
|
+
this.bounds.expandByPoint(new import_three23.Vector2(bounds.max.x, -bounds.min.y));
|
|
7956
8180
|
continue;
|
|
7957
8181
|
}
|
|
7958
8182
|
const key = typeof layer.texture === "string" ? AssetKey.parse("textures", layer.texture) : layer.texture;
|
|
@@ -7960,7 +8184,7 @@ var GuiObject = class extends SceneObject {
|
|
|
7960
8184
|
const image = material.map.image;
|
|
7961
8185
|
const [cropX, cropY, cropWidth, cropHeight] = layer.crop ?? [0, 0, image.width, image.height];
|
|
7962
8186
|
const [width, height] = layer.size ?? [cropWidth, cropHeight];
|
|
7963
|
-
const geometry = new
|
|
8187
|
+
const geometry = new import_three23.PlaneGeometry(width, height);
|
|
7964
8188
|
this.geometries.add(geometry);
|
|
7965
8189
|
const uv = geometry.getAttribute("uv");
|
|
7966
8190
|
for (let i = 0; i < uv.count; i++) {
|
|
@@ -7970,13 +8194,13 @@ var GuiObject = class extends SceneObject {
|
|
|
7970
8194
|
1 - (cropY + (1 - uv.getY(i)) * cropHeight) / image.height
|
|
7971
8195
|
);
|
|
7972
8196
|
}
|
|
7973
|
-
const mesh = new
|
|
8197
|
+
const mesh = new import_three23.Mesh(geometry, material);
|
|
7974
8198
|
mesh.name = `mesh:${layer.name ?? index}`;
|
|
7975
8199
|
mesh.position.set(x + width / 2, -y - height / 2, depth);
|
|
7976
8200
|
mesh.renderOrder = index;
|
|
7977
8201
|
this.add(mesh);
|
|
7978
|
-
this.bounds.expandByPoint(new
|
|
7979
|
-
this.bounds.expandByPoint(new
|
|
8202
|
+
this.bounds.expandByPoint(new import_three23.Vector2(x, y));
|
|
8203
|
+
this.bounds.expandByPoint(new import_three23.Vector2(x + width, y + height));
|
|
7980
8204
|
depth += 0.01;
|
|
7981
8205
|
}
|
|
7982
8206
|
for (const child of this.children) child.position.z -= depth - 0.01;
|
|
@@ -8051,7 +8275,7 @@ function isGuiObject(obj) {
|
|
|
8051
8275
|
init_image();
|
|
8052
8276
|
|
|
8053
8277
|
// src/inspector/SceneInspector.ts
|
|
8054
|
-
var
|
|
8278
|
+
var import_three24 = require("three");
|
|
8055
8279
|
init_SceneObject();
|
|
8056
8280
|
init_util();
|
|
8057
8281
|
init_log();
|
|
@@ -8061,11 +8285,11 @@ var help = "<span>Ctrl/Cmd+Click to Select<br/></span><br/>";
|
|
|
8061
8285
|
var SceneInspector = class {
|
|
8062
8286
|
constructor(renderer) {
|
|
8063
8287
|
this.renderer = renderer;
|
|
8064
|
-
this.mouse = new
|
|
8288
|
+
this.mouse = new import_three24.Vector2();
|
|
8065
8289
|
this.listeners = new AbortController();
|
|
8066
8290
|
this.objectInfoContainer = document.createElement("div");
|
|
8067
8291
|
this.objectControlsContainer = document.createElement("div");
|
|
8068
|
-
this.raycaster = new
|
|
8292
|
+
this.raycaster = new import_three24.Raycaster();
|
|
8069
8293
|
this.init();
|
|
8070
8294
|
}
|
|
8071
8295
|
init() {
|
|
@@ -8481,7 +8705,7 @@ init_ModelGenerator();
|
|
|
8481
8705
|
init_ModelMerger();
|
|
8482
8706
|
|
|
8483
8707
|
// src/model/block/BlockStateResolver.ts
|
|
8484
|
-
var
|
|
8708
|
+
var import_three26 = require("three");
|
|
8485
8709
|
init_BlockStates();
|
|
8486
8710
|
init_MineRenderError();
|
|
8487
8711
|
init_util();
|
|
@@ -8559,7 +8783,7 @@ var BlockStateResolver = class {
|
|
|
8559
8783
|
return variants[variants.length - 1];
|
|
8560
8784
|
}
|
|
8561
8785
|
static rotation(variant) {
|
|
8562
|
-
const rotation = new
|
|
8786
|
+
const rotation = new import_three26.Euler();
|
|
8563
8787
|
if (typeof variant.x !== "undefined") {
|
|
8564
8788
|
rotation.x = toRadians(clampRotationDegrees(variant.x));
|
|
8565
8789
|
}
|
|
@@ -8666,7 +8890,7 @@ init_SceneObject();
|
|
|
8666
8890
|
init_ModelObject();
|
|
8667
8891
|
init_Models();
|
|
8668
8892
|
var import_ts_deepmerge6 = __toESM(require_dist());
|
|
8669
|
-
var
|
|
8893
|
+
var import_three29 = require("three");
|
|
8670
8894
|
init_MineRenderError();
|
|
8671
8895
|
init_InstanceReference();
|
|
8672
8896
|
init_AssetKey();
|
|
@@ -8686,6 +8910,9 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
8686
8910
|
this._variants = [];
|
|
8687
8911
|
this._models = [];
|
|
8688
8912
|
this._cullMask = 0;
|
|
8913
|
+
this._entities = [];
|
|
8914
|
+
this._entityPlacement = new import_three29.Matrix4();
|
|
8915
|
+
this._entityGeneration = 0;
|
|
8689
8916
|
this.options = (0, import_ts_deepmerge6.default)({}, _BlockObject.DEFAULT_OPTIONS, options ?? {});
|
|
8690
8917
|
}
|
|
8691
8918
|
static {
|
|
@@ -8710,6 +8937,8 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
8710
8937
|
}
|
|
8711
8938
|
clearModels() {
|
|
8712
8939
|
this.removeModels(this._models.splice(0));
|
|
8940
|
+
this._entityGeneration++;
|
|
8941
|
+
this.removeEntities(this._entities.splice(0));
|
|
8713
8942
|
this._fluidKey = void 0;
|
|
8714
8943
|
this._fluidModel = void 0;
|
|
8715
8944
|
this._isInstanced = false;
|
|
@@ -8721,6 +8950,57 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
8721
8950
|
if (!isInstanceReference(model)) model.dispose();
|
|
8722
8951
|
}
|
|
8723
8952
|
}
|
|
8953
|
+
removeEntities(entities) {
|
|
8954
|
+
for (const entity of entities) {
|
|
8955
|
+
entity.removeFromScene();
|
|
8956
|
+
entity.dispose();
|
|
8957
|
+
}
|
|
8958
|
+
}
|
|
8959
|
+
/** Entity models drawn for this block instead of its block model; they are scene children, unlike the block. */
|
|
8960
|
+
get blockEntities() {
|
|
8961
|
+
return this._entities;
|
|
8962
|
+
}
|
|
8963
|
+
/**
|
|
8964
|
+
* Draws the block through the dataset's block-entity index. Returns false, leaving nothing behind,
|
|
8965
|
+
* when the block is not listed or one of its models cannot be loaded.
|
|
8966
|
+
*/
|
|
8967
|
+
async createBlockEntities() {
|
|
8968
|
+
const key = this.blockState.key;
|
|
8969
|
+
if (!key || this.options.displayPosition) return false;
|
|
8970
|
+
const generation = this._entityGeneration;
|
|
8971
|
+
const created = [];
|
|
8972
|
+
let resolved;
|
|
8973
|
+
try {
|
|
8974
|
+
resolved = BlockEntities.resolve(await BlockEntities.getIndex(key.root), key.toNamespacedString(), this.state);
|
|
8975
|
+
if (!resolved) return false;
|
|
8976
|
+
for (const part of resolved.parts) {
|
|
8977
|
+
const [namespace, path] = part.model.includes(":") ? part.model.split(":") : [key.namespace, part.model];
|
|
8978
|
+
const texture = part.textureLocation === void 0 ? void 0 : AssetKey.parse("textures", part.textureLocation.replace(/^([^:]+:)?textures\//, "$1"));
|
|
8979
|
+
if (texture) texture.root = key.root;
|
|
8980
|
+
const entity = await Entities.getEntity(new BasicAssetKey(namespace, path), texture, { layer: part.layer });
|
|
8981
|
+
if (!entity) throw new MineRenderError(`Missing entity model ${part.model}`);
|
|
8982
|
+
created.push(await this.scene.addEntity(entity, { wireframe: this.options.wireframe }));
|
|
8983
|
+
}
|
|
8984
|
+
} catch (error) {
|
|
8985
|
+
console.warn(`Could not draw block entity ${key.toNamespacedString()}, using its block model`, error);
|
|
8986
|
+
this.removeEntities(created);
|
|
8987
|
+
return false;
|
|
8988
|
+
}
|
|
8989
|
+
if (generation !== this._entityGeneration) {
|
|
8990
|
+
this.removeEntities(created);
|
|
8991
|
+
return true;
|
|
8992
|
+
}
|
|
8993
|
+
BlockEntities.matrix(resolved, this._entityPlacement);
|
|
8994
|
+
this._entities = created;
|
|
8995
|
+
this.placeEntities();
|
|
8996
|
+
return true;
|
|
8997
|
+
}
|
|
8998
|
+
placeEntities() {
|
|
8999
|
+
const matrix = new import_three29.Matrix4().makeTranslation(this.position.x - 8, this.position.y - 8, this.position.z - 8).multiply(this._entityPlacement);
|
|
9000
|
+
for (const entity of this._entities) {
|
|
9001
|
+
matrix.decompose(entity.position, entity.quaternion, entity.scale);
|
|
9002
|
+
}
|
|
9003
|
+
}
|
|
8724
9004
|
get isOccluding() {
|
|
8725
9005
|
return this._models.some((model) => {
|
|
8726
9006
|
const object = isInstanceReference(model) ? model.instanceable : model;
|
|
@@ -8735,12 +9015,12 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
8735
9015
|
getModelCullMask(model, worldMask) {
|
|
8736
9016
|
const object = isInstanceReference(model) ? model.instanceable : model;
|
|
8737
9017
|
if (object.options.displayPosition) return 0;
|
|
8738
|
-
const position = new
|
|
8739
|
-
const rotation = new
|
|
8740
|
-
const scale = new
|
|
9018
|
+
const position = new import_three29.Vector3();
|
|
9019
|
+
const rotation = new import_three29.Quaternion();
|
|
9020
|
+
const scale = new import_three29.Vector3();
|
|
8741
9021
|
this.getModelMatrix(model).decompose(position, rotation, scale);
|
|
8742
|
-
if (position.distanceToSquared(this.position) > 1e-10 || scale.distanceToSquared(new
|
|
8743
|
-
return ModelCulling.toLocalMask(worldMask, new
|
|
9022
|
+
if (position.distanceToSquared(this.position) > 1e-10 || scale.distanceToSquared(new import_three29.Vector3(1, 1, 1)) > 1e-10) return 0;
|
|
9023
|
+
return ModelCulling.toLocalMask(worldMask, new import_three29.Euler().setFromQuaternion(rotation));
|
|
8744
9024
|
}
|
|
8745
9025
|
async setCullMask(worldMask) {
|
|
8746
9026
|
worldMask &= 63;
|
|
@@ -8802,7 +9082,7 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
8802
9082
|
() => new FluidModelObject2(kind, surface.sample, this.blockState.key, this.options)
|
|
8803
9083
|
);
|
|
8804
9084
|
const previous = this._fluidModel;
|
|
8805
|
-
const matrix = previous ? this.getModelMatrix(previous) : new
|
|
9085
|
+
const matrix = previous ? this.getModelMatrix(previous) : new import_three29.Matrix4().makeTranslation(...this.position.toArray());
|
|
8806
9086
|
if (isInstanceReference(replacement)) replacement.setMatrix(matrix);
|
|
8807
9087
|
else matrix.decompose(replacement.position, replacement.quaternion, replacement.scale);
|
|
8808
9088
|
this._models = this._models.filter((model) => model !== previous);
|
|
@@ -8832,13 +9112,20 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
8832
9112
|
await this.updateFluid(this._fluidSampler);
|
|
8833
9113
|
return;
|
|
8834
9114
|
}
|
|
9115
|
+
const hasEntities = await this.createBlockEntities();
|
|
8835
9116
|
const variantsToCreate = await this.mapStateToVariant(this.state);
|
|
8836
9117
|
this._variants = variantsToCreate;
|
|
8837
9118
|
for (let blockStateVariant of variantsToCreate) {
|
|
9119
|
+
if (hasEntities && !await this.hasGeometry(blockStateVariant)) continue;
|
|
8838
9120
|
this._models.push(await this.createVariant(blockStateVariant));
|
|
8839
9121
|
}
|
|
8840
9122
|
await this.updateFluid(this._fluidSampler);
|
|
8841
9123
|
}
|
|
9124
|
+
async hasGeometry(variant) {
|
|
9125
|
+
const modelKey = AssetKey.parse("models", variant.model);
|
|
9126
|
+
modelKey.root = this.blockState.key?.root;
|
|
9127
|
+
return !!(await Models.getMerged(modelKey))?.elements?.length;
|
|
9128
|
+
}
|
|
8842
9129
|
getSingleVariant(variants) {
|
|
8843
9130
|
return BlockStateResolver.choose(variants);
|
|
8844
9131
|
}
|
|
@@ -8933,7 +9220,7 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
8933
9220
|
setPositionRotationScaleAt(index, position, rotation, scale) {
|
|
8934
9221
|
super.setPositionRotationScaleAt(index, position, rotation, scale);
|
|
8935
9222
|
}
|
|
8936
|
-
getMatrixAt(index, matrix = new
|
|
9223
|
+
getMatrixAt(index, matrix = new import_three29.Matrix4()) {
|
|
8937
9224
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
8938
9225
|
const child = this._models[0];
|
|
8939
9226
|
if (child && isModelObject(child)) {
|
|
@@ -8958,6 +9245,7 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
8958
9245
|
for (let model of this._models) {
|
|
8959
9246
|
model.setPosition(position);
|
|
8960
9247
|
}
|
|
9248
|
+
this.placeEntities();
|
|
8961
9249
|
this.notifyDirty();
|
|
8962
9250
|
}
|
|
8963
9251
|
//TODO: should override rotation + scale methods
|
|
@@ -10799,7 +11087,7 @@ init_ModelObject();
|
|
|
10799
11087
|
init_nbt();
|
|
10800
11088
|
|
|
10801
11089
|
// src/renderer/MineRenderScene.ts
|
|
10802
|
-
var
|
|
11090
|
+
var import_three31 = require("three");
|
|
10803
11091
|
init_SceneObject();
|
|
10804
11092
|
var import_ts_deepmerge8 = __toESM(require_dist());
|
|
10805
11093
|
init_ModelObject();
|
|
@@ -11532,7 +11820,7 @@ var import_ts_deepmerge7 = __toESM(require_dist());
|
|
|
11532
11820
|
init_util();
|
|
11533
11821
|
|
|
11534
11822
|
// src/skin/SkinTextures.ts
|
|
11535
|
-
var
|
|
11823
|
+
var import_three30 = require("three");
|
|
11536
11824
|
init_Caching();
|
|
11537
11825
|
init_CacheKey();
|
|
11538
11826
|
init_MineRenderError();
|
|
@@ -11616,11 +11904,11 @@ var SkinTextures = class {
|
|
|
11616
11904
|
});
|
|
11617
11905
|
}
|
|
11618
11906
|
static createMaterial(pixels, width, height, transparent = true) {
|
|
11619
|
-
const texture = Textures.initTextureProps(new
|
|
11620
|
-
texture.colorSpace =
|
|
11907
|
+
const texture = Textures.initTextureProps(new import_three30.DataTexture(pixels, width, height));
|
|
11908
|
+
texture.colorSpace = import_three30.SRGBColorSpace;
|
|
11621
11909
|
texture.flipY = true;
|
|
11622
11910
|
texture.needsUpdate = true;
|
|
11623
|
-
return new
|
|
11911
|
+
return new import_three30.MeshBasicMaterial({ map: texture, transparent, side: transparent ? import_three30.DoubleSide : import_three30.FrontSide, alphaTest: transparent ? 0.1 : 0 });
|
|
11624
11912
|
}
|
|
11625
11913
|
static isSlim(image, scale) {
|
|
11626
11914
|
for (const [x, y] of [[46, 52], [54, 20]]) {
|
|
@@ -11848,7 +12136,7 @@ var SkinObject = class extends SceneObject {
|
|
|
11848
12136
|
};
|
|
11849
12137
|
|
|
11850
12138
|
// src/renderer/MineRenderScene.ts
|
|
11851
|
-
var MineRenderScene = class _MineRenderScene extends
|
|
12139
|
+
var MineRenderScene = class _MineRenderScene extends import_three31.Scene {
|
|
11852
12140
|
constructor(options) {
|
|
11853
12141
|
super();
|
|
11854
12142
|
this.isMineRenderScene = true;
|
|
@@ -11976,7 +12264,7 @@ function isMineRenderScene(obj) {
|
|
|
11976
12264
|
}
|
|
11977
12265
|
|
|
11978
12266
|
// src/renderer/Renderer.ts
|
|
11979
|
-
var
|
|
12267
|
+
var import_three33 = require("three");
|
|
11980
12268
|
var import_ts_deepmerge9 = __toESM(require_dist());
|
|
11981
12269
|
var import_stats = __toESM(require("stats.js"));
|
|
11982
12270
|
var import_postprocessing = require("postprocessing");
|
|
@@ -11984,11 +12272,11 @@ init_util();
|
|
|
11984
12272
|
init_three();
|
|
11985
12273
|
|
|
11986
12274
|
// src/three/OrbitControls.js
|
|
11987
|
-
var
|
|
12275
|
+
var import_three32 = require("three");
|
|
11988
12276
|
var _changeEvent = { type: "change" };
|
|
11989
12277
|
var _startEvent = { type: "start" };
|
|
11990
12278
|
var _endEvent = { type: "end" };
|
|
11991
|
-
var OrbitControls = class extends
|
|
12279
|
+
var OrbitControls = class extends import_three32.EventDispatcher {
|
|
11992
12280
|
constructor(object, domElement) {
|
|
11993
12281
|
super();
|
|
11994
12282
|
if (domElement === void 0) console.warn('THREE.OrbitControls: The second parameter "domElement" is now mandatory.');
|
|
@@ -11997,7 +12285,7 @@ var OrbitControls = class extends import_three31.EventDispatcher {
|
|
|
11997
12285
|
this.domElement = domElement;
|
|
11998
12286
|
this.domElement.style.touchAction = "none";
|
|
11999
12287
|
this.enabled = true;
|
|
12000
|
-
this.target = new
|
|
12288
|
+
this.target = new import_three32.Vector3();
|
|
12001
12289
|
this.minDistance = 0;
|
|
12002
12290
|
this.maxDistance = Infinity;
|
|
12003
12291
|
this.minZoom = 0;
|
|
@@ -12019,8 +12307,8 @@ var OrbitControls = class extends import_three31.EventDispatcher {
|
|
|
12019
12307
|
this.autoRotate = false;
|
|
12020
12308
|
this.autoRotateSpeed = 2;
|
|
12021
12309
|
this.keys = { LEFT: "ArrowLeft", UP: "ArrowUp", RIGHT: "ArrowRight", BOTTOM: "ArrowDown" };
|
|
12022
|
-
this.mouseButtons = { LEFT:
|
|
12023
|
-
this.touches = { ONE:
|
|
12310
|
+
this.mouseButtons = { LEFT: import_three32.MOUSE.ROTATE, MIDDLE: import_three32.MOUSE.DOLLY, RIGHT: import_three32.MOUSE.PAN };
|
|
12311
|
+
this.touches = { ONE: import_three32.TOUCH.ROTATE, TWO: import_three32.TOUCH.DOLLY_PAN };
|
|
12024
12312
|
this.target0 = this.target.clone();
|
|
12025
12313
|
this.position0 = this.object.position.clone();
|
|
12026
12314
|
this.zoom0 = this.object.zoom;
|
|
@@ -12049,11 +12337,11 @@ var OrbitControls = class extends import_three31.EventDispatcher {
|
|
|
12049
12337
|
state = STATE.NONE;
|
|
12050
12338
|
};
|
|
12051
12339
|
this.update = function() {
|
|
12052
|
-
const offset = new
|
|
12053
|
-
const quat = new
|
|
12340
|
+
const offset = new import_three32.Vector3();
|
|
12341
|
+
const quat = new import_three32.Quaternion().setFromUnitVectors(object.up, new import_three32.Vector3(0, 1, 0));
|
|
12054
12342
|
const quatInverse = quat.clone().invert();
|
|
12055
|
-
const lastPosition = new
|
|
12056
|
-
const lastQuaternion = new
|
|
12343
|
+
const lastPosition = new import_three32.Vector3();
|
|
12344
|
+
const lastQuaternion = new import_three32.Quaternion();
|
|
12057
12345
|
const twoPI = 2 * Math.PI;
|
|
12058
12346
|
return function update() {
|
|
12059
12347
|
const position = scope.object.position;
|
|
@@ -12139,20 +12427,20 @@ var OrbitControls = class extends import_three31.EventDispatcher {
|
|
|
12139
12427
|
};
|
|
12140
12428
|
let state = STATE.NONE;
|
|
12141
12429
|
const EPS = 1e-6;
|
|
12142
|
-
const spherical = new
|
|
12143
|
-
const sphericalDelta = new
|
|
12430
|
+
const spherical = new import_three32.Spherical();
|
|
12431
|
+
const sphericalDelta = new import_three32.Spherical();
|
|
12144
12432
|
let scale = 1;
|
|
12145
|
-
const panOffset = new
|
|
12433
|
+
const panOffset = new import_three32.Vector3();
|
|
12146
12434
|
let zoomChanged = false;
|
|
12147
|
-
const rotateStart = new
|
|
12148
|
-
const rotateEnd = new
|
|
12149
|
-
const rotateDelta = new
|
|
12150
|
-
const panStart = new
|
|
12151
|
-
const panEnd = new
|
|
12152
|
-
const panDelta = new
|
|
12153
|
-
const dollyStart = new
|
|
12154
|
-
const dollyEnd = new
|
|
12155
|
-
const dollyDelta = new
|
|
12435
|
+
const rotateStart = new import_three32.Vector2();
|
|
12436
|
+
const rotateEnd = new import_three32.Vector2();
|
|
12437
|
+
const rotateDelta = new import_three32.Vector2();
|
|
12438
|
+
const panStart = new import_three32.Vector2();
|
|
12439
|
+
const panEnd = new import_three32.Vector2();
|
|
12440
|
+
const panDelta = new import_three32.Vector2();
|
|
12441
|
+
const dollyStart = new import_three32.Vector2();
|
|
12442
|
+
const dollyEnd = new import_three32.Vector2();
|
|
12443
|
+
const dollyDelta = new import_three32.Vector2();
|
|
12156
12444
|
const pointers = [];
|
|
12157
12445
|
const pointerPositions = {};
|
|
12158
12446
|
function getAutoRotationAngle() {
|
|
@@ -12168,7 +12456,7 @@ var OrbitControls = class extends import_three31.EventDispatcher {
|
|
|
12168
12456
|
sphericalDelta.phi -= angle;
|
|
12169
12457
|
}
|
|
12170
12458
|
const panLeft = function() {
|
|
12171
|
-
const v = new
|
|
12459
|
+
const v = new import_three32.Vector3();
|
|
12172
12460
|
return function panLeft2(distance, objectMatrix) {
|
|
12173
12461
|
v.setFromMatrixColumn(objectMatrix, 0);
|
|
12174
12462
|
v.multiplyScalar(-distance);
|
|
@@ -12176,7 +12464,7 @@ var OrbitControls = class extends import_three31.EventDispatcher {
|
|
|
12176
12464
|
};
|
|
12177
12465
|
}();
|
|
12178
12466
|
const panUp = function() {
|
|
12179
|
-
const v = new
|
|
12467
|
+
const v = new import_three32.Vector3();
|
|
12180
12468
|
return function panUp2(distance, objectMatrix) {
|
|
12181
12469
|
if (scope.screenSpacePanning === true) {
|
|
12182
12470
|
v.setFromMatrixColumn(objectMatrix, 1);
|
|
@@ -12189,7 +12477,7 @@ var OrbitControls = class extends import_three31.EventDispatcher {
|
|
|
12189
12477
|
};
|
|
12190
12478
|
}();
|
|
12191
12479
|
const pan = function() {
|
|
12192
|
-
const offset = new
|
|
12480
|
+
const offset = new import_three32.Vector3();
|
|
12193
12481
|
return function pan2(deltaX, deltaY) {
|
|
12194
12482
|
const element = scope.domElement;
|
|
12195
12483
|
if (scope.object.isPerspectiveCamera) {
|
|
@@ -12438,12 +12726,12 @@ var OrbitControls = class extends import_three31.EventDispatcher {
|
|
|
12438
12726
|
mouseAction = -1;
|
|
12439
12727
|
}
|
|
12440
12728
|
switch (mouseAction) {
|
|
12441
|
-
case
|
|
12729
|
+
case import_three32.MOUSE.DOLLY:
|
|
12442
12730
|
if (scope.enableZoom === false) return;
|
|
12443
12731
|
handleMouseDownDolly(event);
|
|
12444
12732
|
state = STATE.DOLLY;
|
|
12445
12733
|
break;
|
|
12446
|
-
case
|
|
12734
|
+
case import_three32.MOUSE.ROTATE:
|
|
12447
12735
|
if (event.ctrlKey || event.metaKey || event.shiftKey) {
|
|
12448
12736
|
if (scope.enablePan === false) return;
|
|
12449
12737
|
handleMouseDownPan(event);
|
|
@@ -12454,7 +12742,7 @@ var OrbitControls = class extends import_three31.EventDispatcher {
|
|
|
12454
12742
|
state = STATE.ROTATE;
|
|
12455
12743
|
}
|
|
12456
12744
|
break;
|
|
12457
|
-
case
|
|
12745
|
+
case import_three32.MOUSE.PAN:
|
|
12458
12746
|
if (event.ctrlKey || event.metaKey || event.shiftKey) {
|
|
12459
12747
|
if (scope.enableRotate === false) return;
|
|
12460
12748
|
handleMouseDownRotate(event);
|
|
@@ -12510,12 +12798,12 @@ var OrbitControls = class extends import_three31.EventDispatcher {
|
|
|
12510
12798
|
switch (pointers.length) {
|
|
12511
12799
|
case 1:
|
|
12512
12800
|
switch (scope.touches.ONE) {
|
|
12513
|
-
case
|
|
12801
|
+
case import_three32.TOUCH.ROTATE:
|
|
12514
12802
|
if (scope.enableRotate === false) return;
|
|
12515
12803
|
handleTouchStartRotate();
|
|
12516
12804
|
state = STATE.TOUCH_ROTATE;
|
|
12517
12805
|
break;
|
|
12518
|
-
case
|
|
12806
|
+
case import_three32.TOUCH.PAN:
|
|
12519
12807
|
if (scope.enablePan === false) return;
|
|
12520
12808
|
handleTouchStartPan();
|
|
12521
12809
|
state = STATE.TOUCH_PAN;
|
|
@@ -12526,12 +12814,12 @@ var OrbitControls = class extends import_three31.EventDispatcher {
|
|
|
12526
12814
|
break;
|
|
12527
12815
|
case 2:
|
|
12528
12816
|
switch (scope.touches.TWO) {
|
|
12529
|
-
case
|
|
12817
|
+
case import_three32.TOUCH.DOLLY_PAN:
|
|
12530
12818
|
if (scope.enableZoom === false && scope.enablePan === false) return;
|
|
12531
12819
|
handleTouchStartDollyPan();
|
|
12532
12820
|
state = STATE.TOUCH_DOLLY_PAN;
|
|
12533
12821
|
break;
|
|
12534
|
-
case
|
|
12822
|
+
case import_three32.TOUCH.DOLLY_ROTATE:
|
|
12535
12823
|
if (scope.enableZoom === false && scope.enableRotate === false) return;
|
|
12536
12824
|
handleTouchStartDollyRotate();
|
|
12537
12825
|
state = STATE.TOUCH_DOLLY_ROTATE;
|
|
@@ -12598,7 +12886,7 @@ var OrbitControls = class extends import_three31.EventDispatcher {
|
|
|
12598
12886
|
function trackPointer(event) {
|
|
12599
12887
|
let position = pointerPositions[event.pointerId];
|
|
12600
12888
|
if (position === void 0) {
|
|
12601
|
-
position = new
|
|
12889
|
+
position = new import_three32.Vector2();
|
|
12602
12890
|
pointerPositions[event.pointerId] = position;
|
|
12603
12891
|
}
|
|
12604
12892
|
position.set(event.pageX, event.pageY);
|
|
@@ -12618,10 +12906,10 @@ var MapControls = class extends OrbitControls {
|
|
|
12618
12906
|
constructor(object, domElement) {
|
|
12619
12907
|
super(object, domElement);
|
|
12620
12908
|
this.screenSpacePanning = false;
|
|
12621
|
-
this.mouseButtons.LEFT =
|
|
12622
|
-
this.mouseButtons.RIGHT =
|
|
12623
|
-
this.touches.ONE =
|
|
12624
|
-
this.touches.TWO =
|
|
12909
|
+
this.mouseButtons.LEFT = import_three32.MOUSE.PAN;
|
|
12910
|
+
this.mouseButtons.RIGHT = import_three32.MOUSE.ROTATE;
|
|
12911
|
+
this.touches.ONE = import_three32.TOUCH.PAN;
|
|
12912
|
+
this.touches.TWO = import_three32.TOUCH.DOLLY_ROTATE;
|
|
12625
12913
|
}
|
|
12626
12914
|
};
|
|
12627
12915
|
|
|
@@ -12680,8 +12968,8 @@ var Renderer = class _Renderer {
|
|
|
12680
12968
|
top: void 0,
|
|
12681
12969
|
bottom: void 0
|
|
12682
12970
|
},
|
|
12683
|
-
position: new
|
|
12684
|
-
lookingAt: new
|
|
12971
|
+
position: new import_three33.Vector3(50, 50, 50),
|
|
12972
|
+
lookingAt: new import_three33.Vector3(0, 0, 0)
|
|
12685
12973
|
},
|
|
12686
12974
|
render: {
|
|
12687
12975
|
fpsLimit: 60,
|
|
@@ -12712,14 +13000,14 @@ var Renderer = class _Renderer {
|
|
|
12712
13000
|
switch (this.options.camera.type) {
|
|
12713
13001
|
case "perspective":
|
|
12714
13002
|
default:
|
|
12715
|
-
return new
|
|
13003
|
+
return new import_three33.PerspectiveCamera(
|
|
12716
13004
|
this.options.camera.perspective.fov,
|
|
12717
13005
|
this.options.camera.perspective.aspect ?? this.viewWidth / this.viewHeight,
|
|
12718
13006
|
this.options.camera.near,
|
|
12719
13007
|
this.options.camera.far
|
|
12720
13008
|
);
|
|
12721
13009
|
case "orthographic":
|
|
12722
|
-
return new
|
|
13010
|
+
return new import_three33.OrthographicCamera(
|
|
12723
13011
|
this.options.camera.orthographic.left ?? this.viewWidth / -2,
|
|
12724
13012
|
this.options.camera.orthographic.right ?? this.viewWidth / 2,
|
|
12725
13013
|
this.options.camera.orthographic.top ?? this.viewHeight / 2,
|
|
@@ -12730,7 +13018,7 @@ var Renderer = class _Renderer {
|
|
|
12730
13018
|
}
|
|
12731
13019
|
}
|
|
12732
13020
|
createRenderer() {
|
|
12733
|
-
const renderer = new
|
|
13021
|
+
const renderer = new import_three33.WebGLRenderer({
|
|
12734
13022
|
antialias: this.options.render.antialias,
|
|
12735
13023
|
alpha: true,
|
|
12736
13024
|
powerPreference: "high-performance",
|
|
@@ -12738,8 +13026,8 @@ var Renderer = class _Renderer {
|
|
|
12738
13026
|
});
|
|
12739
13027
|
renderer.setClearColor(0, 0);
|
|
12740
13028
|
renderer.shadowMap.enabled = true;
|
|
12741
|
-
renderer.shadowMap.type =
|
|
12742
|
-
renderer.outputColorSpace =
|
|
13029
|
+
renderer.shadowMap.type = import_three33.PCFSoftShadowMap;
|
|
13030
|
+
renderer.outputColorSpace = import_three33.SRGBColorSpace;
|
|
12743
13031
|
renderer.setPixelRatio(this.options.render.pixelRatio ?? 1);
|
|
12744
13032
|
renderer.setSize(this.viewWidth, this.viewHeight);
|
|
12745
13033
|
return renderer;
|
|
@@ -12774,20 +13062,20 @@ var Renderer = class _Renderer {
|
|
|
12774
13062
|
window["__THREE_DEVTOOLS__"].dispatchEvent(new CustomEvent("observe", { detail: this.scene }));
|
|
12775
13063
|
}
|
|
12776
13064
|
if (this.options.debug.grid) {
|
|
12777
|
-
const gridHelper = new
|
|
13065
|
+
const gridHelper = new import_three33.GridHelper(128, 16);
|
|
12778
13066
|
this._debugHelpers.push(gridHelper);
|
|
12779
13067
|
this.scene.add(gridHelper);
|
|
12780
|
-
const gridHelper2 = new
|
|
13068
|
+
const gridHelper2 = new import_three33.GridHelper(128, 16);
|
|
12781
13069
|
this._debugHelpers.push(gridHelper2);
|
|
12782
13070
|
gridHelper2.rotation.x = 90 * (Math.PI / 180);
|
|
12783
13071
|
this.scene.add(gridHelper2);
|
|
12784
|
-
const gridHelper3 = new
|
|
13072
|
+
const gridHelper3 = new import_three33.GridHelper(128, 16);
|
|
12785
13073
|
this._debugHelpers.push(gridHelper3);
|
|
12786
13074
|
gridHelper3.rotation.z = 90 * (Math.PI / 180);
|
|
12787
13075
|
this.scene.add(gridHelper3);
|
|
12788
13076
|
}
|
|
12789
13077
|
if (this.options.debug.axes) {
|
|
12790
|
-
const axesHelper = new
|
|
13078
|
+
const axesHelper = new import_three33.AxesHelper(64);
|
|
12791
13079
|
this._debugHelpers.push(axesHelper);
|
|
12792
13080
|
this.scene.add(axesHelper);
|
|
12793
13081
|
}
|
|
@@ -13472,19 +13760,19 @@ var AnvilParser = class {
|
|
|
13472
13760
|
};
|
|
13473
13761
|
|
|
13474
13762
|
// src/world/Chunk.ts
|
|
13475
|
-
var
|
|
13763
|
+
var import_three38 = require("three");
|
|
13476
13764
|
init_BlockStates();
|
|
13477
13765
|
init_AssetKey();
|
|
13478
13766
|
|
|
13479
13767
|
// src/world/MineRenderWorld.ts
|
|
13480
|
-
var
|
|
13768
|
+
var import_three36 = require("three");
|
|
13481
13769
|
init_BatchedExecutor();
|
|
13482
13770
|
init_AssetKey();
|
|
13483
13771
|
init_BlockStates();
|
|
13484
13772
|
init_CubeFace();
|
|
13485
13773
|
|
|
13486
13774
|
// src/world/SectionModels.ts
|
|
13487
|
-
var
|
|
13775
|
+
var import_three35 = require("three");
|
|
13488
13776
|
init_AssetKey();
|
|
13489
13777
|
init_Models();
|
|
13490
13778
|
init_CubeFace();
|
|
@@ -13550,12 +13838,12 @@ var SectionModels = class {
|
|
|
13550
13838
|
});
|
|
13551
13839
|
await object.init();
|
|
13552
13840
|
const geometry = object.children[0].geometry;
|
|
13553
|
-
geometry.applyMatrix4(new
|
|
13841
|
+
geometry.applyMatrix4(new import_three35.Matrix4().makeRotationFromEuler(rotation));
|
|
13554
13842
|
object.clear();
|
|
13555
13843
|
const cullFaces = CUBE_FACES.map((face) => {
|
|
13556
13844
|
const local = CUBE_FACES.findIndex((name) => name === atlas.model.elements[0].faces[face]?.cullface);
|
|
13557
13845
|
if (local < 0) return 0;
|
|
13558
|
-
const normal = new
|
|
13846
|
+
const normal = new import_three35.Vector3(...CUBE_FACE_OFFSETS[local]).applyEuler(rotation);
|
|
13559
13847
|
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);
|
|
13560
13848
|
return 1 << world;
|
|
13561
13849
|
});
|
|
@@ -13585,20 +13873,20 @@ var MineRenderWorld = class {
|
|
|
13585
13873
|
}
|
|
13586
13874
|
getBlockAt(posOrX, y, z) {
|
|
13587
13875
|
if (typeof posOrX == "number") {
|
|
13588
|
-
return this.getBlockAt(new
|
|
13876
|
+
return this.getBlockAt(new import_three36.Vector3(posOrX, y, z));
|
|
13589
13877
|
}
|
|
13590
13878
|
if (isTripleArray(posOrX)) {
|
|
13591
|
-
return this.getBlockAt(new
|
|
13879
|
+
return this.getBlockAt(new import_three36.Vector3(posOrX[0], posOrX[1], posOrX[2]));
|
|
13592
13880
|
}
|
|
13593
13881
|
this.validatePosBounds(posOrX);
|
|
13594
13882
|
return this.getChunkAt(posOrX)?.getBlockAt(posOrX);
|
|
13595
13883
|
}
|
|
13596
13884
|
async setBlockAt(posOrX, yOrBlock, z, block) {
|
|
13597
13885
|
if (typeof posOrX == "number") {
|
|
13598
|
-
return this.setBlockAt(new
|
|
13886
|
+
return this.setBlockAt(new import_three36.Vector3(posOrX, yOrBlock, z), block);
|
|
13599
13887
|
}
|
|
13600
13888
|
if (isTripleArray(posOrX)) {
|
|
13601
|
-
return this.setBlockAt(new
|
|
13889
|
+
return this.setBlockAt(new import_three36.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
|
|
13602
13890
|
}
|
|
13603
13891
|
return this.placeBlock(posOrX, yOrBlock);
|
|
13604
13892
|
}
|
|
@@ -13619,7 +13907,7 @@ var MineRenderWorld = class {
|
|
|
13619
13907
|
const collect = async (positions2) => {
|
|
13620
13908
|
for (const pos of positions2) changes.set(pos.toArray().join(","), pos);
|
|
13621
13909
|
};
|
|
13622
|
-
const place = (block) => this.placeBlock(new
|
|
13910
|
+
const place = (block) => this.placeBlock(new import_three36.Vector3(...block.position), block, collect);
|
|
13623
13911
|
const keys = /* @__PURE__ */ new Map();
|
|
13624
13912
|
for (const block of multiblock.blocks) {
|
|
13625
13913
|
if (Chunk.isAir(block)) continue;
|
|
@@ -13697,13 +13985,13 @@ var MineRenderWorld = class {
|
|
|
13697
13985
|
for (const pos of positions) {
|
|
13698
13986
|
this.pendingCulling.set(pos.toArray().join(","), pos.clone());
|
|
13699
13987
|
for (const offset of CUBE_FACE_OFFSETS) {
|
|
13700
|
-
const neighbor = pos.clone().add(new
|
|
13988
|
+
const neighbor = pos.clone().add(new import_three36.Vector3(...offset));
|
|
13701
13989
|
this.pendingCulling.set(neighbor.toArray().join(","), neighbor);
|
|
13702
13990
|
}
|
|
13703
13991
|
for (let y = -1; y <= 1; y++) {
|
|
13704
13992
|
for (let z = -1; z <= 1; z++) {
|
|
13705
13993
|
for (let x = -1; x <= 1; x++) {
|
|
13706
|
-
const neighbor = pos.clone().add(new
|
|
13994
|
+
const neighbor = pos.clone().add(new import_three36.Vector3(x, y, z));
|
|
13707
13995
|
if (this.getBlockAt(neighbor)?.object?.fluidKind) {
|
|
13708
13996
|
this.pendingCulling.set(neighbor.toArray().join(","), neighbor);
|
|
13709
13997
|
}
|
|
@@ -13725,7 +14013,7 @@ var MineRenderWorld = class {
|
|
|
13725
14013
|
if (!block) continue;
|
|
13726
14014
|
if (block.object?.fluidKind) {
|
|
13727
14015
|
await block.object.updateFluid((x, y, z) => {
|
|
13728
|
-
const neighbor = pos.clone().add(new
|
|
14016
|
+
const neighbor = pos.clone().add(new import_three36.Vector3(x, y, z));
|
|
13729
14017
|
const section = this.getChunkAt(neighbor);
|
|
13730
14018
|
const object = section?.getBlockAt(neighbor)?.object;
|
|
13731
14019
|
return {
|
|
@@ -13737,7 +14025,7 @@ var MineRenderWorld = class {
|
|
|
13737
14025
|
}
|
|
13738
14026
|
let mask = 0;
|
|
13739
14027
|
for (const [face, offset] of CUBE_FACE_OFFSETS.entries()) {
|
|
13740
|
-
const neighbor = pos.clone().add(new
|
|
14028
|
+
const neighbor = pos.clone().add(new import_three36.Vector3(...offset));
|
|
13741
14029
|
if (this.getChunkAt(neighbor)?.isOccludingAt(neighbor)) {
|
|
13742
14030
|
mask |= 1 << face;
|
|
13743
14031
|
}
|
|
@@ -13771,14 +14059,14 @@ var MineRenderWorld = class {
|
|
|
13771
14059
|
return this._chunks.get(this.worldPosToChunkKey(pos));
|
|
13772
14060
|
}
|
|
13773
14061
|
static worldToScenePosition(pos) {
|
|
13774
|
-
return new
|
|
14062
|
+
return new import_three36.Vector3(
|
|
13775
14063
|
pos.x * 16,
|
|
13776
14064
|
pos.y * 16,
|
|
13777
14065
|
pos.z * 16
|
|
13778
14066
|
);
|
|
13779
14067
|
}
|
|
13780
14068
|
static sceneToWorldPosition(pos) {
|
|
13781
|
-
return new
|
|
14069
|
+
return new import_three36.Vector3(
|
|
13782
14070
|
pos.x / 16,
|
|
13783
14071
|
pos.y / 16,
|
|
13784
14072
|
pos.z / 16
|
|
@@ -13798,10 +14086,10 @@ var MineRenderWorld = class {
|
|
|
13798
14086
|
};
|
|
13799
14087
|
|
|
13800
14088
|
// src/world/SectionMesh.ts
|
|
13801
|
-
var
|
|
14089
|
+
var import_three37 = require("three");
|
|
13802
14090
|
init_CanvasCompat();
|
|
13803
14091
|
init_Materials();
|
|
13804
|
-
var SectionMesh = class _SectionMesh extends
|
|
14092
|
+
var SectionMesh = class _SectionMesh extends import_three37.Group {
|
|
13805
14093
|
constructor() {
|
|
13806
14094
|
super(...arguments);
|
|
13807
14095
|
this.ownedMeshes = [];
|
|
@@ -13874,18 +14162,18 @@ var SectionMesh = class _SectionMesh extends import_three36.Group {
|
|
|
13874
14162
|
for (let corner = 0; corner < 6; corner++) indices.push(start + sourceIndices.getX(face * 6 + corner) - face * 4);
|
|
13875
14163
|
}
|
|
13876
14164
|
}
|
|
13877
|
-
const geometry = new
|
|
13878
|
-
geometry.setAttribute("position", new
|
|
13879
|
-
geometry.setAttribute("normal", new
|
|
13880
|
-
geometry.setAttribute("uv", new
|
|
13881
|
-
geometry.setAttribute("color", new
|
|
14165
|
+
const geometry = new import_three37.BufferGeometry();
|
|
14166
|
+
geometry.setAttribute("position", new import_three37.Float32BufferAttribute(positions, 3));
|
|
14167
|
+
geometry.setAttribute("normal", new import_three37.Float32BufferAttribute(normals, 3));
|
|
14168
|
+
geometry.setAttribute("uv", new import_three37.Float32BufferAttribute(uvs, 2));
|
|
14169
|
+
geometry.setAttribute("color", new import_three37.Float32BufferAttribute(colors, 3));
|
|
13882
14170
|
geometry.setIndex(indices);
|
|
13883
14171
|
geometry.computeBoundingBox();
|
|
13884
14172
|
geometry.computeBoundingSphere();
|
|
13885
14173
|
const material = Materials.createShadedCanvasMaterial(canvas, false);
|
|
13886
14174
|
material.vertexColors = true;
|
|
13887
14175
|
const texture = material.uniforms?.map?.value ?? material.map;
|
|
13888
|
-
const mesh = new
|
|
14176
|
+
const mesh = new import_three37.Mesh(geometry, material);
|
|
13889
14177
|
section.add(mesh);
|
|
13890
14178
|
section.ownedMeshes.push({ mesh, texture });
|
|
13891
14179
|
}
|
|
@@ -13919,10 +14207,10 @@ var Chunk = class _Chunk {
|
|
|
13919
14207
|
}
|
|
13920
14208
|
getBlockAt(posOrX, y, z) {
|
|
13921
14209
|
if (typeof posOrX == "number") {
|
|
13922
|
-
return this.getBlockAt(new
|
|
14210
|
+
return this.getBlockAt(new import_three38.Vector3(posOrX, y, z));
|
|
13923
14211
|
}
|
|
13924
14212
|
if (isTripleArray(posOrX)) {
|
|
13925
|
-
return this.getBlockAt(new
|
|
14213
|
+
return this.getBlockAt(new import_three38.Vector3(posOrX[0], posOrX[1], posOrX[2]));
|
|
13926
14214
|
}
|
|
13927
14215
|
const pos = this.worldPosToChunkPos(posOrX);
|
|
13928
14216
|
const index = _Chunk.chunkPosToBlockIndex(pos);
|
|
@@ -13930,10 +14218,10 @@ var Chunk = class _Chunk {
|
|
|
13930
14218
|
}
|
|
13931
14219
|
async setBlockAt(posOrX, yOrBlock, z, block) {
|
|
13932
14220
|
if (typeof posOrX == "number") {
|
|
13933
|
-
return this.setBlockAt(new
|
|
14221
|
+
return this.setBlockAt(new import_three38.Vector3(posOrX, yOrBlock, z), block);
|
|
13934
14222
|
}
|
|
13935
14223
|
if (isTripleArray(posOrX)) {
|
|
13936
|
-
return this.setBlockAt(new
|
|
14224
|
+
return this.setBlockAt(new import_three38.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
|
|
13937
14225
|
}
|
|
13938
14226
|
const worldPos = posOrX;
|
|
13939
14227
|
const pos = this.worldPosToChunkPos(worldPos);
|
|
@@ -13962,7 +14250,8 @@ var Chunk = class _Chunk {
|
|
|
13962
14250
|
this.data.set(index, void 0);
|
|
13963
14251
|
return void 0;
|
|
13964
14252
|
}
|
|
13965
|
-
const
|
|
14253
|
+
const perBlock = !this.sectionModels || getFluidKind(blockState.key, stored.properties) || blockState.key && BlockEntities.entry(await BlockEntities.getIndex(blockState.key.root), blockState.key.toNamespacedString());
|
|
14254
|
+
const template = perBlock ? void 0 : await this.sectionModels.get(blockState, stored.properties);
|
|
13966
14255
|
if (template) {
|
|
13967
14256
|
this.sectionBlocks.set(index, { index, template, cullMask: 0 });
|
|
13968
14257
|
this.meshDirty = true;
|
|
@@ -14018,7 +14307,7 @@ var Chunk = class _Chunk {
|
|
|
14018
14307
|
}
|
|
14019
14308
|
async clear(onBlocksChanged = this.onBlocksChanged) {
|
|
14020
14309
|
const positions = [...this.renderedBlocks.keys()].map((index) => this.chunkPosToWorldPos(
|
|
14021
|
-
new
|
|
14310
|
+
new import_three38.Vector3(index % 16, Math.floor(index / 256), Math.floor(index / 16) % 16)
|
|
14022
14311
|
));
|
|
14023
14312
|
for (const info of this.renderedBlocks.values()) info.object?.removeFromScene();
|
|
14024
14313
|
this.sectionBlocks.clear();
|
|
@@ -14042,14 +14331,14 @@ var Chunk = class _Chunk {
|
|
|
14042
14331
|
return pos.y * 16 * 16 + pos.z * 16 + pos.x;
|
|
14043
14332
|
}
|
|
14044
14333
|
worldPosToChunkPos(pos) {
|
|
14045
|
-
return new
|
|
14334
|
+
return new import_three38.Vector3(
|
|
14046
14335
|
pos.x - this.x * 16,
|
|
14047
14336
|
pos.y - this.y * 16,
|
|
14048
14337
|
pos.z - this.z * 16
|
|
14049
14338
|
);
|
|
14050
14339
|
}
|
|
14051
14340
|
chunkPosToWorldPos(pos) {
|
|
14052
|
-
return new
|
|
14341
|
+
return new import_three38.Vector3(
|
|
14053
14342
|
this.x * 16 + pos.x,
|
|
14054
14343
|
this.y * 16 + pos.y,
|
|
14055
14344
|
this.z * 16 + pos.z
|
|
@@ -14072,6 +14361,7 @@ var Chunk = class _Chunk {
|
|
|
14072
14361
|
BUILTIN_GENERATED,
|
|
14073
14362
|
BasicAssetKey,
|
|
14074
14363
|
BatchedExecutor,
|
|
14364
|
+
BlockEntities,
|
|
14075
14365
|
BlockObject,
|
|
14076
14366
|
BlockStateResolver,
|
|
14077
14367
|
BlockStates,
|
|
@@ -14093,7 +14383,9 @@ var Chunk = class _Chunk {
|
|
|
14093
14383
|
DefaultBlockStates,
|
|
14094
14384
|
DisplayPosition,
|
|
14095
14385
|
DisplayTransforms,
|
|
14386
|
+
ENTITY_ANIMATION_CHANNELS,
|
|
14096
14387
|
Entities,
|
|
14388
|
+
EntityAnimationPlayer,
|
|
14097
14389
|
EntityObject,
|
|
14098
14390
|
Env,
|
|
14099
14391
|
FluidModelObject,
|
|
@@ -14169,6 +14461,7 @@ var Chunk = class _Chunk {
|
|
|
14169
14461
|
createCanvas,
|
|
14170
14462
|
createFluidGeometry,
|
|
14171
14463
|
createImage,
|
|
14464
|
+
entityAnimationTime,
|
|
14172
14465
|
estimateBytesUsed,
|
|
14173
14466
|
getBlockFluidState,
|
|
14174
14467
|
getFluidKind,
|
|
@@ -14201,6 +14494,8 @@ var Chunk = class _Chunk {
|
|
|
14201
14494
|
mergeVertices,
|
|
14202
14495
|
prefix,
|
|
14203
14496
|
registerNodeEnv,
|
|
14497
|
+
sampleEntityAnimation,
|
|
14498
|
+
sampleEntityKeyframes,
|
|
14204
14499
|
sampleFluid,
|
|
14205
14500
|
serializeBoxGeometryKey,
|
|
14206
14501
|
serializeImageKey,
|