minerender 2.1.0-alpha.60 → 2.1.0-alpha.62
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 +47 -13
- package/dist/browser/index.d.ts +47 -13
- package/dist/browser/index.js +443 -320
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +245 -122
- package/dist/browser/index.mjs.map +1 -1
- package/dist/bundle.js +177 -48
- package/dist/bundle.js.map +1 -1
- package/dist/node/index.d.mts +47 -13
- package/dist/node/index.d.ts +47 -13
- package/dist/node/index.js +445 -320
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +245 -122
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/browser/index.js
CHANGED
|
@@ -1452,7 +1452,7 @@ var init_Models = __esm({
|
|
|
1452
1452
|
}
|
|
1453
1453
|
static async getItemModel(key) {
|
|
1454
1454
|
const itemKey = new AssetKey(key.namespace, key.path, "items", void 0, key.rootType, ".json", key.root);
|
|
1455
|
-
const model = await this.PERSISTENT_CACHE.getOrLoad(AssetLoader.persistentKey(itemKey.serialize())
|
|
1455
|
+
const model = await this.PERSISTENT_CACHE.getOrLoad(`item-v2:${AssetLoader.persistentKey(itemKey.serialize())}`, async () => {
|
|
1456
1456
|
const result = await AssetLoader.getFirst([itemKey, key], "json" /* JSON */);
|
|
1457
1457
|
if (!result) return void 0;
|
|
1458
1458
|
if (result.key.assetType !== "items") return { ...result.asset, key };
|
|
@@ -1461,7 +1461,7 @@ var init_Models = __esm({
|
|
|
1461
1461
|
modelKey.root = key.root;
|
|
1462
1462
|
const model2 = await this.getRaw(modelKey);
|
|
1463
1463
|
if (!model2) throw new Error(`Item ${key.toNamespacedString()} references missing model ${selected.model}`);
|
|
1464
|
-
return selected.special
|
|
1464
|
+
return { ...model2, ...selected.special && { special: selected.special }, ...selected.tints && { tints: selected.tints } };
|
|
1465
1465
|
});
|
|
1466
1466
|
return model ? { ...model, key: Object.assign(new AssetKey("", ""), model.key) } : void 0;
|
|
1467
1467
|
}
|
|
@@ -1472,7 +1472,7 @@ var init_Models = __esm({
|
|
|
1472
1472
|
}
|
|
1473
1473
|
switch (node.type.replace(/^minecraft:/, "")) {
|
|
1474
1474
|
case "model":
|
|
1475
|
-
if (typeof node.model === "string" && node.model) return { model: node.model };
|
|
1475
|
+
if (typeof node.model === "string" && node.model) return { model: node.model, tints: node.tints };
|
|
1476
1476
|
break;
|
|
1477
1477
|
case "special": {
|
|
1478
1478
|
if (!node.base || !node.model || typeof node.model !== "object") break;
|
|
@@ -3238,11 +3238,11 @@ var init_Entities = __esm({
|
|
|
3238
3238
|
return { ...layers[names[0]], id: model.id, layers, ...model.transform && { transform: model.transform } };
|
|
3239
3239
|
}
|
|
3240
3240
|
/**
|
|
3241
|
-
*
|
|
3241
|
+
* Native and sampled vanilla clips by name, or undefined when the model or selected version has none.
|
|
3242
3242
|
*/
|
|
3243
3243
|
static async getAnimations(modelKey) {
|
|
3244
3244
|
const path = isAssetKey(modelKey) ? modelKey.getFullPath() : modelKey.path;
|
|
3245
|
-
const key = new AssetKey(modelKey.namespace, path, void 0, void 0, "entity-models/animations", ".json");
|
|
3245
|
+
const key = new AssetKey(modelKey.namespace, path, void 0, void 0, "entity-models/animations", ".json", isAssetKey(modelKey) ? modelKey.root : void 0);
|
|
3246
3246
|
const file = await Caching.entityAnimationCache.get(key.serialize(), () => AssetLoader.get(key, "json" /* JSON */));
|
|
3247
3247
|
return file?.animations;
|
|
3248
3248
|
}
|
|
@@ -3292,7 +3292,7 @@ function sampleEntityKeyframes(keyframes, time) {
|
|
|
3292
3292
|
let low = 0, high = keyframes.length;
|
|
3293
3293
|
while (low < high) {
|
|
3294
3294
|
const middle = low + high >>> 1;
|
|
3295
|
-
if (time
|
|
3295
|
+
if (time < keyframes[middle].time) high = middle;
|
|
3296
3296
|
else low = middle + 1;
|
|
3297
3297
|
}
|
|
3298
3298
|
const a = Math.max(0, low - 1);
|
|
@@ -3331,9 +3331,10 @@ var init_EntityAnimation = __esm({
|
|
|
3331
3331
|
});
|
|
3332
3332
|
|
|
3333
3333
|
// src/entity/scene/EntityAnimationPlayer.ts
|
|
3334
|
-
var ZERO, EntityAnimationPlayer;
|
|
3334
|
+
var import_three11, ZERO, EntityAnimationPlayer;
|
|
3335
3335
|
var init_EntityAnimationPlayer = __esm({
|
|
3336
3336
|
"src/entity/scene/EntityAnimationPlayer.ts"() {
|
|
3337
|
+
import_three11 = require("three");
|
|
3337
3338
|
init_EntityAnimation();
|
|
3338
3339
|
ZERO = [0, 0, 0];
|
|
3339
3340
|
EntityAnimationPlayer = class {
|
|
@@ -3350,25 +3351,45 @@ var init_EntityAnimationPlayer = __esm({
|
|
|
3350
3351
|
return this._time;
|
|
3351
3352
|
}
|
|
3352
3353
|
/**
|
|
3353
|
-
* Starts an animation on
|
|
3354
|
-
*
|
|
3354
|
+
* Starts an animation on matching named parts. Supplied baked poses are the baseline for offsets;
|
|
3355
|
+
* without them, the current pose is used. Stopping restores the pose from before playback.
|
|
3355
3356
|
*/
|
|
3356
|
-
play(layers, animation, options = {}) {
|
|
3357
|
+
play(layers, animation, options = {}, poses) {
|
|
3357
3358
|
this.stop();
|
|
3358
3359
|
this._animation = animation;
|
|
3359
3360
|
this._time = options.time ?? 0;
|
|
3360
3361
|
this.loop = options.loop ?? animation.loop;
|
|
3361
3362
|
this.speed = options.speed ?? 1;
|
|
3362
3363
|
for (const layer of layers) {
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3364
|
+
const objects = [];
|
|
3365
|
+
if (poses) {
|
|
3366
|
+
layer.traverse((object) => {
|
|
3367
|
+
if (poses.has(object)) objects.push(object);
|
|
3368
|
+
});
|
|
3369
|
+
} else {
|
|
3370
|
+
for (const bone of Object.keys(animation.bones)) {
|
|
3371
|
+
const object = layer.getObjectByName(`group:${bone}`);
|
|
3372
|
+
if (object) objects.push(object);
|
|
3373
|
+
}
|
|
3374
|
+
}
|
|
3375
|
+
for (const object of objects) {
|
|
3376
|
+
const bone = object.name.slice("group:".length);
|
|
3377
|
+
const pose = poses?.get(object);
|
|
3378
|
+
this.parts.push({
|
|
3379
|
+
bone,
|
|
3380
|
+
object,
|
|
3381
|
+
position: object.position.clone(),
|
|
3382
|
+
rotation: object.rotation.clone(),
|
|
3383
|
+
scale: object.scale.clone(),
|
|
3384
|
+
basePosition: pose ? new import_three11.Vector3(...pose.offset) : object.position.clone(),
|
|
3385
|
+
baseRotation: pose ? new import_three11.Euler(...pose.rotation, "ZYX") : object.rotation.clone(),
|
|
3386
|
+
baseScale: pose ? new import_three11.Vector3(...pose.scale ?? [1, 1, 1]) : object.scale.clone()
|
|
3387
|
+
});
|
|
3367
3388
|
}
|
|
3368
3389
|
}
|
|
3369
3390
|
this.apply();
|
|
3370
3391
|
}
|
|
3371
|
-
/** Restores the
|
|
3392
|
+
/** Restores the poses from before playback. Returns whether an animation was active. */
|
|
3372
3393
|
stop() {
|
|
3373
3394
|
if (!this._animation) return false;
|
|
3374
3395
|
for (const part of this.parts) {
|
|
@@ -3397,10 +3418,10 @@ var init_EntityAnimationPlayer = __esm({
|
|
|
3397
3418
|
apply() {
|
|
3398
3419
|
const pose = sampleEntityAnimation(this._animation, this._time, this.loop);
|
|
3399
3420
|
for (const part of this.parts) {
|
|
3400
|
-
const { position = ZERO, rotation = ZERO, scale = ZERO } = pose[part.bone];
|
|
3401
|
-
part.object.position.set(part.
|
|
3402
|
-
part.object.rotation.set(part.
|
|
3403
|
-
part.object.scale.set(part.
|
|
3421
|
+
const { position = ZERO, rotation = ZERO, scale = ZERO } = pose[part.bone] ?? {};
|
|
3422
|
+
part.object.position.set(part.basePosition.x + position[0], part.basePosition.y + position[1], part.basePosition.z + position[2]);
|
|
3423
|
+
part.object.rotation.set(part.baseRotation.x + rotation[0], part.baseRotation.y + rotation[1], part.baseRotation.z + rotation[2], part.baseRotation.order);
|
|
3424
|
+
part.object.scale.set(part.baseScale.x + scale[0], part.baseScale.y + scale[1], part.baseScale.z + scale[2]);
|
|
3404
3425
|
}
|
|
3405
3426
|
}
|
|
3406
3427
|
};
|
|
@@ -3470,10 +3491,10 @@ var init_InstanceReference = __esm({
|
|
|
3470
3491
|
function isSceneObject(obj) {
|
|
3471
3492
|
return obj.isSceneObject;
|
|
3472
3493
|
}
|
|
3473
|
-
var
|
|
3494
|
+
var import_three12, import_ts_deepmerge3, p6, _SceneObject, SceneObject;
|
|
3474
3495
|
var init_SceneObject = __esm({
|
|
3475
3496
|
"src/renderer/SceneObject.ts"() {
|
|
3476
|
-
|
|
3497
|
+
import_three12 = require("three");
|
|
3477
3498
|
init_Geometries();
|
|
3478
3499
|
init_UVMapper();
|
|
3479
3500
|
init_Axis();
|
|
@@ -3485,7 +3506,7 @@ var init_SceneObject = __esm({
|
|
|
3485
3506
|
import_ts_deepmerge3 = __toESM(require_dist());
|
|
3486
3507
|
init_log();
|
|
3487
3508
|
p6 = prefix("SceneObject");
|
|
3488
|
-
_SceneObject = class _SceneObject extends
|
|
3509
|
+
_SceneObject = class _SceneObject extends import_three12.Object3D {
|
|
3489
3510
|
constructor(options) {
|
|
3490
3511
|
super();
|
|
3491
3512
|
this.isSceneObject = true;
|
|
@@ -3529,7 +3550,7 @@ var init_SceneObject = __esm({
|
|
|
3529
3550
|
return group;
|
|
3530
3551
|
}
|
|
3531
3552
|
createGroup(name, x = 0, y = 0, z = 0, offsetAxis, offset = 0) {
|
|
3532
|
-
const obj = new
|
|
3553
|
+
const obj = new import_three12.Object3D();
|
|
3533
3554
|
if (name) {
|
|
3534
3555
|
obj.name = `group:${name}`;
|
|
3535
3556
|
}
|
|
@@ -3579,7 +3600,7 @@ var init_SceneObject = __esm({
|
|
|
3579
3600
|
return mesh;
|
|
3580
3601
|
}
|
|
3581
3602
|
createMesh(name, geometry, material, offsetAxis, offset = 0) {
|
|
3582
|
-
const mesh = new
|
|
3603
|
+
const mesh = new import_three12.Mesh(geometry, material);
|
|
3583
3604
|
if (name) {
|
|
3584
3605
|
mesh.name = `mesh:${name}`;
|
|
3585
3606
|
}
|
|
@@ -3591,7 +3612,7 @@ var init_SceneObject = __esm({
|
|
|
3591
3612
|
return mesh;
|
|
3592
3613
|
}
|
|
3593
3614
|
createInstancedMesh(name, geometry, material, count) {
|
|
3594
|
-
const mesh = new
|
|
3615
|
+
const mesh = new import_three12.InstancedMesh(geometry, material, count);
|
|
3595
3616
|
mesh.count = 0;
|
|
3596
3617
|
this.instanceMesh = mesh;
|
|
3597
3618
|
this._isInstanced = true;
|
|
@@ -3671,11 +3692,11 @@ var init_SceneObject = __esm({
|
|
|
3671
3692
|
this._instanceCounter = this.instanceReferences.size;
|
|
3672
3693
|
mesh.count = Math.max(mesh.count, index + 1);
|
|
3673
3694
|
if (mesh.instanceColor) {
|
|
3674
|
-
mesh.setColorAt(index, new
|
|
3695
|
+
mesh.setColorAt(index, new import_three12.Color(16777215));
|
|
3675
3696
|
mesh.instanceColor.needsUpdate = true;
|
|
3676
3697
|
}
|
|
3677
3698
|
if (this._scene) this._scene.stats.instanceCount++;
|
|
3678
|
-
this.setMatrixAt(index, new
|
|
3699
|
+
this.setMatrixAt(index, new import_three12.Matrix4());
|
|
3679
3700
|
return reference;
|
|
3680
3701
|
}
|
|
3681
3702
|
/** Returns the live reference for a raycast hit on this object's instance mesh. */
|
|
@@ -3688,7 +3709,7 @@ var init_SceneObject = __esm({
|
|
|
3688
3709
|
removeInstanceAt(index) {
|
|
3689
3710
|
if (!this.instanceReferences.has(index)) return;
|
|
3690
3711
|
const mesh = this.instanceMesh;
|
|
3691
|
-
this.setMatrixAt(index, new
|
|
3712
|
+
this.setMatrixAt(index, new import_three12.Matrix4().makeScale(0, 0, 0));
|
|
3692
3713
|
this.instanceReferences.delete(index);
|
|
3693
3714
|
this.freeInstanceIndices.push(index);
|
|
3694
3715
|
this._instanceCounter = this.instanceReferences.size;
|
|
@@ -3701,7 +3722,7 @@ var init_SceneObject = __esm({
|
|
|
3701
3722
|
const grow = (attribute, fill) => {
|
|
3702
3723
|
const array = new Float32Array(capacity * attribute.itemSize).fill(fill);
|
|
3703
3724
|
array.set(attribute.array);
|
|
3704
|
-
return new
|
|
3725
|
+
return new import_three12.InstancedBufferAttribute(array, attribute.itemSize, attribute.normalized, attribute.meshPerAttribute).setUsage(attribute.usage);
|
|
3705
3726
|
};
|
|
3706
3727
|
const matrix = grow(mesh.instanceMatrix, 0);
|
|
3707
3728
|
const color = mesh.instanceColor ? grow(mesh.instanceColor, 1) : null;
|
|
@@ -3718,7 +3739,7 @@ var init_SceneObject = __esm({
|
|
|
3718
3739
|
}
|
|
3719
3740
|
//</editor-fold>
|
|
3720
3741
|
//<editor-fold desc="TRANSFORMATION">
|
|
3721
|
-
getMatrixAt(index, matrix = new
|
|
3742
|
+
getMatrixAt(index, matrix = new import_three12.Matrix4()) {
|
|
3722
3743
|
if (!this.instanceReferences.has(index)) throw new MineRenderError("Instance is not active");
|
|
3723
3744
|
this.instanceMesh.getMatrixAt(index, matrix);
|
|
3724
3745
|
return matrix;
|
|
@@ -3734,16 +3755,16 @@ var init_SceneObject = __esm({
|
|
|
3734
3755
|
}
|
|
3735
3756
|
setPositionRotationScaleAt(index, position, rotation, scale) {
|
|
3736
3757
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3737
|
-
const oldPosition = new
|
|
3738
|
-
const oldRotation = new
|
|
3739
|
-
const oldScale = new
|
|
3740
|
-
const matrix = new
|
|
3758
|
+
const oldPosition = new import_three12.Vector3();
|
|
3759
|
+
const oldRotation = new import_three12.Quaternion();
|
|
3760
|
+
const oldScale = new import_three12.Vector3();
|
|
3761
|
+
const matrix = new import_three12.Matrix4();
|
|
3741
3762
|
if (!scale || !rotation || !position) {
|
|
3742
3763
|
this.getMatrixAt(index, matrix).decompose(oldPosition, oldRotation, oldScale);
|
|
3743
3764
|
}
|
|
3744
3765
|
matrix.compose(
|
|
3745
3766
|
position ? position : oldPosition,
|
|
3746
|
-
rotation ? new
|
|
3767
|
+
rotation ? new import_three12.Quaternion().setFromEuler(rotation) : oldRotation,
|
|
3747
3768
|
scale ? scale : oldScale
|
|
3748
3769
|
);
|
|
3749
3770
|
this.setMatrixAt(index, matrix);
|
|
@@ -3752,7 +3773,7 @@ var init_SceneObject = __esm({
|
|
|
3752
3773
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3753
3774
|
this.setPositionRotationScaleAt(index, position);
|
|
3754
3775
|
}
|
|
3755
|
-
getPositionAt(index, vector = new
|
|
3776
|
+
getPositionAt(index, vector = new import_three12.Vector3()) {
|
|
3756
3777
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3757
3778
|
const matrix = this.getMatrixAt(index);
|
|
3758
3779
|
vector.setFromMatrixPosition(matrix);
|
|
@@ -3762,17 +3783,17 @@ var init_SceneObject = __esm({
|
|
|
3762
3783
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3763
3784
|
this.setPositionRotationScaleAt(index, void 0, rotation, void 0);
|
|
3764
3785
|
}
|
|
3765
|
-
getRotationAt(index, euler = new
|
|
3786
|
+
getRotationAt(index, euler = new import_three12.Euler()) {
|
|
3766
3787
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3767
|
-
const rotation = new
|
|
3768
|
-
this.getMatrixAt(index).decompose(new
|
|
3788
|
+
const rotation = new import_three12.Quaternion();
|
|
3789
|
+
this.getMatrixAt(index).decompose(new import_three12.Vector3(), rotation, new import_three12.Vector3());
|
|
3769
3790
|
return euler.setFromQuaternion(rotation);
|
|
3770
3791
|
}
|
|
3771
3792
|
setScaleAt(index, scale) {
|
|
3772
3793
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3773
3794
|
this.setPositionRotationScaleAt(index, void 0, void 0, scale);
|
|
3774
3795
|
}
|
|
3775
|
-
getScaleAt(index, vector = new
|
|
3796
|
+
getScaleAt(index, vector = new import_three12.Vector3()) {
|
|
3776
3797
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3777
3798
|
const matrix = this.getMatrixAt(index);
|
|
3778
3799
|
vector.setFromMatrixScale(matrix);
|
|
@@ -3907,13 +3928,13 @@ var init_SceneObject = __esm({
|
|
|
3907
3928
|
function isEntityObject(obj) {
|
|
3908
3929
|
return obj.isEntityObject;
|
|
3909
3930
|
}
|
|
3910
|
-
var import_ts_deepmerge4,
|
|
3931
|
+
var import_ts_deepmerge4, import_three14, _EntityObject, EntityObject;
|
|
3911
3932
|
var init_EntityObject = __esm({
|
|
3912
3933
|
"src/entity/scene/EntityObject.ts"() {
|
|
3913
3934
|
init_SceneObject();
|
|
3914
3935
|
init_Caching();
|
|
3915
3936
|
import_ts_deepmerge4 = __toESM(require_dist());
|
|
3916
|
-
|
|
3937
|
+
import_three14 = require("three");
|
|
3917
3938
|
init_Ticker();
|
|
3918
3939
|
init_model();
|
|
3919
3940
|
init_ModelTextures();
|
|
@@ -3934,7 +3955,8 @@ var init_EntityObject = __esm({
|
|
|
3934
3955
|
this.scrollMaterials = [];
|
|
3935
3956
|
/** Entity age in ticks, as vanilla's `ageInTicks`; drives the scrolling render modes. */
|
|
3936
3957
|
this.age = 0;
|
|
3937
|
-
this.
|
|
3958
|
+
this.animationPlayers = [];
|
|
3959
|
+
this.partPoses = /* @__PURE__ */ new Map();
|
|
3938
3960
|
this.options = (0, import_ts_deepmerge4.default)({}, _EntityObject.DEFAULT_OPTIONS, options ?? {});
|
|
3939
3961
|
this.addEventListener("added", () => this.updateScrollSubscription());
|
|
3940
3962
|
this.addEventListener("removed", () => this.updateScrollSubscription());
|
|
@@ -3951,7 +3973,8 @@ var init_EntityObject = __esm({
|
|
|
3951
3973
|
for (const geometry of this.geometries) geometry.dispose();
|
|
3952
3974
|
this.geometries.clear();
|
|
3953
3975
|
for (const dispose of this.disposeWireframes.splice(0)) dispose();
|
|
3954
|
-
this.
|
|
3976
|
+
for (const player of this.animationPlayers.splice(0)) player.clear();
|
|
3977
|
+
this.partPoses.clear();
|
|
3955
3978
|
super.disposeAndRemoveAllChildren();
|
|
3956
3979
|
}
|
|
3957
3980
|
clearScrollMaterials() {
|
|
@@ -3983,36 +4006,61 @@ var init_EntityObject = __esm({
|
|
|
3983
4006
|
this.notifyDirty();
|
|
3984
4007
|
}
|
|
3985
4008
|
//<editor-fold desc="ANIMATION">
|
|
3986
|
-
/** The
|
|
4009
|
+
/** The first active clip, until playback is stopped or the object is disposed. */
|
|
3987
4010
|
get animation() {
|
|
3988
|
-
return this.
|
|
4011
|
+
return this.animationPlayers[0]?.animation;
|
|
4012
|
+
}
|
|
4013
|
+
/** Clips playing together, each targeting a separate geometry layer. */
|
|
4014
|
+
get activeAnimations() {
|
|
4015
|
+
return this.animationPlayers.map((player) => player.animation);
|
|
3989
4016
|
}
|
|
3990
4017
|
/** Seconds since the animation started, before looping. */
|
|
3991
4018
|
get animationTime() {
|
|
3992
|
-
return this.
|
|
4019
|
+
return this.animationPlayers[0]?.time ?? 0;
|
|
3993
4020
|
}
|
|
3994
4021
|
/**
|
|
3995
|
-
*
|
|
3996
|
-
*
|
|
4022
|
+
* Plays a clip from {@link Entities.getAnimations}, replacing all active clips.
|
|
4023
|
+
* Offsets apply to the baked pose in the clip's layer (`main` by default), including repeated draws of that layer.
|
|
3997
4024
|
* The object owns no clock: call {@link advanceAnimation} per frame, or {@link setAnimationTime}.
|
|
3998
4025
|
*/
|
|
3999
4026
|
playAnimation(animation, options) {
|
|
4027
|
+
this.playAnimations([animation], options);
|
|
4028
|
+
}
|
|
4029
|
+
/** Plays one clip per selected geometry layer, with a shared clock and no blending between clips. */
|
|
4030
|
+
playAnimations(animations, options) {
|
|
4031
|
+
const targets = /* @__PURE__ */ new Set();
|
|
4032
|
+
const selections = animations.map((animation) => {
|
|
4033
|
+
const layer = animation.layer ?? "main";
|
|
4034
|
+
if (targets.has(layer)) throw new Error(`Multiple animations target layer "${layer}"`);
|
|
4035
|
+
targets.add(layer);
|
|
4036
|
+
const names = Object.keys(this.entityLayers).filter((name) => name.split("#")[0] === layer);
|
|
4037
|
+
if (!names.length) throw new Error(`Entity ${this.entity.id} has no selected animation layer "${layer}"`);
|
|
4038
|
+
return { animation, names };
|
|
4039
|
+
});
|
|
4000
4040
|
this.createMeshes();
|
|
4001
|
-
|
|
4002
|
-
|
|
4041
|
+
this.stopAnimation();
|
|
4042
|
+
for (const { animation, names } of selections) {
|
|
4043
|
+
const player = new EntityAnimationPlayer();
|
|
4044
|
+
player.play(names.map((name) => this.getLayerGroup(name)), animation, options, this.partPoses);
|
|
4045
|
+
this.animationPlayers.push(player);
|
|
4046
|
+
}
|
|
4003
4047
|
this.notifyDirty();
|
|
4004
4048
|
}
|
|
4005
|
-
/** Stops
|
|
4049
|
+
/** Stops all clips and restores the poses from before playback. */
|
|
4006
4050
|
stopAnimation() {
|
|
4007
|
-
|
|
4051
|
+
const players = this.animationPlayers.splice(0);
|
|
4052
|
+
for (const player of players) player.stop();
|
|
4053
|
+
if (players.length) this.notifyDirty();
|
|
4008
4054
|
}
|
|
4009
4055
|
/** Poses the object at an explicit time in seconds. Has no effect without an animation. */
|
|
4010
4056
|
setAnimationTime(seconds) {
|
|
4011
|
-
|
|
4057
|
+
for (const player of this.animationPlayers) player.setTime(seconds);
|
|
4058
|
+
if (this.animationPlayers.length) this.notifyDirty();
|
|
4012
4059
|
}
|
|
4013
4060
|
/** Advances the animation by a frame delta in seconds, scaled by its speed. Has no effect without an animation. */
|
|
4014
4061
|
advanceAnimation(deltaSeconds) {
|
|
4015
|
-
|
|
4062
|
+
for (const player of this.animationPlayers) player.advance(deltaSeconds);
|
|
4063
|
+
if (this.animationPlayers.length) this.notifyDirty();
|
|
4016
4064
|
}
|
|
4017
4065
|
//</editor-fold>
|
|
4018
4066
|
getLayerGroup(name) {
|
|
@@ -4044,14 +4092,14 @@ var init_EntityObject = __esm({
|
|
|
4044
4092
|
}
|
|
4045
4093
|
createMeshes(force = false) {
|
|
4046
4094
|
if (this.meshesCreated && !force) return;
|
|
4047
|
-
const modelRoot = new
|
|
4095
|
+
const modelRoot = new import_three14.Object3D();
|
|
4048
4096
|
const transform = this.options.flip === void 0 ? this.entity.transform : void 0;
|
|
4049
4097
|
if (transform) {
|
|
4050
4098
|
for (const op of transform) {
|
|
4051
|
-
const matrix = new
|
|
4099
|
+
const matrix = new import_three14.Matrix4();
|
|
4052
4100
|
if ("scale" in op) matrix.makeScale(...op.scale);
|
|
4053
4101
|
else if ("translate" in op) matrix.makeTranslation(...op.translate);
|
|
4054
|
-
else matrix.makeRotationFromEuler(new
|
|
4102
|
+
else matrix.makeRotationFromEuler(new import_three14.Euler(...op.rotate, "ZYX"));
|
|
4055
4103
|
modelRoot.matrix.multiply(matrix);
|
|
4056
4104
|
}
|
|
4057
4105
|
modelRoot.matrixAutoUpdate = false;
|
|
@@ -4072,6 +4120,7 @@ var init_EntityObject = __esm({
|
|
|
4072
4120
|
anchor.position.fromArray(part.pose.offset);
|
|
4073
4121
|
anchor.rotation.set(...part.pose.rotation, "ZYX");
|
|
4074
4122
|
anchor.scale.fromArray(part.pose.scale ?? [1, 1, 1]);
|
|
4123
|
+
this.partPoses.set(anchor, part.pose);
|
|
4075
4124
|
parent.add(anchor);
|
|
4076
4125
|
const size = part.texture ?? textureSize;
|
|
4077
4126
|
for (const cube of part.cubes) {
|
|
@@ -4107,7 +4156,7 @@ var init_EntityObject = __esm({
|
|
|
4107
4156
|
const tint = layer.tint === void 0 ? void 0 : this.options.tints?.[layer.tint];
|
|
4108
4157
|
const scroll = Materials.entityModeScroll(mode);
|
|
4109
4158
|
const assetKeyStr = this.getTextureKey(layer).serialize();
|
|
4110
|
-
const keyStr = `entity:${mode}:${tint === void 0 ? "" : new
|
|
4159
|
+
const keyStr = `entity:${mode}:${tint === void 0 ? "" : new import_three14.Color(tint).getHexString()}:${assetKeyStr}`;
|
|
4111
4160
|
let mat = scroll ? void 0 : Caching.materialCache.getIfPresent(keyStr);
|
|
4112
4161
|
if (!mat) {
|
|
4113
4162
|
const cachedAsset = Caching.textureAssetCache.getIfPresent(assetKeyStr);
|
|
@@ -4150,7 +4199,7 @@ function mergeBufferGeometries(geometries, useGroups = false) {
|
|
|
4150
4199
|
const attributes = {};
|
|
4151
4200
|
const morphAttributes = {};
|
|
4152
4201
|
const morphTargetsRelative = geometries[0].morphTargetsRelative;
|
|
4153
|
-
const mergedGeometry = new
|
|
4202
|
+
const mergedGeometry = new import_three21.BufferGeometry();
|
|
4154
4203
|
let offset = 0;
|
|
4155
4204
|
for (let i = 0; i < geometries.length; ++i) {
|
|
4156
4205
|
const geometry = geometries[i];
|
|
@@ -4274,7 +4323,7 @@ function mergeBufferAttributes(attributes) {
|
|
|
4274
4323
|
array.set(attributes[i].array, offset);
|
|
4275
4324
|
offset += attributes[i].array.length;
|
|
4276
4325
|
}
|
|
4277
|
-
return new
|
|
4326
|
+
return new import_three21.BufferAttribute(array, itemSize, normalized);
|
|
4278
4327
|
}
|
|
4279
4328
|
function interleaveAttributes(attributes) {
|
|
4280
4329
|
let TypedArray;
|
|
@@ -4290,7 +4339,7 @@ function interleaveAttributes(attributes) {
|
|
|
4290
4339
|
arrayLength += attribute.array.length;
|
|
4291
4340
|
stride += attribute.itemSize;
|
|
4292
4341
|
}
|
|
4293
|
-
const interleavedBuffer = new
|
|
4342
|
+
const interleavedBuffer = new import_three21.InterleavedBuffer(new TypedArray(arrayLength), stride);
|
|
4294
4343
|
let offset = 0;
|
|
4295
4344
|
const res = [];
|
|
4296
4345
|
const getters = ["getX", "getY", "getZ", "getW"];
|
|
@@ -4299,7 +4348,7 @@ function interleaveAttributes(attributes) {
|
|
|
4299
4348
|
const attribute = attributes[j];
|
|
4300
4349
|
const itemSize = attribute.itemSize;
|
|
4301
4350
|
const count = attribute.count;
|
|
4302
|
-
const iba = new
|
|
4351
|
+
const iba = new import_three21.InterleavedBufferAttribute(interleavedBuffer, itemSize, offset, attribute.normalized);
|
|
4303
4352
|
res.push(iba);
|
|
4304
4353
|
offset += itemSize;
|
|
4305
4354
|
for (let c = 0; c < count; c++) {
|
|
@@ -4383,13 +4432,13 @@ function mergeVertices(geometry, tolerance = 1e-4) {
|
|
|
4383
4432
|
const name = attributeNames[i];
|
|
4384
4433
|
const oldAttribute = geometry.getAttribute(name);
|
|
4385
4434
|
const buffer = new oldAttribute.array.constructor(attrArrays[name]);
|
|
4386
|
-
const attribute = new
|
|
4435
|
+
const attribute = new import_three21.BufferAttribute(buffer, oldAttribute.itemSize, oldAttribute.normalized);
|
|
4387
4436
|
result.setAttribute(name, attribute);
|
|
4388
4437
|
if (name in morphAttrsArrays) {
|
|
4389
4438
|
for (let j = 0; j < morphAttrsArrays[name].length; j++) {
|
|
4390
4439
|
const oldMorphAttribute = geometry.morphAttributes[name][j];
|
|
4391
4440
|
const buffer2 = new oldMorphAttribute.array.constructor(morphAttrsArrays[name][j]);
|
|
4392
|
-
const morphAttribute = new
|
|
4441
|
+
const morphAttribute = new import_three21.BufferAttribute(buffer2, oldMorphAttribute.itemSize, oldMorphAttribute.normalized);
|
|
4393
4442
|
result.morphAttributes[name][j] = morphAttribute;
|
|
4394
4443
|
}
|
|
4395
4444
|
}
|
|
@@ -4398,11 +4447,11 @@ function mergeVertices(geometry, tolerance = 1e-4) {
|
|
|
4398
4447
|
return result;
|
|
4399
4448
|
}
|
|
4400
4449
|
function toTrianglesDrawMode(geometry, drawMode) {
|
|
4401
|
-
if (drawMode ===
|
|
4450
|
+
if (drawMode === import_three21.TrianglesDrawMode) {
|
|
4402
4451
|
console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles.");
|
|
4403
4452
|
return geometry;
|
|
4404
4453
|
}
|
|
4405
|
-
if (drawMode ===
|
|
4454
|
+
if (drawMode === import_three21.TriangleFanDrawMode || drawMode === import_three21.TriangleStripDrawMode) {
|
|
4406
4455
|
let index = geometry.getIndex();
|
|
4407
4456
|
if (index === null) {
|
|
4408
4457
|
const indices = [];
|
|
@@ -4420,7 +4469,7 @@ function toTrianglesDrawMode(geometry, drawMode) {
|
|
|
4420
4469
|
}
|
|
4421
4470
|
const numberOfTriangles = index.count - 2;
|
|
4422
4471
|
const newIndices = [];
|
|
4423
|
-
if (drawMode ===
|
|
4472
|
+
if (drawMode === import_three21.TriangleFanDrawMode) {
|
|
4424
4473
|
for (let i = 1; i <= numberOfTriangles; i++) {
|
|
4425
4474
|
newIndices.push(index.getX(0));
|
|
4426
4475
|
newIndices.push(index.getX(i));
|
|
@@ -4456,15 +4505,15 @@ function computeMorphedAttributes(object) {
|
|
|
4456
4505
|
console.error("THREE.BufferGeometryUtils: Geometry is not of type BufferGeometry.");
|
|
4457
4506
|
return null;
|
|
4458
4507
|
}
|
|
4459
|
-
const _vA = new
|
|
4460
|
-
const _vB = new
|
|
4461
|
-
const _vC = new
|
|
4462
|
-
const _tempA = new
|
|
4463
|
-
const _tempB = new
|
|
4464
|
-
const _tempC = new
|
|
4465
|
-
const _morphA = new
|
|
4466
|
-
const _morphB = new
|
|
4467
|
-
const _morphC = new
|
|
4508
|
+
const _vA = new import_three21.Vector3();
|
|
4509
|
+
const _vB = new import_three21.Vector3();
|
|
4510
|
+
const _vC = new import_three21.Vector3();
|
|
4511
|
+
const _tempA = new import_three21.Vector3();
|
|
4512
|
+
const _tempB = new import_three21.Vector3();
|
|
4513
|
+
const _tempC = new import_three21.Vector3();
|
|
4514
|
+
const _morphA = new import_three21.Vector3();
|
|
4515
|
+
const _morphB = new import_three21.Vector3();
|
|
4516
|
+
const _morphC = new import_three21.Vector3();
|
|
4468
4517
|
function _calculateMorphedAttributeData(object2, material2, attribute, morphAttribute, morphTargetsRelative2, a2, b2, c2, modifiedAttributeArray) {
|
|
4469
4518
|
_vA.fromBufferAttribute(attribute, a2);
|
|
4470
4519
|
_vB.fromBufferAttribute(attribute, b2);
|
|
@@ -4659,8 +4708,8 @@ function computeMorphedAttributes(object) {
|
|
|
4659
4708
|
}
|
|
4660
4709
|
}
|
|
4661
4710
|
}
|
|
4662
|
-
const morphedPositionAttribute = new
|
|
4663
|
-
const morphedNormalAttribute = new
|
|
4711
|
+
const morphedPositionAttribute = new import_three21.Float32BufferAttribute(modifiedPosition, 3);
|
|
4712
|
+
const morphedNormalAttribute = new import_three21.Float32BufferAttribute(modifiedNormal, 3);
|
|
4664
4713
|
return {
|
|
4665
4714
|
positionAttribute,
|
|
4666
4715
|
normalAttribute,
|
|
@@ -4668,24 +4717,24 @@ function computeMorphedAttributes(object) {
|
|
|
4668
4717
|
morphedNormalAttribute
|
|
4669
4718
|
};
|
|
4670
4719
|
}
|
|
4671
|
-
var
|
|
4720
|
+
var import_three21;
|
|
4672
4721
|
var init_BufferGeometryUtils = __esm({
|
|
4673
4722
|
"src/three/BufferGeometryUtils.js"() {
|
|
4674
|
-
|
|
4723
|
+
import_three21 = require("three");
|
|
4675
4724
|
}
|
|
4676
4725
|
});
|
|
4677
4726
|
|
|
4678
4727
|
// src/model/ModelCulling.ts
|
|
4679
|
-
var
|
|
4728
|
+
var import_three22, ModelCulling;
|
|
4680
4729
|
var init_ModelCulling = __esm({
|
|
4681
4730
|
"src/model/ModelCulling.ts"() {
|
|
4682
|
-
|
|
4731
|
+
import_three22 = require("three");
|
|
4683
4732
|
init_CubeFace();
|
|
4684
4733
|
ModelCulling = class {
|
|
4685
4734
|
static toLocalMask(worldMask, rotation) {
|
|
4686
4735
|
let localMask = 0;
|
|
4687
4736
|
for (const [localFace, offset] of CUBE_FACE_OFFSETS.entries()) {
|
|
4688
|
-
const normal = new
|
|
4737
|
+
const normal = new import_three22.Vector3(...offset).applyEuler(rotation);
|
|
4689
4738
|
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);
|
|
4690
4739
|
if (worldFace < 0) return 0;
|
|
4691
4740
|
if (worldMask & 1 << worldFace) localMask |= 1 << localFace;
|
|
@@ -4718,10 +4767,10 @@ var init_ModelCulling = __esm({
|
|
|
4718
4767
|
});
|
|
4719
4768
|
|
|
4720
4769
|
// src/model/SpecialItems.ts
|
|
4721
|
-
var
|
|
4770
|
+
var import_three23, SpecialItems;
|
|
4722
4771
|
var init_SpecialItems = __esm({
|
|
4723
4772
|
"src/model/SpecialItems.ts"() {
|
|
4724
|
-
|
|
4773
|
+
import_three23 = require("three");
|
|
4725
4774
|
init_AssetKey();
|
|
4726
4775
|
init_Entities();
|
|
4727
4776
|
SpecialItems = class {
|
|
@@ -4749,7 +4798,7 @@ var init_SpecialItems = __esm({
|
|
|
4749
4798
|
case "minecraft:chest":
|
|
4750
4799
|
case "chest": {
|
|
4751
4800
|
const angle = -(special.openness ?? 0) * Math.PI / 2;
|
|
4752
|
-
const chest = await load("chest", texture(special.texture, "chest"), new
|
|
4801
|
+
const chest = await load("chest", texture(special.texture, "chest"), new import_three23.Matrix4(), {
|
|
4753
4802
|
lid: [angle, 0, 0],
|
|
4754
4803
|
lock: [angle, 0, 0]
|
|
4755
4804
|
});
|
|
@@ -4758,11 +4807,11 @@ var init_SpecialItems = __esm({
|
|
|
4758
4807
|
}
|
|
4759
4808
|
case "minecraft:bed":
|
|
4760
4809
|
case "bed": {
|
|
4761
|
-
const transform = new
|
|
4810
|
+
const transform = new import_three23.Matrix4().makeTranslation(0, 9, 0).multiply(new import_three23.Matrix4().makeRotationX(Math.PI / 2)).multiply(new import_three23.Matrix4().makeTranslation(8, 8, 8)).multiply(new import_three23.Matrix4().makeRotationZ(Math.PI)).multiply(new import_three23.Matrix4().makeTranslation(-8, -8, -8));
|
|
4762
4811
|
const key = texture(special.texture, "bed");
|
|
4763
4812
|
return Promise.all([
|
|
4764
4813
|
load("bed_head", key, transform),
|
|
4765
|
-
load("bed_foot", key, new
|
|
4814
|
+
load("bed_foot", key, new import_three23.Matrix4().makeTranslation(0, 0, -16).multiply(transform))
|
|
4766
4815
|
]);
|
|
4767
4816
|
}
|
|
4768
4817
|
case "minecraft:head":
|
|
@@ -4787,7 +4836,7 @@ var init_SpecialItems = __esm({
|
|
|
4787
4836
|
return [await load(
|
|
4788
4837
|
id,
|
|
4789
4838
|
special.texture ? texture(special.texture, "") : void 0,
|
|
4790
|
-
new
|
|
4839
|
+
new import_three23.Matrix4().makeTranslation(8, 0, 8).multiply(new import_three23.Matrix4().makeScale(-1, -1, 1)),
|
|
4791
4840
|
rotations
|
|
4792
4841
|
)];
|
|
4793
4842
|
}
|
|
@@ -4830,17 +4879,98 @@ var init_GuiLight = __esm({
|
|
|
4830
4879
|
}
|
|
4831
4880
|
});
|
|
4832
4881
|
|
|
4882
|
+
// src/texture/Colormaps.ts
|
|
4883
|
+
var Colormaps;
|
|
4884
|
+
var init_Colormaps = __esm({
|
|
4885
|
+
"src/texture/Colormaps.ts"() {
|
|
4886
|
+
init_AssetKey();
|
|
4887
|
+
init_ModelTextures();
|
|
4888
|
+
init_Caching();
|
|
4889
|
+
init_MineRenderError();
|
|
4890
|
+
Colormaps = class {
|
|
4891
|
+
/** Samples the selected resource pack's grass colormap using Minecraft's climate coordinates. */
|
|
4892
|
+
static async grassColor(origin, temperature = 0.5, downfall = 1) {
|
|
4893
|
+
const key = AssetKey.parse("textures", "minecraft:colormap/grass", origin);
|
|
4894
|
+
const temp = Math.fround(temperature);
|
|
4895
|
+
const rain = Math.fround(downfall) * temp;
|
|
4896
|
+
const x = Math.floor((1 - temp) * 255), y = Math.floor((1 - rain) * 255);
|
|
4897
|
+
return await Caching.blockTintCache.get(`${key.serialize()}|${x},${y}`, async () => {
|
|
4898
|
+
const image = await ModelTextures.get(key);
|
|
4899
|
+
if (!image) throw new MineRenderError(`Missing grass colormap: ${key.toNamespacedString()}`);
|
|
4900
|
+
if (image.width !== 256 || image.height !== 256) {
|
|
4901
|
+
throw new MineRenderError("Grass colormaps must be 256 \xD7 256 pixels");
|
|
4902
|
+
}
|
|
4903
|
+
const [red, green, blue] = image.data.getImageData(x, y, 1, 1).data;
|
|
4904
|
+
return red << 16 | green << 8 | blue;
|
|
4905
|
+
});
|
|
4906
|
+
}
|
|
4907
|
+
};
|
|
4908
|
+
}
|
|
4909
|
+
});
|
|
4910
|
+
|
|
4911
|
+
// src/model/ItemTints.ts
|
|
4912
|
+
var ItemTints;
|
|
4913
|
+
var init_ItemTints = __esm({
|
|
4914
|
+
"src/model/ItemTints.ts"() {
|
|
4915
|
+
init_MineRenderError();
|
|
4916
|
+
init_Colormaps();
|
|
4917
|
+
ItemTints = class {
|
|
4918
|
+
/** Resolves preview colors from item definitions; explicit per-index colors take precedence. */
|
|
4919
|
+
static async get(model, tints) {
|
|
4920
|
+
const sources = model.tints;
|
|
4921
|
+
if (!sources?.length) return tints;
|
|
4922
|
+
const colors = { ...tints };
|
|
4923
|
+
await Promise.all(sources.map(async (source, index) => {
|
|
4924
|
+
if (colors[index] !== void 0) return;
|
|
4925
|
+
switch (source.type) {
|
|
4926
|
+
case "constant":
|
|
4927
|
+
case "minecraft:constant":
|
|
4928
|
+
colors[index] = this.rgb(source.value);
|
|
4929
|
+
break;
|
|
4930
|
+
case "grass":
|
|
4931
|
+
case "minecraft:grass":
|
|
4932
|
+
colors[index] = await Colormaps.grassColor(model.key, source.temperature, source.downfall);
|
|
4933
|
+
break;
|
|
4934
|
+
case "dye":
|
|
4935
|
+
case "minecraft:dye":
|
|
4936
|
+
case "potion":
|
|
4937
|
+
case "minecraft:potion":
|
|
4938
|
+
case "map_color":
|
|
4939
|
+
case "minecraft:map_color":
|
|
4940
|
+
case "firework":
|
|
4941
|
+
case "minecraft:firework":
|
|
4942
|
+
case "team":
|
|
4943
|
+
case "minecraft:team":
|
|
4944
|
+
case "custom_model_data":
|
|
4945
|
+
case "minecraft:custom_model_data":
|
|
4946
|
+
colors[index] = this.rgb(source.default);
|
|
4947
|
+
break;
|
|
4948
|
+
default:
|
|
4949
|
+
throw new MineRenderError(`Unsupported item tint source ${source.type}`);
|
|
4950
|
+
}
|
|
4951
|
+
}));
|
|
4952
|
+
return colors;
|
|
4953
|
+
}
|
|
4954
|
+
static rgb(color) {
|
|
4955
|
+
if (!Array.isArray(color)) return color & 16777215;
|
|
4956
|
+
const [red, green, blue] = color.map((channel) => Math.floor(Math.fround(Math.fround(channel) * 255)));
|
|
4957
|
+
return red << 16 | green << 8 | blue;
|
|
4958
|
+
}
|
|
4959
|
+
};
|
|
4960
|
+
}
|
|
4961
|
+
});
|
|
4962
|
+
|
|
4833
4963
|
// src/model/scene/ModelObject.ts
|
|
4834
4964
|
function isModelObject(obj) {
|
|
4835
4965
|
return obj.isModelObject;
|
|
4836
4966
|
}
|
|
4837
|
-
var
|
|
4967
|
+
var import_three24, import_ts_deepmerge5, p7, _ModelObject, ModelObject;
|
|
4838
4968
|
var init_ModelObject = __esm({
|
|
4839
4969
|
"src/model/scene/ModelObject.ts"() {
|
|
4840
4970
|
init_SceneObject();
|
|
4841
4971
|
init_Materials();
|
|
4842
4972
|
init_UVMapper();
|
|
4843
|
-
|
|
4973
|
+
import_three24 = require("three");
|
|
4844
4974
|
init_BufferGeometryUtils();
|
|
4845
4975
|
init_model();
|
|
4846
4976
|
import_ts_deepmerge5 = __toESM(require_dist());
|
|
@@ -4852,6 +4982,7 @@ var init_ModelObject = __esm({
|
|
|
4852
4982
|
init_SpecialItems();
|
|
4853
4983
|
init_EntityObject();
|
|
4854
4984
|
init_GuiLight();
|
|
4985
|
+
init_ItemTints();
|
|
4855
4986
|
p7 = prefix("ModelObject");
|
|
4856
4987
|
_ModelObject = class _ModelObject extends SceneObject {
|
|
4857
4988
|
constructor(originalModel, options) {
|
|
@@ -4867,11 +4998,12 @@ var init_ModelObject = __esm({
|
|
|
4867
4998
|
this.addEventListener("removed", () => this.updateAnimationSubscription());
|
|
4868
4999
|
}
|
|
4869
5000
|
async init() {
|
|
5001
|
+
this.options.tints = await ItemTints.get(this.originalModel, this.options.tints);
|
|
4870
5002
|
const special = this.originalModel.special;
|
|
4871
5003
|
if (special) {
|
|
4872
5004
|
const parts = await SpecialItems.getParts(special, this.originalModel.key?.root);
|
|
4873
|
-
const transform = this.options.displayPosition ? DisplayTransforms.getMatrix(this.originalModel.display, this.options.displayPosition) : new
|
|
4874
|
-
transform.multiply(new
|
|
5005
|
+
const transform = this.options.displayPosition ? DisplayTransforms.getMatrix(this.originalModel.display, this.options.displayPosition) : new import_three24.Matrix4();
|
|
5006
|
+
transform.multiply(new import_three24.Matrix4().makeTranslation(-8, -8, -8));
|
|
4875
5007
|
try {
|
|
4876
5008
|
for (const part of parts) {
|
|
4877
5009
|
const object = new EntityObject(part.model, { flip: false, wireframe: this.options.wireframe });
|
|
@@ -4933,7 +5065,7 @@ var init_ModelObject = __esm({
|
|
|
4933
5065
|
elGeo.clearGroups();
|
|
4934
5066
|
}
|
|
4935
5067
|
if (this.options.uvLockRotation) {
|
|
4936
|
-
UVMapper.lockUvs(elGeo, el.faces, this.atlas, new
|
|
5068
|
+
UVMapper.lockUvs(elGeo, el.faces, this.atlas, new import_three24.Euler(...this.options.uvLockRotation));
|
|
4937
5069
|
}
|
|
4938
5070
|
if (this.options.tints) {
|
|
4939
5071
|
const colors = new Float32Array(elGeo.getAttribute("position").count * 3).fill(1);
|
|
@@ -4942,19 +5074,19 @@ var init_ModelObject = __esm({
|
|
|
4942
5074
|
if (tintIndex === void 0 || tintIndex < 0) continue;
|
|
4943
5075
|
const tint = this.options.tints[tintIndex];
|
|
4944
5076
|
if (tint === void 0) continue;
|
|
4945
|
-
const color = new
|
|
5077
|
+
const color = new import_three24.Color(tint);
|
|
4946
5078
|
for (let vertex = 0; vertex < 4; vertex++) {
|
|
4947
5079
|
color.toArray(colors, (faceIndex * 4 + vertex) * 3);
|
|
4948
5080
|
}
|
|
4949
5081
|
}
|
|
4950
|
-
elGeo.setAttribute("color", new
|
|
5082
|
+
elGeo.setAttribute("color", new import_three24.BufferAttribute(colors, 3));
|
|
4951
5083
|
}
|
|
4952
|
-
elGeo.applyMatrix4(new
|
|
4953
|
-
elGeo.applyMatrix4(new
|
|
5084
|
+
elGeo.applyMatrix4(new import_three24.Matrix4().makeTranslation((el.to[0] - el.from[0]) / 2, (el.to[1] - el.from[1]) / 2, (el.to[2] - el.from[2]) / 2));
|
|
5085
|
+
elGeo.applyMatrix4(new import_three24.Matrix4().makeTranslation(el.from[0], el.from[1], el.from[2]));
|
|
4954
5086
|
if (el.rotation) {
|
|
4955
5087
|
applyElementRotation(el.rotation, elGeo);
|
|
4956
5088
|
}
|
|
4957
|
-
elGeo.applyMatrix4(new
|
|
5089
|
+
elGeo.applyMatrix4(new import_three24.Matrix4().makeTranslation(-8, -8, -8));
|
|
4958
5090
|
if (displayTransform) DisplayTransforms.apply(elGeo, displayTransform);
|
|
4959
5091
|
if (this.options.mergeMeshes) {
|
|
4960
5092
|
allGeos.push(elGeo);
|
|
@@ -4976,7 +5108,7 @@ var init_ModelObject = __esm({
|
|
|
4976
5108
|
if (allGeos.length > 0) {
|
|
4977
5109
|
combinedGeo = mergeBufferGeometries(allGeos);
|
|
4978
5110
|
} else {
|
|
4979
|
-
combinedGeo = new
|
|
5111
|
+
combinedGeo = new import_three24.BoxGeometry(16, 16, 16);
|
|
4980
5112
|
if (displayTransform) DisplayTransforms.apply(combinedGeo, displayTransform);
|
|
4981
5113
|
}
|
|
4982
5114
|
combinedGeo.computeBoundingBox();
|
|
@@ -5088,7 +5220,7 @@ function ownHeight(sample) {
|
|
|
5088
5220
|
return (level === 0 || level >= 8 ? 8 : 8 - level) / 9;
|
|
5089
5221
|
}
|
|
5090
5222
|
function createFluidGeometry(kind, sample) {
|
|
5091
|
-
const geometry = new
|
|
5223
|
+
const geometry = new import_three29.BufferGeometry();
|
|
5092
5224
|
const positions = [], normals = [], uvs = [], indices = [];
|
|
5093
5225
|
const self = sample(0, 0, 0);
|
|
5094
5226
|
const height = (x, z) => {
|
|
@@ -5187,16 +5319,16 @@ function createFluidGeometry(kind, sample) {
|
|
|
5187
5319
|
1
|
|
5188
5320
|
);
|
|
5189
5321
|
}
|
|
5190
|
-
geometry.setAttribute("position", new
|
|
5191
|
-
geometry.setAttribute("normal", new
|
|
5192
|
-
geometry.setAttribute("uv", new
|
|
5322
|
+
geometry.setAttribute("position", new import_three29.Float32BufferAttribute(positions, 3));
|
|
5323
|
+
geometry.setAttribute("normal", new import_three29.Float32BufferAttribute(normals, 3));
|
|
5324
|
+
geometry.setAttribute("uv", new import_three29.Float32BufferAttribute(uvs, 2));
|
|
5193
5325
|
geometry.setIndex(indices);
|
|
5194
5326
|
return geometry;
|
|
5195
5327
|
}
|
|
5196
|
-
var
|
|
5328
|
+
var import_three29, fluidRules, HORIZONTAL, EPSILON;
|
|
5197
5329
|
var init_FluidGeometry = __esm({
|
|
5198
5330
|
"src/model/fluid/FluidGeometry.ts"() {
|
|
5199
|
-
|
|
5331
|
+
import_three29 = require("three");
|
|
5200
5332
|
init_fluidBlocks();
|
|
5201
5333
|
fluidRules = fluidBlocks_default;
|
|
5202
5334
|
HORIZONTAL = [[0, -1], [0, 1], [-1, 0], [1, 0]];
|
|
@@ -5225,10 +5357,10 @@ function sampleFluid(kind, sample) {
|
|
|
5225
5357
|
}
|
|
5226
5358
|
return { key: key.join(""), sample: (x, y, z) => cells[(y + 1) * 9 + (z + 1) * 3 + x + 1] };
|
|
5227
5359
|
}
|
|
5228
|
-
var
|
|
5360
|
+
var import_three30, FluidModelObject;
|
|
5229
5361
|
var init_FluidModelObject = __esm({
|
|
5230
5362
|
"src/model/fluid/FluidModelObject.ts"() {
|
|
5231
|
-
|
|
5363
|
+
import_three30 = require("three");
|
|
5232
5364
|
init_AssetKey();
|
|
5233
5365
|
init_Materials();
|
|
5234
5366
|
init_ModelObject();
|
|
@@ -5261,10 +5393,10 @@ var init_FluidModelObject = __esm({
|
|
|
5261
5393
|
}
|
|
5262
5394
|
}
|
|
5263
5395
|
geometry.clearGroups();
|
|
5264
|
-
const color = new
|
|
5396
|
+
const color = new import_three30.Color(this.options.tints?.[0] ?? (this.kind === "water" ? 4159204 : 16777215));
|
|
5265
5397
|
const colors = new Float32Array(geometry.getAttribute("position").count * 3);
|
|
5266
5398
|
for (let i = 0; i < colors.length; i += 3) color.toArray(colors, i);
|
|
5267
|
-
geometry.setAttribute("color", new
|
|
5399
|
+
geometry.setAttribute("color", new import_three30.BufferAttribute(colors, 3));
|
|
5268
5400
|
geometry.computeBoundingBox();
|
|
5269
5401
|
geometry.computeBoundingSphere();
|
|
5270
5402
|
if (this.options.instanceMeshes) {
|
|
@@ -5278,7 +5410,7 @@ var init_FluidModelObject = __esm({
|
|
|
5278
5410
|
super.applyTextures();
|
|
5279
5411
|
this.iterateAllMeshes((mesh) => {
|
|
5280
5412
|
const material = mesh.material;
|
|
5281
|
-
material.side =
|
|
5413
|
+
material.side = import_three30.DoubleSide;
|
|
5282
5414
|
material.forceSinglePass = true;
|
|
5283
5415
|
material.depthWrite = !material.transparent;
|
|
5284
5416
|
});
|
|
@@ -5323,6 +5455,7 @@ __export(index_browser_exports, {
|
|
|
5323
5455
|
CanvasImage: () => CanvasImage,
|
|
5324
5456
|
Chunk: () => Chunk,
|
|
5325
5457
|
ChunkData: () => ChunkData,
|
|
5458
|
+
Colormaps: () => Colormaps,
|
|
5326
5459
|
CubeFace: () => CubeFace,
|
|
5327
5460
|
CubeFaceIndex: () => CubeFaceIndex,
|
|
5328
5461
|
DEFAULT_ELEMENTS: () => DEFAULT_ELEMENTS,
|
|
@@ -5348,6 +5481,7 @@ __export(index_browser_exports, {
|
|
|
5348
5481
|
ImageLoader: () => ImageLoader,
|
|
5349
5482
|
InstanceManager: () => InstanceManager,
|
|
5350
5483
|
InstanceReference: () => InstanceReference,
|
|
5484
|
+
ItemTints: () => ItemTints,
|
|
5351
5485
|
MapControls: () => MapControls,
|
|
5352
5486
|
Materials: () => Materials,
|
|
5353
5487
|
Meshes: () => Meshes,
|
|
@@ -5763,27 +5897,27 @@ init_EntityObject();
|
|
|
5763
5897
|
init_MineRenderError();
|
|
5764
5898
|
|
|
5765
5899
|
// src/export/SceneExporter.ts
|
|
5766
|
-
var
|
|
5900
|
+
var import_three20 = require("three");
|
|
5767
5901
|
|
|
5768
5902
|
// ../../node_modules/three/examples/jsm/exporters/OBJExporter.js
|
|
5769
|
-
var
|
|
5903
|
+
var import_three16 = require("three");
|
|
5770
5904
|
var OBJExporter = class {
|
|
5771
5905
|
parse(object) {
|
|
5772
5906
|
let output = "";
|
|
5773
5907
|
let indexVertex = 0;
|
|
5774
5908
|
let indexVertexUvs = 0;
|
|
5775
5909
|
let indexNormals = 0;
|
|
5776
|
-
const vertex = new
|
|
5777
|
-
const color = new
|
|
5778
|
-
const normal = new
|
|
5779
|
-
const uv = new
|
|
5910
|
+
const vertex = new import_three16.Vector3();
|
|
5911
|
+
const color = new import_three16.Color();
|
|
5912
|
+
const normal = new import_three16.Vector3();
|
|
5913
|
+
const uv = new import_three16.Vector2();
|
|
5780
5914
|
const face = [];
|
|
5781
5915
|
function parseMesh(mesh) {
|
|
5782
5916
|
let nbVertex = 0;
|
|
5783
5917
|
let nbNormals = 0;
|
|
5784
5918
|
let nbVertexUvs = 0;
|
|
5785
5919
|
const geometry = mesh.geometry;
|
|
5786
|
-
const normalMatrixWorld = new
|
|
5920
|
+
const normalMatrixWorld = new import_three16.Matrix3();
|
|
5787
5921
|
const vertices = geometry.getAttribute("position");
|
|
5788
5922
|
const normals = geometry.getAttribute("normal");
|
|
5789
5923
|
const uvs = geometry.getAttribute("uv");
|
|
@@ -5902,7 +6036,7 @@ var OBJExporter = class {
|
|
|
5902
6036
|
};
|
|
5903
6037
|
|
|
5904
6038
|
// ../../node_modules/three/examples/jsm/exporters/PLYExporter.js
|
|
5905
|
-
var
|
|
6039
|
+
var import_three17 = require("three");
|
|
5906
6040
|
var PLYExporter = class {
|
|
5907
6041
|
parse(object, onDone, options = {}) {
|
|
5908
6042
|
function traverseMeshes(cb) {
|
|
@@ -5959,7 +6093,7 @@ var PLYExporter = class {
|
|
|
5959
6093
|
includeIndices = false;
|
|
5960
6094
|
}
|
|
5961
6095
|
});
|
|
5962
|
-
const tempColor = new
|
|
6096
|
+
const tempColor = new import_three17.Color();
|
|
5963
6097
|
includeIndices = includeIndices && excludeAttributes.indexOf("index") === -1;
|
|
5964
6098
|
includeNormals = includeNormals && excludeAttributes.indexOf("normal") === -1;
|
|
5965
6099
|
includeColors = includeColors && excludeAttributes.indexOf("color") === -1;
|
|
@@ -5993,8 +6127,8 @@ property list uchar int vertex_index
|
|
|
5993
6127
|
`;
|
|
5994
6128
|
}
|
|
5995
6129
|
header += "end_header\n";
|
|
5996
|
-
const vertex = new
|
|
5997
|
-
const normalMatrixWorld = new
|
|
6130
|
+
const vertex = new import_three17.Vector3();
|
|
6131
|
+
const normalMatrixWorld = new import_three17.Matrix3();
|
|
5998
6132
|
let result = null;
|
|
5999
6133
|
if (options.binary === true) {
|
|
6000
6134
|
const headerBin = new TextEncoder().encode(header);
|
|
@@ -6168,18 +6302,18 @@ property list uchar int vertex_index
|
|
|
6168
6302
|
};
|
|
6169
6303
|
|
|
6170
6304
|
// ../../node_modules/three/examples/jsm/exporters/GLTFExporter.js
|
|
6171
|
-
var
|
|
6305
|
+
var import_three19 = require("three");
|
|
6172
6306
|
|
|
6173
6307
|
// ../../node_modules/three/examples/jsm/utils/TextureUtils.js
|
|
6174
|
-
var
|
|
6308
|
+
var import_three18 = require("three");
|
|
6175
6309
|
var _renderer;
|
|
6176
6310
|
var fullscreenQuadGeometry;
|
|
6177
6311
|
var fullscreenQuadMaterial;
|
|
6178
6312
|
var fullscreenQuad;
|
|
6179
6313
|
function decompress(texture, maxTextureSize = Infinity, renderer = null) {
|
|
6180
|
-
if (!fullscreenQuadGeometry) fullscreenQuadGeometry = new
|
|
6181
|
-
if (!fullscreenQuadMaterial) fullscreenQuadMaterial = new
|
|
6182
|
-
uniforms: { blitTexture: new
|
|
6314
|
+
if (!fullscreenQuadGeometry) fullscreenQuadGeometry = new import_three18.PlaneGeometry(2, 2, 1, 1);
|
|
6315
|
+
if (!fullscreenQuadMaterial) fullscreenQuadMaterial = new import_three18.ShaderMaterial({
|
|
6316
|
+
uniforms: { blitTexture: new import_three18.Uniform(texture) },
|
|
6183
6317
|
vertexShader: `
|
|
6184
6318
|
varying vec2 vUv;
|
|
6185
6319
|
void main(){
|
|
@@ -6201,22 +6335,22 @@ function decompress(texture, maxTextureSize = Infinity, renderer = null) {
|
|
|
6201
6335
|
}`
|
|
6202
6336
|
});
|
|
6203
6337
|
fullscreenQuadMaterial.uniforms.blitTexture.value = texture;
|
|
6204
|
-
fullscreenQuadMaterial.defines.IS_SRGB = texture.colorSpace ==
|
|
6338
|
+
fullscreenQuadMaterial.defines.IS_SRGB = texture.colorSpace == import_three18.SRGBColorSpace;
|
|
6205
6339
|
fullscreenQuadMaterial.needsUpdate = true;
|
|
6206
6340
|
if (!fullscreenQuad) {
|
|
6207
|
-
fullscreenQuad = new
|
|
6341
|
+
fullscreenQuad = new import_three18.Mesh(fullscreenQuadGeometry, fullscreenQuadMaterial);
|
|
6208
6342
|
fullscreenQuad.frustrumCulled = false;
|
|
6209
6343
|
}
|
|
6210
|
-
const _camera = new
|
|
6211
|
-
const _scene = new
|
|
6344
|
+
const _camera = new import_three18.PerspectiveCamera();
|
|
6345
|
+
const _scene = new import_three18.Scene();
|
|
6212
6346
|
_scene.add(fullscreenQuad);
|
|
6213
6347
|
if (!renderer) {
|
|
6214
|
-
renderer = _renderer = new
|
|
6348
|
+
renderer = _renderer = new import_three18.WebGLRenderer({ antialias: false });
|
|
6215
6349
|
}
|
|
6216
6350
|
renderer.setSize(Math.min(texture.image.width, maxTextureSize), Math.min(texture.image.height, maxTextureSize));
|
|
6217
6351
|
renderer.clear();
|
|
6218
6352
|
renderer.render(_scene, _camera);
|
|
6219
|
-
const readableTexture = new
|
|
6353
|
+
const readableTexture = new import_three18.Texture(renderer.domElement);
|
|
6220
6354
|
readableTexture.minFilter = texture.minFilter;
|
|
6221
6355
|
readableTexture.magFilter = texture.magFilter;
|
|
6222
6356
|
readableTexture.wrapS = texture.wrapS;
|
|
@@ -6362,22 +6496,22 @@ var WEBGL_CONSTANTS = {
|
|
|
6362
6496
|
};
|
|
6363
6497
|
var KHR_MESH_QUANTIZATION = "KHR_mesh_quantization";
|
|
6364
6498
|
var THREE_TO_WEBGL = {};
|
|
6365
|
-
THREE_TO_WEBGL[
|
|
6366
|
-
THREE_TO_WEBGL[
|
|
6367
|
-
THREE_TO_WEBGL[
|
|
6368
|
-
THREE_TO_WEBGL[
|
|
6369
|
-
THREE_TO_WEBGL[
|
|
6370
|
-
THREE_TO_WEBGL[
|
|
6371
|
-
THREE_TO_WEBGL[
|
|
6372
|
-
THREE_TO_WEBGL[
|
|
6373
|
-
THREE_TO_WEBGL[
|
|
6499
|
+
THREE_TO_WEBGL[import_three19.NearestFilter] = WEBGL_CONSTANTS.NEAREST;
|
|
6500
|
+
THREE_TO_WEBGL[import_three19.NearestMipmapNearestFilter] = WEBGL_CONSTANTS.NEAREST_MIPMAP_NEAREST;
|
|
6501
|
+
THREE_TO_WEBGL[import_three19.NearestMipmapLinearFilter] = WEBGL_CONSTANTS.NEAREST_MIPMAP_LINEAR;
|
|
6502
|
+
THREE_TO_WEBGL[import_three19.LinearFilter] = WEBGL_CONSTANTS.LINEAR;
|
|
6503
|
+
THREE_TO_WEBGL[import_three19.LinearMipmapNearestFilter] = WEBGL_CONSTANTS.LINEAR_MIPMAP_NEAREST;
|
|
6504
|
+
THREE_TO_WEBGL[import_three19.LinearMipmapLinearFilter] = WEBGL_CONSTANTS.LINEAR_MIPMAP_LINEAR;
|
|
6505
|
+
THREE_TO_WEBGL[import_three19.ClampToEdgeWrapping] = WEBGL_CONSTANTS.CLAMP_TO_EDGE;
|
|
6506
|
+
THREE_TO_WEBGL[import_three19.RepeatWrapping] = WEBGL_CONSTANTS.REPEAT;
|
|
6507
|
+
THREE_TO_WEBGL[import_three19.MirroredRepeatWrapping] = WEBGL_CONSTANTS.MIRRORED_REPEAT;
|
|
6374
6508
|
var PATH_PROPERTIES = {
|
|
6375
6509
|
scale: "scale",
|
|
6376
6510
|
position: "translation",
|
|
6377
6511
|
quaternion: "rotation",
|
|
6378
6512
|
morphTargetInfluences: "weights"
|
|
6379
6513
|
};
|
|
6380
|
-
var DEFAULT_SPECULAR_COLOR = new
|
|
6514
|
+
var DEFAULT_SPECULAR_COLOR = new import_three19.Color();
|
|
6381
6515
|
var GLB_HEADER_BYTES = 12;
|
|
6382
6516
|
var GLB_HEADER_MAGIC = 1179937895;
|
|
6383
6517
|
var GLB_VERSION = 2;
|
|
@@ -6411,7 +6545,7 @@ function getMinMax(attribute, start, count) {
|
|
|
6411
6545
|
else if (a === 2) value = attribute.getZ(i);
|
|
6412
6546
|
else if (a === 3) value = attribute.getW(i);
|
|
6413
6547
|
if (attribute.normalized === true) {
|
|
6414
|
-
value =
|
|
6548
|
+
value = import_three19.MathUtils.normalize(value, attribute.array);
|
|
6415
6549
|
}
|
|
6416
6550
|
}
|
|
6417
6551
|
output.min[a] = Math.min(output.min[a], value);
|
|
@@ -6617,7 +6751,7 @@ var GLTFWriter = class {
|
|
|
6617
6751
|
isNormalizedNormalAttribute(normal) {
|
|
6618
6752
|
const cache = this.cache;
|
|
6619
6753
|
if (cache.attributesNormalized.has(normal)) return false;
|
|
6620
|
-
const v = new
|
|
6754
|
+
const v = new import_three19.Vector3();
|
|
6621
6755
|
for (let i = 0, il = normal.count; i < il; i++) {
|
|
6622
6756
|
if (Math.abs(v.fromBufferAttribute(normal, i).length() - 1) > 5e-4) return false;
|
|
6623
6757
|
}
|
|
@@ -6634,7 +6768,7 @@ var GLTFWriter = class {
|
|
|
6634
6768
|
const cache = this.cache;
|
|
6635
6769
|
if (cache.attributesNormalized.has(normal)) return cache.attributesNormalized.get(normal);
|
|
6636
6770
|
const attribute = normal.clone();
|
|
6637
|
-
const v = new
|
|
6771
|
+
const v = new import_three19.Vector3();
|
|
6638
6772
|
for (let i = 0, il = attribute.count; i < il; i++) {
|
|
6639
6773
|
v.fromBufferAttribute(attribute, i);
|
|
6640
6774
|
if (v.x === 0 && v.y === 0 && v.z === 0) {
|
|
@@ -6678,7 +6812,7 @@ var GLTFWriter = class {
|
|
|
6678
6812
|
buildMetalRoughTexture(metalnessMap, roughnessMap) {
|
|
6679
6813
|
if (metalnessMap === roughnessMap) return metalnessMap;
|
|
6680
6814
|
function getEncodingConversion(map) {
|
|
6681
|
-
if (map.colorSpace ===
|
|
6815
|
+
if (map.colorSpace === import_three19.SRGBColorSpace) {
|
|
6682
6816
|
return function SRGBToLinear(c) {
|
|
6683
6817
|
return c < 0.04045 ? c * 0.0773993808 : Math.pow(c * 0.9478672986 + 0.0521327014, 2.4);
|
|
6684
6818
|
};
|
|
@@ -6688,10 +6822,10 @@ var GLTFWriter = class {
|
|
|
6688
6822
|
};
|
|
6689
6823
|
}
|
|
6690
6824
|
console.warn("THREE.GLTFExporter: Merged metalnessMap and roughnessMap textures.");
|
|
6691
|
-
if (metalnessMap instanceof
|
|
6825
|
+
if (metalnessMap instanceof import_three19.CompressedTexture) {
|
|
6692
6826
|
metalnessMap = decompress(metalnessMap);
|
|
6693
6827
|
}
|
|
6694
|
-
if (roughnessMap instanceof
|
|
6828
|
+
if (roughnessMap instanceof import_three19.CompressedTexture) {
|
|
6695
6829
|
roughnessMap = decompress(roughnessMap);
|
|
6696
6830
|
}
|
|
6697
6831
|
const metalness = metalnessMap ? metalnessMap.image : null;
|
|
@@ -6724,8 +6858,8 @@ var GLTFWriter = class {
|
|
|
6724
6858
|
context.putImageData(composite, 0, 0);
|
|
6725
6859
|
const reference = metalnessMap || roughnessMap;
|
|
6726
6860
|
const texture = reference.clone();
|
|
6727
|
-
texture.source = new
|
|
6728
|
-
texture.colorSpace =
|
|
6861
|
+
texture.source = new import_three19.Source(canvas);
|
|
6862
|
+
texture.colorSpace = import_three19.NoColorSpace;
|
|
6729
6863
|
texture.channel = (metalnessMap || roughnessMap).channel;
|
|
6730
6864
|
if (metalnessMap && roughnessMap && metalnessMap.channel !== roughnessMap.channel) {
|
|
6731
6865
|
console.warn("THREE.GLTFExporter: UV channels for metalnessMap and roughnessMap textures must match.");
|
|
@@ -6783,7 +6917,7 @@ var GLTFWriter = class {
|
|
|
6783
6917
|
else if (a === 2) value = attribute.getZ(i);
|
|
6784
6918
|
else if (a === 3) value = attribute.getW(i);
|
|
6785
6919
|
if (attribute.normalized === true) {
|
|
6786
|
-
value =
|
|
6920
|
+
value = import_three19.MathUtils.normalize(value, attribute.array);
|
|
6787
6921
|
}
|
|
6788
6922
|
}
|
|
6789
6923
|
if (componentType === WEBGL_CONSTANTS.FLOAT) {
|
|
@@ -6933,7 +7067,7 @@ var GLTFWriter = class {
|
|
|
6933
7067
|
ctx.scale(1, -1);
|
|
6934
7068
|
}
|
|
6935
7069
|
if (image.data !== void 0) {
|
|
6936
|
-
if (format !==
|
|
7070
|
+
if (format !== import_three19.RGBAFormat) {
|
|
6937
7071
|
console.error("GLTFExporter: Only RGBAFormat is supported.", format);
|
|
6938
7072
|
}
|
|
6939
7073
|
if (image.width > options.maxTextureSize || image.height > options.maxTextureSize) {
|
|
@@ -7002,7 +7136,7 @@ var GLTFWriter = class {
|
|
|
7002
7136
|
const json = this.json;
|
|
7003
7137
|
if (cache.textures.has(map)) return cache.textures.get(map);
|
|
7004
7138
|
if (!json.textures) json.textures = [];
|
|
7005
|
-
if (map instanceof
|
|
7139
|
+
if (map instanceof import_three19.CompressedTexture) {
|
|
7006
7140
|
map = decompress(map, options.maxTextureSize);
|
|
7007
7141
|
}
|
|
7008
7142
|
let mimeType = map.userData.mimeType;
|
|
@@ -7110,7 +7244,7 @@ var GLTFWriter = class {
|
|
|
7110
7244
|
materialDef.alphaCutoff = material.alphaTest;
|
|
7111
7245
|
}
|
|
7112
7246
|
}
|
|
7113
|
-
if (material.side ===
|
|
7247
|
+
if (material.side === import_three19.DoubleSide) materialDef.doubleSided = true;
|
|
7114
7248
|
if (material.name !== "") materialDef.name = material.name;
|
|
7115
7249
|
this.serializeUserData(material, materialDef);
|
|
7116
7250
|
this._invokeAll(function(ext) {
|
|
@@ -7184,7 +7318,7 @@ var GLTFWriter = class {
|
|
|
7184
7318
|
const array = attribute.array;
|
|
7185
7319
|
if (attributeName === "JOINTS_0" && !(array instanceof Uint16Array) && !(array instanceof Uint8Array)) {
|
|
7186
7320
|
console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.');
|
|
7187
|
-
modifiedAttribute = new
|
|
7321
|
+
modifiedAttribute = new import_three19.BufferAttribute(new Uint16Array(array), attribute.itemSize, attribute.normalized);
|
|
7188
7322
|
}
|
|
7189
7323
|
const accessor = this.processAccessor(modifiedAttribute || attribute, geometry);
|
|
7190
7324
|
if (accessor !== null) {
|
|
@@ -7344,7 +7478,7 @@ var GLTFWriter = class {
|
|
|
7344
7478
|
} else {
|
|
7345
7479
|
cameraDef.perspective = {
|
|
7346
7480
|
aspectRatio: camera.aspect,
|
|
7347
|
-
yfov:
|
|
7481
|
+
yfov: import_three19.MathUtils.degToRad(camera.fov),
|
|
7348
7482
|
zfar: camera.far <= 0 ? 1e-3 : camera.far,
|
|
7349
7483
|
znear: camera.near < 0 ? 0 : camera.near
|
|
7350
7484
|
};
|
|
@@ -7372,8 +7506,8 @@ var GLTFWriter = class {
|
|
|
7372
7506
|
const samplers = [];
|
|
7373
7507
|
for (let i = 0; i < tracks.length; ++i) {
|
|
7374
7508
|
const track = tracks[i];
|
|
7375
|
-
const trackBinding =
|
|
7376
|
-
let trackNode =
|
|
7509
|
+
const trackBinding = import_three19.PropertyBinding.parseTrackName(track.name);
|
|
7510
|
+
let trackNode = import_three19.PropertyBinding.findNode(root, trackBinding.nodeName);
|
|
7377
7511
|
const trackProperty = PATH_PROPERTIES[trackBinding.propertyName];
|
|
7378
7512
|
if (trackBinding.objectName === "bones") {
|
|
7379
7513
|
if (trackNode.isSkinnedMesh === true) {
|
|
@@ -7395,14 +7529,14 @@ var GLTFWriter = class {
|
|
|
7395
7529
|
if (track.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline === true) {
|
|
7396
7530
|
interpolation = "CUBICSPLINE";
|
|
7397
7531
|
outputItemSize /= 3;
|
|
7398
|
-
} else if (track.getInterpolation() ===
|
|
7532
|
+
} else if (track.getInterpolation() === import_three19.InterpolateDiscrete) {
|
|
7399
7533
|
interpolation = "STEP";
|
|
7400
7534
|
} else {
|
|
7401
7535
|
interpolation = "LINEAR";
|
|
7402
7536
|
}
|
|
7403
7537
|
samplers.push({
|
|
7404
|
-
input: this.processAccessor(new
|
|
7405
|
-
output: this.processAccessor(new
|
|
7538
|
+
input: this.processAccessor(new import_three19.BufferAttribute(track.times, inputItemSize)),
|
|
7539
|
+
output: this.processAccessor(new import_three19.BufferAttribute(track.values, outputItemSize)),
|
|
7406
7540
|
interpolation
|
|
7407
7541
|
});
|
|
7408
7542
|
channels.push({
|
|
@@ -7434,7 +7568,7 @@ var GLTFWriter = class {
|
|
|
7434
7568
|
if (rootJoint === void 0) return null;
|
|
7435
7569
|
const joints = [];
|
|
7436
7570
|
const inverseBindMatrices = new Float32Array(skeleton.bones.length * 16);
|
|
7437
|
-
const temporaryBoneInverse = new
|
|
7571
|
+
const temporaryBoneInverse = new import_three19.Matrix4();
|
|
7438
7572
|
for (let i = 0; i < skeleton.bones.length; ++i) {
|
|
7439
7573
|
joints.push(nodeMap.get(skeleton.bones[i]));
|
|
7440
7574
|
temporaryBoneInverse.copy(skeleton.boneInverses[i]);
|
|
@@ -7442,7 +7576,7 @@ var GLTFWriter = class {
|
|
|
7442
7576
|
}
|
|
7443
7577
|
if (json.skins === void 0) json.skins = [];
|
|
7444
7578
|
json.skins.push({
|
|
7445
|
-
inverseBindMatrices: this.processAccessor(new
|
|
7579
|
+
inverseBindMatrices: this.processAccessor(new import_three19.BufferAttribute(inverseBindMatrices, 16)),
|
|
7446
7580
|
joints,
|
|
7447
7581
|
skeleton: nodeMap.get(rootJoint)
|
|
7448
7582
|
});
|
|
@@ -7538,7 +7672,7 @@ var GLTFWriter = class {
|
|
|
7538
7672
|
* @param {Array} objects List of objects to process
|
|
7539
7673
|
*/
|
|
7540
7674
|
processObjects(objects) {
|
|
7541
|
-
const scene = new
|
|
7675
|
+
const scene = new import_three19.Scene();
|
|
7542
7676
|
scene.name = "AuxScene";
|
|
7543
7677
|
for (let i = 0; i < objects.length; i++) {
|
|
7544
7678
|
scene.children.push(objects[i]);
|
|
@@ -7556,7 +7690,7 @@ var GLTFWriter = class {
|
|
|
7556
7690
|
});
|
|
7557
7691
|
const objectsWithoutScene = [];
|
|
7558
7692
|
for (let i = 0; i < input.length; i++) {
|
|
7559
|
-
if (input[i] instanceof
|
|
7693
|
+
if (input[i] instanceof import_three19.Scene) {
|
|
7560
7694
|
this.processScene(input[i]);
|
|
7561
7695
|
} else {
|
|
7562
7696
|
objectsWithoutScene.push(input[i]);
|
|
@@ -7900,10 +8034,10 @@ var GLTFMeshGpuInstancing = class {
|
|
|
7900
8034
|
const translationAttr = new Float32Array(mesh.count * 3);
|
|
7901
8035
|
const rotationAttr = new Float32Array(mesh.count * 4);
|
|
7902
8036
|
const scaleAttr = new Float32Array(mesh.count * 3);
|
|
7903
|
-
const matrix = new
|
|
7904
|
-
const position = new
|
|
7905
|
-
const quaternion = new
|
|
7906
|
-
const scale = new
|
|
8037
|
+
const matrix = new import_three19.Matrix4();
|
|
8038
|
+
const position = new import_three19.Vector3();
|
|
8039
|
+
const quaternion = new import_three19.Quaternion();
|
|
8040
|
+
const scale = new import_three19.Vector3();
|
|
7907
8041
|
for (let i = 0; i < mesh.count; i++) {
|
|
7908
8042
|
mesh.getMatrixAt(i, matrix);
|
|
7909
8043
|
matrix.decompose(position, quaternion, scale);
|
|
@@ -7912,9 +8046,9 @@ var GLTFMeshGpuInstancing = class {
|
|
|
7912
8046
|
scale.toArray(scaleAttr, i * 3);
|
|
7913
8047
|
}
|
|
7914
8048
|
const attributes = {
|
|
7915
|
-
TRANSLATION: writer.processAccessor(new
|
|
7916
|
-
ROTATION: writer.processAccessor(new
|
|
7917
|
-
SCALE: writer.processAccessor(new
|
|
8049
|
+
TRANSLATION: writer.processAccessor(new import_three19.BufferAttribute(translationAttr, 3)),
|
|
8050
|
+
ROTATION: writer.processAccessor(new import_three19.BufferAttribute(rotationAttr, 4)),
|
|
8051
|
+
SCALE: writer.processAccessor(new import_three19.BufferAttribute(scaleAttr, 3))
|
|
7918
8052
|
};
|
|
7919
8053
|
if (mesh.instanceColor)
|
|
7920
8054
|
attributes._COLOR_0 = writer.processAccessor(mesh.instanceColor);
|
|
@@ -7979,8 +8113,8 @@ GLTFExporter.Utils = {
|
|
|
7979
8113
|
const sourceTracks = clip.tracks;
|
|
7980
8114
|
for (let i = 0; i < sourceTracks.length; ++i) {
|
|
7981
8115
|
let sourceTrack = sourceTracks[i];
|
|
7982
|
-
const sourceTrackBinding =
|
|
7983
|
-
const sourceTrackNode =
|
|
8116
|
+
const sourceTrackBinding = import_three19.PropertyBinding.parseTrackName(sourceTrack.name);
|
|
8117
|
+
const sourceTrackNode = import_three19.PropertyBinding.findNode(root, sourceTrackBinding.nodeName);
|
|
7984
8118
|
if (sourceTrackBinding.propertyName !== "morphTargetInfluences" || sourceTrackBinding.propertyIndex === void 0) {
|
|
7985
8119
|
tracks.push(sourceTrack);
|
|
7986
8120
|
continue;
|
|
@@ -7991,7 +8125,7 @@ GLTFExporter.Utils = {
|
|
|
7991
8125
|
}
|
|
7992
8126
|
console.warn("THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead.");
|
|
7993
8127
|
sourceTrack = sourceTrack.clone();
|
|
7994
|
-
sourceTrack.setInterpolation(
|
|
8128
|
+
sourceTrack.setInterpolation(import_three19.InterpolateLinear);
|
|
7995
8129
|
}
|
|
7996
8130
|
const targetCount = sourceTrackNode.morphTargetInfluences.length;
|
|
7997
8131
|
const targetIndex = sourceTrackNode.morphTargetDictionary[sourceTrackBinding.propertyIndex];
|
|
@@ -8074,10 +8208,10 @@ var SceneExporter = class {
|
|
|
8074
8208
|
}
|
|
8075
8209
|
};
|
|
8076
8210
|
function localMatrix(object) {
|
|
8077
|
-
return object.matrixAutoUpdate ? new
|
|
8211
|
+
return object.matrixAutoUpdate ? new import_three20.Matrix4().compose(object.position, object.quaternion, object.scale) : object.matrix.clone();
|
|
8078
8212
|
}
|
|
8079
8213
|
function createSnapshot(root, gltf, bakeColors = false) {
|
|
8080
|
-
const scene = new
|
|
8214
|
+
const scene = new import_three20.Scene();
|
|
8081
8215
|
const geometries = [];
|
|
8082
8216
|
const materials = [];
|
|
8083
8217
|
const textures = [];
|
|
@@ -8095,7 +8229,7 @@ function createSnapshot(root, gltf, bakeColors = false) {
|
|
|
8095
8229
|
if (!uniforms.map?.value?.isTexture || !uniforms.SHADE || !uniforms.BRIGHTNESS || !uniforms.EMISSIVE) {
|
|
8096
8230
|
throw new MineRenderError("glTF export does not support this custom ShaderMaterial");
|
|
8097
8231
|
}
|
|
8098
|
-
material = new
|
|
8232
|
+
material = new import_three20.MeshBasicMaterial({
|
|
8099
8233
|
map: uniforms.map.value,
|
|
8100
8234
|
vertexColors: source.vertexColors,
|
|
8101
8235
|
transparent: source.transparent,
|
|
@@ -8105,7 +8239,7 @@ function createSnapshot(root, gltf, bakeColors = false) {
|
|
|
8105
8239
|
});
|
|
8106
8240
|
material.name = source.name;
|
|
8107
8241
|
} else if (shader.isShaderMaterial) {
|
|
8108
|
-
material = new
|
|
8242
|
+
material = new import_three20.MeshBasicMaterial({ vertexColors: source.vertexColors });
|
|
8109
8243
|
material.name = source.name;
|
|
8110
8244
|
} else {
|
|
8111
8245
|
const copySource = Object.create(source);
|
|
@@ -8159,11 +8293,11 @@ function createSnapshot(root, gltf, bakeColors = false) {
|
|
|
8159
8293
|
const material = copyMaterial(sourceMaterial, geometry);
|
|
8160
8294
|
if (!sourceMaterial.vertexColors) geometry.deleteAttribute("color");
|
|
8161
8295
|
if (bakeColors || instanceColor) {
|
|
8162
|
-
const tint = (material.color ?? new
|
|
8296
|
+
const tint = (material.color ?? new import_three20.Color()).clone();
|
|
8163
8297
|
if (instanceColor) tint.multiply(instanceColor);
|
|
8164
8298
|
if (bakeColors) {
|
|
8165
8299
|
const original = geometry.getAttribute("color");
|
|
8166
|
-
const colors = new
|
|
8300
|
+
const colors = new import_three20.Float32BufferAttribute(new Float32Array(geometry.getAttribute("position").count * 3), 3);
|
|
8167
8301
|
for (let i = 0; i < colors.count; i++) {
|
|
8168
8302
|
colors.setXYZ(i, (original?.getX(i) ?? 1) * tint.r, (original?.getY(i) ?? 1) * tint.g, (original?.getZ(i) ?? 1) * tint.b);
|
|
8169
8303
|
}
|
|
@@ -8172,7 +8306,7 @@ function createSnapshot(root, gltf, bakeColors = false) {
|
|
|
8172
8306
|
material.color.copy(tint);
|
|
8173
8307
|
}
|
|
8174
8308
|
}
|
|
8175
|
-
const copy = new
|
|
8309
|
+
const copy = new import_three20.Mesh(geometry, material);
|
|
8176
8310
|
copy.name = mesh.name;
|
|
8177
8311
|
copy.renderOrder = mesh.renderOrder;
|
|
8178
8312
|
scene.add(copy);
|
|
@@ -8186,9 +8320,9 @@ function createSnapshot(root, gltf, bakeColors = false) {
|
|
|
8186
8320
|
const instanced = mesh;
|
|
8187
8321
|
if (instanced.isInstancedMesh) {
|
|
8188
8322
|
for (let i = 0; i < instanced.count; i++) {
|
|
8189
|
-
const matrix = new
|
|
8323
|
+
const matrix = new import_three20.Matrix4();
|
|
8190
8324
|
instanced.getMatrixAt(i, matrix);
|
|
8191
|
-
const color = instanced.instanceColor ? new
|
|
8325
|
+
const color = instanced.instanceColor ? new import_three20.Color().fromBufferAttribute(instanced.instanceColor, i) : void 0;
|
|
8192
8326
|
addMesh(mesh, world.clone().multiply(matrix), color);
|
|
8193
8327
|
}
|
|
8194
8328
|
} else {
|
|
@@ -8200,7 +8334,7 @@ function createSnapshot(root, gltf, bakeColors = false) {
|
|
|
8200
8334
|
try {
|
|
8201
8335
|
const ancestors = [];
|
|
8202
8336
|
for (let parent = root.parent; parent; parent = parent.parent) ancestors.unshift(parent);
|
|
8203
|
-
const world = new
|
|
8337
|
+
const world = new import_three20.Matrix4();
|
|
8204
8338
|
for (const ancestor of ancestors) {
|
|
8205
8339
|
if (!ancestor.visible) return { scene, dispose };
|
|
8206
8340
|
world.multiply(localMatrix(ancestor));
|
|
@@ -8214,7 +8348,7 @@ function createSnapshot(root, gltf, bakeColors = false) {
|
|
|
8214
8348
|
}
|
|
8215
8349
|
function selectAlphaMode(material, geometry) {
|
|
8216
8350
|
const texture = material.map;
|
|
8217
|
-
if (material.type !== "MeshBasicMaterial" || !material.transparent || !material.depthWrite || material.opacity !== 1 || material.alphaMap || !texture?.isDataTexture || texture.format !==
|
|
8351
|
+
if (material.type !== "MeshBasicMaterial" || !material.transparent || !material.depthWrite || material.opacity !== 1 || material.alphaMap || !texture?.isDataTexture || texture.format !== import_three20.RGBAFormat || texture.type !== import_three20.UnsignedByteType || texture.wrapS !== import_three20.ClampToEdgeWrapping || texture.wrapT !== import_three20.ClampToEdgeWrapping || texture.magFilter !== import_three20.NearestFilter || texture.minFilter !== import_three20.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;
|
|
8218
8352
|
const uv = geometry.getAttribute(texture.channel === 0 ? "uv" : `uv${texture.channel}`);
|
|
8219
8353
|
const colors = geometry.getAttribute("color");
|
|
8220
8354
|
if (!uv || material.vertexColors && colors?.itemSize === 4) return;
|
|
@@ -8251,7 +8385,7 @@ function selectAlphaMode(material, geometry) {
|
|
|
8251
8385
|
}
|
|
8252
8386
|
function copyDataTexture(source) {
|
|
8253
8387
|
const image = source.image;
|
|
8254
|
-
if (source.format !==
|
|
8388
|
+
if (source.format !== import_three20.RGBAFormat || source.type !== import_three20.UnsignedByteType) {
|
|
8255
8389
|
throw new MineRenderError("glTF export requires RGBA unsigned-byte data textures");
|
|
8256
8390
|
}
|
|
8257
8391
|
const canvas = createCanvas(image.width, image.height);
|
|
@@ -8262,8 +8396,8 @@ function copyDataTexture(source) {
|
|
|
8262
8396
|
context.putImageData(pixels, 0, 0);
|
|
8263
8397
|
const copySource = Object.create(source);
|
|
8264
8398
|
copySource.userData = {};
|
|
8265
|
-
copySource.source = new
|
|
8266
|
-
return new
|
|
8399
|
+
copySource.source = new import_three20.Source(canvas);
|
|
8400
|
+
return new import_three20.Texture().copy(copySource);
|
|
8267
8401
|
}
|
|
8268
8402
|
|
|
8269
8403
|
// src/gui/GuiHelper.ts
|
|
@@ -8333,7 +8467,7 @@ var GuiHelper = class {
|
|
|
8333
8467
|
};
|
|
8334
8468
|
|
|
8335
8469
|
// src/gui/scene/GuiObject.ts
|
|
8336
|
-
var
|
|
8470
|
+
var import_three25 = require("three");
|
|
8337
8471
|
init_AssetKey();
|
|
8338
8472
|
init_ModelTextures();
|
|
8339
8473
|
init_Models();
|
|
@@ -8349,7 +8483,7 @@ var GuiObject = class extends SceneObject {
|
|
|
8349
8483
|
this.textureLayers = textureLayers;
|
|
8350
8484
|
this.isGuiObject = true;
|
|
8351
8485
|
/** Local bounds in GUI pixels, with y growing down from the origin. */
|
|
8352
|
-
this.bounds = new
|
|
8486
|
+
this.bounds = new import_three25.Box2();
|
|
8353
8487
|
this.geometries = /* @__PURE__ */ new Set();
|
|
8354
8488
|
this.ownedMaterials = /* @__PURE__ */ new Set();
|
|
8355
8489
|
this.initialized = false;
|
|
@@ -8367,17 +8501,17 @@ var GuiObject = class extends SceneObject {
|
|
|
8367
8501
|
item.scale.set(width2 / 16, height2 / 16, width2 / 16);
|
|
8368
8502
|
item.updateWorldMatrix(true, true);
|
|
8369
8503
|
const inverse = this.matrixWorld.clone().invert();
|
|
8370
|
-
const bounds = new
|
|
8504
|
+
const bounds = new import_three25.Box3();
|
|
8371
8505
|
item.iterateAllMeshes((mesh2) => {
|
|
8372
8506
|
mesh2.geometry.computeBoundingBox();
|
|
8373
|
-
bounds.union(mesh2.geometry.boundingBox.clone().applyMatrix4(new
|
|
8507
|
+
bounds.union(mesh2.geometry.boundingBox.clone().applyMatrix4(new import_three25.Matrix4().multiplyMatrices(inverse, mesh2.matrixWorld)));
|
|
8374
8508
|
});
|
|
8375
8509
|
item.position.z = depth - bounds.min.z;
|
|
8376
8510
|
depth += bounds.max.z - bounds.min.z + 0.01;
|
|
8377
|
-
this.bounds.expandByPoint(new
|
|
8378
|
-
this.bounds.expandByPoint(new
|
|
8379
|
-
this.bounds.expandByPoint(new
|
|
8380
|
-
this.bounds.expandByPoint(new
|
|
8511
|
+
this.bounds.expandByPoint(new import_three25.Vector2(x, y));
|
|
8512
|
+
this.bounds.expandByPoint(new import_three25.Vector2(x + width2, y + height2));
|
|
8513
|
+
this.bounds.expandByPoint(new import_three25.Vector2(bounds.min.x, -bounds.max.y));
|
|
8514
|
+
this.bounds.expandByPoint(new import_three25.Vector2(bounds.max.x, -bounds.min.y));
|
|
8381
8515
|
continue;
|
|
8382
8516
|
}
|
|
8383
8517
|
const key = typeof layer.texture === "string" ? AssetKey.parse("textures", layer.texture) : layer.texture;
|
|
@@ -8385,7 +8519,7 @@ var GuiObject = class extends SceneObject {
|
|
|
8385
8519
|
const image = material.map.image;
|
|
8386
8520
|
const [cropX, cropY, cropWidth, cropHeight] = layer.crop ?? [0, 0, image.width, image.height];
|
|
8387
8521
|
const [width, height] = layer.size ?? [cropWidth, cropHeight];
|
|
8388
|
-
const geometry = new
|
|
8522
|
+
const geometry = new import_three25.PlaneGeometry(width, height);
|
|
8389
8523
|
this.geometries.add(geometry);
|
|
8390
8524
|
const uv = geometry.getAttribute("uv");
|
|
8391
8525
|
for (let i = 0; i < uv.count; i++) {
|
|
@@ -8395,13 +8529,13 @@ var GuiObject = class extends SceneObject {
|
|
|
8395
8529
|
1 - (cropY + (1 - uv.getY(i)) * cropHeight) / image.height
|
|
8396
8530
|
);
|
|
8397
8531
|
}
|
|
8398
|
-
const mesh = new
|
|
8532
|
+
const mesh = new import_three25.Mesh(geometry, material);
|
|
8399
8533
|
mesh.name = `mesh:${layer.name ?? index}`;
|
|
8400
8534
|
mesh.position.set(x + width / 2, -y - height / 2, depth);
|
|
8401
8535
|
mesh.renderOrder = index;
|
|
8402
8536
|
this.add(mesh);
|
|
8403
|
-
this.bounds.expandByPoint(new
|
|
8404
|
-
this.bounds.expandByPoint(new
|
|
8537
|
+
this.bounds.expandByPoint(new import_three25.Vector2(x, y));
|
|
8538
|
+
this.bounds.expandByPoint(new import_three25.Vector2(x + width, y + height));
|
|
8405
8539
|
depth += 0.01;
|
|
8406
8540
|
}
|
|
8407
8541
|
for (const child of this.children) child.position.z -= depth - 0.01;
|
|
@@ -8476,7 +8610,7 @@ function isGuiObject(obj) {
|
|
|
8476
8610
|
init_image();
|
|
8477
8611
|
|
|
8478
8612
|
// src/inspector/SceneInspector.ts
|
|
8479
|
-
var
|
|
8613
|
+
var import_three26 = require("three");
|
|
8480
8614
|
init_SceneObject();
|
|
8481
8615
|
init_util();
|
|
8482
8616
|
init_log();
|
|
@@ -8486,11 +8620,11 @@ var help = "<span>Ctrl/Cmd+Click to Select<br/></span><br/>";
|
|
|
8486
8620
|
var SceneInspector = class {
|
|
8487
8621
|
constructor(renderer) {
|
|
8488
8622
|
this.renderer = renderer;
|
|
8489
|
-
this.mouse = new
|
|
8623
|
+
this.mouse = new import_three26.Vector2();
|
|
8490
8624
|
this.listeners = new AbortController();
|
|
8491
8625
|
this.objectInfoContainer = document.createElement("div");
|
|
8492
8626
|
this.objectControlsContainer = document.createElement("div");
|
|
8493
|
-
this.raycaster = new
|
|
8627
|
+
this.raycaster = new import_three26.Raycaster();
|
|
8494
8628
|
this.init();
|
|
8495
8629
|
}
|
|
8496
8630
|
init() {
|
|
@@ -8885,6 +9019,7 @@ function isInstanceable(obj) {
|
|
|
8885
9019
|
init_DisplayPosition();
|
|
8886
9020
|
init_DisplayTransforms();
|
|
8887
9021
|
init_GuiLight();
|
|
9022
|
+
init_ItemTints();
|
|
8888
9023
|
init_Model();
|
|
8889
9024
|
init_ModelCulling();
|
|
8890
9025
|
init_ModelGenerator();
|
|
@@ -8892,7 +9027,7 @@ init_ModelMerger();
|
|
|
8892
9027
|
init_SpecialItems();
|
|
8893
9028
|
|
|
8894
9029
|
// src/model/block/BlockStateResolver.ts
|
|
8895
|
-
var
|
|
9030
|
+
var import_three28 = require("three");
|
|
8896
9031
|
init_BlockStates();
|
|
8897
9032
|
init_MineRenderError();
|
|
8898
9033
|
init_util();
|
|
@@ -8970,7 +9105,7 @@ var BlockStateResolver = class {
|
|
|
8970
9105
|
return variants[variants.length - 1];
|
|
8971
9106
|
}
|
|
8972
9107
|
static rotation(variant) {
|
|
8973
|
-
const rotation = new
|
|
9108
|
+
const rotation = new import_three28.Euler();
|
|
8974
9109
|
if (typeof variant.x !== "undefined") {
|
|
8975
9110
|
rotation.x = toRadians(clampRotationDegrees(variant.x));
|
|
8976
9111
|
}
|
|
@@ -8982,10 +9117,7 @@ var BlockStateResolver = class {
|
|
|
8982
9117
|
};
|
|
8983
9118
|
|
|
8984
9119
|
// src/model/block/BlockTints.ts
|
|
8985
|
-
|
|
8986
|
-
init_ModelTextures();
|
|
8987
|
-
init_Caching();
|
|
8988
|
-
init_MineRenderError();
|
|
9120
|
+
init_Colormaps();
|
|
8989
9121
|
|
|
8990
9122
|
// src/model/block/blockTints.json
|
|
8991
9123
|
var blockTints_default = {
|
|
@@ -9040,7 +9172,7 @@ var BlockTints = class {
|
|
|
9040
9172
|
color = rule.color;
|
|
9041
9173
|
break;
|
|
9042
9174
|
case "grass":
|
|
9043
|
-
color = await
|
|
9175
|
+
color = await Colormaps.grassColor(key);
|
|
9044
9176
|
break;
|
|
9045
9177
|
case "redstone": {
|
|
9046
9178
|
const power = Number(state.power ?? 0) / 15;
|
|
@@ -9058,18 +9190,6 @@ var BlockTints = class {
|
|
|
9058
9190
|
}
|
|
9059
9191
|
return { ...Object.fromEntries([...indices].map((index) => [index, color])), ...tints };
|
|
9060
9192
|
}
|
|
9061
|
-
static async grassColor(origin) {
|
|
9062
|
-
const key = AssetKey.parse("textures", "minecraft:colormap/grass", origin);
|
|
9063
|
-
return await Caching.blockTintCache.get(key.serialize(), async () => {
|
|
9064
|
-
const image = await ModelTextures.get(key);
|
|
9065
|
-
if (!image) throw new MineRenderError(`Missing grass colormap: ${key.toNamespacedString()}`);
|
|
9066
|
-
if (image.width !== 256 || image.height !== 256) {
|
|
9067
|
-
throw new MineRenderError("Grass colormaps must be 256 \xD7 256 pixels");
|
|
9068
|
-
}
|
|
9069
|
-
const [red, green, blue] = image.data.getImageData(127, 127, 1, 1).data;
|
|
9070
|
-
return red << 16 | green << 8 | blue;
|
|
9071
|
-
});
|
|
9072
|
-
}
|
|
9073
9193
|
};
|
|
9074
9194
|
|
|
9075
9195
|
// src/model/block/scene/BlockObject.ts
|
|
@@ -9077,7 +9197,7 @@ init_SceneObject();
|
|
|
9077
9197
|
init_ModelObject();
|
|
9078
9198
|
init_Models();
|
|
9079
9199
|
var import_ts_deepmerge6 = __toESM(require_dist());
|
|
9080
|
-
var
|
|
9200
|
+
var import_three31 = require("three");
|
|
9081
9201
|
init_MineRenderError();
|
|
9082
9202
|
init_InstanceReference();
|
|
9083
9203
|
init_AssetKey();
|
|
@@ -9099,7 +9219,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
9099
9219
|
this._models = [];
|
|
9100
9220
|
this._cullMask = 0;
|
|
9101
9221
|
this._entities = [];
|
|
9102
|
-
this._entityPlacement = new
|
|
9222
|
+
this._entityPlacement = new import_three31.Matrix4();
|
|
9103
9223
|
this._entityGeneration = 0;
|
|
9104
9224
|
this.options = (0, import_ts_deepmerge6.default)({}, _BlockObject.DEFAULT_OPTIONS, options ?? {});
|
|
9105
9225
|
}
|
|
@@ -9179,7 +9299,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
9179
9299
|
return true;
|
|
9180
9300
|
}
|
|
9181
9301
|
placeEntities() {
|
|
9182
|
-
const matrix = new
|
|
9302
|
+
const matrix = new import_three31.Matrix4().makeTranslation(this.position.x - 8, this.position.y - 8, this.position.z - 8).multiply(this._entityPlacement);
|
|
9183
9303
|
for (const entity of this._entities) {
|
|
9184
9304
|
matrix.decompose(entity.position, entity.quaternion, entity.scale);
|
|
9185
9305
|
}
|
|
@@ -9198,12 +9318,12 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
9198
9318
|
getModelCullMask(model, worldMask) {
|
|
9199
9319
|
const object = isInstanceReference(model) ? model.instanceable : model;
|
|
9200
9320
|
if (object.options.displayPosition) return 0;
|
|
9201
|
-
const position = new
|
|
9202
|
-
const rotation = new
|
|
9203
|
-
const scale = new
|
|
9321
|
+
const position = new import_three31.Vector3();
|
|
9322
|
+
const rotation = new import_three31.Quaternion();
|
|
9323
|
+
const scale = new import_three31.Vector3();
|
|
9204
9324
|
this.getModelMatrix(model).decompose(position, rotation, scale);
|
|
9205
|
-
if (position.distanceToSquared(this.position) > 1e-10 || scale.distanceToSquared(new
|
|
9206
|
-
return ModelCulling.toLocalMask(worldMask, new
|
|
9325
|
+
if (position.distanceToSquared(this.position) > 1e-10 || scale.distanceToSquared(new import_three31.Vector3(1, 1, 1)) > 1e-10) return 0;
|
|
9326
|
+
return ModelCulling.toLocalMask(worldMask, new import_three31.Euler().setFromQuaternion(rotation));
|
|
9207
9327
|
}
|
|
9208
9328
|
async setCullMask(worldMask) {
|
|
9209
9329
|
worldMask &= 63;
|
|
@@ -9265,7 +9385,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
9265
9385
|
() => new FluidModelObject2(kind, surface.sample, this.blockState.key, this.options)
|
|
9266
9386
|
);
|
|
9267
9387
|
const previous = this._fluidModel;
|
|
9268
|
-
const matrix = previous ? this.getModelMatrix(previous) : new
|
|
9388
|
+
const matrix = previous ? this.getModelMatrix(previous) : new import_three31.Matrix4().makeTranslation(...this.position.toArray());
|
|
9269
9389
|
if (isInstanceReference(replacement)) replacement.setMatrix(matrix);
|
|
9270
9390
|
else matrix.decompose(replacement.position, replacement.quaternion, replacement.scale);
|
|
9271
9391
|
this._models = this._models.filter((model) => model !== previous);
|
|
@@ -9403,7 +9523,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
9403
9523
|
setPositionRotationScaleAt(index, position, rotation, scale) {
|
|
9404
9524
|
super.setPositionRotationScaleAt(index, position, rotation, scale);
|
|
9405
9525
|
}
|
|
9406
|
-
getMatrixAt(index, matrix = new
|
|
9526
|
+
getMatrixAt(index, matrix = new import_three31.Matrix4()) {
|
|
9407
9527
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
9408
9528
|
const child = this._models[0];
|
|
9409
9529
|
if (child && isModelObject(child)) {
|
|
@@ -11274,7 +11394,7 @@ init_ModelObject();
|
|
|
11274
11394
|
init_nbt();
|
|
11275
11395
|
|
|
11276
11396
|
// src/renderer/MineRenderScene.ts
|
|
11277
|
-
var
|
|
11397
|
+
var import_three33 = require("three");
|
|
11278
11398
|
init_SceneObject();
|
|
11279
11399
|
var import_ts_deepmerge8 = __toESM(require_dist());
|
|
11280
11400
|
init_ModelObject();
|
|
@@ -12007,7 +12127,7 @@ var import_ts_deepmerge7 = __toESM(require_dist());
|
|
|
12007
12127
|
init_util();
|
|
12008
12128
|
|
|
12009
12129
|
// src/skin/SkinTextures.ts
|
|
12010
|
-
var
|
|
12130
|
+
var import_three32 = require("three");
|
|
12011
12131
|
init_Caching();
|
|
12012
12132
|
init_CacheKey();
|
|
12013
12133
|
init_MineRenderError();
|
|
@@ -12091,11 +12211,11 @@ var SkinTextures = class {
|
|
|
12091
12211
|
});
|
|
12092
12212
|
}
|
|
12093
12213
|
static createMaterial(pixels, width, height, transparent = true) {
|
|
12094
|
-
const texture = Textures.initTextureProps(new
|
|
12095
|
-
texture.colorSpace =
|
|
12214
|
+
const texture = Textures.initTextureProps(new import_three32.DataTexture(pixels, width, height));
|
|
12215
|
+
texture.colorSpace = import_three32.SRGBColorSpace;
|
|
12096
12216
|
texture.flipY = true;
|
|
12097
12217
|
texture.needsUpdate = true;
|
|
12098
|
-
return new
|
|
12218
|
+
return new import_three32.MeshBasicMaterial({ map: texture, transparent, side: transparent ? import_three32.DoubleSide : import_three32.FrontSide, alphaTest: transparent ? 0.1 : 0 });
|
|
12099
12219
|
}
|
|
12100
12220
|
static isSlim(image, scale) {
|
|
12101
12221
|
for (const [x, y] of [[46, 52], [54, 20]]) {
|
|
@@ -12324,7 +12444,8 @@ var SkinObject = class extends SceneObject {
|
|
|
12324
12444
|
|
|
12325
12445
|
// src/renderer/MineRenderScene.ts
|
|
12326
12446
|
init_EntityObject();
|
|
12327
|
-
|
|
12447
|
+
init_ItemTints();
|
|
12448
|
+
var _MineRenderScene = class _MineRenderScene extends import_three33.Scene {
|
|
12328
12449
|
constructor(options) {
|
|
12329
12450
|
super();
|
|
12330
12451
|
this.isMineRenderScene = true;
|
|
@@ -12416,6 +12537,7 @@ var _MineRenderScene = class _MineRenderScene extends import_three32.Scene {
|
|
|
12416
12537
|
}
|
|
12417
12538
|
}
|
|
12418
12539
|
async addModel(model, options, parent = this) {
|
|
12540
|
+
options = { ...options, tints: await ItemTints.get(model, options?.tints) };
|
|
12419
12541
|
return this.addSceneObject(model, () => new ModelObject(model, options), options, parent);
|
|
12420
12542
|
}
|
|
12421
12543
|
async addBlock(blockState, options, parent = this) {
|
|
@@ -12451,7 +12573,7 @@ function isMineRenderScene(obj) {
|
|
|
12451
12573
|
}
|
|
12452
12574
|
|
|
12453
12575
|
// src/renderer/Renderer.ts
|
|
12454
|
-
var
|
|
12576
|
+
var import_three35 = require("three");
|
|
12455
12577
|
var import_ts_deepmerge9 = __toESM(require_dist());
|
|
12456
12578
|
var import_stats = __toESM(require("stats.js"));
|
|
12457
12579
|
var import_postprocessing = require("postprocessing");
|
|
@@ -12460,11 +12582,11 @@ init_Model();
|
|
|
12460
12582
|
init_three();
|
|
12461
12583
|
|
|
12462
12584
|
// src/three/OrbitControls.js
|
|
12463
|
-
var
|
|
12585
|
+
var import_three34 = require("three");
|
|
12464
12586
|
var _changeEvent = { type: "change" };
|
|
12465
12587
|
var _startEvent = { type: "start" };
|
|
12466
12588
|
var _endEvent = { type: "end" };
|
|
12467
|
-
var OrbitControls = class extends
|
|
12589
|
+
var OrbitControls = class extends import_three34.EventDispatcher {
|
|
12468
12590
|
constructor(object, domElement) {
|
|
12469
12591
|
super();
|
|
12470
12592
|
if (domElement === void 0) console.warn('THREE.OrbitControls: The second parameter "domElement" is now mandatory.');
|
|
@@ -12473,7 +12595,7 @@ var OrbitControls = class extends import_three33.EventDispatcher {
|
|
|
12473
12595
|
this.domElement = domElement;
|
|
12474
12596
|
this.domElement.style.touchAction = "none";
|
|
12475
12597
|
this.enabled = true;
|
|
12476
|
-
this.target = new
|
|
12598
|
+
this.target = new import_three34.Vector3();
|
|
12477
12599
|
this.minDistance = 0;
|
|
12478
12600
|
this.maxDistance = Infinity;
|
|
12479
12601
|
this.minZoom = 0;
|
|
@@ -12495,8 +12617,8 @@ var OrbitControls = class extends import_three33.EventDispatcher {
|
|
|
12495
12617
|
this.autoRotate = false;
|
|
12496
12618
|
this.autoRotateSpeed = 2;
|
|
12497
12619
|
this.keys = { LEFT: "ArrowLeft", UP: "ArrowUp", RIGHT: "ArrowRight", BOTTOM: "ArrowDown" };
|
|
12498
|
-
this.mouseButtons = { LEFT:
|
|
12499
|
-
this.touches = { ONE:
|
|
12620
|
+
this.mouseButtons = { LEFT: import_three34.MOUSE.ROTATE, MIDDLE: import_three34.MOUSE.DOLLY, RIGHT: import_three34.MOUSE.PAN };
|
|
12621
|
+
this.touches = { ONE: import_three34.TOUCH.ROTATE, TWO: import_three34.TOUCH.DOLLY_PAN };
|
|
12500
12622
|
this.target0 = this.target.clone();
|
|
12501
12623
|
this.position0 = this.object.position.clone();
|
|
12502
12624
|
this.zoom0 = this.object.zoom;
|
|
@@ -12525,11 +12647,11 @@ var OrbitControls = class extends import_three33.EventDispatcher {
|
|
|
12525
12647
|
state = STATE.NONE;
|
|
12526
12648
|
};
|
|
12527
12649
|
this.update = function() {
|
|
12528
|
-
const offset = new
|
|
12529
|
-
const quat = new
|
|
12650
|
+
const offset = new import_three34.Vector3();
|
|
12651
|
+
const quat = new import_three34.Quaternion().setFromUnitVectors(object.up, new import_three34.Vector3(0, 1, 0));
|
|
12530
12652
|
const quatInverse = quat.clone().invert();
|
|
12531
|
-
const lastPosition = new
|
|
12532
|
-
const lastQuaternion = new
|
|
12653
|
+
const lastPosition = new import_three34.Vector3();
|
|
12654
|
+
const lastQuaternion = new import_three34.Quaternion();
|
|
12533
12655
|
const twoPI = 2 * Math.PI;
|
|
12534
12656
|
return function update() {
|
|
12535
12657
|
const position = scope.object.position;
|
|
@@ -12615,20 +12737,20 @@ var OrbitControls = class extends import_three33.EventDispatcher {
|
|
|
12615
12737
|
};
|
|
12616
12738
|
let state = STATE.NONE;
|
|
12617
12739
|
const EPS = 1e-6;
|
|
12618
|
-
const spherical = new
|
|
12619
|
-
const sphericalDelta = new
|
|
12740
|
+
const spherical = new import_three34.Spherical();
|
|
12741
|
+
const sphericalDelta = new import_three34.Spherical();
|
|
12620
12742
|
let scale = 1;
|
|
12621
|
-
const panOffset = new
|
|
12743
|
+
const panOffset = new import_three34.Vector3();
|
|
12622
12744
|
let zoomChanged = false;
|
|
12623
|
-
const rotateStart = new
|
|
12624
|
-
const rotateEnd = new
|
|
12625
|
-
const rotateDelta = new
|
|
12626
|
-
const panStart = new
|
|
12627
|
-
const panEnd = new
|
|
12628
|
-
const panDelta = new
|
|
12629
|
-
const dollyStart = new
|
|
12630
|
-
const dollyEnd = new
|
|
12631
|
-
const dollyDelta = new
|
|
12745
|
+
const rotateStart = new import_three34.Vector2();
|
|
12746
|
+
const rotateEnd = new import_three34.Vector2();
|
|
12747
|
+
const rotateDelta = new import_three34.Vector2();
|
|
12748
|
+
const panStart = new import_three34.Vector2();
|
|
12749
|
+
const panEnd = new import_three34.Vector2();
|
|
12750
|
+
const panDelta = new import_three34.Vector2();
|
|
12751
|
+
const dollyStart = new import_three34.Vector2();
|
|
12752
|
+
const dollyEnd = new import_three34.Vector2();
|
|
12753
|
+
const dollyDelta = new import_three34.Vector2();
|
|
12632
12754
|
const pointers = [];
|
|
12633
12755
|
const pointerPositions = {};
|
|
12634
12756
|
function getAutoRotationAngle() {
|
|
@@ -12644,7 +12766,7 @@ var OrbitControls = class extends import_three33.EventDispatcher {
|
|
|
12644
12766
|
sphericalDelta.phi -= angle;
|
|
12645
12767
|
}
|
|
12646
12768
|
const panLeft = function() {
|
|
12647
|
-
const v = new
|
|
12769
|
+
const v = new import_three34.Vector3();
|
|
12648
12770
|
return function panLeft2(distance, objectMatrix) {
|
|
12649
12771
|
v.setFromMatrixColumn(objectMatrix, 0);
|
|
12650
12772
|
v.multiplyScalar(-distance);
|
|
@@ -12652,7 +12774,7 @@ var OrbitControls = class extends import_three33.EventDispatcher {
|
|
|
12652
12774
|
};
|
|
12653
12775
|
}();
|
|
12654
12776
|
const panUp = function() {
|
|
12655
|
-
const v = new
|
|
12777
|
+
const v = new import_three34.Vector3();
|
|
12656
12778
|
return function panUp2(distance, objectMatrix) {
|
|
12657
12779
|
if (scope.screenSpacePanning === true) {
|
|
12658
12780
|
v.setFromMatrixColumn(objectMatrix, 1);
|
|
@@ -12665,7 +12787,7 @@ var OrbitControls = class extends import_three33.EventDispatcher {
|
|
|
12665
12787
|
};
|
|
12666
12788
|
}();
|
|
12667
12789
|
const pan = function() {
|
|
12668
|
-
const offset = new
|
|
12790
|
+
const offset = new import_three34.Vector3();
|
|
12669
12791
|
return function pan2(deltaX, deltaY) {
|
|
12670
12792
|
const element = scope.domElement;
|
|
12671
12793
|
if (scope.object.isPerspectiveCamera) {
|
|
@@ -12914,12 +13036,12 @@ var OrbitControls = class extends import_three33.EventDispatcher {
|
|
|
12914
13036
|
mouseAction = -1;
|
|
12915
13037
|
}
|
|
12916
13038
|
switch (mouseAction) {
|
|
12917
|
-
case
|
|
13039
|
+
case import_three34.MOUSE.DOLLY:
|
|
12918
13040
|
if (scope.enableZoom === false) return;
|
|
12919
13041
|
handleMouseDownDolly(event);
|
|
12920
13042
|
state = STATE.DOLLY;
|
|
12921
13043
|
break;
|
|
12922
|
-
case
|
|
13044
|
+
case import_three34.MOUSE.ROTATE:
|
|
12923
13045
|
if (event.ctrlKey || event.metaKey || event.shiftKey) {
|
|
12924
13046
|
if (scope.enablePan === false) return;
|
|
12925
13047
|
handleMouseDownPan(event);
|
|
@@ -12930,7 +13052,7 @@ var OrbitControls = class extends import_three33.EventDispatcher {
|
|
|
12930
13052
|
state = STATE.ROTATE;
|
|
12931
13053
|
}
|
|
12932
13054
|
break;
|
|
12933
|
-
case
|
|
13055
|
+
case import_three34.MOUSE.PAN:
|
|
12934
13056
|
if (event.ctrlKey || event.metaKey || event.shiftKey) {
|
|
12935
13057
|
if (scope.enableRotate === false) return;
|
|
12936
13058
|
handleMouseDownRotate(event);
|
|
@@ -12986,12 +13108,12 @@ var OrbitControls = class extends import_three33.EventDispatcher {
|
|
|
12986
13108
|
switch (pointers.length) {
|
|
12987
13109
|
case 1:
|
|
12988
13110
|
switch (scope.touches.ONE) {
|
|
12989
|
-
case
|
|
13111
|
+
case import_three34.TOUCH.ROTATE:
|
|
12990
13112
|
if (scope.enableRotate === false) return;
|
|
12991
13113
|
handleTouchStartRotate();
|
|
12992
13114
|
state = STATE.TOUCH_ROTATE;
|
|
12993
13115
|
break;
|
|
12994
|
-
case
|
|
13116
|
+
case import_three34.TOUCH.PAN:
|
|
12995
13117
|
if (scope.enablePan === false) return;
|
|
12996
13118
|
handleTouchStartPan();
|
|
12997
13119
|
state = STATE.TOUCH_PAN;
|
|
@@ -13002,12 +13124,12 @@ var OrbitControls = class extends import_three33.EventDispatcher {
|
|
|
13002
13124
|
break;
|
|
13003
13125
|
case 2:
|
|
13004
13126
|
switch (scope.touches.TWO) {
|
|
13005
|
-
case
|
|
13127
|
+
case import_three34.TOUCH.DOLLY_PAN:
|
|
13006
13128
|
if (scope.enableZoom === false && scope.enablePan === false) return;
|
|
13007
13129
|
handleTouchStartDollyPan();
|
|
13008
13130
|
state = STATE.TOUCH_DOLLY_PAN;
|
|
13009
13131
|
break;
|
|
13010
|
-
case
|
|
13132
|
+
case import_three34.TOUCH.DOLLY_ROTATE:
|
|
13011
13133
|
if (scope.enableZoom === false && scope.enableRotate === false) return;
|
|
13012
13134
|
handleTouchStartDollyRotate();
|
|
13013
13135
|
state = STATE.TOUCH_DOLLY_ROTATE;
|
|
@@ -13074,7 +13196,7 @@ var OrbitControls = class extends import_three33.EventDispatcher {
|
|
|
13074
13196
|
function trackPointer(event) {
|
|
13075
13197
|
let position = pointerPositions[event.pointerId];
|
|
13076
13198
|
if (position === void 0) {
|
|
13077
|
-
position = new
|
|
13199
|
+
position = new import_three34.Vector2();
|
|
13078
13200
|
pointerPositions[event.pointerId] = position;
|
|
13079
13201
|
}
|
|
13080
13202
|
position.set(event.pageX, event.pageY);
|
|
@@ -13094,10 +13216,10 @@ var MapControls = class extends OrbitControls {
|
|
|
13094
13216
|
constructor(object, domElement) {
|
|
13095
13217
|
super(object, domElement);
|
|
13096
13218
|
this.screenSpacePanning = false;
|
|
13097
|
-
this.mouseButtons.LEFT =
|
|
13098
|
-
this.mouseButtons.RIGHT =
|
|
13099
|
-
this.touches.ONE =
|
|
13100
|
-
this.touches.TWO =
|
|
13219
|
+
this.mouseButtons.LEFT = import_three34.MOUSE.PAN;
|
|
13220
|
+
this.mouseButtons.RIGHT = import_three34.MOUSE.ROTATE;
|
|
13221
|
+
this.touches.ONE = import_three34.TOUCH.PAN;
|
|
13222
|
+
this.touches.TWO = import_three34.TOUCH.DOLLY_ROTATE;
|
|
13101
13223
|
}
|
|
13102
13224
|
};
|
|
13103
13225
|
|
|
@@ -13148,14 +13270,14 @@ var _Renderer = class _Renderer {
|
|
|
13148
13270
|
switch (this.options.camera.type) {
|
|
13149
13271
|
case "perspective":
|
|
13150
13272
|
default:
|
|
13151
|
-
return new
|
|
13273
|
+
return new import_three35.PerspectiveCamera(
|
|
13152
13274
|
this.options.camera.perspective.fov,
|
|
13153
13275
|
this.options.camera.perspective.aspect ?? this.viewWidth / this.viewHeight,
|
|
13154
13276
|
this.options.camera.near,
|
|
13155
13277
|
this.options.camera.far
|
|
13156
13278
|
);
|
|
13157
13279
|
case "orthographic":
|
|
13158
|
-
return new
|
|
13280
|
+
return new import_three35.OrthographicCamera(
|
|
13159
13281
|
this.options.camera.orthographic.left ?? this.viewWidth / -2,
|
|
13160
13282
|
this.options.camera.orthographic.right ?? this.viewWidth / 2,
|
|
13161
13283
|
this.options.camera.orthographic.top ?? this.viewHeight / 2,
|
|
@@ -13166,7 +13288,7 @@ var _Renderer = class _Renderer {
|
|
|
13166
13288
|
}
|
|
13167
13289
|
}
|
|
13168
13290
|
createRenderer() {
|
|
13169
|
-
const renderer = new
|
|
13291
|
+
const renderer = new import_three35.WebGLRenderer({
|
|
13170
13292
|
antialias: this.options.render.antialias,
|
|
13171
13293
|
alpha: true,
|
|
13172
13294
|
powerPreference: "high-performance",
|
|
@@ -13174,8 +13296,8 @@ var _Renderer = class _Renderer {
|
|
|
13174
13296
|
});
|
|
13175
13297
|
renderer.setClearColor(0, 0);
|
|
13176
13298
|
renderer.shadowMap.enabled = true;
|
|
13177
|
-
renderer.shadowMap.type =
|
|
13178
|
-
renderer.outputColorSpace =
|
|
13299
|
+
renderer.shadowMap.type = import_three35.PCFSoftShadowMap;
|
|
13300
|
+
renderer.outputColorSpace = import_three35.SRGBColorSpace;
|
|
13179
13301
|
renderer.setPixelRatio(this.options.render.pixelRatio ?? 1);
|
|
13180
13302
|
renderer.setSize(this.viewWidth, this.viewHeight);
|
|
13181
13303
|
return renderer;
|
|
@@ -13210,20 +13332,20 @@ var _Renderer = class _Renderer {
|
|
|
13210
13332
|
window["__THREE_DEVTOOLS__"].dispatchEvent(new CustomEvent("observe", { detail: this.scene }));
|
|
13211
13333
|
}
|
|
13212
13334
|
if (this.options.debug.grid) {
|
|
13213
|
-
const gridHelper = new
|
|
13335
|
+
const gridHelper = new import_three35.GridHelper(128, 16);
|
|
13214
13336
|
this._debugHelpers.push(gridHelper);
|
|
13215
13337
|
this.scene.add(gridHelper);
|
|
13216
|
-
const gridHelper2 = new
|
|
13338
|
+
const gridHelper2 = new import_three35.GridHelper(128, 16);
|
|
13217
13339
|
this._debugHelpers.push(gridHelper2);
|
|
13218
13340
|
gridHelper2.rotation.x = 90 * (Math.PI / 180);
|
|
13219
13341
|
this.scene.add(gridHelper2);
|
|
13220
|
-
const gridHelper3 = new
|
|
13342
|
+
const gridHelper3 = new import_three35.GridHelper(128, 16);
|
|
13221
13343
|
this._debugHelpers.push(gridHelper3);
|
|
13222
13344
|
gridHelper3.rotation.z = 90 * (Math.PI / 180);
|
|
13223
13345
|
this.scene.add(gridHelper3);
|
|
13224
13346
|
}
|
|
13225
13347
|
if (this.options.debug.axes) {
|
|
13226
|
-
const axesHelper = new
|
|
13348
|
+
const axesHelper = new import_three35.AxesHelper(64);
|
|
13227
13349
|
this._debugHelpers.push(axesHelper);
|
|
13228
13350
|
this.scene.add(axesHelper);
|
|
13229
13351
|
}
|
|
@@ -13482,8 +13604,8 @@ _Renderer.DEFAULT_OPTIONS = (0, import_ts_deepmerge9.default)({}, {
|
|
|
13482
13604
|
top: void 0,
|
|
13483
13605
|
bottom: void 0
|
|
13484
13606
|
},
|
|
13485
|
-
position: new
|
|
13486
|
-
lookingAt: new
|
|
13607
|
+
position: new import_three35.Vector3(50, 50, 50),
|
|
13608
|
+
lookingAt: new import_three35.Vector3(0, 0, 0)
|
|
13487
13609
|
},
|
|
13488
13610
|
render: {
|
|
13489
13611
|
fpsLimit: 60,
|
|
@@ -13679,6 +13801,7 @@ var Skins = class {
|
|
|
13679
13801
|
};
|
|
13680
13802
|
|
|
13681
13803
|
// src/texture/index.ts
|
|
13804
|
+
init_Colormaps();
|
|
13682
13805
|
init_TextureAtlas();
|
|
13683
13806
|
init_TextureLoader();
|
|
13684
13807
|
init_Textures();
|
|
@@ -13947,12 +14070,12 @@ var AnvilParser = class {
|
|
|
13947
14070
|
};
|
|
13948
14071
|
|
|
13949
14072
|
// src/world/Chunk.ts
|
|
13950
|
-
var
|
|
14073
|
+
var import_three40 = require("three");
|
|
13951
14074
|
init_BlockStates();
|
|
13952
14075
|
init_AssetKey();
|
|
13953
14076
|
|
|
13954
14077
|
// src/world/MineRenderWorld.ts
|
|
13955
|
-
var
|
|
14078
|
+
var import_three38 = require("three");
|
|
13956
14079
|
init_Model();
|
|
13957
14080
|
init_BatchedExecutor();
|
|
13958
14081
|
init_AssetKey();
|
|
@@ -13960,7 +14083,7 @@ init_BlockStates();
|
|
|
13960
14083
|
init_CubeFace();
|
|
13961
14084
|
|
|
13962
14085
|
// src/world/SectionModels.ts
|
|
13963
|
-
var
|
|
14086
|
+
var import_three37 = require("three");
|
|
13964
14087
|
init_AssetKey();
|
|
13965
14088
|
init_Models();
|
|
13966
14089
|
init_CubeFace();
|
|
@@ -14026,12 +14149,12 @@ var SectionModels = class {
|
|
|
14026
14149
|
});
|
|
14027
14150
|
await object.init();
|
|
14028
14151
|
const geometry = object.children[0].geometry;
|
|
14029
|
-
geometry.applyMatrix4(new
|
|
14152
|
+
geometry.applyMatrix4(new import_three37.Matrix4().makeRotationFromEuler(rotation));
|
|
14030
14153
|
object.clear();
|
|
14031
14154
|
const cullFaces = CUBE_FACES.map((face) => {
|
|
14032
14155
|
const local = CUBE_FACES.findIndex((name) => name === atlas.model.elements[0].faces[face]?.cullface);
|
|
14033
14156
|
if (local < 0) return 0;
|
|
14034
|
-
const normal = new
|
|
14157
|
+
const normal = new import_three37.Vector3(...CUBE_FACE_OFFSETS[local]).applyEuler(rotation);
|
|
14035
14158
|
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);
|
|
14036
14159
|
return 1 << world;
|
|
14037
14160
|
});
|
|
@@ -14061,20 +14184,20 @@ var MineRenderWorld = class {
|
|
|
14061
14184
|
}
|
|
14062
14185
|
getBlockAt(posOrX, y, z) {
|
|
14063
14186
|
if (typeof posOrX == "number") {
|
|
14064
|
-
return this.getBlockAt(new
|
|
14187
|
+
return this.getBlockAt(new import_three38.Vector3(posOrX, y, z));
|
|
14065
14188
|
}
|
|
14066
14189
|
if (isTripleArray(posOrX)) {
|
|
14067
|
-
return this.getBlockAt(new
|
|
14190
|
+
return this.getBlockAt(new import_three38.Vector3(posOrX[0], posOrX[1], posOrX[2]));
|
|
14068
14191
|
}
|
|
14069
14192
|
this.validatePosBounds(posOrX);
|
|
14070
14193
|
return this.getChunkAt(posOrX)?.getBlockAt(posOrX);
|
|
14071
14194
|
}
|
|
14072
14195
|
async setBlockAt(posOrX, yOrBlock, z, block) {
|
|
14073
14196
|
if (typeof posOrX == "number") {
|
|
14074
|
-
return this.setBlockAt(new
|
|
14197
|
+
return this.setBlockAt(new import_three38.Vector3(posOrX, yOrBlock, z), block);
|
|
14075
14198
|
}
|
|
14076
14199
|
if (isTripleArray(posOrX)) {
|
|
14077
|
-
return this.setBlockAt(new
|
|
14200
|
+
return this.setBlockAt(new import_three38.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
|
|
14078
14201
|
}
|
|
14079
14202
|
return this.placeBlock(posOrX, yOrBlock);
|
|
14080
14203
|
}
|
|
@@ -14095,7 +14218,7 @@ var MineRenderWorld = class {
|
|
|
14095
14218
|
const collect = async (positions2) => {
|
|
14096
14219
|
for (const pos of positions2) changes.set(pos.toArray().join(","), pos);
|
|
14097
14220
|
};
|
|
14098
|
-
const place = (block) => this.placeBlock(new
|
|
14221
|
+
const place = (block) => this.placeBlock(new import_three38.Vector3(...block.position), block, collect);
|
|
14099
14222
|
const keys = /* @__PURE__ */ new Map();
|
|
14100
14223
|
for (const block of multiblock.blocks) {
|
|
14101
14224
|
if (Chunk.isAir(block)) continue;
|
|
@@ -14173,13 +14296,13 @@ var MineRenderWorld = class {
|
|
|
14173
14296
|
for (const pos of positions) {
|
|
14174
14297
|
this.pendingCulling.set(pos.toArray().join(","), pos.clone());
|
|
14175
14298
|
for (const offset of CUBE_FACE_OFFSETS) {
|
|
14176
|
-
const neighbor = pos.clone().add(new
|
|
14299
|
+
const neighbor = pos.clone().add(new import_three38.Vector3(...offset));
|
|
14177
14300
|
this.pendingCulling.set(neighbor.toArray().join(","), neighbor);
|
|
14178
14301
|
}
|
|
14179
14302
|
for (let y = -1; y <= 1; y++) {
|
|
14180
14303
|
for (let z = -1; z <= 1; z++) {
|
|
14181
14304
|
for (let x = -1; x <= 1; x++) {
|
|
14182
|
-
const neighbor = pos.clone().add(new
|
|
14305
|
+
const neighbor = pos.clone().add(new import_three38.Vector3(x, y, z));
|
|
14183
14306
|
if (this.getBlockAt(neighbor)?.object?.fluidKind) {
|
|
14184
14307
|
this.pendingCulling.set(neighbor.toArray().join(","), neighbor);
|
|
14185
14308
|
}
|
|
@@ -14201,7 +14324,7 @@ var MineRenderWorld = class {
|
|
|
14201
14324
|
if (!block) continue;
|
|
14202
14325
|
if (block.object?.fluidKind) {
|
|
14203
14326
|
await block.object.updateFluid((x, y, z) => {
|
|
14204
|
-
const neighbor = pos.clone().add(new
|
|
14327
|
+
const neighbor = pos.clone().add(new import_three38.Vector3(x, y, z));
|
|
14205
14328
|
const section = this.getChunkAt(neighbor);
|
|
14206
14329
|
const object = section?.getBlockAt(neighbor)?.object;
|
|
14207
14330
|
return {
|
|
@@ -14213,7 +14336,7 @@ var MineRenderWorld = class {
|
|
|
14213
14336
|
}
|
|
14214
14337
|
let mask = 0;
|
|
14215
14338
|
for (const [face, offset] of CUBE_FACE_OFFSETS.entries()) {
|
|
14216
|
-
const neighbor = pos.clone().add(new
|
|
14339
|
+
const neighbor = pos.clone().add(new import_three38.Vector3(...offset));
|
|
14217
14340
|
if (this.getChunkAt(neighbor)?.isOccludingAt(neighbor)) {
|
|
14218
14341
|
mask |= 1 << face;
|
|
14219
14342
|
}
|
|
@@ -14247,14 +14370,14 @@ var MineRenderWorld = class {
|
|
|
14247
14370
|
return this._chunks.get(this.worldPosToChunkKey(pos));
|
|
14248
14371
|
}
|
|
14249
14372
|
static worldToScenePosition(pos) {
|
|
14250
|
-
return new
|
|
14373
|
+
return new import_three38.Vector3(
|
|
14251
14374
|
pos.x * 16,
|
|
14252
14375
|
pos.y * 16,
|
|
14253
14376
|
pos.z * 16
|
|
14254
14377
|
);
|
|
14255
14378
|
}
|
|
14256
14379
|
static sceneToWorldPosition(pos) {
|
|
14257
|
-
return new
|
|
14380
|
+
return new import_three38.Vector3(
|
|
14258
14381
|
pos.x / 16,
|
|
14259
14382
|
pos.y / 16,
|
|
14260
14383
|
pos.z / 16
|
|
@@ -14277,10 +14400,10 @@ var MineRenderWorld = class {
|
|
|
14277
14400
|
init_Model();
|
|
14278
14401
|
|
|
14279
14402
|
// src/world/SectionMesh.ts
|
|
14280
|
-
var
|
|
14403
|
+
var import_three39 = require("three");
|
|
14281
14404
|
init_CanvasCompat();
|
|
14282
14405
|
init_Materials();
|
|
14283
|
-
var SectionMesh = class _SectionMesh extends
|
|
14406
|
+
var SectionMesh = class _SectionMesh extends import_three39.Group {
|
|
14284
14407
|
constructor() {
|
|
14285
14408
|
super(...arguments);
|
|
14286
14409
|
this.ownedMeshes = [];
|
|
@@ -14353,18 +14476,18 @@ var SectionMesh = class _SectionMesh extends import_three38.Group {
|
|
|
14353
14476
|
for (let corner = 0; corner < 6; corner++) indices.push(start + sourceIndices.getX(face * 6 + corner) - face * 4);
|
|
14354
14477
|
}
|
|
14355
14478
|
}
|
|
14356
|
-
const geometry = new
|
|
14357
|
-
geometry.setAttribute("position", new
|
|
14358
|
-
geometry.setAttribute("normal", new
|
|
14359
|
-
geometry.setAttribute("uv", new
|
|
14360
|
-
geometry.setAttribute("color", new
|
|
14479
|
+
const geometry = new import_three39.BufferGeometry();
|
|
14480
|
+
geometry.setAttribute("position", new import_three39.Float32BufferAttribute(positions, 3));
|
|
14481
|
+
geometry.setAttribute("normal", new import_three39.Float32BufferAttribute(normals, 3));
|
|
14482
|
+
geometry.setAttribute("uv", new import_three39.Float32BufferAttribute(uvs, 2));
|
|
14483
|
+
geometry.setAttribute("color", new import_three39.Float32BufferAttribute(colors, 3));
|
|
14361
14484
|
geometry.setIndex(indices);
|
|
14362
14485
|
geometry.computeBoundingBox();
|
|
14363
14486
|
geometry.computeBoundingSphere();
|
|
14364
14487
|
const material = Materials.createShadedCanvasMaterial(canvas, false);
|
|
14365
14488
|
material.vertexColors = true;
|
|
14366
14489
|
const texture = material.uniforms?.map?.value ?? material.map;
|
|
14367
|
-
const mesh = new
|
|
14490
|
+
const mesh = new import_three39.Mesh(geometry, material);
|
|
14368
14491
|
section.add(mesh);
|
|
14369
14492
|
section.ownedMeshes.push({ mesh, texture });
|
|
14370
14493
|
}
|
|
@@ -14398,10 +14521,10 @@ var Chunk = class _Chunk {
|
|
|
14398
14521
|
}
|
|
14399
14522
|
getBlockAt(posOrX, y, z) {
|
|
14400
14523
|
if (typeof posOrX == "number") {
|
|
14401
|
-
return this.getBlockAt(new
|
|
14524
|
+
return this.getBlockAt(new import_three40.Vector3(posOrX, y, z));
|
|
14402
14525
|
}
|
|
14403
14526
|
if (isTripleArray(posOrX)) {
|
|
14404
|
-
return this.getBlockAt(new
|
|
14527
|
+
return this.getBlockAt(new import_three40.Vector3(posOrX[0], posOrX[1], posOrX[2]));
|
|
14405
14528
|
}
|
|
14406
14529
|
const pos = this.worldPosToChunkPos(posOrX);
|
|
14407
14530
|
const index = _Chunk.chunkPosToBlockIndex(pos);
|
|
@@ -14409,10 +14532,10 @@ var Chunk = class _Chunk {
|
|
|
14409
14532
|
}
|
|
14410
14533
|
async setBlockAt(posOrX, yOrBlock, z, block) {
|
|
14411
14534
|
if (typeof posOrX == "number") {
|
|
14412
|
-
return this.setBlockAt(new
|
|
14535
|
+
return this.setBlockAt(new import_three40.Vector3(posOrX, yOrBlock, z), block);
|
|
14413
14536
|
}
|
|
14414
14537
|
if (isTripleArray(posOrX)) {
|
|
14415
|
-
return this.setBlockAt(new
|
|
14538
|
+
return this.setBlockAt(new import_three40.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
|
|
14416
14539
|
}
|
|
14417
14540
|
const worldPos = posOrX;
|
|
14418
14541
|
const pos = this.worldPosToChunkPos(worldPos);
|
|
@@ -14498,7 +14621,7 @@ var Chunk = class _Chunk {
|
|
|
14498
14621
|
}
|
|
14499
14622
|
async clear(onBlocksChanged = this.onBlocksChanged) {
|
|
14500
14623
|
const positions = [...this.renderedBlocks.keys()].map((index) => this.chunkPosToWorldPos(
|
|
14501
|
-
new
|
|
14624
|
+
new import_three40.Vector3(index % 16, Math.floor(index / 256), Math.floor(index / 16) % 16)
|
|
14502
14625
|
));
|
|
14503
14626
|
for (const info of this.renderedBlocks.values()) info.object?.removeFromScene();
|
|
14504
14627
|
this.sectionBlocks.clear();
|
|
@@ -14522,14 +14645,14 @@ var Chunk = class _Chunk {
|
|
|
14522
14645
|
return pos.y * 16 * 16 + pos.z * 16 + pos.x;
|
|
14523
14646
|
}
|
|
14524
14647
|
worldPosToChunkPos(pos) {
|
|
14525
|
-
return new
|
|
14648
|
+
return new import_three40.Vector3(
|
|
14526
14649
|
pos.x - this.x * 16,
|
|
14527
14650
|
pos.y - this.y * 16,
|
|
14528
14651
|
pos.z - this.z * 16
|
|
14529
14652
|
);
|
|
14530
14653
|
}
|
|
14531
14654
|
chunkPosToWorldPos(pos) {
|
|
14532
|
-
return new
|
|
14655
|
+
return new import_three40.Vector3(
|
|
14533
14656
|
this.x * 16 + pos.x,
|
|
14534
14657
|
this.y * 16 + pos.y,
|
|
14535
14658
|
this.z * 16 + pos.z
|