minerender 2.1.0-alpha.54 → 2.1.0-alpha.59
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 +163 -2
- package/dist/browser/index.d.ts +163 -2
- package/dist/browser/index.js +574 -266
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +338 -30
- package/dist/browser/index.mjs.map +1 -1
- package/dist/bundle.js +324 -7
- package/dist/bundle.js.map +1 -1
- package/dist/node/index.d.mts +163 -2
- package/dist/node/index.d.ts +163 -2
- package/dist/node/index.js +584 -266
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +342 -30
- 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() {
|
|
@@ -1770,6 +1778,11 @@ function addWireframeToMesh(geo, mesh, color = 16777215, w = 2) {
|
|
|
1770
1778
|
mesh.add(wireframe);
|
|
1771
1779
|
let axes = new import_three8.AxesHelper(1);
|
|
1772
1780
|
mesh.add(axes);
|
|
1781
|
+
return () => {
|
|
1782
|
+
wireGeo.dispose();
|
|
1783
|
+
wireMat.dispose();
|
|
1784
|
+
axes.dispose();
|
|
1785
|
+
};
|
|
1773
1786
|
}
|
|
1774
1787
|
var import_three8;
|
|
1775
1788
|
var init_model = __esm({
|
|
@@ -3166,10 +3179,10 @@ var init_InstanceReference = __esm({
|
|
|
3166
3179
|
function isSceneObject(obj) {
|
|
3167
3180
|
return obj.isSceneObject;
|
|
3168
3181
|
}
|
|
3169
|
-
var
|
|
3182
|
+
var import_three11, import_ts_deepmerge3, p6, SceneObject;
|
|
3170
3183
|
var init_SceneObject = __esm({
|
|
3171
3184
|
"src/renderer/SceneObject.ts"() {
|
|
3172
|
-
|
|
3185
|
+
import_three11 = require("three");
|
|
3173
3186
|
init_Geometries();
|
|
3174
3187
|
init_UVMapper();
|
|
3175
3188
|
init_Axis();
|
|
@@ -3181,7 +3194,7 @@ var init_SceneObject = __esm({
|
|
|
3181
3194
|
import_ts_deepmerge3 = __toESM(require_dist());
|
|
3182
3195
|
init_log();
|
|
3183
3196
|
p6 = prefix("SceneObject");
|
|
3184
|
-
SceneObject = class _SceneObject extends
|
|
3197
|
+
SceneObject = class _SceneObject extends import_three11.Object3D {
|
|
3185
3198
|
constructor(options) {
|
|
3186
3199
|
super();
|
|
3187
3200
|
this.isSceneObject = true;
|
|
@@ -3233,7 +3246,7 @@ var init_SceneObject = __esm({
|
|
|
3233
3246
|
return group;
|
|
3234
3247
|
}
|
|
3235
3248
|
createGroup(name, x = 0, y = 0, z = 0, offsetAxis, offset = 0) {
|
|
3236
|
-
const obj = new
|
|
3249
|
+
const obj = new import_three11.Object3D();
|
|
3237
3250
|
if (name) {
|
|
3238
3251
|
obj.name = `group:${name}`;
|
|
3239
3252
|
}
|
|
@@ -3283,7 +3296,7 @@ var init_SceneObject = __esm({
|
|
|
3283
3296
|
return mesh;
|
|
3284
3297
|
}
|
|
3285
3298
|
createMesh(name, geometry, material, offsetAxis, offset = 0) {
|
|
3286
|
-
const mesh = new
|
|
3299
|
+
const mesh = new import_three11.Mesh(geometry, material);
|
|
3287
3300
|
if (name) {
|
|
3288
3301
|
mesh.name = `mesh:${name}`;
|
|
3289
3302
|
}
|
|
@@ -3295,7 +3308,7 @@ var init_SceneObject = __esm({
|
|
|
3295
3308
|
return mesh;
|
|
3296
3309
|
}
|
|
3297
3310
|
createInstancedMesh(name, geometry, material, count) {
|
|
3298
|
-
const mesh = new
|
|
3311
|
+
const mesh = new import_three11.InstancedMesh(geometry, material, count);
|
|
3299
3312
|
mesh.count = 0;
|
|
3300
3313
|
this.instanceMesh = mesh;
|
|
3301
3314
|
this._isInstanced = true;
|
|
@@ -3375,11 +3388,11 @@ var init_SceneObject = __esm({
|
|
|
3375
3388
|
this._instanceCounter = this.instanceReferences.size;
|
|
3376
3389
|
mesh.count = Math.max(mesh.count, index + 1);
|
|
3377
3390
|
if (mesh.instanceColor) {
|
|
3378
|
-
mesh.setColorAt(index, new
|
|
3391
|
+
mesh.setColorAt(index, new import_three11.Color(16777215));
|
|
3379
3392
|
mesh.instanceColor.needsUpdate = true;
|
|
3380
3393
|
}
|
|
3381
3394
|
if (this._scene) this._scene.stats.instanceCount++;
|
|
3382
|
-
this.setMatrixAt(index, new
|
|
3395
|
+
this.setMatrixAt(index, new import_three11.Matrix4());
|
|
3383
3396
|
return reference;
|
|
3384
3397
|
}
|
|
3385
3398
|
/** Returns the live reference for a raycast hit on this object's instance mesh. */
|
|
@@ -3392,7 +3405,7 @@ var init_SceneObject = __esm({
|
|
|
3392
3405
|
removeInstanceAt(index) {
|
|
3393
3406
|
if (!this.instanceReferences.has(index)) return;
|
|
3394
3407
|
const mesh = this.instanceMesh;
|
|
3395
|
-
this.setMatrixAt(index, new
|
|
3408
|
+
this.setMatrixAt(index, new import_three11.Matrix4().makeScale(0, 0, 0));
|
|
3396
3409
|
this.instanceReferences.delete(index);
|
|
3397
3410
|
this.freeInstanceIndices.push(index);
|
|
3398
3411
|
this._instanceCounter = this.instanceReferences.size;
|
|
@@ -3405,7 +3418,7 @@ var init_SceneObject = __esm({
|
|
|
3405
3418
|
const grow = (attribute, fill) => {
|
|
3406
3419
|
const array = new Float32Array(capacity * attribute.itemSize).fill(fill);
|
|
3407
3420
|
array.set(attribute.array);
|
|
3408
|
-
return new
|
|
3421
|
+
return new import_three11.InstancedBufferAttribute(array, attribute.itemSize, attribute.normalized, attribute.meshPerAttribute).setUsage(attribute.usage);
|
|
3409
3422
|
};
|
|
3410
3423
|
const matrix = grow(mesh.instanceMatrix, 0);
|
|
3411
3424
|
const color = mesh.instanceColor ? grow(mesh.instanceColor, 1) : null;
|
|
@@ -3422,7 +3435,7 @@ var init_SceneObject = __esm({
|
|
|
3422
3435
|
}
|
|
3423
3436
|
//</editor-fold>
|
|
3424
3437
|
//<editor-fold desc="TRANSFORMATION">
|
|
3425
|
-
getMatrixAt(index, matrix = new
|
|
3438
|
+
getMatrixAt(index, matrix = new import_three11.Matrix4()) {
|
|
3426
3439
|
if (!this.instanceReferences.has(index)) throw new MineRenderError("Instance is not active");
|
|
3427
3440
|
this.instanceMesh.getMatrixAt(index, matrix);
|
|
3428
3441
|
return matrix;
|
|
@@ -3438,16 +3451,16 @@ var init_SceneObject = __esm({
|
|
|
3438
3451
|
}
|
|
3439
3452
|
setPositionRotationScaleAt(index, position, rotation, scale) {
|
|
3440
3453
|
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
|
|
3454
|
+
const oldPosition = new import_three11.Vector3();
|
|
3455
|
+
const oldRotation = new import_three11.Quaternion();
|
|
3456
|
+
const oldScale = new import_three11.Vector3();
|
|
3457
|
+
const matrix = new import_three11.Matrix4();
|
|
3445
3458
|
if (!scale || !rotation || !position) {
|
|
3446
3459
|
this.getMatrixAt(index, matrix).decompose(oldPosition, oldRotation, oldScale);
|
|
3447
3460
|
}
|
|
3448
3461
|
matrix.compose(
|
|
3449
3462
|
position ? position : oldPosition,
|
|
3450
|
-
rotation ? new
|
|
3463
|
+
rotation ? new import_three11.Quaternion().setFromEuler(rotation) : oldRotation,
|
|
3451
3464
|
scale ? scale : oldScale
|
|
3452
3465
|
);
|
|
3453
3466
|
this.setMatrixAt(index, matrix);
|
|
@@ -3456,7 +3469,7 @@ var init_SceneObject = __esm({
|
|
|
3456
3469
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3457
3470
|
this.setPositionRotationScaleAt(index, position);
|
|
3458
3471
|
}
|
|
3459
|
-
getPositionAt(index, vector = new
|
|
3472
|
+
getPositionAt(index, vector = new import_three11.Vector3()) {
|
|
3460
3473
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3461
3474
|
const matrix = this.getMatrixAt(index);
|
|
3462
3475
|
vector.setFromMatrixPosition(matrix);
|
|
@@ -3466,17 +3479,17 @@ var init_SceneObject = __esm({
|
|
|
3466
3479
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3467
3480
|
this.setPositionRotationScaleAt(index, void 0, rotation, void 0);
|
|
3468
3481
|
}
|
|
3469
|
-
getRotationAt(index, euler = new
|
|
3482
|
+
getRotationAt(index, euler = new import_three11.Euler()) {
|
|
3470
3483
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3471
|
-
const rotation = new
|
|
3472
|
-
this.getMatrixAt(index).decompose(new
|
|
3484
|
+
const rotation = new import_three11.Quaternion();
|
|
3485
|
+
this.getMatrixAt(index).decompose(new import_three11.Vector3(), rotation, new import_three11.Vector3());
|
|
3473
3486
|
return euler.setFromQuaternion(rotation);
|
|
3474
3487
|
}
|
|
3475
3488
|
setScaleAt(index, scale) {
|
|
3476
3489
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3477
3490
|
this.setPositionRotationScaleAt(index, void 0, void 0, scale);
|
|
3478
3491
|
}
|
|
3479
|
-
getScaleAt(index, vector = new
|
|
3492
|
+
getScaleAt(index, vector = new import_three11.Vector3()) {
|
|
3480
3493
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3481
3494
|
const matrix = this.getMatrixAt(index);
|
|
3482
3495
|
vector.setFromMatrixScale(matrix);
|
|
@@ -3612,7 +3625,7 @@ function mergeBufferGeometries(geometries, useGroups = false) {
|
|
|
3612
3625
|
const attributes = {};
|
|
3613
3626
|
const morphAttributes = {};
|
|
3614
3627
|
const morphTargetsRelative = geometries[0].morphTargetsRelative;
|
|
3615
|
-
const mergedGeometry = new
|
|
3628
|
+
const mergedGeometry = new import_three20.BufferGeometry();
|
|
3616
3629
|
let offset = 0;
|
|
3617
3630
|
for (let i = 0; i < geometries.length; ++i) {
|
|
3618
3631
|
const geometry = geometries[i];
|
|
@@ -3736,7 +3749,7 @@ function mergeBufferAttributes(attributes) {
|
|
|
3736
3749
|
array.set(attributes[i].array, offset);
|
|
3737
3750
|
offset += attributes[i].array.length;
|
|
3738
3751
|
}
|
|
3739
|
-
return new
|
|
3752
|
+
return new import_three20.BufferAttribute(array, itemSize, normalized);
|
|
3740
3753
|
}
|
|
3741
3754
|
function interleaveAttributes(attributes) {
|
|
3742
3755
|
let TypedArray;
|
|
@@ -3752,7 +3765,7 @@ function interleaveAttributes(attributes) {
|
|
|
3752
3765
|
arrayLength += attribute.array.length;
|
|
3753
3766
|
stride += attribute.itemSize;
|
|
3754
3767
|
}
|
|
3755
|
-
const interleavedBuffer = new
|
|
3768
|
+
const interleavedBuffer = new import_three20.InterleavedBuffer(new TypedArray(arrayLength), stride);
|
|
3756
3769
|
let offset = 0;
|
|
3757
3770
|
const res = [];
|
|
3758
3771
|
const getters = ["getX", "getY", "getZ", "getW"];
|
|
@@ -3761,7 +3774,7 @@ function interleaveAttributes(attributes) {
|
|
|
3761
3774
|
const attribute = attributes[j];
|
|
3762
3775
|
const itemSize = attribute.itemSize;
|
|
3763
3776
|
const count = attribute.count;
|
|
3764
|
-
const iba = new
|
|
3777
|
+
const iba = new import_three20.InterleavedBufferAttribute(interleavedBuffer, itemSize, offset, attribute.normalized);
|
|
3765
3778
|
res.push(iba);
|
|
3766
3779
|
offset += itemSize;
|
|
3767
3780
|
for (let c = 0; c < count; c++) {
|
|
@@ -3845,13 +3858,13 @@ function mergeVertices(geometry, tolerance = 1e-4) {
|
|
|
3845
3858
|
const name = attributeNames[i];
|
|
3846
3859
|
const oldAttribute = geometry.getAttribute(name);
|
|
3847
3860
|
const buffer = new oldAttribute.array.constructor(attrArrays[name]);
|
|
3848
|
-
const attribute = new
|
|
3861
|
+
const attribute = new import_three20.BufferAttribute(buffer, oldAttribute.itemSize, oldAttribute.normalized);
|
|
3849
3862
|
result.setAttribute(name, attribute);
|
|
3850
3863
|
if (name in morphAttrsArrays) {
|
|
3851
3864
|
for (let j = 0; j < morphAttrsArrays[name].length; j++) {
|
|
3852
3865
|
const oldMorphAttribute = geometry.morphAttributes[name][j];
|
|
3853
3866
|
const buffer2 = new oldMorphAttribute.array.constructor(morphAttrsArrays[name][j]);
|
|
3854
|
-
const morphAttribute = new
|
|
3867
|
+
const morphAttribute = new import_three20.BufferAttribute(buffer2, oldMorphAttribute.itemSize, oldMorphAttribute.normalized);
|
|
3855
3868
|
result.morphAttributes[name][j] = morphAttribute;
|
|
3856
3869
|
}
|
|
3857
3870
|
}
|
|
@@ -3860,11 +3873,11 @@ function mergeVertices(geometry, tolerance = 1e-4) {
|
|
|
3860
3873
|
return result;
|
|
3861
3874
|
}
|
|
3862
3875
|
function toTrianglesDrawMode(geometry, drawMode) {
|
|
3863
|
-
if (drawMode ===
|
|
3876
|
+
if (drawMode === import_three20.TrianglesDrawMode) {
|
|
3864
3877
|
console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles.");
|
|
3865
3878
|
return geometry;
|
|
3866
3879
|
}
|
|
3867
|
-
if (drawMode ===
|
|
3880
|
+
if (drawMode === import_three20.TriangleFanDrawMode || drawMode === import_three20.TriangleStripDrawMode) {
|
|
3868
3881
|
let index = geometry.getIndex();
|
|
3869
3882
|
if (index === null) {
|
|
3870
3883
|
const indices = [];
|
|
@@ -3882,7 +3895,7 @@ function toTrianglesDrawMode(geometry, drawMode) {
|
|
|
3882
3895
|
}
|
|
3883
3896
|
const numberOfTriangles = index.count - 2;
|
|
3884
3897
|
const newIndices = [];
|
|
3885
|
-
if (drawMode ===
|
|
3898
|
+
if (drawMode === import_three20.TriangleFanDrawMode) {
|
|
3886
3899
|
for (let i = 1; i <= numberOfTriangles; i++) {
|
|
3887
3900
|
newIndices.push(index.getX(0));
|
|
3888
3901
|
newIndices.push(index.getX(i));
|
|
@@ -3918,15 +3931,15 @@ function computeMorphedAttributes(object) {
|
|
|
3918
3931
|
console.error("THREE.BufferGeometryUtils: Geometry is not of type BufferGeometry.");
|
|
3919
3932
|
return null;
|
|
3920
3933
|
}
|
|
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
|
|
3934
|
+
const _vA = new import_three20.Vector3();
|
|
3935
|
+
const _vB = new import_three20.Vector3();
|
|
3936
|
+
const _vC = new import_three20.Vector3();
|
|
3937
|
+
const _tempA = new import_three20.Vector3();
|
|
3938
|
+
const _tempB = new import_three20.Vector3();
|
|
3939
|
+
const _tempC = new import_three20.Vector3();
|
|
3940
|
+
const _morphA = new import_three20.Vector3();
|
|
3941
|
+
const _morphB = new import_three20.Vector3();
|
|
3942
|
+
const _morphC = new import_three20.Vector3();
|
|
3930
3943
|
function _calculateMorphedAttributeData(object2, material2, attribute, morphAttribute, morphTargetsRelative2, a2, b2, c2, modifiedAttributeArray) {
|
|
3931
3944
|
_vA.fromBufferAttribute(attribute, a2);
|
|
3932
3945
|
_vB.fromBufferAttribute(attribute, b2);
|
|
@@ -4121,8 +4134,8 @@ function computeMorphedAttributes(object) {
|
|
|
4121
4134
|
}
|
|
4122
4135
|
}
|
|
4123
4136
|
}
|
|
4124
|
-
const morphedPositionAttribute = new
|
|
4125
|
-
const morphedNormalAttribute = new
|
|
4137
|
+
const morphedPositionAttribute = new import_three20.Float32BufferAttribute(modifiedPosition, 3);
|
|
4138
|
+
const morphedNormalAttribute = new import_three20.Float32BufferAttribute(modifiedNormal, 3);
|
|
4126
4139
|
return {
|
|
4127
4140
|
positionAttribute,
|
|
4128
4141
|
normalAttribute,
|
|
@@ -4130,24 +4143,24 @@ function computeMorphedAttributes(object) {
|
|
|
4130
4143
|
morphedNormalAttribute
|
|
4131
4144
|
};
|
|
4132
4145
|
}
|
|
4133
|
-
var
|
|
4146
|
+
var import_three20;
|
|
4134
4147
|
var init_BufferGeometryUtils = __esm({
|
|
4135
4148
|
"src/three/BufferGeometryUtils.js"() {
|
|
4136
|
-
|
|
4149
|
+
import_three20 = require("three");
|
|
4137
4150
|
}
|
|
4138
4151
|
});
|
|
4139
4152
|
|
|
4140
4153
|
// src/model/ModelCulling.ts
|
|
4141
|
-
var
|
|
4154
|
+
var import_three21, ModelCulling;
|
|
4142
4155
|
var init_ModelCulling = __esm({
|
|
4143
4156
|
"src/model/ModelCulling.ts"() {
|
|
4144
|
-
|
|
4157
|
+
import_three21 = require("three");
|
|
4145
4158
|
init_CubeFace();
|
|
4146
4159
|
ModelCulling = class {
|
|
4147
4160
|
static toLocalMask(worldMask, rotation) {
|
|
4148
4161
|
let localMask = 0;
|
|
4149
4162
|
for (const [localFace, offset] of CUBE_FACE_OFFSETS.entries()) {
|
|
4150
|
-
const normal = new
|
|
4163
|
+
const normal = new import_three21.Vector3(...offset).applyEuler(rotation);
|
|
4151
4164
|
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
4165
|
if (worldFace < 0) return 0;
|
|
4153
4166
|
if (worldMask & 1 << worldFace) localMask |= 1 << localFace;
|
|
@@ -4183,13 +4196,13 @@ var init_ModelCulling = __esm({
|
|
|
4183
4196
|
function isModelObject(obj) {
|
|
4184
4197
|
return obj.isModelObject;
|
|
4185
4198
|
}
|
|
4186
|
-
var
|
|
4199
|
+
var import_three22, import_ts_deepmerge5, p7, ModelObject;
|
|
4187
4200
|
var init_ModelObject = __esm({
|
|
4188
4201
|
"src/model/scene/ModelObject.ts"() {
|
|
4189
4202
|
init_SceneObject();
|
|
4190
4203
|
init_Materials();
|
|
4191
4204
|
init_UVMapper();
|
|
4192
|
-
|
|
4205
|
+
import_three22 = require("three");
|
|
4193
4206
|
init_BufferGeometryUtils();
|
|
4194
4207
|
init_model();
|
|
4195
4208
|
import_ts_deepmerge5 = __toESM(require_dist());
|
|
@@ -4246,7 +4259,7 @@ var init_ModelObject = __esm({
|
|
|
4246
4259
|
elGeo.clearGroups();
|
|
4247
4260
|
}
|
|
4248
4261
|
if (this.options.uvLockRotation) {
|
|
4249
|
-
UVMapper.lockUvs(elGeo, el.faces, this.atlas, new
|
|
4262
|
+
UVMapper.lockUvs(elGeo, el.faces, this.atlas, new import_three22.Euler(...this.options.uvLockRotation));
|
|
4250
4263
|
}
|
|
4251
4264
|
if (this.options.tints) {
|
|
4252
4265
|
const colors = new Float32Array(elGeo.getAttribute("position").count * 3).fill(1);
|
|
@@ -4255,19 +4268,19 @@ var init_ModelObject = __esm({
|
|
|
4255
4268
|
if (tintIndex === void 0 || tintIndex < 0) continue;
|
|
4256
4269
|
const tint = this.options.tints[tintIndex];
|
|
4257
4270
|
if (tint === void 0) continue;
|
|
4258
|
-
const color = new
|
|
4271
|
+
const color = new import_three22.Color(tint);
|
|
4259
4272
|
for (let vertex = 0; vertex < 4; vertex++) {
|
|
4260
4273
|
color.toArray(colors, (faceIndex * 4 + vertex) * 3);
|
|
4261
4274
|
}
|
|
4262
4275
|
}
|
|
4263
|
-
elGeo.setAttribute("color", new
|
|
4276
|
+
elGeo.setAttribute("color", new import_three22.BufferAttribute(colors, 3));
|
|
4264
4277
|
}
|
|
4265
|
-
elGeo.applyMatrix4(new
|
|
4266
|
-
elGeo.applyMatrix4(new
|
|
4278
|
+
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));
|
|
4279
|
+
elGeo.applyMatrix4(new import_three22.Matrix4().makeTranslation(el.from[0], el.from[1], el.from[2]));
|
|
4267
4280
|
if (el.rotation) {
|
|
4268
4281
|
applyElementRotation(el.rotation, elGeo);
|
|
4269
4282
|
}
|
|
4270
|
-
elGeo.applyMatrix4(new
|
|
4283
|
+
elGeo.applyMatrix4(new import_three22.Matrix4().makeTranslation(-8, -8, -8));
|
|
4271
4284
|
if (displayTransform) DisplayTransforms.apply(elGeo, displayTransform);
|
|
4272
4285
|
if (this.options.mergeMeshes) {
|
|
4273
4286
|
allGeos.push(elGeo);
|
|
@@ -4289,7 +4302,7 @@ var init_ModelObject = __esm({
|
|
|
4289
4302
|
if (allGeos.length > 0) {
|
|
4290
4303
|
combinedGeo = mergeBufferGeometries(allGeos);
|
|
4291
4304
|
} else {
|
|
4292
|
-
combinedGeo = new
|
|
4305
|
+
combinedGeo = new import_three22.BoxGeometry(16, 16, 16);
|
|
4293
4306
|
if (displayTransform) DisplayTransforms.apply(combinedGeo, displayTransform);
|
|
4294
4307
|
}
|
|
4295
4308
|
combinedGeo.computeBoundingBox();
|
|
@@ -4397,7 +4410,7 @@ function ownHeight(sample) {
|
|
|
4397
4410
|
return (level === 0 || level >= 8 ? 8 : 8 - level) / 9;
|
|
4398
4411
|
}
|
|
4399
4412
|
function createFluidGeometry(kind, sample) {
|
|
4400
|
-
const geometry = new
|
|
4413
|
+
const geometry = new import_three27.BufferGeometry();
|
|
4401
4414
|
const positions = [], normals = [], uvs = [], indices = [];
|
|
4402
4415
|
const self = sample(0, 0, 0);
|
|
4403
4416
|
const height = (x, z) => {
|
|
@@ -4496,16 +4509,16 @@ function createFluidGeometry(kind, sample) {
|
|
|
4496
4509
|
1
|
|
4497
4510
|
);
|
|
4498
4511
|
}
|
|
4499
|
-
geometry.setAttribute("position", new
|
|
4500
|
-
geometry.setAttribute("normal", new
|
|
4501
|
-
geometry.setAttribute("uv", new
|
|
4512
|
+
geometry.setAttribute("position", new import_three27.Float32BufferAttribute(positions, 3));
|
|
4513
|
+
geometry.setAttribute("normal", new import_three27.Float32BufferAttribute(normals, 3));
|
|
4514
|
+
geometry.setAttribute("uv", new import_three27.Float32BufferAttribute(uvs, 2));
|
|
4502
4515
|
geometry.setIndex(indices);
|
|
4503
4516
|
return geometry;
|
|
4504
4517
|
}
|
|
4505
|
-
var
|
|
4518
|
+
var import_three27, fluidRules, HORIZONTAL, EPSILON;
|
|
4506
4519
|
var init_FluidGeometry = __esm({
|
|
4507
4520
|
"src/model/fluid/FluidGeometry.ts"() {
|
|
4508
|
-
|
|
4521
|
+
import_three27 = require("three");
|
|
4509
4522
|
init_fluidBlocks();
|
|
4510
4523
|
fluidRules = fluidBlocks_default;
|
|
4511
4524
|
HORIZONTAL = [[0, -1], [0, 1], [-1, 0], [1, 0]];
|
|
@@ -4534,10 +4547,10 @@ function sampleFluid(kind, sample) {
|
|
|
4534
4547
|
}
|
|
4535
4548
|
return { key: key.join(""), sample: (x, y, z) => cells[(y + 1) * 9 + (z + 1) * 3 + x + 1] };
|
|
4536
4549
|
}
|
|
4537
|
-
var
|
|
4550
|
+
var import_three28, FluidModelObject;
|
|
4538
4551
|
var init_FluidModelObject = __esm({
|
|
4539
4552
|
"src/model/fluid/FluidModelObject.ts"() {
|
|
4540
|
-
|
|
4553
|
+
import_three28 = require("three");
|
|
4541
4554
|
init_AssetKey();
|
|
4542
4555
|
init_Materials();
|
|
4543
4556
|
init_ModelObject();
|
|
@@ -4570,10 +4583,10 @@ var init_FluidModelObject = __esm({
|
|
|
4570
4583
|
}
|
|
4571
4584
|
}
|
|
4572
4585
|
geometry.clearGroups();
|
|
4573
|
-
const color = new
|
|
4586
|
+
const color = new import_three28.Color(this.options.tints?.[0] ?? (this.kind === "water" ? 4159204 : 16777215));
|
|
4574
4587
|
const colors = new Float32Array(geometry.getAttribute("position").count * 3);
|
|
4575
4588
|
for (let i = 0; i < colors.length; i += 3) color.toArray(colors, i);
|
|
4576
|
-
geometry.setAttribute("color", new
|
|
4589
|
+
geometry.setAttribute("color", new import_three28.BufferAttribute(colors, 3));
|
|
4577
4590
|
geometry.computeBoundingBox();
|
|
4578
4591
|
geometry.computeBoundingSphere();
|
|
4579
4592
|
if (this.options.instanceMeshes) {
|
|
@@ -4587,7 +4600,7 @@ var init_FluidModelObject = __esm({
|
|
|
4587
4600
|
super.applyTextures();
|
|
4588
4601
|
this.iterateAllMeshes((mesh) => {
|
|
4589
4602
|
const material = mesh.material;
|
|
4590
|
-
material.side =
|
|
4603
|
+
material.side = import_three28.DoubleSide;
|
|
4591
4604
|
material.forceSinglePass = true;
|
|
4592
4605
|
material.depthWrite = !material.transparent;
|
|
4593
4606
|
});
|
|
@@ -4618,6 +4631,7 @@ __export(index_node_exports, {
|
|
|
4618
4631
|
BUILTIN_GENERATED: () => BUILTIN_GENERATED,
|
|
4619
4632
|
BasicAssetKey: () => BasicAssetKey,
|
|
4620
4633
|
BatchedExecutor: () => BatchedExecutor,
|
|
4634
|
+
BlockEntities: () => BlockEntities,
|
|
4621
4635
|
BlockObject: () => BlockObject,
|
|
4622
4636
|
BlockStateResolver: () => BlockStateResolver,
|
|
4623
4637
|
BlockStates: () => BlockStates,
|
|
@@ -4639,7 +4653,9 @@ __export(index_node_exports, {
|
|
|
4639
4653
|
DefaultBlockStates: () => DefaultBlockStates,
|
|
4640
4654
|
DisplayPosition: () => DisplayPosition,
|
|
4641
4655
|
DisplayTransforms: () => DisplayTransforms,
|
|
4656
|
+
ENTITY_ANIMATION_CHANNELS: () => ENTITY_ANIMATION_CHANNELS,
|
|
4642
4657
|
Entities: () => Entities,
|
|
4658
|
+
EntityAnimationPlayer: () => EntityAnimationPlayer,
|
|
4643
4659
|
EntityObject: () => EntityObject,
|
|
4644
4660
|
Env: () => Env,
|
|
4645
4661
|
FluidModelObject: () => FluidModelObject,
|
|
@@ -4715,6 +4731,7 @@ __export(index_node_exports, {
|
|
|
4715
4731
|
createCanvas: () => createCanvas2,
|
|
4716
4732
|
createFluidGeometry: () => createFluidGeometry,
|
|
4717
4733
|
createImage: () => createImage,
|
|
4734
|
+
entityAnimationTime: () => entityAnimationTime,
|
|
4718
4735
|
estimateBytesUsed: () => estimateBytesUsed,
|
|
4719
4736
|
getBlockFluidState: () => getBlockFluidState,
|
|
4720
4737
|
getFluidKind: () => getFluidKind,
|
|
@@ -4747,6 +4764,8 @@ __export(index_node_exports, {
|
|
|
4747
4764
|
mergeVertices: () => mergeVertices,
|
|
4748
4765
|
prefix: () => prefix,
|
|
4749
4766
|
registerNodeEnv: () => registerNodeEnv,
|
|
4767
|
+
sampleEntityAnimation: () => sampleEntityAnimation,
|
|
4768
|
+
sampleEntityKeyframes: () => sampleEntityKeyframes,
|
|
4750
4769
|
sampleFluid: () => sampleFluid,
|
|
4751
4770
|
serializeBoxGeometryKey: () => serializeBoxGeometryKey,
|
|
4752
4771
|
serializeImageKey: () => serializeImageKey,
|
|
@@ -5004,6 +5023,59 @@ function shutdown() {
|
|
|
5004
5023
|
init_AssetKey();
|
|
5005
5024
|
init_AssetLoader();
|
|
5006
5025
|
init_Assets();
|
|
5026
|
+
|
|
5027
|
+
// src/assets/BlockEntities.ts
|
|
5028
|
+
var import_three10 = require("three");
|
|
5029
|
+
init_AssetKey();
|
|
5030
|
+
init_AssetLoader();
|
|
5031
|
+
init_source();
|
|
5032
|
+
init_Caching();
|
|
5033
|
+
var BlockEntities = class {
|
|
5034
|
+
/**
|
|
5035
|
+
* Loads the block index of a version. Versions and sources without one yield an empty index, and so does
|
|
5036
|
+
* a failed load: the index is optional, and blocks must not retry or fail with it one by one. The empty
|
|
5037
|
+
* result is cached like any other; `Caching.clear()` or `AssetLoader.setVersion()` forces a new attempt.
|
|
5038
|
+
*/
|
|
5039
|
+
static async getIndex(root) {
|
|
5040
|
+
const key = new AssetKey("entity-models", "blocks", void 0, void 0, void 0, ".json", root);
|
|
5041
|
+
key.rootType = void 0;
|
|
5042
|
+
const index = await Caching.blockEntityIndexCache.get(key.serialize(), async () => {
|
|
5043
|
+
try {
|
|
5044
|
+
return await AssetLoader.get(key, "json" /* JSON */) ?? {};
|
|
5045
|
+
} catch (error) {
|
|
5046
|
+
console.warn("Could not load the block entity index; block entities are drawn as plain block models", error);
|
|
5047
|
+
return {};
|
|
5048
|
+
}
|
|
5049
|
+
});
|
|
5050
|
+
return index ?? {};
|
|
5051
|
+
}
|
|
5052
|
+
/** The index entry of a block ID such as `minecraft:chest`. */
|
|
5053
|
+
static entry(index, block) {
|
|
5054
|
+
const entry = Object.prototype.hasOwnProperty.call(index, block) ? index[block] : void 0;
|
|
5055
|
+
return Array.isArray(entry?.parts) ? entry : void 0;
|
|
5056
|
+
}
|
|
5057
|
+
/** Selects the parts and placement for a block ID such as `minecraft:chest`; undefined when nothing is drawn. */
|
|
5058
|
+
static resolve(index, block, state = {}) {
|
|
5059
|
+
const entry = this.entry(index, block);
|
|
5060
|
+
if (!entry) return void 0;
|
|
5061
|
+
const value = (property) => String(state[property]).toLowerCase();
|
|
5062
|
+
const parts = entry.parts.filter((part) => Object.entries(part.when ?? {}).every(([property, values]) => String(values).split("|").includes(value(property))));
|
|
5063
|
+
if (!parts.length) return void 0;
|
|
5064
|
+
let rotation = 0;
|
|
5065
|
+
if (entry.rotation) {
|
|
5066
|
+
const selected = value(entry.rotation.property);
|
|
5067
|
+
rotation = "degrees" in entry.rotation ? entry.rotation.degrees[selected] : Number(selected) * entry.rotation.step;
|
|
5068
|
+
if (!Number.isFinite(rotation)) rotation = 0;
|
|
5069
|
+
}
|
|
5070
|
+
return { parts, rotation, translation: entry.translation ?? [0, 0, 0] };
|
|
5071
|
+
}
|
|
5072
|
+
/** Placement in block space (0..16 per axis), applied on top of the model's own transform. */
|
|
5073
|
+
static matrix(resolved, matrix = new import_three10.Matrix4()) {
|
|
5074
|
+
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));
|
|
5075
|
+
}
|
|
5076
|
+
};
|
|
5077
|
+
|
|
5078
|
+
// src/assets/index.ts
|
|
5007
5079
|
init_BlockStates();
|
|
5008
5080
|
|
|
5009
5081
|
// src/assets/Entities.ts
|
|
@@ -5074,6 +5146,15 @@ var Entities = class {
|
|
|
5074
5146
|
})));
|
|
5075
5147
|
return { ...layers[names[0]], id: model.id, layers, ...model.transform && { transform: model.transform } };
|
|
5076
5148
|
}
|
|
5149
|
+
/**
|
|
5150
|
+
* Vanilla's keyframe animations of a model by name, or undefined when the model or the selected version has none.
|
|
5151
|
+
*/
|
|
5152
|
+
static async getAnimations(modelKey) {
|
|
5153
|
+
const path = isAssetKey(modelKey) ? modelKey.getFullPath() : modelKey.path;
|
|
5154
|
+
const key = new AssetKey(modelKey.namespace, path, void 0, void 0, "entity-models/animations", ".json");
|
|
5155
|
+
const file = await Caching.entityAnimationCache.get(key.serialize(), () => AssetLoader.get(key, "json" /* JSON */));
|
|
5156
|
+
return file?.animations;
|
|
5157
|
+
}
|
|
5077
5158
|
static async resolveTexture(modelKey) {
|
|
5078
5159
|
const path = isAssetKey(modelKey) ? modelKey.getFullPath() : modelKey.path;
|
|
5079
5160
|
const key = new AssetKey(modelKey.namespace, path, void 0, void 0, "entity-models", ".json");
|
|
@@ -5150,11 +5231,124 @@ function trimCanvas(source) {
|
|
|
5150
5231
|
return canvas;
|
|
5151
5232
|
}
|
|
5152
5233
|
|
|
5234
|
+
// src/entity/EntityAnimation.ts
|
|
5235
|
+
var ENTITY_ANIMATION_CHANNELS = ["position", "rotation", "scale"];
|
|
5236
|
+
function catmullRom(delta, p0, p1, p22, p32) {
|
|
5237
|
+
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);
|
|
5238
|
+
}
|
|
5239
|
+
function sampleEntityKeyframes(keyframes, time) {
|
|
5240
|
+
if (keyframes.length === 0) return [0, 0, 0];
|
|
5241
|
+
let low = 0, high = keyframes.length;
|
|
5242
|
+
while (low < high) {
|
|
5243
|
+
const middle = low + high >>> 1;
|
|
5244
|
+
if (time <= keyframes[middle].time) high = middle;
|
|
5245
|
+
else low = middle + 1;
|
|
5246
|
+
}
|
|
5247
|
+
const a = Math.max(0, low - 1);
|
|
5248
|
+
const b = Math.min(keyframes.length - 1, a + 1);
|
|
5249
|
+
const from = keyframes[a];
|
|
5250
|
+
const to = keyframes[b];
|
|
5251
|
+
const delta = a === b ? 0 : Math.min(1, Math.max(0, (time - from.time) / (to.time - from.time)));
|
|
5252
|
+
if (to.interpolation === "catmullrom") {
|
|
5253
|
+
const before = keyframes[Math.max(0, a - 1)].value;
|
|
5254
|
+
const after = keyframes[Math.min(keyframes.length - 1, b + 1)].value;
|
|
5255
|
+
return [0, 1, 2].map((i) => catmullRom(delta, before[i], from.value[i], to.value[i], after[i]));
|
|
5256
|
+
}
|
|
5257
|
+
const target = to.pre ?? to.value;
|
|
5258
|
+
return [0, 1, 2].map((i) => from.value[i] + (target[i] - from.value[i]) * delta);
|
|
5259
|
+
}
|
|
5260
|
+
function entityAnimationTime(animation, time, loop = animation.loop) {
|
|
5261
|
+
return loop && animation.length > 0 ? time % animation.length : time;
|
|
5262
|
+
}
|
|
5263
|
+
function sampleEntityAnimation(animation, time, loop = animation.loop) {
|
|
5264
|
+
const elapsed = entityAnimationTime(animation, time, loop);
|
|
5265
|
+
const pose = {};
|
|
5266
|
+
for (const [name, bone] of Object.entries(animation.bones)) {
|
|
5267
|
+
const sampled = pose[name] = {};
|
|
5268
|
+
for (const channel of ENTITY_ANIMATION_CHANNELS) {
|
|
5269
|
+
const keyframes = bone[channel];
|
|
5270
|
+
if (keyframes?.length) sampled[channel] = sampleEntityKeyframes(keyframes, elapsed);
|
|
5271
|
+
}
|
|
5272
|
+
}
|
|
5273
|
+
return pose;
|
|
5274
|
+
}
|
|
5275
|
+
|
|
5276
|
+
// src/entity/scene/EntityAnimationPlayer.ts
|
|
5277
|
+
var ZERO = [0, 0, 0];
|
|
5278
|
+
var EntityAnimationPlayer = class {
|
|
5279
|
+
constructor() {
|
|
5280
|
+
this.parts = [];
|
|
5281
|
+
this._time = 0;
|
|
5282
|
+
this.loop = false;
|
|
5283
|
+
this.speed = 1;
|
|
5284
|
+
}
|
|
5285
|
+
get animation() {
|
|
5286
|
+
return this._animation;
|
|
5287
|
+
}
|
|
5288
|
+
get time() {
|
|
5289
|
+
return this._time;
|
|
5290
|
+
}
|
|
5291
|
+
/**
|
|
5292
|
+
* Starts an animation on the named parts below each layer root. The current pose of a part becomes its default;
|
|
5293
|
+
* bones without a matching part are skipped.
|
|
5294
|
+
*/
|
|
5295
|
+
play(layers, animation, options = {}) {
|
|
5296
|
+
this.stop();
|
|
5297
|
+
this._animation = animation;
|
|
5298
|
+
this._time = options.time ?? 0;
|
|
5299
|
+
this.loop = options.loop ?? animation.loop;
|
|
5300
|
+
this.speed = options.speed ?? 1;
|
|
5301
|
+
for (const layer of layers) {
|
|
5302
|
+
for (const bone of Object.keys(animation.bones)) {
|
|
5303
|
+
const object = layer.getObjectByName(`group:${bone}`);
|
|
5304
|
+
if (!object) continue;
|
|
5305
|
+
this.parts.push({ bone, object, position: object.position.clone(), rotation: object.rotation.clone(), scale: object.scale.clone() });
|
|
5306
|
+
}
|
|
5307
|
+
}
|
|
5308
|
+
this.apply();
|
|
5309
|
+
}
|
|
5310
|
+
/** Restores the default poses. Returns whether an animation was active. */
|
|
5311
|
+
stop() {
|
|
5312
|
+
if (!this._animation) return false;
|
|
5313
|
+
for (const part of this.parts) {
|
|
5314
|
+
part.object.position.copy(part.position);
|
|
5315
|
+
part.object.rotation.copy(part.rotation);
|
|
5316
|
+
part.object.scale.copy(part.scale);
|
|
5317
|
+
}
|
|
5318
|
+
this.clear();
|
|
5319
|
+
return true;
|
|
5320
|
+
}
|
|
5321
|
+
/** Forgets the animation without touching the parts, for parts that no longer exist. */
|
|
5322
|
+
clear() {
|
|
5323
|
+
this.parts = [];
|
|
5324
|
+
this._animation = void 0;
|
|
5325
|
+
this._time = 0;
|
|
5326
|
+
}
|
|
5327
|
+
setTime(seconds) {
|
|
5328
|
+
if (!this._animation) return false;
|
|
5329
|
+
this._time = seconds;
|
|
5330
|
+
this.apply();
|
|
5331
|
+
return true;
|
|
5332
|
+
}
|
|
5333
|
+
advance(deltaSeconds) {
|
|
5334
|
+
return this.setTime(this._time + deltaSeconds * this.speed);
|
|
5335
|
+
}
|
|
5336
|
+
apply() {
|
|
5337
|
+
const pose = sampleEntityAnimation(this._animation, this._time, this.loop);
|
|
5338
|
+
for (const part of this.parts) {
|
|
5339
|
+
const { position = ZERO, rotation = ZERO, scale = ZERO } = pose[part.bone];
|
|
5340
|
+
part.object.position.set(part.position.x + position[0], part.position.y + position[1], part.position.z + position[2]);
|
|
5341
|
+
part.object.rotation.set(part.rotation.x + rotation[0], part.rotation.y + rotation[1], part.rotation.z + rotation[2], part.rotation.order);
|
|
5342
|
+
part.object.scale.set(part.scale.x + scale[0], part.scale.y + scale[1], part.scale.z + scale[2]);
|
|
5343
|
+
}
|
|
5344
|
+
}
|
|
5345
|
+
};
|
|
5346
|
+
|
|
5153
5347
|
// src/entity/scene/EntityObject.ts
|
|
5154
5348
|
init_SceneObject();
|
|
5155
5349
|
init_Caching();
|
|
5156
5350
|
var import_ts_deepmerge4 = __toESM(require_dist());
|
|
5157
|
-
var
|
|
5351
|
+
var import_three13 = require("three");
|
|
5158
5352
|
init_Ticker();
|
|
5159
5353
|
init_model();
|
|
5160
5354
|
init_ModelTextures();
|
|
@@ -5167,11 +5361,16 @@ var EntityObject = class _EntityObject extends SceneObject {
|
|
|
5167
5361
|
this.entity = entity;
|
|
5168
5362
|
this.isEntityObject = true;
|
|
5169
5363
|
this.meshesCreated = false;
|
|
5364
|
+
this.geometries = /* @__PURE__ */ new Set();
|
|
5365
|
+
this.disposeWireframes = [];
|
|
5170
5366
|
/** Scrolling materials are owned: their texture offset follows this entity's age. */
|
|
5171
5367
|
this.scrollMaterials = [];
|
|
5172
5368
|
/** Entity age in ticks, as vanilla's `ageInTicks`; drives the scrolling render modes. */
|
|
5173
5369
|
this.age = 0;
|
|
5370
|
+
this.animationPlayer = new EntityAnimationPlayer();
|
|
5174
5371
|
this.options = (0, import_ts_deepmerge4.default)({}, _EntityObject.DEFAULT_OPTIONS, options ?? {});
|
|
5372
|
+
this.addEventListener("added", () => this.updateScrollSubscription());
|
|
5373
|
+
this.addEventListener("removed", () => this.updateScrollSubscription());
|
|
5175
5374
|
}
|
|
5176
5375
|
static {
|
|
5177
5376
|
this.DEFAULT_OPTIONS = (0, import_ts_deepmerge4.default)({}, SceneObject.DEFAULT_OPTIONS);
|
|
@@ -5185,6 +5384,10 @@ var EntityObject = class _EntityObject extends SceneObject {
|
|
|
5185
5384
|
}
|
|
5186
5385
|
disposeAndRemoveAllChildren() {
|
|
5187
5386
|
this.clearScrollMaterials();
|
|
5387
|
+
for (const geometry of this.geometries) geometry.dispose();
|
|
5388
|
+
this.geometries.clear();
|
|
5389
|
+
for (const dispose of this.disposeWireframes.splice(0)) dispose();
|
|
5390
|
+
this.animationPlayer.clear();
|
|
5188
5391
|
super.disposeAndRemoveAllChildren();
|
|
5189
5392
|
}
|
|
5190
5393
|
clearScrollMaterials() {
|
|
@@ -5195,6 +5398,19 @@ var EntityObject = class _EntityObject extends SceneObject {
|
|
|
5195
5398
|
material.dispose();
|
|
5196
5399
|
}
|
|
5197
5400
|
}
|
|
5401
|
+
updateScrollSubscription() {
|
|
5402
|
+
if (this.parent && this.scrollMaterials.length) {
|
|
5403
|
+
if (this.scrollTicker === void 0) {
|
|
5404
|
+
this.scrollTicker = Ticker.add(() => {
|
|
5405
|
+
this.age++;
|
|
5406
|
+
this.updateScroll();
|
|
5407
|
+
});
|
|
5408
|
+
}
|
|
5409
|
+
} else {
|
|
5410
|
+
Ticker.remove(this.scrollTicker);
|
|
5411
|
+
this.scrollTicker = void 0;
|
|
5412
|
+
}
|
|
5413
|
+
}
|
|
5198
5414
|
/** Applies the entity age to the scrolling materials; the ticker calls this 20 times per second. */
|
|
5199
5415
|
updateScroll() {
|
|
5200
5416
|
for (const { offset, speed } of this.scrollMaterials) {
|
|
@@ -5202,6 +5418,39 @@ var EntityObject = class _EntityObject extends SceneObject {
|
|
|
5202
5418
|
}
|
|
5203
5419
|
this.notifyDirty();
|
|
5204
5420
|
}
|
|
5421
|
+
//<editor-fold desc="ANIMATION">
|
|
5422
|
+
/** The animation started by {@link playAnimation}, until {@link stopAnimation} or disposal. */
|
|
5423
|
+
get animation() {
|
|
5424
|
+
return this.animationPlayer.animation;
|
|
5425
|
+
}
|
|
5426
|
+
/** Seconds since the animation started, before looping. */
|
|
5427
|
+
get animationTime() {
|
|
5428
|
+
return this.animationPlayer.time;
|
|
5429
|
+
}
|
|
5430
|
+
/**
|
|
5431
|
+
* Poses the object from a keyframe animation of {@link Entities.getAnimations}, replacing the current one.
|
|
5432
|
+
* Parts of every layer are matched by name and their current pose is the default the offsets add to.
|
|
5433
|
+
* The object owns no clock: call {@link advanceAnimation} per frame, or {@link setAnimationTime}.
|
|
5434
|
+
*/
|
|
5435
|
+
playAnimation(animation, options) {
|
|
5436
|
+
this.createMeshes();
|
|
5437
|
+
const layers = Object.keys(this.entityLayers).map((name) => this.getLayerGroup(name)).filter((layer) => !!layer);
|
|
5438
|
+
this.animationPlayer.play(layers, animation, options);
|
|
5439
|
+
this.notifyDirty();
|
|
5440
|
+
}
|
|
5441
|
+
/** Stops the animation and restores the default pose. */
|
|
5442
|
+
stopAnimation() {
|
|
5443
|
+
if (this.animationPlayer.stop()) this.notifyDirty();
|
|
5444
|
+
}
|
|
5445
|
+
/** Poses the object at an explicit time in seconds. Has no effect without an animation. */
|
|
5446
|
+
setAnimationTime(seconds) {
|
|
5447
|
+
if (this.animationPlayer.setTime(seconds)) this.notifyDirty();
|
|
5448
|
+
}
|
|
5449
|
+
/** Advances the animation by a frame delta in seconds, scaled by its speed. Has no effect without an animation. */
|
|
5450
|
+
advanceAnimation(deltaSeconds) {
|
|
5451
|
+
if (this.animationPlayer.advance(deltaSeconds)) this.notifyDirty();
|
|
5452
|
+
}
|
|
5453
|
+
//</editor-fold>
|
|
5205
5454
|
getLayerGroup(name) {
|
|
5206
5455
|
return super.getGroupByName(`layer:${name}`);
|
|
5207
5456
|
}
|
|
@@ -5231,14 +5480,14 @@ var EntityObject = class _EntityObject extends SceneObject {
|
|
|
5231
5480
|
}
|
|
5232
5481
|
createMeshes(force = false) {
|
|
5233
5482
|
if (this.meshesCreated && !force) return;
|
|
5234
|
-
const modelRoot = new
|
|
5483
|
+
const modelRoot = new import_three13.Object3D();
|
|
5235
5484
|
const transform = this.options.flip === void 0 ? this.entity.transform : void 0;
|
|
5236
5485
|
if (transform) {
|
|
5237
5486
|
for (const op of transform) {
|
|
5238
|
-
const matrix = new
|
|
5487
|
+
const matrix = new import_three13.Matrix4();
|
|
5239
5488
|
if ("scale" in op) matrix.makeScale(...op.scale);
|
|
5240
5489
|
else if ("translate" in op) matrix.makeTranslation(...op.translate);
|
|
5241
|
-
else matrix.makeRotationFromEuler(new
|
|
5490
|
+
else matrix.makeRotationFromEuler(new import_three13.Euler(...op.rotate, "ZYX"));
|
|
5242
5491
|
modelRoot.matrix.multiply(matrix);
|
|
5243
5492
|
}
|
|
5244
5493
|
modelRoot.matrixAutoUpdate = false;
|
|
@@ -5272,6 +5521,7 @@ var EntityObject = class _EntityObject extends SceneObject {
|
|
|
5272
5521
|
depth + growZ * 2,
|
|
5273
5522
|
uv
|
|
5274
5523
|
).clone();
|
|
5524
|
+
this.geometries.add(geometry);
|
|
5275
5525
|
geometry.translate(cube.origin[0] + width / 2, cube.origin[1] + height / 2, cube.origin[2] + depth / 2);
|
|
5276
5526
|
if (inward && Math.min(width + growX * 2, height + growY * 2, depth + growZ * 2) > 0) {
|
|
5277
5527
|
const index = Array.from(geometry.getIndex().array);
|
|
@@ -5280,7 +5530,7 @@ var EntityObject = class _EntityObject extends SceneObject {
|
|
|
5280
5530
|
const mesh = this.createMesh(name, geometry, material);
|
|
5281
5531
|
mesh.renderOrder = renderOrder;
|
|
5282
5532
|
anchor.add(mesh);
|
|
5283
|
-
if (this.options.wireframe) addWireframeToMesh(geometry, mesh);
|
|
5533
|
+
if (this.options.wireframe) this.disposeWireframes.push(addWireframeToMesh(geometry, mesh));
|
|
5284
5534
|
}
|
|
5285
5535
|
for (const [childName, child] of Object.entries(part.children)) {
|
|
5286
5536
|
this.createPart(childName, child, anchor, size, material, renderOrder, inward);
|
|
@@ -5293,7 +5543,7 @@ var EntityObject = class _EntityObject extends SceneObject {
|
|
|
5293
5543
|
const tint = layer.tint === void 0 ? void 0 : this.options.tints?.[layer.tint];
|
|
5294
5544
|
const scroll = Materials.entityModeScroll(mode);
|
|
5295
5545
|
const assetKeyStr = this.getTextureKey(layer).serialize();
|
|
5296
|
-
const keyStr = `entity:${mode}:${tint === void 0 ? "" : new
|
|
5546
|
+
const keyStr = `entity:${mode}:${tint === void 0 ? "" : new import_three13.Color(tint).getHexString()}:${assetKeyStr}`;
|
|
5297
5547
|
let mat = scroll ? void 0 : Caching.materialCache.getIfPresent(keyStr);
|
|
5298
5548
|
if (!mat) {
|
|
5299
5549
|
const cachedAsset = Caching.textureAssetCache.getIfPresent(assetKeyStr);
|
|
@@ -5314,11 +5564,8 @@ var EntityObject = class _EntityObject extends SceneObject {
|
|
|
5314
5564
|
this.clearScrollMaterials();
|
|
5315
5565
|
} else if (this.scrollMaterials.length) {
|
|
5316
5566
|
this.updateScroll();
|
|
5317
|
-
this.scrollTicker = Ticker.add(() => {
|
|
5318
|
-
this.age++;
|
|
5319
|
-
this.updateScroll();
|
|
5320
|
-
});
|
|
5321
5567
|
}
|
|
5568
|
+
this.updateScrollSubscription();
|
|
5322
5569
|
this.notifyDirty();
|
|
5323
5570
|
}
|
|
5324
5571
|
};
|
|
@@ -5330,27 +5577,27 @@ function isEntityObject(obj) {
|
|
|
5330
5577
|
init_MineRenderError();
|
|
5331
5578
|
|
|
5332
5579
|
// src/export/SceneExporter.ts
|
|
5333
|
-
var
|
|
5580
|
+
var import_three19 = require("three");
|
|
5334
5581
|
|
|
5335
5582
|
// ../../node_modules/three/examples/jsm/exporters/OBJExporter.js
|
|
5336
|
-
var
|
|
5583
|
+
var import_three15 = require("three");
|
|
5337
5584
|
var OBJExporter = class {
|
|
5338
5585
|
parse(object) {
|
|
5339
5586
|
let output = "";
|
|
5340
5587
|
let indexVertex = 0;
|
|
5341
5588
|
let indexVertexUvs = 0;
|
|
5342
5589
|
let indexNormals = 0;
|
|
5343
|
-
const vertex = new
|
|
5344
|
-
const color = new
|
|
5345
|
-
const normal = new
|
|
5346
|
-
const uv = new
|
|
5590
|
+
const vertex = new import_three15.Vector3();
|
|
5591
|
+
const color = new import_three15.Color();
|
|
5592
|
+
const normal = new import_three15.Vector3();
|
|
5593
|
+
const uv = new import_three15.Vector2();
|
|
5347
5594
|
const face = [];
|
|
5348
5595
|
function parseMesh(mesh) {
|
|
5349
5596
|
let nbVertex = 0;
|
|
5350
5597
|
let nbNormals = 0;
|
|
5351
5598
|
let nbVertexUvs = 0;
|
|
5352
5599
|
const geometry = mesh.geometry;
|
|
5353
|
-
const normalMatrixWorld = new
|
|
5600
|
+
const normalMatrixWorld = new import_three15.Matrix3();
|
|
5354
5601
|
const vertices = geometry.getAttribute("position");
|
|
5355
5602
|
const normals = geometry.getAttribute("normal");
|
|
5356
5603
|
const uvs = geometry.getAttribute("uv");
|
|
@@ -5469,7 +5716,7 @@ var OBJExporter = class {
|
|
|
5469
5716
|
};
|
|
5470
5717
|
|
|
5471
5718
|
// ../../node_modules/three/examples/jsm/exporters/PLYExporter.js
|
|
5472
|
-
var
|
|
5719
|
+
var import_three16 = require("three");
|
|
5473
5720
|
var PLYExporter = class {
|
|
5474
5721
|
parse(object, onDone, options = {}) {
|
|
5475
5722
|
function traverseMeshes(cb) {
|
|
@@ -5526,7 +5773,7 @@ var PLYExporter = class {
|
|
|
5526
5773
|
includeIndices = false;
|
|
5527
5774
|
}
|
|
5528
5775
|
});
|
|
5529
|
-
const tempColor = new
|
|
5776
|
+
const tempColor = new import_three16.Color();
|
|
5530
5777
|
includeIndices = includeIndices && excludeAttributes.indexOf("index") === -1;
|
|
5531
5778
|
includeNormals = includeNormals && excludeAttributes.indexOf("normal") === -1;
|
|
5532
5779
|
includeColors = includeColors && excludeAttributes.indexOf("color") === -1;
|
|
@@ -5560,8 +5807,8 @@ property list uchar int vertex_index
|
|
|
5560
5807
|
`;
|
|
5561
5808
|
}
|
|
5562
5809
|
header += "end_header\n";
|
|
5563
|
-
const vertex = new
|
|
5564
|
-
const normalMatrixWorld = new
|
|
5810
|
+
const vertex = new import_three16.Vector3();
|
|
5811
|
+
const normalMatrixWorld = new import_three16.Matrix3();
|
|
5565
5812
|
let result = null;
|
|
5566
5813
|
if (options.binary === true) {
|
|
5567
5814
|
const headerBin = new TextEncoder().encode(header);
|
|
@@ -5735,18 +5982,18 @@ property list uchar int vertex_index
|
|
|
5735
5982
|
};
|
|
5736
5983
|
|
|
5737
5984
|
// ../../node_modules/three/examples/jsm/exporters/GLTFExporter.js
|
|
5738
|
-
var
|
|
5985
|
+
var import_three18 = require("three");
|
|
5739
5986
|
|
|
5740
5987
|
// ../../node_modules/three/examples/jsm/utils/TextureUtils.js
|
|
5741
|
-
var
|
|
5988
|
+
var import_three17 = require("three");
|
|
5742
5989
|
var _renderer;
|
|
5743
5990
|
var fullscreenQuadGeometry;
|
|
5744
5991
|
var fullscreenQuadMaterial;
|
|
5745
5992
|
var fullscreenQuad;
|
|
5746
5993
|
function decompress(texture, maxTextureSize = Infinity, renderer = null) {
|
|
5747
|
-
if (!fullscreenQuadGeometry) fullscreenQuadGeometry = new
|
|
5748
|
-
if (!fullscreenQuadMaterial) fullscreenQuadMaterial = new
|
|
5749
|
-
uniforms: { blitTexture: new
|
|
5994
|
+
if (!fullscreenQuadGeometry) fullscreenQuadGeometry = new import_three17.PlaneGeometry(2, 2, 1, 1);
|
|
5995
|
+
if (!fullscreenQuadMaterial) fullscreenQuadMaterial = new import_three17.ShaderMaterial({
|
|
5996
|
+
uniforms: { blitTexture: new import_three17.Uniform(texture) },
|
|
5750
5997
|
vertexShader: `
|
|
5751
5998
|
varying vec2 vUv;
|
|
5752
5999
|
void main(){
|
|
@@ -5768,22 +6015,22 @@ function decompress(texture, maxTextureSize = Infinity, renderer = null) {
|
|
|
5768
6015
|
}`
|
|
5769
6016
|
});
|
|
5770
6017
|
fullscreenQuadMaterial.uniforms.blitTexture.value = texture;
|
|
5771
|
-
fullscreenQuadMaterial.defines.IS_SRGB = texture.colorSpace ==
|
|
6018
|
+
fullscreenQuadMaterial.defines.IS_SRGB = texture.colorSpace == import_three17.SRGBColorSpace;
|
|
5772
6019
|
fullscreenQuadMaterial.needsUpdate = true;
|
|
5773
6020
|
if (!fullscreenQuad) {
|
|
5774
|
-
fullscreenQuad = new
|
|
6021
|
+
fullscreenQuad = new import_three17.Mesh(fullscreenQuadGeometry, fullscreenQuadMaterial);
|
|
5775
6022
|
fullscreenQuad.frustrumCulled = false;
|
|
5776
6023
|
}
|
|
5777
|
-
const _camera = new
|
|
5778
|
-
const _scene = new
|
|
6024
|
+
const _camera = new import_three17.PerspectiveCamera();
|
|
6025
|
+
const _scene = new import_three17.Scene();
|
|
5779
6026
|
_scene.add(fullscreenQuad);
|
|
5780
6027
|
if (!renderer) {
|
|
5781
|
-
renderer = _renderer = new
|
|
6028
|
+
renderer = _renderer = new import_three17.WebGLRenderer({ antialias: false });
|
|
5782
6029
|
}
|
|
5783
6030
|
renderer.setSize(Math.min(texture.image.width, maxTextureSize), Math.min(texture.image.height, maxTextureSize));
|
|
5784
6031
|
renderer.clear();
|
|
5785
6032
|
renderer.render(_scene, _camera);
|
|
5786
|
-
const readableTexture = new
|
|
6033
|
+
const readableTexture = new import_three17.Texture(renderer.domElement);
|
|
5787
6034
|
readableTexture.minFilter = texture.minFilter;
|
|
5788
6035
|
readableTexture.magFilter = texture.magFilter;
|
|
5789
6036
|
readableTexture.wrapS = texture.wrapS;
|
|
@@ -5929,22 +6176,22 @@ var WEBGL_CONSTANTS = {
|
|
|
5929
6176
|
};
|
|
5930
6177
|
var KHR_MESH_QUANTIZATION = "KHR_mesh_quantization";
|
|
5931
6178
|
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[
|
|
6179
|
+
THREE_TO_WEBGL[import_three18.NearestFilter] = WEBGL_CONSTANTS.NEAREST;
|
|
6180
|
+
THREE_TO_WEBGL[import_three18.NearestMipmapNearestFilter] = WEBGL_CONSTANTS.NEAREST_MIPMAP_NEAREST;
|
|
6181
|
+
THREE_TO_WEBGL[import_three18.NearestMipmapLinearFilter] = WEBGL_CONSTANTS.NEAREST_MIPMAP_LINEAR;
|
|
6182
|
+
THREE_TO_WEBGL[import_three18.LinearFilter] = WEBGL_CONSTANTS.LINEAR;
|
|
6183
|
+
THREE_TO_WEBGL[import_three18.LinearMipmapNearestFilter] = WEBGL_CONSTANTS.LINEAR_MIPMAP_NEAREST;
|
|
6184
|
+
THREE_TO_WEBGL[import_three18.LinearMipmapLinearFilter] = WEBGL_CONSTANTS.LINEAR_MIPMAP_LINEAR;
|
|
6185
|
+
THREE_TO_WEBGL[import_three18.ClampToEdgeWrapping] = WEBGL_CONSTANTS.CLAMP_TO_EDGE;
|
|
6186
|
+
THREE_TO_WEBGL[import_three18.RepeatWrapping] = WEBGL_CONSTANTS.REPEAT;
|
|
6187
|
+
THREE_TO_WEBGL[import_three18.MirroredRepeatWrapping] = WEBGL_CONSTANTS.MIRRORED_REPEAT;
|
|
5941
6188
|
var PATH_PROPERTIES = {
|
|
5942
6189
|
scale: "scale",
|
|
5943
6190
|
position: "translation",
|
|
5944
6191
|
quaternion: "rotation",
|
|
5945
6192
|
morphTargetInfluences: "weights"
|
|
5946
6193
|
};
|
|
5947
|
-
var DEFAULT_SPECULAR_COLOR = new
|
|
6194
|
+
var DEFAULT_SPECULAR_COLOR = new import_three18.Color();
|
|
5948
6195
|
var GLB_HEADER_BYTES = 12;
|
|
5949
6196
|
var GLB_HEADER_MAGIC = 1179937895;
|
|
5950
6197
|
var GLB_VERSION = 2;
|
|
@@ -5978,7 +6225,7 @@ function getMinMax(attribute, start, count) {
|
|
|
5978
6225
|
else if (a === 2) value = attribute.getZ(i);
|
|
5979
6226
|
else if (a === 3) value = attribute.getW(i);
|
|
5980
6227
|
if (attribute.normalized === true) {
|
|
5981
|
-
value =
|
|
6228
|
+
value = import_three18.MathUtils.normalize(value, attribute.array);
|
|
5982
6229
|
}
|
|
5983
6230
|
}
|
|
5984
6231
|
output.min[a] = Math.min(output.min[a], value);
|
|
@@ -6184,7 +6431,7 @@ var GLTFWriter = class {
|
|
|
6184
6431
|
isNormalizedNormalAttribute(normal) {
|
|
6185
6432
|
const cache = this.cache;
|
|
6186
6433
|
if (cache.attributesNormalized.has(normal)) return false;
|
|
6187
|
-
const v = new
|
|
6434
|
+
const v = new import_three18.Vector3();
|
|
6188
6435
|
for (let i = 0, il = normal.count; i < il; i++) {
|
|
6189
6436
|
if (Math.abs(v.fromBufferAttribute(normal, i).length() - 1) > 5e-4) return false;
|
|
6190
6437
|
}
|
|
@@ -6201,7 +6448,7 @@ var GLTFWriter = class {
|
|
|
6201
6448
|
const cache = this.cache;
|
|
6202
6449
|
if (cache.attributesNormalized.has(normal)) return cache.attributesNormalized.get(normal);
|
|
6203
6450
|
const attribute = normal.clone();
|
|
6204
|
-
const v = new
|
|
6451
|
+
const v = new import_three18.Vector3();
|
|
6205
6452
|
for (let i = 0, il = attribute.count; i < il; i++) {
|
|
6206
6453
|
v.fromBufferAttribute(attribute, i);
|
|
6207
6454
|
if (v.x === 0 && v.y === 0 && v.z === 0) {
|
|
@@ -6245,7 +6492,7 @@ var GLTFWriter = class {
|
|
|
6245
6492
|
buildMetalRoughTexture(metalnessMap, roughnessMap) {
|
|
6246
6493
|
if (metalnessMap === roughnessMap) return metalnessMap;
|
|
6247
6494
|
function getEncodingConversion(map) {
|
|
6248
|
-
if (map.colorSpace ===
|
|
6495
|
+
if (map.colorSpace === import_three18.SRGBColorSpace) {
|
|
6249
6496
|
return function SRGBToLinear(c) {
|
|
6250
6497
|
return c < 0.04045 ? c * 0.0773993808 : Math.pow(c * 0.9478672986 + 0.0521327014, 2.4);
|
|
6251
6498
|
};
|
|
@@ -6255,10 +6502,10 @@ var GLTFWriter = class {
|
|
|
6255
6502
|
};
|
|
6256
6503
|
}
|
|
6257
6504
|
console.warn("THREE.GLTFExporter: Merged metalnessMap and roughnessMap textures.");
|
|
6258
|
-
if (metalnessMap instanceof
|
|
6505
|
+
if (metalnessMap instanceof import_three18.CompressedTexture) {
|
|
6259
6506
|
metalnessMap = decompress(metalnessMap);
|
|
6260
6507
|
}
|
|
6261
|
-
if (roughnessMap instanceof
|
|
6508
|
+
if (roughnessMap instanceof import_three18.CompressedTexture) {
|
|
6262
6509
|
roughnessMap = decompress(roughnessMap);
|
|
6263
6510
|
}
|
|
6264
6511
|
const metalness = metalnessMap ? metalnessMap.image : null;
|
|
@@ -6291,8 +6538,8 @@ var GLTFWriter = class {
|
|
|
6291
6538
|
context.putImageData(composite, 0, 0);
|
|
6292
6539
|
const reference = metalnessMap || roughnessMap;
|
|
6293
6540
|
const texture = reference.clone();
|
|
6294
|
-
texture.source = new
|
|
6295
|
-
texture.colorSpace =
|
|
6541
|
+
texture.source = new import_three18.Source(canvas);
|
|
6542
|
+
texture.colorSpace = import_three18.NoColorSpace;
|
|
6296
6543
|
texture.channel = (metalnessMap || roughnessMap).channel;
|
|
6297
6544
|
if (metalnessMap && roughnessMap && metalnessMap.channel !== roughnessMap.channel) {
|
|
6298
6545
|
console.warn("THREE.GLTFExporter: UV channels for metalnessMap and roughnessMap textures must match.");
|
|
@@ -6350,7 +6597,7 @@ var GLTFWriter = class {
|
|
|
6350
6597
|
else if (a === 2) value = attribute.getZ(i);
|
|
6351
6598
|
else if (a === 3) value = attribute.getW(i);
|
|
6352
6599
|
if (attribute.normalized === true) {
|
|
6353
|
-
value =
|
|
6600
|
+
value = import_three18.MathUtils.normalize(value, attribute.array);
|
|
6354
6601
|
}
|
|
6355
6602
|
}
|
|
6356
6603
|
if (componentType === WEBGL_CONSTANTS.FLOAT) {
|
|
@@ -6500,7 +6747,7 @@ var GLTFWriter = class {
|
|
|
6500
6747
|
ctx.scale(1, -1);
|
|
6501
6748
|
}
|
|
6502
6749
|
if (image.data !== void 0) {
|
|
6503
|
-
if (format !==
|
|
6750
|
+
if (format !== import_three18.RGBAFormat) {
|
|
6504
6751
|
console.error("GLTFExporter: Only RGBAFormat is supported.", format);
|
|
6505
6752
|
}
|
|
6506
6753
|
if (image.width > options.maxTextureSize || image.height > options.maxTextureSize) {
|
|
@@ -6569,7 +6816,7 @@ var GLTFWriter = class {
|
|
|
6569
6816
|
const json = this.json;
|
|
6570
6817
|
if (cache.textures.has(map)) return cache.textures.get(map);
|
|
6571
6818
|
if (!json.textures) json.textures = [];
|
|
6572
|
-
if (map instanceof
|
|
6819
|
+
if (map instanceof import_three18.CompressedTexture) {
|
|
6573
6820
|
map = decompress(map, options.maxTextureSize);
|
|
6574
6821
|
}
|
|
6575
6822
|
let mimeType = map.userData.mimeType;
|
|
@@ -6677,7 +6924,7 @@ var GLTFWriter = class {
|
|
|
6677
6924
|
materialDef.alphaCutoff = material.alphaTest;
|
|
6678
6925
|
}
|
|
6679
6926
|
}
|
|
6680
|
-
if (material.side ===
|
|
6927
|
+
if (material.side === import_three18.DoubleSide) materialDef.doubleSided = true;
|
|
6681
6928
|
if (material.name !== "") materialDef.name = material.name;
|
|
6682
6929
|
this.serializeUserData(material, materialDef);
|
|
6683
6930
|
this._invokeAll(function(ext) {
|
|
@@ -6751,7 +6998,7 @@ var GLTFWriter = class {
|
|
|
6751
6998
|
const array = attribute.array;
|
|
6752
6999
|
if (attributeName === "JOINTS_0" && !(array instanceof Uint16Array) && !(array instanceof Uint8Array)) {
|
|
6753
7000
|
console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.');
|
|
6754
|
-
modifiedAttribute = new
|
|
7001
|
+
modifiedAttribute = new import_three18.BufferAttribute(new Uint16Array(array), attribute.itemSize, attribute.normalized);
|
|
6755
7002
|
}
|
|
6756
7003
|
const accessor = this.processAccessor(modifiedAttribute || attribute, geometry);
|
|
6757
7004
|
if (accessor !== null) {
|
|
@@ -6911,7 +7158,7 @@ var GLTFWriter = class {
|
|
|
6911
7158
|
} else {
|
|
6912
7159
|
cameraDef.perspective = {
|
|
6913
7160
|
aspectRatio: camera.aspect,
|
|
6914
|
-
yfov:
|
|
7161
|
+
yfov: import_three18.MathUtils.degToRad(camera.fov),
|
|
6915
7162
|
zfar: camera.far <= 0 ? 1e-3 : camera.far,
|
|
6916
7163
|
znear: camera.near < 0 ? 0 : camera.near
|
|
6917
7164
|
};
|
|
@@ -6939,8 +7186,8 @@ var GLTFWriter = class {
|
|
|
6939
7186
|
const samplers = [];
|
|
6940
7187
|
for (let i = 0; i < tracks.length; ++i) {
|
|
6941
7188
|
const track = tracks[i];
|
|
6942
|
-
const trackBinding =
|
|
6943
|
-
let trackNode =
|
|
7189
|
+
const trackBinding = import_three18.PropertyBinding.parseTrackName(track.name);
|
|
7190
|
+
let trackNode = import_three18.PropertyBinding.findNode(root, trackBinding.nodeName);
|
|
6944
7191
|
const trackProperty = PATH_PROPERTIES[trackBinding.propertyName];
|
|
6945
7192
|
if (trackBinding.objectName === "bones") {
|
|
6946
7193
|
if (trackNode.isSkinnedMesh === true) {
|
|
@@ -6962,14 +7209,14 @@ var GLTFWriter = class {
|
|
|
6962
7209
|
if (track.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline === true) {
|
|
6963
7210
|
interpolation = "CUBICSPLINE";
|
|
6964
7211
|
outputItemSize /= 3;
|
|
6965
|
-
} else if (track.getInterpolation() ===
|
|
7212
|
+
} else if (track.getInterpolation() === import_three18.InterpolateDiscrete) {
|
|
6966
7213
|
interpolation = "STEP";
|
|
6967
7214
|
} else {
|
|
6968
7215
|
interpolation = "LINEAR";
|
|
6969
7216
|
}
|
|
6970
7217
|
samplers.push({
|
|
6971
|
-
input: this.processAccessor(new
|
|
6972
|
-
output: this.processAccessor(new
|
|
7218
|
+
input: this.processAccessor(new import_three18.BufferAttribute(track.times, inputItemSize)),
|
|
7219
|
+
output: this.processAccessor(new import_three18.BufferAttribute(track.values, outputItemSize)),
|
|
6973
7220
|
interpolation
|
|
6974
7221
|
});
|
|
6975
7222
|
channels.push({
|
|
@@ -7001,7 +7248,7 @@ var GLTFWriter = class {
|
|
|
7001
7248
|
if (rootJoint === void 0) return null;
|
|
7002
7249
|
const joints = [];
|
|
7003
7250
|
const inverseBindMatrices = new Float32Array(skeleton.bones.length * 16);
|
|
7004
|
-
const temporaryBoneInverse = new
|
|
7251
|
+
const temporaryBoneInverse = new import_three18.Matrix4();
|
|
7005
7252
|
for (let i = 0; i < skeleton.bones.length; ++i) {
|
|
7006
7253
|
joints.push(nodeMap.get(skeleton.bones[i]));
|
|
7007
7254
|
temporaryBoneInverse.copy(skeleton.boneInverses[i]);
|
|
@@ -7009,7 +7256,7 @@ var GLTFWriter = class {
|
|
|
7009
7256
|
}
|
|
7010
7257
|
if (json.skins === void 0) json.skins = [];
|
|
7011
7258
|
json.skins.push({
|
|
7012
|
-
inverseBindMatrices: this.processAccessor(new
|
|
7259
|
+
inverseBindMatrices: this.processAccessor(new import_three18.BufferAttribute(inverseBindMatrices, 16)),
|
|
7013
7260
|
joints,
|
|
7014
7261
|
skeleton: nodeMap.get(rootJoint)
|
|
7015
7262
|
});
|
|
@@ -7105,7 +7352,7 @@ var GLTFWriter = class {
|
|
|
7105
7352
|
* @param {Array} objects List of objects to process
|
|
7106
7353
|
*/
|
|
7107
7354
|
processObjects(objects) {
|
|
7108
|
-
const scene = new
|
|
7355
|
+
const scene = new import_three18.Scene();
|
|
7109
7356
|
scene.name = "AuxScene";
|
|
7110
7357
|
for (let i = 0; i < objects.length; i++) {
|
|
7111
7358
|
scene.children.push(objects[i]);
|
|
@@ -7123,7 +7370,7 @@ var GLTFWriter = class {
|
|
|
7123
7370
|
});
|
|
7124
7371
|
const objectsWithoutScene = [];
|
|
7125
7372
|
for (let i = 0; i < input.length; i++) {
|
|
7126
|
-
if (input[i] instanceof
|
|
7373
|
+
if (input[i] instanceof import_three18.Scene) {
|
|
7127
7374
|
this.processScene(input[i]);
|
|
7128
7375
|
} else {
|
|
7129
7376
|
objectsWithoutScene.push(input[i]);
|
|
@@ -7467,10 +7714,10 @@ var GLTFMeshGpuInstancing = class {
|
|
|
7467
7714
|
const translationAttr = new Float32Array(mesh.count * 3);
|
|
7468
7715
|
const rotationAttr = new Float32Array(mesh.count * 4);
|
|
7469
7716
|
const scaleAttr = new Float32Array(mesh.count * 3);
|
|
7470
|
-
const matrix = new
|
|
7471
|
-
const position = new
|
|
7472
|
-
const quaternion = new
|
|
7473
|
-
const scale = new
|
|
7717
|
+
const matrix = new import_three18.Matrix4();
|
|
7718
|
+
const position = new import_three18.Vector3();
|
|
7719
|
+
const quaternion = new import_three18.Quaternion();
|
|
7720
|
+
const scale = new import_three18.Vector3();
|
|
7474
7721
|
for (let i = 0; i < mesh.count; i++) {
|
|
7475
7722
|
mesh.getMatrixAt(i, matrix);
|
|
7476
7723
|
matrix.decompose(position, quaternion, scale);
|
|
@@ -7479,9 +7726,9 @@ var GLTFMeshGpuInstancing = class {
|
|
|
7479
7726
|
scale.toArray(scaleAttr, i * 3);
|
|
7480
7727
|
}
|
|
7481
7728
|
const attributes = {
|
|
7482
|
-
TRANSLATION: writer.processAccessor(new
|
|
7483
|
-
ROTATION: writer.processAccessor(new
|
|
7484
|
-
SCALE: writer.processAccessor(new
|
|
7729
|
+
TRANSLATION: writer.processAccessor(new import_three18.BufferAttribute(translationAttr, 3)),
|
|
7730
|
+
ROTATION: writer.processAccessor(new import_three18.BufferAttribute(rotationAttr, 4)),
|
|
7731
|
+
SCALE: writer.processAccessor(new import_three18.BufferAttribute(scaleAttr, 3))
|
|
7485
7732
|
};
|
|
7486
7733
|
if (mesh.instanceColor)
|
|
7487
7734
|
attributes._COLOR_0 = writer.processAccessor(mesh.instanceColor);
|
|
@@ -7546,8 +7793,8 @@ GLTFExporter.Utils = {
|
|
|
7546
7793
|
const sourceTracks = clip.tracks;
|
|
7547
7794
|
for (let i = 0; i < sourceTracks.length; ++i) {
|
|
7548
7795
|
let sourceTrack = sourceTracks[i];
|
|
7549
|
-
const sourceTrackBinding =
|
|
7550
|
-
const sourceTrackNode =
|
|
7796
|
+
const sourceTrackBinding = import_three18.PropertyBinding.parseTrackName(sourceTrack.name);
|
|
7797
|
+
const sourceTrackNode = import_three18.PropertyBinding.findNode(root, sourceTrackBinding.nodeName);
|
|
7551
7798
|
if (sourceTrackBinding.propertyName !== "morphTargetInfluences" || sourceTrackBinding.propertyIndex === void 0) {
|
|
7552
7799
|
tracks.push(sourceTrack);
|
|
7553
7800
|
continue;
|
|
@@ -7558,7 +7805,7 @@ GLTFExporter.Utils = {
|
|
|
7558
7805
|
}
|
|
7559
7806
|
console.warn("THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead.");
|
|
7560
7807
|
sourceTrack = sourceTrack.clone();
|
|
7561
|
-
sourceTrack.setInterpolation(
|
|
7808
|
+
sourceTrack.setInterpolation(import_three18.InterpolateLinear);
|
|
7562
7809
|
}
|
|
7563
7810
|
const targetCount = sourceTrackNode.morphTargetInfluences.length;
|
|
7564
7811
|
const targetIndex = sourceTrackNode.morphTargetDictionary[sourceTrackBinding.propertyIndex];
|
|
@@ -7641,10 +7888,10 @@ var SceneExporter = class {
|
|
|
7641
7888
|
}
|
|
7642
7889
|
};
|
|
7643
7890
|
function localMatrix(object) {
|
|
7644
|
-
return object.matrixAutoUpdate ? new
|
|
7891
|
+
return object.matrixAutoUpdate ? new import_three19.Matrix4().compose(object.position, object.quaternion, object.scale) : object.matrix.clone();
|
|
7645
7892
|
}
|
|
7646
7893
|
function createSnapshot(root, gltf, bakeColors = false) {
|
|
7647
|
-
const scene = new
|
|
7894
|
+
const scene = new import_three19.Scene();
|
|
7648
7895
|
const geometries = [];
|
|
7649
7896
|
const materials = [];
|
|
7650
7897
|
const textures = [];
|
|
@@ -7662,7 +7909,7 @@ function createSnapshot(root, gltf, bakeColors = false) {
|
|
|
7662
7909
|
if (!uniforms.map?.value?.isTexture || !uniforms.SHADE || !uniforms.BRIGHTNESS || !uniforms.EMISSIVE) {
|
|
7663
7910
|
throw new MineRenderError("glTF export does not support this custom ShaderMaterial");
|
|
7664
7911
|
}
|
|
7665
|
-
material = new
|
|
7912
|
+
material = new import_three19.MeshBasicMaterial({
|
|
7666
7913
|
map: uniforms.map.value,
|
|
7667
7914
|
vertexColors: source.vertexColors,
|
|
7668
7915
|
transparent: source.transparent,
|
|
@@ -7672,7 +7919,7 @@ function createSnapshot(root, gltf, bakeColors = false) {
|
|
|
7672
7919
|
});
|
|
7673
7920
|
material.name = source.name;
|
|
7674
7921
|
} else if (shader.isShaderMaterial) {
|
|
7675
|
-
material = new
|
|
7922
|
+
material = new import_three19.MeshBasicMaterial({ vertexColors: source.vertexColors });
|
|
7676
7923
|
material.name = source.name;
|
|
7677
7924
|
} else {
|
|
7678
7925
|
const copySource = Object.create(source);
|
|
@@ -7726,11 +7973,11 @@ function createSnapshot(root, gltf, bakeColors = false) {
|
|
|
7726
7973
|
const material = copyMaterial(sourceMaterial, geometry);
|
|
7727
7974
|
if (!sourceMaterial.vertexColors) geometry.deleteAttribute("color");
|
|
7728
7975
|
if (bakeColors || instanceColor) {
|
|
7729
|
-
const tint = (material.color ?? new
|
|
7976
|
+
const tint = (material.color ?? new import_three19.Color()).clone();
|
|
7730
7977
|
if (instanceColor) tint.multiply(instanceColor);
|
|
7731
7978
|
if (bakeColors) {
|
|
7732
7979
|
const original = geometry.getAttribute("color");
|
|
7733
|
-
const colors = new
|
|
7980
|
+
const colors = new import_three19.Float32BufferAttribute(new Float32Array(geometry.getAttribute("position").count * 3), 3);
|
|
7734
7981
|
for (let i = 0; i < colors.count; i++) {
|
|
7735
7982
|
colors.setXYZ(i, (original?.getX(i) ?? 1) * tint.r, (original?.getY(i) ?? 1) * tint.g, (original?.getZ(i) ?? 1) * tint.b);
|
|
7736
7983
|
}
|
|
@@ -7739,7 +7986,7 @@ function createSnapshot(root, gltf, bakeColors = false) {
|
|
|
7739
7986
|
material.color.copy(tint);
|
|
7740
7987
|
}
|
|
7741
7988
|
}
|
|
7742
|
-
const copy = new
|
|
7989
|
+
const copy = new import_three19.Mesh(geometry, material);
|
|
7743
7990
|
copy.name = mesh.name;
|
|
7744
7991
|
copy.renderOrder = mesh.renderOrder;
|
|
7745
7992
|
scene.add(copy);
|
|
@@ -7753,9 +8000,9 @@ function createSnapshot(root, gltf, bakeColors = false) {
|
|
|
7753
8000
|
const instanced = mesh;
|
|
7754
8001
|
if (instanced.isInstancedMesh) {
|
|
7755
8002
|
for (let i = 0; i < instanced.count; i++) {
|
|
7756
|
-
const matrix = new
|
|
8003
|
+
const matrix = new import_three19.Matrix4();
|
|
7757
8004
|
instanced.getMatrixAt(i, matrix);
|
|
7758
|
-
const color = instanced.instanceColor ? new
|
|
8005
|
+
const color = instanced.instanceColor ? new import_three19.Color().fromBufferAttribute(instanced.instanceColor, i) : void 0;
|
|
7759
8006
|
addMesh(mesh, world.clone().multiply(matrix), color);
|
|
7760
8007
|
}
|
|
7761
8008
|
} else {
|
|
@@ -7767,7 +8014,7 @@ function createSnapshot(root, gltf, bakeColors = false) {
|
|
|
7767
8014
|
try {
|
|
7768
8015
|
const ancestors = [];
|
|
7769
8016
|
for (let parent = root.parent; parent; parent = parent.parent) ancestors.unshift(parent);
|
|
7770
|
-
const world = new
|
|
8017
|
+
const world = new import_three19.Matrix4();
|
|
7771
8018
|
for (const ancestor of ancestors) {
|
|
7772
8019
|
if (!ancestor.visible) return { scene, dispose };
|
|
7773
8020
|
world.multiply(localMatrix(ancestor));
|
|
@@ -7781,7 +8028,7 @@ function createSnapshot(root, gltf, bakeColors = false) {
|
|
|
7781
8028
|
}
|
|
7782
8029
|
function selectAlphaMode(material, geometry) {
|
|
7783
8030
|
const texture = material.map;
|
|
7784
|
-
if (material.type !== "MeshBasicMaterial" || !material.transparent || !material.depthWrite || material.opacity !== 1 || material.alphaMap || !texture?.isDataTexture || texture.format !==
|
|
8031
|
+
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
8032
|
const uv = geometry.getAttribute(texture.channel === 0 ? "uv" : `uv${texture.channel}`);
|
|
7786
8033
|
const colors = geometry.getAttribute("color");
|
|
7787
8034
|
if (!uv || material.vertexColors && colors?.itemSize === 4) return;
|
|
@@ -7818,7 +8065,7 @@ function selectAlphaMode(material, geometry) {
|
|
|
7818
8065
|
}
|
|
7819
8066
|
function copyDataTexture(source) {
|
|
7820
8067
|
const image = source.image;
|
|
7821
|
-
if (source.format !==
|
|
8068
|
+
if (source.format !== import_three19.RGBAFormat || source.type !== import_three19.UnsignedByteType) {
|
|
7822
8069
|
throw new MineRenderError("glTF export requires RGBA unsigned-byte data textures");
|
|
7823
8070
|
}
|
|
7824
8071
|
const canvas = createCanvas2(image.width, image.height);
|
|
@@ -7829,8 +8076,8 @@ function copyDataTexture(source) {
|
|
|
7829
8076
|
context.putImageData(pixels, 0, 0);
|
|
7830
8077
|
const copySource = Object.create(source);
|
|
7831
8078
|
copySource.userData = {};
|
|
7832
|
-
copySource.source = new
|
|
7833
|
-
return new
|
|
8079
|
+
copySource.source = new import_three19.Source(canvas);
|
|
8080
|
+
return new import_three19.Texture().copy(copySource);
|
|
7834
8081
|
}
|
|
7835
8082
|
|
|
7836
8083
|
// src/gui/GuiHelper.ts
|
|
@@ -7900,7 +8147,7 @@ var GuiHelper = class {
|
|
|
7900
8147
|
};
|
|
7901
8148
|
|
|
7902
8149
|
// src/gui/scene/GuiObject.ts
|
|
7903
|
-
var
|
|
8150
|
+
var import_three23 = require("three");
|
|
7904
8151
|
init_AssetKey();
|
|
7905
8152
|
init_ModelTextures();
|
|
7906
8153
|
init_Models();
|
|
@@ -7924,7 +8171,7 @@ var GuiObject = class extends SceneObject {
|
|
|
7924
8171
|
this.textureLayers = textureLayers;
|
|
7925
8172
|
this.isGuiObject = true;
|
|
7926
8173
|
/** Local bounds in GUI pixels, with y growing down from the origin. */
|
|
7927
|
-
this.bounds = new
|
|
8174
|
+
this.bounds = new import_three23.Box2();
|
|
7928
8175
|
this.geometries = /* @__PURE__ */ new Set();
|
|
7929
8176
|
this.ownedMaterials = /* @__PURE__ */ new Set();
|
|
7930
8177
|
this.initialized = false;
|
|
@@ -7941,7 +8188,7 @@ var GuiObject = class extends SceneObject {
|
|
|
7941
8188
|
item.position.set(x + width2 / 2, -y - height2 / 2, 0);
|
|
7942
8189
|
item.scale.set(width2 / 16, height2 / 16, width2 / 16);
|
|
7943
8190
|
item.updateMatrix();
|
|
7944
|
-
const bounds = new
|
|
8191
|
+
const bounds = new import_three23.Box3();
|
|
7945
8192
|
item.iterateAllMeshes((mesh2) => {
|
|
7946
8193
|
mesh2.geometry.computeBoundingBox();
|
|
7947
8194
|
bounds.union(mesh2.geometry.boundingBox);
|
|
@@ -7949,10 +8196,10 @@ var GuiObject = class extends SceneObject {
|
|
|
7949
8196
|
bounds.applyMatrix4(item.matrix);
|
|
7950
8197
|
item.position.z = depth - bounds.min.z;
|
|
7951
8198
|
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
|
|
8199
|
+
this.bounds.expandByPoint(new import_three23.Vector2(x, y));
|
|
8200
|
+
this.bounds.expandByPoint(new import_three23.Vector2(x + width2, y + height2));
|
|
8201
|
+
this.bounds.expandByPoint(new import_three23.Vector2(bounds.min.x, -bounds.max.y));
|
|
8202
|
+
this.bounds.expandByPoint(new import_three23.Vector2(bounds.max.x, -bounds.min.y));
|
|
7956
8203
|
continue;
|
|
7957
8204
|
}
|
|
7958
8205
|
const key = typeof layer.texture === "string" ? AssetKey.parse("textures", layer.texture) : layer.texture;
|
|
@@ -7960,7 +8207,7 @@ var GuiObject = class extends SceneObject {
|
|
|
7960
8207
|
const image = material.map.image;
|
|
7961
8208
|
const [cropX, cropY, cropWidth, cropHeight] = layer.crop ?? [0, 0, image.width, image.height];
|
|
7962
8209
|
const [width, height] = layer.size ?? [cropWidth, cropHeight];
|
|
7963
|
-
const geometry = new
|
|
8210
|
+
const geometry = new import_three23.PlaneGeometry(width, height);
|
|
7964
8211
|
this.geometries.add(geometry);
|
|
7965
8212
|
const uv = geometry.getAttribute("uv");
|
|
7966
8213
|
for (let i = 0; i < uv.count; i++) {
|
|
@@ -7970,13 +8217,13 @@ var GuiObject = class extends SceneObject {
|
|
|
7970
8217
|
1 - (cropY + (1 - uv.getY(i)) * cropHeight) / image.height
|
|
7971
8218
|
);
|
|
7972
8219
|
}
|
|
7973
|
-
const mesh = new
|
|
8220
|
+
const mesh = new import_three23.Mesh(geometry, material);
|
|
7974
8221
|
mesh.name = `mesh:${layer.name ?? index}`;
|
|
7975
8222
|
mesh.position.set(x + width / 2, -y - height / 2, depth);
|
|
7976
8223
|
mesh.renderOrder = index;
|
|
7977
8224
|
this.add(mesh);
|
|
7978
|
-
this.bounds.expandByPoint(new
|
|
7979
|
-
this.bounds.expandByPoint(new
|
|
8225
|
+
this.bounds.expandByPoint(new import_three23.Vector2(x, y));
|
|
8226
|
+
this.bounds.expandByPoint(new import_three23.Vector2(x + width, y + height));
|
|
7980
8227
|
depth += 0.01;
|
|
7981
8228
|
}
|
|
7982
8229
|
for (const child of this.children) child.position.z -= depth - 0.01;
|
|
@@ -8051,7 +8298,7 @@ function isGuiObject(obj) {
|
|
|
8051
8298
|
init_image();
|
|
8052
8299
|
|
|
8053
8300
|
// src/inspector/SceneInspector.ts
|
|
8054
|
-
var
|
|
8301
|
+
var import_three24 = require("three");
|
|
8055
8302
|
init_SceneObject();
|
|
8056
8303
|
init_util();
|
|
8057
8304
|
init_log();
|
|
@@ -8061,11 +8308,11 @@ var help = "<span>Ctrl/Cmd+Click to Select<br/></span><br/>";
|
|
|
8061
8308
|
var SceneInspector = class {
|
|
8062
8309
|
constructor(renderer) {
|
|
8063
8310
|
this.renderer = renderer;
|
|
8064
|
-
this.mouse = new
|
|
8311
|
+
this.mouse = new import_three24.Vector2();
|
|
8065
8312
|
this.listeners = new AbortController();
|
|
8066
8313
|
this.objectInfoContainer = document.createElement("div");
|
|
8067
8314
|
this.objectControlsContainer = document.createElement("div");
|
|
8068
|
-
this.raycaster = new
|
|
8315
|
+
this.raycaster = new import_three24.Raycaster();
|
|
8069
8316
|
this.init();
|
|
8070
8317
|
}
|
|
8071
8318
|
init() {
|
|
@@ -8481,7 +8728,7 @@ init_ModelGenerator();
|
|
|
8481
8728
|
init_ModelMerger();
|
|
8482
8729
|
|
|
8483
8730
|
// src/model/block/BlockStateResolver.ts
|
|
8484
|
-
var
|
|
8731
|
+
var import_three26 = require("three");
|
|
8485
8732
|
init_BlockStates();
|
|
8486
8733
|
init_MineRenderError();
|
|
8487
8734
|
init_util();
|
|
@@ -8559,7 +8806,7 @@ var BlockStateResolver = class {
|
|
|
8559
8806
|
return variants[variants.length - 1];
|
|
8560
8807
|
}
|
|
8561
8808
|
static rotation(variant) {
|
|
8562
|
-
const rotation = new
|
|
8809
|
+
const rotation = new import_three26.Euler();
|
|
8563
8810
|
if (typeof variant.x !== "undefined") {
|
|
8564
8811
|
rotation.x = toRadians(clampRotationDegrees(variant.x));
|
|
8565
8812
|
}
|
|
@@ -8666,7 +8913,7 @@ init_SceneObject();
|
|
|
8666
8913
|
init_ModelObject();
|
|
8667
8914
|
init_Models();
|
|
8668
8915
|
var import_ts_deepmerge6 = __toESM(require_dist());
|
|
8669
|
-
var
|
|
8916
|
+
var import_three29 = require("three");
|
|
8670
8917
|
init_MineRenderError();
|
|
8671
8918
|
init_InstanceReference();
|
|
8672
8919
|
init_AssetKey();
|
|
@@ -8686,6 +8933,9 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
8686
8933
|
this._variants = [];
|
|
8687
8934
|
this._models = [];
|
|
8688
8935
|
this._cullMask = 0;
|
|
8936
|
+
this._entities = [];
|
|
8937
|
+
this._entityPlacement = new import_three29.Matrix4();
|
|
8938
|
+
this._entityGeneration = 0;
|
|
8689
8939
|
this.options = (0, import_ts_deepmerge6.default)({}, _BlockObject.DEFAULT_OPTIONS, options ?? {});
|
|
8690
8940
|
}
|
|
8691
8941
|
static {
|
|
@@ -8710,6 +8960,8 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
8710
8960
|
}
|
|
8711
8961
|
clearModels() {
|
|
8712
8962
|
this.removeModels(this._models.splice(0));
|
|
8963
|
+
this._entityGeneration++;
|
|
8964
|
+
this.removeEntities(this._entities.splice(0));
|
|
8713
8965
|
this._fluidKey = void 0;
|
|
8714
8966
|
this._fluidModel = void 0;
|
|
8715
8967
|
this._isInstanced = false;
|
|
@@ -8721,6 +8973,57 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
8721
8973
|
if (!isInstanceReference(model)) model.dispose();
|
|
8722
8974
|
}
|
|
8723
8975
|
}
|
|
8976
|
+
removeEntities(entities) {
|
|
8977
|
+
for (const entity of entities) {
|
|
8978
|
+
entity.removeFromScene();
|
|
8979
|
+
entity.dispose();
|
|
8980
|
+
}
|
|
8981
|
+
}
|
|
8982
|
+
/** Entity models drawn for this block instead of its block model; they are scene children, unlike the block. */
|
|
8983
|
+
get blockEntities() {
|
|
8984
|
+
return this._entities;
|
|
8985
|
+
}
|
|
8986
|
+
/**
|
|
8987
|
+
* Draws the block through the dataset's block-entity index. Returns false, leaving nothing behind,
|
|
8988
|
+
* when the block is not listed or one of its models cannot be loaded.
|
|
8989
|
+
*/
|
|
8990
|
+
async createBlockEntities() {
|
|
8991
|
+
const key = this.blockState.key;
|
|
8992
|
+
if (!key || this.options.displayPosition) return false;
|
|
8993
|
+
const generation = this._entityGeneration;
|
|
8994
|
+
const created = [];
|
|
8995
|
+
let resolved;
|
|
8996
|
+
try {
|
|
8997
|
+
resolved = BlockEntities.resolve(await BlockEntities.getIndex(key.root), key.toNamespacedString(), this.state);
|
|
8998
|
+
if (!resolved) return false;
|
|
8999
|
+
for (const part of resolved.parts) {
|
|
9000
|
+
const [namespace, path] = part.model.includes(":") ? part.model.split(":") : [key.namespace, part.model];
|
|
9001
|
+
const texture = part.textureLocation === void 0 ? void 0 : AssetKey.parse("textures", part.textureLocation.replace(/^([^:]+:)?textures\//, "$1"));
|
|
9002
|
+
if (texture) texture.root = key.root;
|
|
9003
|
+
const entity = await Entities.getEntity(new BasicAssetKey(namespace, path), texture, { layer: part.layer });
|
|
9004
|
+
if (!entity) throw new MineRenderError(`Missing entity model ${part.model}`);
|
|
9005
|
+
created.push(await this.scene.addEntity(entity, { wireframe: this.options.wireframe }));
|
|
9006
|
+
}
|
|
9007
|
+
} catch (error) {
|
|
9008
|
+
console.warn(`Could not draw block entity ${key.toNamespacedString()}, using its block model`, error);
|
|
9009
|
+
this.removeEntities(created);
|
|
9010
|
+
return false;
|
|
9011
|
+
}
|
|
9012
|
+
if (generation !== this._entityGeneration) {
|
|
9013
|
+
this.removeEntities(created);
|
|
9014
|
+
return true;
|
|
9015
|
+
}
|
|
9016
|
+
BlockEntities.matrix(resolved, this._entityPlacement);
|
|
9017
|
+
this._entities = created;
|
|
9018
|
+
this.placeEntities();
|
|
9019
|
+
return true;
|
|
9020
|
+
}
|
|
9021
|
+
placeEntities() {
|
|
9022
|
+
const matrix = new import_three29.Matrix4().makeTranslation(this.position.x - 8, this.position.y - 8, this.position.z - 8).multiply(this._entityPlacement);
|
|
9023
|
+
for (const entity of this._entities) {
|
|
9024
|
+
matrix.decompose(entity.position, entity.quaternion, entity.scale);
|
|
9025
|
+
}
|
|
9026
|
+
}
|
|
8724
9027
|
get isOccluding() {
|
|
8725
9028
|
return this._models.some((model) => {
|
|
8726
9029
|
const object = isInstanceReference(model) ? model.instanceable : model;
|
|
@@ -8735,12 +9038,12 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
8735
9038
|
getModelCullMask(model, worldMask) {
|
|
8736
9039
|
const object = isInstanceReference(model) ? model.instanceable : model;
|
|
8737
9040
|
if (object.options.displayPosition) return 0;
|
|
8738
|
-
const position = new
|
|
8739
|
-
const rotation = new
|
|
8740
|
-
const scale = new
|
|
9041
|
+
const position = new import_three29.Vector3();
|
|
9042
|
+
const rotation = new import_three29.Quaternion();
|
|
9043
|
+
const scale = new import_three29.Vector3();
|
|
8741
9044
|
this.getModelMatrix(model).decompose(position, rotation, scale);
|
|
8742
|
-
if (position.distanceToSquared(this.position) > 1e-10 || scale.distanceToSquared(new
|
|
8743
|
-
return ModelCulling.toLocalMask(worldMask, new
|
|
9045
|
+
if (position.distanceToSquared(this.position) > 1e-10 || scale.distanceToSquared(new import_three29.Vector3(1, 1, 1)) > 1e-10) return 0;
|
|
9046
|
+
return ModelCulling.toLocalMask(worldMask, new import_three29.Euler().setFromQuaternion(rotation));
|
|
8744
9047
|
}
|
|
8745
9048
|
async setCullMask(worldMask) {
|
|
8746
9049
|
worldMask &= 63;
|
|
@@ -8802,7 +9105,7 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
8802
9105
|
() => new FluidModelObject2(kind, surface.sample, this.blockState.key, this.options)
|
|
8803
9106
|
);
|
|
8804
9107
|
const previous = this._fluidModel;
|
|
8805
|
-
const matrix = previous ? this.getModelMatrix(previous) : new
|
|
9108
|
+
const matrix = previous ? this.getModelMatrix(previous) : new import_three29.Matrix4().makeTranslation(...this.position.toArray());
|
|
8806
9109
|
if (isInstanceReference(replacement)) replacement.setMatrix(matrix);
|
|
8807
9110
|
else matrix.decompose(replacement.position, replacement.quaternion, replacement.scale);
|
|
8808
9111
|
this._models = this._models.filter((model) => model !== previous);
|
|
@@ -8832,13 +9135,20 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
8832
9135
|
await this.updateFluid(this._fluidSampler);
|
|
8833
9136
|
return;
|
|
8834
9137
|
}
|
|
9138
|
+
const hasEntities = await this.createBlockEntities();
|
|
8835
9139
|
const variantsToCreate = await this.mapStateToVariant(this.state);
|
|
8836
9140
|
this._variants = variantsToCreate;
|
|
8837
9141
|
for (let blockStateVariant of variantsToCreate) {
|
|
9142
|
+
if (hasEntities && !await this.hasGeometry(blockStateVariant)) continue;
|
|
8838
9143
|
this._models.push(await this.createVariant(blockStateVariant));
|
|
8839
9144
|
}
|
|
8840
9145
|
await this.updateFluid(this._fluidSampler);
|
|
8841
9146
|
}
|
|
9147
|
+
async hasGeometry(variant) {
|
|
9148
|
+
const modelKey = AssetKey.parse("models", variant.model);
|
|
9149
|
+
modelKey.root = this.blockState.key?.root;
|
|
9150
|
+
return !!(await Models.getMerged(modelKey))?.elements?.length;
|
|
9151
|
+
}
|
|
8842
9152
|
getSingleVariant(variants) {
|
|
8843
9153
|
return BlockStateResolver.choose(variants);
|
|
8844
9154
|
}
|
|
@@ -8933,7 +9243,7 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
8933
9243
|
setPositionRotationScaleAt(index, position, rotation, scale) {
|
|
8934
9244
|
super.setPositionRotationScaleAt(index, position, rotation, scale);
|
|
8935
9245
|
}
|
|
8936
|
-
getMatrixAt(index, matrix = new
|
|
9246
|
+
getMatrixAt(index, matrix = new import_three29.Matrix4()) {
|
|
8937
9247
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
8938
9248
|
const child = this._models[0];
|
|
8939
9249
|
if (child && isModelObject(child)) {
|
|
@@ -8958,6 +9268,7 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
8958
9268
|
for (let model of this._models) {
|
|
8959
9269
|
model.setPosition(position);
|
|
8960
9270
|
}
|
|
9271
|
+
this.placeEntities();
|
|
8961
9272
|
this.notifyDirty();
|
|
8962
9273
|
}
|
|
8963
9274
|
//TODO: should override rotation + scale methods
|
|
@@ -10799,7 +11110,7 @@ init_ModelObject();
|
|
|
10799
11110
|
init_nbt();
|
|
10800
11111
|
|
|
10801
11112
|
// src/renderer/MineRenderScene.ts
|
|
10802
|
-
var
|
|
11113
|
+
var import_three31 = require("three");
|
|
10803
11114
|
init_SceneObject();
|
|
10804
11115
|
var import_ts_deepmerge8 = __toESM(require_dist());
|
|
10805
11116
|
init_ModelObject();
|
|
@@ -11532,7 +11843,7 @@ var import_ts_deepmerge7 = __toESM(require_dist());
|
|
|
11532
11843
|
init_util();
|
|
11533
11844
|
|
|
11534
11845
|
// src/skin/SkinTextures.ts
|
|
11535
|
-
var
|
|
11846
|
+
var import_three30 = require("three");
|
|
11536
11847
|
init_Caching();
|
|
11537
11848
|
init_CacheKey();
|
|
11538
11849
|
init_MineRenderError();
|
|
@@ -11616,11 +11927,11 @@ var SkinTextures = class {
|
|
|
11616
11927
|
});
|
|
11617
11928
|
}
|
|
11618
11929
|
static createMaterial(pixels, width, height, transparent = true) {
|
|
11619
|
-
const texture = Textures.initTextureProps(new
|
|
11620
|
-
texture.colorSpace =
|
|
11930
|
+
const texture = Textures.initTextureProps(new import_three30.DataTexture(pixels, width, height));
|
|
11931
|
+
texture.colorSpace = import_three30.SRGBColorSpace;
|
|
11621
11932
|
texture.flipY = true;
|
|
11622
11933
|
texture.needsUpdate = true;
|
|
11623
|
-
return new
|
|
11934
|
+
return new import_three30.MeshBasicMaterial({ map: texture, transparent, side: transparent ? import_three30.DoubleSide : import_three30.FrontSide, alphaTest: transparent ? 0.1 : 0 });
|
|
11624
11935
|
}
|
|
11625
11936
|
static isSlim(image, scale) {
|
|
11626
11937
|
for (const [x, y] of [[46, 52], [54, 20]]) {
|
|
@@ -11848,7 +12159,7 @@ var SkinObject = class extends SceneObject {
|
|
|
11848
12159
|
};
|
|
11849
12160
|
|
|
11850
12161
|
// src/renderer/MineRenderScene.ts
|
|
11851
|
-
var MineRenderScene = class _MineRenderScene extends
|
|
12162
|
+
var MineRenderScene = class _MineRenderScene extends import_three31.Scene {
|
|
11852
12163
|
constructor(options) {
|
|
11853
12164
|
super();
|
|
11854
12165
|
this.isMineRenderScene = true;
|
|
@@ -11976,7 +12287,7 @@ function isMineRenderScene(obj) {
|
|
|
11976
12287
|
}
|
|
11977
12288
|
|
|
11978
12289
|
// src/renderer/Renderer.ts
|
|
11979
|
-
var
|
|
12290
|
+
var import_three33 = require("three");
|
|
11980
12291
|
var import_ts_deepmerge9 = __toESM(require_dist());
|
|
11981
12292
|
var import_stats = __toESM(require("stats.js"));
|
|
11982
12293
|
var import_postprocessing = require("postprocessing");
|
|
@@ -11984,11 +12295,11 @@ init_util();
|
|
|
11984
12295
|
init_three();
|
|
11985
12296
|
|
|
11986
12297
|
// src/three/OrbitControls.js
|
|
11987
|
-
var
|
|
12298
|
+
var import_three32 = require("three");
|
|
11988
12299
|
var _changeEvent = { type: "change" };
|
|
11989
12300
|
var _startEvent = { type: "start" };
|
|
11990
12301
|
var _endEvent = { type: "end" };
|
|
11991
|
-
var OrbitControls = class extends
|
|
12302
|
+
var OrbitControls = class extends import_three32.EventDispatcher {
|
|
11992
12303
|
constructor(object, domElement) {
|
|
11993
12304
|
super();
|
|
11994
12305
|
if (domElement === void 0) console.warn('THREE.OrbitControls: The second parameter "domElement" is now mandatory.');
|
|
@@ -11997,7 +12308,7 @@ var OrbitControls = class extends import_three31.EventDispatcher {
|
|
|
11997
12308
|
this.domElement = domElement;
|
|
11998
12309
|
this.domElement.style.touchAction = "none";
|
|
11999
12310
|
this.enabled = true;
|
|
12000
|
-
this.target = new
|
|
12311
|
+
this.target = new import_three32.Vector3();
|
|
12001
12312
|
this.minDistance = 0;
|
|
12002
12313
|
this.maxDistance = Infinity;
|
|
12003
12314
|
this.minZoom = 0;
|
|
@@ -12019,8 +12330,8 @@ var OrbitControls = class extends import_three31.EventDispatcher {
|
|
|
12019
12330
|
this.autoRotate = false;
|
|
12020
12331
|
this.autoRotateSpeed = 2;
|
|
12021
12332
|
this.keys = { LEFT: "ArrowLeft", UP: "ArrowUp", RIGHT: "ArrowRight", BOTTOM: "ArrowDown" };
|
|
12022
|
-
this.mouseButtons = { LEFT:
|
|
12023
|
-
this.touches = { ONE:
|
|
12333
|
+
this.mouseButtons = { LEFT: import_three32.MOUSE.ROTATE, MIDDLE: import_three32.MOUSE.DOLLY, RIGHT: import_three32.MOUSE.PAN };
|
|
12334
|
+
this.touches = { ONE: import_three32.TOUCH.ROTATE, TWO: import_three32.TOUCH.DOLLY_PAN };
|
|
12024
12335
|
this.target0 = this.target.clone();
|
|
12025
12336
|
this.position0 = this.object.position.clone();
|
|
12026
12337
|
this.zoom0 = this.object.zoom;
|
|
@@ -12049,11 +12360,11 @@ var OrbitControls = class extends import_three31.EventDispatcher {
|
|
|
12049
12360
|
state = STATE.NONE;
|
|
12050
12361
|
};
|
|
12051
12362
|
this.update = function() {
|
|
12052
|
-
const offset = new
|
|
12053
|
-
const quat = new
|
|
12363
|
+
const offset = new import_three32.Vector3();
|
|
12364
|
+
const quat = new import_three32.Quaternion().setFromUnitVectors(object.up, new import_three32.Vector3(0, 1, 0));
|
|
12054
12365
|
const quatInverse = quat.clone().invert();
|
|
12055
|
-
const lastPosition = new
|
|
12056
|
-
const lastQuaternion = new
|
|
12366
|
+
const lastPosition = new import_three32.Vector3();
|
|
12367
|
+
const lastQuaternion = new import_three32.Quaternion();
|
|
12057
12368
|
const twoPI = 2 * Math.PI;
|
|
12058
12369
|
return function update() {
|
|
12059
12370
|
const position = scope.object.position;
|
|
@@ -12139,20 +12450,20 @@ var OrbitControls = class extends import_three31.EventDispatcher {
|
|
|
12139
12450
|
};
|
|
12140
12451
|
let state = STATE.NONE;
|
|
12141
12452
|
const EPS = 1e-6;
|
|
12142
|
-
const spherical = new
|
|
12143
|
-
const sphericalDelta = new
|
|
12453
|
+
const spherical = new import_three32.Spherical();
|
|
12454
|
+
const sphericalDelta = new import_three32.Spherical();
|
|
12144
12455
|
let scale = 1;
|
|
12145
|
-
const panOffset = new
|
|
12456
|
+
const panOffset = new import_three32.Vector3();
|
|
12146
12457
|
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
|
|
12458
|
+
const rotateStart = new import_three32.Vector2();
|
|
12459
|
+
const rotateEnd = new import_three32.Vector2();
|
|
12460
|
+
const rotateDelta = new import_three32.Vector2();
|
|
12461
|
+
const panStart = new import_three32.Vector2();
|
|
12462
|
+
const panEnd = new import_three32.Vector2();
|
|
12463
|
+
const panDelta = new import_three32.Vector2();
|
|
12464
|
+
const dollyStart = new import_three32.Vector2();
|
|
12465
|
+
const dollyEnd = new import_three32.Vector2();
|
|
12466
|
+
const dollyDelta = new import_three32.Vector2();
|
|
12156
12467
|
const pointers = [];
|
|
12157
12468
|
const pointerPositions = {};
|
|
12158
12469
|
function getAutoRotationAngle() {
|
|
@@ -12168,7 +12479,7 @@ var OrbitControls = class extends import_three31.EventDispatcher {
|
|
|
12168
12479
|
sphericalDelta.phi -= angle;
|
|
12169
12480
|
}
|
|
12170
12481
|
const panLeft = function() {
|
|
12171
|
-
const v = new
|
|
12482
|
+
const v = new import_three32.Vector3();
|
|
12172
12483
|
return function panLeft2(distance, objectMatrix) {
|
|
12173
12484
|
v.setFromMatrixColumn(objectMatrix, 0);
|
|
12174
12485
|
v.multiplyScalar(-distance);
|
|
@@ -12176,7 +12487,7 @@ var OrbitControls = class extends import_three31.EventDispatcher {
|
|
|
12176
12487
|
};
|
|
12177
12488
|
}();
|
|
12178
12489
|
const panUp = function() {
|
|
12179
|
-
const v = new
|
|
12490
|
+
const v = new import_three32.Vector3();
|
|
12180
12491
|
return function panUp2(distance, objectMatrix) {
|
|
12181
12492
|
if (scope.screenSpacePanning === true) {
|
|
12182
12493
|
v.setFromMatrixColumn(objectMatrix, 1);
|
|
@@ -12189,7 +12500,7 @@ var OrbitControls = class extends import_three31.EventDispatcher {
|
|
|
12189
12500
|
};
|
|
12190
12501
|
}();
|
|
12191
12502
|
const pan = function() {
|
|
12192
|
-
const offset = new
|
|
12503
|
+
const offset = new import_three32.Vector3();
|
|
12193
12504
|
return function pan2(deltaX, deltaY) {
|
|
12194
12505
|
const element = scope.domElement;
|
|
12195
12506
|
if (scope.object.isPerspectiveCamera) {
|
|
@@ -12438,12 +12749,12 @@ var OrbitControls = class extends import_three31.EventDispatcher {
|
|
|
12438
12749
|
mouseAction = -1;
|
|
12439
12750
|
}
|
|
12440
12751
|
switch (mouseAction) {
|
|
12441
|
-
case
|
|
12752
|
+
case import_three32.MOUSE.DOLLY:
|
|
12442
12753
|
if (scope.enableZoom === false) return;
|
|
12443
12754
|
handleMouseDownDolly(event);
|
|
12444
12755
|
state = STATE.DOLLY;
|
|
12445
12756
|
break;
|
|
12446
|
-
case
|
|
12757
|
+
case import_three32.MOUSE.ROTATE:
|
|
12447
12758
|
if (event.ctrlKey || event.metaKey || event.shiftKey) {
|
|
12448
12759
|
if (scope.enablePan === false) return;
|
|
12449
12760
|
handleMouseDownPan(event);
|
|
@@ -12454,7 +12765,7 @@ var OrbitControls = class extends import_three31.EventDispatcher {
|
|
|
12454
12765
|
state = STATE.ROTATE;
|
|
12455
12766
|
}
|
|
12456
12767
|
break;
|
|
12457
|
-
case
|
|
12768
|
+
case import_three32.MOUSE.PAN:
|
|
12458
12769
|
if (event.ctrlKey || event.metaKey || event.shiftKey) {
|
|
12459
12770
|
if (scope.enableRotate === false) return;
|
|
12460
12771
|
handleMouseDownRotate(event);
|
|
@@ -12510,12 +12821,12 @@ var OrbitControls = class extends import_three31.EventDispatcher {
|
|
|
12510
12821
|
switch (pointers.length) {
|
|
12511
12822
|
case 1:
|
|
12512
12823
|
switch (scope.touches.ONE) {
|
|
12513
|
-
case
|
|
12824
|
+
case import_three32.TOUCH.ROTATE:
|
|
12514
12825
|
if (scope.enableRotate === false) return;
|
|
12515
12826
|
handleTouchStartRotate();
|
|
12516
12827
|
state = STATE.TOUCH_ROTATE;
|
|
12517
12828
|
break;
|
|
12518
|
-
case
|
|
12829
|
+
case import_three32.TOUCH.PAN:
|
|
12519
12830
|
if (scope.enablePan === false) return;
|
|
12520
12831
|
handleTouchStartPan();
|
|
12521
12832
|
state = STATE.TOUCH_PAN;
|
|
@@ -12526,12 +12837,12 @@ var OrbitControls = class extends import_three31.EventDispatcher {
|
|
|
12526
12837
|
break;
|
|
12527
12838
|
case 2:
|
|
12528
12839
|
switch (scope.touches.TWO) {
|
|
12529
|
-
case
|
|
12840
|
+
case import_three32.TOUCH.DOLLY_PAN:
|
|
12530
12841
|
if (scope.enableZoom === false && scope.enablePan === false) return;
|
|
12531
12842
|
handleTouchStartDollyPan();
|
|
12532
12843
|
state = STATE.TOUCH_DOLLY_PAN;
|
|
12533
12844
|
break;
|
|
12534
|
-
case
|
|
12845
|
+
case import_three32.TOUCH.DOLLY_ROTATE:
|
|
12535
12846
|
if (scope.enableZoom === false && scope.enableRotate === false) return;
|
|
12536
12847
|
handleTouchStartDollyRotate();
|
|
12537
12848
|
state = STATE.TOUCH_DOLLY_ROTATE;
|
|
@@ -12598,7 +12909,7 @@ var OrbitControls = class extends import_three31.EventDispatcher {
|
|
|
12598
12909
|
function trackPointer(event) {
|
|
12599
12910
|
let position = pointerPositions[event.pointerId];
|
|
12600
12911
|
if (position === void 0) {
|
|
12601
|
-
position = new
|
|
12912
|
+
position = new import_three32.Vector2();
|
|
12602
12913
|
pointerPositions[event.pointerId] = position;
|
|
12603
12914
|
}
|
|
12604
12915
|
position.set(event.pageX, event.pageY);
|
|
@@ -12618,10 +12929,10 @@ var MapControls = class extends OrbitControls {
|
|
|
12618
12929
|
constructor(object, domElement) {
|
|
12619
12930
|
super(object, domElement);
|
|
12620
12931
|
this.screenSpacePanning = false;
|
|
12621
|
-
this.mouseButtons.LEFT =
|
|
12622
|
-
this.mouseButtons.RIGHT =
|
|
12623
|
-
this.touches.ONE =
|
|
12624
|
-
this.touches.TWO =
|
|
12932
|
+
this.mouseButtons.LEFT = import_three32.MOUSE.PAN;
|
|
12933
|
+
this.mouseButtons.RIGHT = import_three32.MOUSE.ROTATE;
|
|
12934
|
+
this.touches.ONE = import_three32.TOUCH.PAN;
|
|
12935
|
+
this.touches.TWO = import_three32.TOUCH.DOLLY_ROTATE;
|
|
12625
12936
|
}
|
|
12626
12937
|
};
|
|
12627
12938
|
|
|
@@ -12680,8 +12991,8 @@ var Renderer = class _Renderer {
|
|
|
12680
12991
|
top: void 0,
|
|
12681
12992
|
bottom: void 0
|
|
12682
12993
|
},
|
|
12683
|
-
position: new
|
|
12684
|
-
lookingAt: new
|
|
12994
|
+
position: new import_three33.Vector3(50, 50, 50),
|
|
12995
|
+
lookingAt: new import_three33.Vector3(0, 0, 0)
|
|
12685
12996
|
},
|
|
12686
12997
|
render: {
|
|
12687
12998
|
fpsLimit: 60,
|
|
@@ -12712,14 +13023,14 @@ var Renderer = class _Renderer {
|
|
|
12712
13023
|
switch (this.options.camera.type) {
|
|
12713
13024
|
case "perspective":
|
|
12714
13025
|
default:
|
|
12715
|
-
return new
|
|
13026
|
+
return new import_three33.PerspectiveCamera(
|
|
12716
13027
|
this.options.camera.perspective.fov,
|
|
12717
13028
|
this.options.camera.perspective.aspect ?? this.viewWidth / this.viewHeight,
|
|
12718
13029
|
this.options.camera.near,
|
|
12719
13030
|
this.options.camera.far
|
|
12720
13031
|
);
|
|
12721
13032
|
case "orthographic":
|
|
12722
|
-
return new
|
|
13033
|
+
return new import_three33.OrthographicCamera(
|
|
12723
13034
|
this.options.camera.orthographic.left ?? this.viewWidth / -2,
|
|
12724
13035
|
this.options.camera.orthographic.right ?? this.viewWidth / 2,
|
|
12725
13036
|
this.options.camera.orthographic.top ?? this.viewHeight / 2,
|
|
@@ -12730,7 +13041,7 @@ var Renderer = class _Renderer {
|
|
|
12730
13041
|
}
|
|
12731
13042
|
}
|
|
12732
13043
|
createRenderer() {
|
|
12733
|
-
const renderer = new
|
|
13044
|
+
const renderer = new import_three33.WebGLRenderer({
|
|
12734
13045
|
antialias: this.options.render.antialias,
|
|
12735
13046
|
alpha: true,
|
|
12736
13047
|
powerPreference: "high-performance",
|
|
@@ -12738,8 +13049,8 @@ var Renderer = class _Renderer {
|
|
|
12738
13049
|
});
|
|
12739
13050
|
renderer.setClearColor(0, 0);
|
|
12740
13051
|
renderer.shadowMap.enabled = true;
|
|
12741
|
-
renderer.shadowMap.type =
|
|
12742
|
-
renderer.outputColorSpace =
|
|
13052
|
+
renderer.shadowMap.type = import_three33.PCFSoftShadowMap;
|
|
13053
|
+
renderer.outputColorSpace = import_three33.SRGBColorSpace;
|
|
12743
13054
|
renderer.setPixelRatio(this.options.render.pixelRatio ?? 1);
|
|
12744
13055
|
renderer.setSize(this.viewWidth, this.viewHeight);
|
|
12745
13056
|
return renderer;
|
|
@@ -12774,20 +13085,20 @@ var Renderer = class _Renderer {
|
|
|
12774
13085
|
window["__THREE_DEVTOOLS__"].dispatchEvent(new CustomEvent("observe", { detail: this.scene }));
|
|
12775
13086
|
}
|
|
12776
13087
|
if (this.options.debug.grid) {
|
|
12777
|
-
const gridHelper = new
|
|
13088
|
+
const gridHelper = new import_three33.GridHelper(128, 16);
|
|
12778
13089
|
this._debugHelpers.push(gridHelper);
|
|
12779
13090
|
this.scene.add(gridHelper);
|
|
12780
|
-
const gridHelper2 = new
|
|
13091
|
+
const gridHelper2 = new import_three33.GridHelper(128, 16);
|
|
12781
13092
|
this._debugHelpers.push(gridHelper2);
|
|
12782
13093
|
gridHelper2.rotation.x = 90 * (Math.PI / 180);
|
|
12783
13094
|
this.scene.add(gridHelper2);
|
|
12784
|
-
const gridHelper3 = new
|
|
13095
|
+
const gridHelper3 = new import_three33.GridHelper(128, 16);
|
|
12785
13096
|
this._debugHelpers.push(gridHelper3);
|
|
12786
13097
|
gridHelper3.rotation.z = 90 * (Math.PI / 180);
|
|
12787
13098
|
this.scene.add(gridHelper3);
|
|
12788
13099
|
}
|
|
12789
13100
|
if (this.options.debug.axes) {
|
|
12790
|
-
const axesHelper = new
|
|
13101
|
+
const axesHelper = new import_three33.AxesHelper(64);
|
|
12791
13102
|
this._debugHelpers.push(axesHelper);
|
|
12792
13103
|
this.scene.add(axesHelper);
|
|
12793
13104
|
}
|
|
@@ -13472,19 +13783,19 @@ var AnvilParser = class {
|
|
|
13472
13783
|
};
|
|
13473
13784
|
|
|
13474
13785
|
// src/world/Chunk.ts
|
|
13475
|
-
var
|
|
13786
|
+
var import_three38 = require("three");
|
|
13476
13787
|
init_BlockStates();
|
|
13477
13788
|
init_AssetKey();
|
|
13478
13789
|
|
|
13479
13790
|
// src/world/MineRenderWorld.ts
|
|
13480
|
-
var
|
|
13791
|
+
var import_three36 = require("three");
|
|
13481
13792
|
init_BatchedExecutor();
|
|
13482
13793
|
init_AssetKey();
|
|
13483
13794
|
init_BlockStates();
|
|
13484
13795
|
init_CubeFace();
|
|
13485
13796
|
|
|
13486
13797
|
// src/world/SectionModels.ts
|
|
13487
|
-
var
|
|
13798
|
+
var import_three35 = require("three");
|
|
13488
13799
|
init_AssetKey();
|
|
13489
13800
|
init_Models();
|
|
13490
13801
|
init_CubeFace();
|
|
@@ -13550,12 +13861,12 @@ var SectionModels = class {
|
|
|
13550
13861
|
});
|
|
13551
13862
|
await object.init();
|
|
13552
13863
|
const geometry = object.children[0].geometry;
|
|
13553
|
-
geometry.applyMatrix4(new
|
|
13864
|
+
geometry.applyMatrix4(new import_three35.Matrix4().makeRotationFromEuler(rotation));
|
|
13554
13865
|
object.clear();
|
|
13555
13866
|
const cullFaces = CUBE_FACES.map((face) => {
|
|
13556
13867
|
const local = CUBE_FACES.findIndex((name) => name === atlas.model.elements[0].faces[face]?.cullface);
|
|
13557
13868
|
if (local < 0) return 0;
|
|
13558
|
-
const normal = new
|
|
13869
|
+
const normal = new import_three35.Vector3(...CUBE_FACE_OFFSETS[local]).applyEuler(rotation);
|
|
13559
13870
|
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
13871
|
return 1 << world;
|
|
13561
13872
|
});
|
|
@@ -13585,20 +13896,20 @@ var MineRenderWorld = class {
|
|
|
13585
13896
|
}
|
|
13586
13897
|
getBlockAt(posOrX, y, z) {
|
|
13587
13898
|
if (typeof posOrX == "number") {
|
|
13588
|
-
return this.getBlockAt(new
|
|
13899
|
+
return this.getBlockAt(new import_three36.Vector3(posOrX, y, z));
|
|
13589
13900
|
}
|
|
13590
13901
|
if (isTripleArray(posOrX)) {
|
|
13591
|
-
return this.getBlockAt(new
|
|
13902
|
+
return this.getBlockAt(new import_three36.Vector3(posOrX[0], posOrX[1], posOrX[2]));
|
|
13592
13903
|
}
|
|
13593
13904
|
this.validatePosBounds(posOrX);
|
|
13594
13905
|
return this.getChunkAt(posOrX)?.getBlockAt(posOrX);
|
|
13595
13906
|
}
|
|
13596
13907
|
async setBlockAt(posOrX, yOrBlock, z, block) {
|
|
13597
13908
|
if (typeof posOrX == "number") {
|
|
13598
|
-
return this.setBlockAt(new
|
|
13909
|
+
return this.setBlockAt(new import_three36.Vector3(posOrX, yOrBlock, z), block);
|
|
13599
13910
|
}
|
|
13600
13911
|
if (isTripleArray(posOrX)) {
|
|
13601
|
-
return this.setBlockAt(new
|
|
13912
|
+
return this.setBlockAt(new import_three36.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
|
|
13602
13913
|
}
|
|
13603
13914
|
return this.placeBlock(posOrX, yOrBlock);
|
|
13604
13915
|
}
|
|
@@ -13619,7 +13930,7 @@ var MineRenderWorld = class {
|
|
|
13619
13930
|
const collect = async (positions2) => {
|
|
13620
13931
|
for (const pos of positions2) changes.set(pos.toArray().join(","), pos);
|
|
13621
13932
|
};
|
|
13622
|
-
const place = (block) => this.placeBlock(new
|
|
13933
|
+
const place = (block) => this.placeBlock(new import_three36.Vector3(...block.position), block, collect);
|
|
13623
13934
|
const keys = /* @__PURE__ */ new Map();
|
|
13624
13935
|
for (const block of multiblock.blocks) {
|
|
13625
13936
|
if (Chunk.isAir(block)) continue;
|
|
@@ -13697,13 +14008,13 @@ var MineRenderWorld = class {
|
|
|
13697
14008
|
for (const pos of positions) {
|
|
13698
14009
|
this.pendingCulling.set(pos.toArray().join(","), pos.clone());
|
|
13699
14010
|
for (const offset of CUBE_FACE_OFFSETS) {
|
|
13700
|
-
const neighbor = pos.clone().add(new
|
|
14011
|
+
const neighbor = pos.clone().add(new import_three36.Vector3(...offset));
|
|
13701
14012
|
this.pendingCulling.set(neighbor.toArray().join(","), neighbor);
|
|
13702
14013
|
}
|
|
13703
14014
|
for (let y = -1; y <= 1; y++) {
|
|
13704
14015
|
for (let z = -1; z <= 1; z++) {
|
|
13705
14016
|
for (let x = -1; x <= 1; x++) {
|
|
13706
|
-
const neighbor = pos.clone().add(new
|
|
14017
|
+
const neighbor = pos.clone().add(new import_three36.Vector3(x, y, z));
|
|
13707
14018
|
if (this.getBlockAt(neighbor)?.object?.fluidKind) {
|
|
13708
14019
|
this.pendingCulling.set(neighbor.toArray().join(","), neighbor);
|
|
13709
14020
|
}
|
|
@@ -13725,7 +14036,7 @@ var MineRenderWorld = class {
|
|
|
13725
14036
|
if (!block) continue;
|
|
13726
14037
|
if (block.object?.fluidKind) {
|
|
13727
14038
|
await block.object.updateFluid((x, y, z) => {
|
|
13728
|
-
const neighbor = pos.clone().add(new
|
|
14039
|
+
const neighbor = pos.clone().add(new import_three36.Vector3(x, y, z));
|
|
13729
14040
|
const section = this.getChunkAt(neighbor);
|
|
13730
14041
|
const object = section?.getBlockAt(neighbor)?.object;
|
|
13731
14042
|
return {
|
|
@@ -13737,7 +14048,7 @@ var MineRenderWorld = class {
|
|
|
13737
14048
|
}
|
|
13738
14049
|
let mask = 0;
|
|
13739
14050
|
for (const [face, offset] of CUBE_FACE_OFFSETS.entries()) {
|
|
13740
|
-
const neighbor = pos.clone().add(new
|
|
14051
|
+
const neighbor = pos.clone().add(new import_three36.Vector3(...offset));
|
|
13741
14052
|
if (this.getChunkAt(neighbor)?.isOccludingAt(neighbor)) {
|
|
13742
14053
|
mask |= 1 << face;
|
|
13743
14054
|
}
|
|
@@ -13771,14 +14082,14 @@ var MineRenderWorld = class {
|
|
|
13771
14082
|
return this._chunks.get(this.worldPosToChunkKey(pos));
|
|
13772
14083
|
}
|
|
13773
14084
|
static worldToScenePosition(pos) {
|
|
13774
|
-
return new
|
|
14085
|
+
return new import_three36.Vector3(
|
|
13775
14086
|
pos.x * 16,
|
|
13776
14087
|
pos.y * 16,
|
|
13777
14088
|
pos.z * 16
|
|
13778
14089
|
);
|
|
13779
14090
|
}
|
|
13780
14091
|
static sceneToWorldPosition(pos) {
|
|
13781
|
-
return new
|
|
14092
|
+
return new import_three36.Vector3(
|
|
13782
14093
|
pos.x / 16,
|
|
13783
14094
|
pos.y / 16,
|
|
13784
14095
|
pos.z / 16
|
|
@@ -13798,10 +14109,10 @@ var MineRenderWorld = class {
|
|
|
13798
14109
|
};
|
|
13799
14110
|
|
|
13800
14111
|
// src/world/SectionMesh.ts
|
|
13801
|
-
var
|
|
14112
|
+
var import_three37 = require("three");
|
|
13802
14113
|
init_CanvasCompat();
|
|
13803
14114
|
init_Materials();
|
|
13804
|
-
var SectionMesh = class _SectionMesh extends
|
|
14115
|
+
var SectionMesh = class _SectionMesh extends import_three37.Group {
|
|
13805
14116
|
constructor() {
|
|
13806
14117
|
super(...arguments);
|
|
13807
14118
|
this.ownedMeshes = [];
|
|
@@ -13874,18 +14185,18 @@ var SectionMesh = class _SectionMesh extends import_three36.Group {
|
|
|
13874
14185
|
for (let corner = 0; corner < 6; corner++) indices.push(start + sourceIndices.getX(face * 6 + corner) - face * 4);
|
|
13875
14186
|
}
|
|
13876
14187
|
}
|
|
13877
|
-
const geometry = new
|
|
13878
|
-
geometry.setAttribute("position", new
|
|
13879
|
-
geometry.setAttribute("normal", new
|
|
13880
|
-
geometry.setAttribute("uv", new
|
|
13881
|
-
geometry.setAttribute("color", new
|
|
14188
|
+
const geometry = new import_three37.BufferGeometry();
|
|
14189
|
+
geometry.setAttribute("position", new import_three37.Float32BufferAttribute(positions, 3));
|
|
14190
|
+
geometry.setAttribute("normal", new import_three37.Float32BufferAttribute(normals, 3));
|
|
14191
|
+
geometry.setAttribute("uv", new import_three37.Float32BufferAttribute(uvs, 2));
|
|
14192
|
+
geometry.setAttribute("color", new import_three37.Float32BufferAttribute(colors, 3));
|
|
13882
14193
|
geometry.setIndex(indices);
|
|
13883
14194
|
geometry.computeBoundingBox();
|
|
13884
14195
|
geometry.computeBoundingSphere();
|
|
13885
14196
|
const material = Materials.createShadedCanvasMaterial(canvas, false);
|
|
13886
14197
|
material.vertexColors = true;
|
|
13887
14198
|
const texture = material.uniforms?.map?.value ?? material.map;
|
|
13888
|
-
const mesh = new
|
|
14199
|
+
const mesh = new import_three37.Mesh(geometry, material);
|
|
13889
14200
|
section.add(mesh);
|
|
13890
14201
|
section.ownedMeshes.push({ mesh, texture });
|
|
13891
14202
|
}
|
|
@@ -13919,10 +14230,10 @@ var Chunk = class _Chunk {
|
|
|
13919
14230
|
}
|
|
13920
14231
|
getBlockAt(posOrX, y, z) {
|
|
13921
14232
|
if (typeof posOrX == "number") {
|
|
13922
|
-
return this.getBlockAt(new
|
|
14233
|
+
return this.getBlockAt(new import_three38.Vector3(posOrX, y, z));
|
|
13923
14234
|
}
|
|
13924
14235
|
if (isTripleArray(posOrX)) {
|
|
13925
|
-
return this.getBlockAt(new
|
|
14236
|
+
return this.getBlockAt(new import_three38.Vector3(posOrX[0], posOrX[1], posOrX[2]));
|
|
13926
14237
|
}
|
|
13927
14238
|
const pos = this.worldPosToChunkPos(posOrX);
|
|
13928
14239
|
const index = _Chunk.chunkPosToBlockIndex(pos);
|
|
@@ -13930,10 +14241,10 @@ var Chunk = class _Chunk {
|
|
|
13930
14241
|
}
|
|
13931
14242
|
async setBlockAt(posOrX, yOrBlock, z, block) {
|
|
13932
14243
|
if (typeof posOrX == "number") {
|
|
13933
|
-
return this.setBlockAt(new
|
|
14244
|
+
return this.setBlockAt(new import_three38.Vector3(posOrX, yOrBlock, z), block);
|
|
13934
14245
|
}
|
|
13935
14246
|
if (isTripleArray(posOrX)) {
|
|
13936
|
-
return this.setBlockAt(new
|
|
14247
|
+
return this.setBlockAt(new import_three38.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
|
|
13937
14248
|
}
|
|
13938
14249
|
const worldPos = posOrX;
|
|
13939
14250
|
const pos = this.worldPosToChunkPos(worldPos);
|
|
@@ -13962,7 +14273,8 @@ var Chunk = class _Chunk {
|
|
|
13962
14273
|
this.data.set(index, void 0);
|
|
13963
14274
|
return void 0;
|
|
13964
14275
|
}
|
|
13965
|
-
const
|
|
14276
|
+
const perBlock = !this.sectionModels || getFluidKind(blockState.key, stored.properties) || blockState.key && BlockEntities.entry(await BlockEntities.getIndex(blockState.key.root), blockState.key.toNamespacedString());
|
|
14277
|
+
const template = perBlock ? void 0 : await this.sectionModels.get(blockState, stored.properties);
|
|
13966
14278
|
if (template) {
|
|
13967
14279
|
this.sectionBlocks.set(index, { index, template, cullMask: 0 });
|
|
13968
14280
|
this.meshDirty = true;
|
|
@@ -14018,7 +14330,7 @@ var Chunk = class _Chunk {
|
|
|
14018
14330
|
}
|
|
14019
14331
|
async clear(onBlocksChanged = this.onBlocksChanged) {
|
|
14020
14332
|
const positions = [...this.renderedBlocks.keys()].map((index) => this.chunkPosToWorldPos(
|
|
14021
|
-
new
|
|
14333
|
+
new import_three38.Vector3(index % 16, Math.floor(index / 256), Math.floor(index / 16) % 16)
|
|
14022
14334
|
));
|
|
14023
14335
|
for (const info of this.renderedBlocks.values()) info.object?.removeFromScene();
|
|
14024
14336
|
this.sectionBlocks.clear();
|
|
@@ -14042,14 +14354,14 @@ var Chunk = class _Chunk {
|
|
|
14042
14354
|
return pos.y * 16 * 16 + pos.z * 16 + pos.x;
|
|
14043
14355
|
}
|
|
14044
14356
|
worldPosToChunkPos(pos) {
|
|
14045
|
-
return new
|
|
14357
|
+
return new import_three38.Vector3(
|
|
14046
14358
|
pos.x - this.x * 16,
|
|
14047
14359
|
pos.y - this.y * 16,
|
|
14048
14360
|
pos.z - this.z * 16
|
|
14049
14361
|
);
|
|
14050
14362
|
}
|
|
14051
14363
|
chunkPosToWorldPos(pos) {
|
|
14052
|
-
return new
|
|
14364
|
+
return new import_three38.Vector3(
|
|
14053
14365
|
this.x * 16 + pos.x,
|
|
14054
14366
|
this.y * 16 + pos.y,
|
|
14055
14367
|
this.z * 16 + pos.z
|
|
@@ -14072,6 +14384,7 @@ var Chunk = class _Chunk {
|
|
|
14072
14384
|
BUILTIN_GENERATED,
|
|
14073
14385
|
BasicAssetKey,
|
|
14074
14386
|
BatchedExecutor,
|
|
14387
|
+
BlockEntities,
|
|
14075
14388
|
BlockObject,
|
|
14076
14389
|
BlockStateResolver,
|
|
14077
14390
|
BlockStates,
|
|
@@ -14093,7 +14406,9 @@ var Chunk = class _Chunk {
|
|
|
14093
14406
|
DefaultBlockStates,
|
|
14094
14407
|
DisplayPosition,
|
|
14095
14408
|
DisplayTransforms,
|
|
14409
|
+
ENTITY_ANIMATION_CHANNELS,
|
|
14096
14410
|
Entities,
|
|
14411
|
+
EntityAnimationPlayer,
|
|
14097
14412
|
EntityObject,
|
|
14098
14413
|
Env,
|
|
14099
14414
|
FluidModelObject,
|
|
@@ -14169,6 +14484,7 @@ var Chunk = class _Chunk {
|
|
|
14169
14484
|
createCanvas,
|
|
14170
14485
|
createFluidGeometry,
|
|
14171
14486
|
createImage,
|
|
14487
|
+
entityAnimationTime,
|
|
14172
14488
|
estimateBytesUsed,
|
|
14173
14489
|
getBlockFluidState,
|
|
14174
14490
|
getFluidKind,
|
|
@@ -14201,6 +14517,8 @@ var Chunk = class _Chunk {
|
|
|
14201
14517
|
mergeVertices,
|
|
14202
14518
|
prefix,
|
|
14203
14519
|
registerNodeEnv,
|
|
14520
|
+
sampleEntityAnimation,
|
|
14521
|
+
sampleEntityKeyframes,
|
|
14204
14522
|
sampleFluid,
|
|
14205
14523
|
serializeBoxGeometryKey,
|
|
14206
14524
|
serializeImageKey,
|