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/node/index.js
CHANGED
|
@@ -1501,7 +1501,7 @@ var init_Models = __esm({
|
|
|
1501
1501
|
}
|
|
1502
1502
|
static async getItemModel(key) {
|
|
1503
1503
|
const itemKey = new AssetKey(key.namespace, key.path, "items", void 0, key.rootType, ".json", key.root);
|
|
1504
|
-
const model = await this.PERSISTENT_CACHE.getOrLoad(AssetLoader.persistentKey(itemKey.serialize())
|
|
1504
|
+
const model = await this.PERSISTENT_CACHE.getOrLoad(`item-v2:${AssetLoader.persistentKey(itemKey.serialize())}`, async () => {
|
|
1505
1505
|
const result = await AssetLoader.getFirst([itemKey, key], "json" /* JSON */);
|
|
1506
1506
|
if (!result) return void 0;
|
|
1507
1507
|
if (result.key.assetType !== "items") return { ...result.asset, key };
|
|
@@ -1510,7 +1510,7 @@ var init_Models = __esm({
|
|
|
1510
1510
|
modelKey.root = key.root;
|
|
1511
1511
|
const model2 = await this.getRaw(modelKey);
|
|
1512
1512
|
if (!model2) throw new Error(`Item ${key.toNamespacedString()} references missing model ${selected.model}`);
|
|
1513
|
-
return selected.special
|
|
1513
|
+
return { ...model2, ...selected.special && { special: selected.special }, ...selected.tints && { tints: selected.tints } };
|
|
1514
1514
|
});
|
|
1515
1515
|
return model ? { ...model, key: Object.assign(new AssetKey("", ""), model.key) } : void 0;
|
|
1516
1516
|
}
|
|
@@ -1521,7 +1521,7 @@ var init_Models = __esm({
|
|
|
1521
1521
|
}
|
|
1522
1522
|
switch (node.type.replace(/^minecraft:/, "")) {
|
|
1523
1523
|
case "model":
|
|
1524
|
-
if (typeof node.model === "string" && node.model) return { model: node.model };
|
|
1524
|
+
if (typeof node.model === "string" && node.model) return { model: node.model, tints: node.tints };
|
|
1525
1525
|
break;
|
|
1526
1526
|
case "special": {
|
|
1527
1527
|
if (!node.base || !node.model || typeof node.model !== "object") break;
|
|
@@ -3324,11 +3324,11 @@ var init_Entities = __esm({
|
|
|
3324
3324
|
return { ...layers[names[0]], id: model.id, layers, ...model.transform && { transform: model.transform } };
|
|
3325
3325
|
}
|
|
3326
3326
|
/**
|
|
3327
|
-
*
|
|
3327
|
+
* Native and sampled vanilla clips by name, or undefined when the model or selected version has none.
|
|
3328
3328
|
*/
|
|
3329
3329
|
static async getAnimations(modelKey) {
|
|
3330
3330
|
const path = isAssetKey(modelKey) ? modelKey.getFullPath() : modelKey.path;
|
|
3331
|
-
const key = new AssetKey(modelKey.namespace, path, void 0, void 0, "entity-models/animations", ".json");
|
|
3331
|
+
const key = new AssetKey(modelKey.namespace, path, void 0, void 0, "entity-models/animations", ".json", isAssetKey(modelKey) ? modelKey.root : void 0);
|
|
3332
3332
|
const file = await Caching.entityAnimationCache.get(key.serialize(), () => AssetLoader.get(key, "json" /* JSON */));
|
|
3333
3333
|
return file?.animations;
|
|
3334
3334
|
}
|
|
@@ -3378,7 +3378,7 @@ function sampleEntityKeyframes(keyframes, time) {
|
|
|
3378
3378
|
let low = 0, high = keyframes.length;
|
|
3379
3379
|
while (low < high) {
|
|
3380
3380
|
const middle = low + high >>> 1;
|
|
3381
|
-
if (time
|
|
3381
|
+
if (time < keyframes[middle].time) high = middle;
|
|
3382
3382
|
else low = middle + 1;
|
|
3383
3383
|
}
|
|
3384
3384
|
const a = Math.max(0, low - 1);
|
|
@@ -3417,9 +3417,10 @@ var init_EntityAnimation = __esm({
|
|
|
3417
3417
|
});
|
|
3418
3418
|
|
|
3419
3419
|
// src/entity/scene/EntityAnimationPlayer.ts
|
|
3420
|
-
var ZERO, EntityAnimationPlayer;
|
|
3420
|
+
var import_three11, ZERO, EntityAnimationPlayer;
|
|
3421
3421
|
var init_EntityAnimationPlayer = __esm({
|
|
3422
3422
|
"src/entity/scene/EntityAnimationPlayer.ts"() {
|
|
3423
|
+
import_three11 = require("three");
|
|
3423
3424
|
init_EntityAnimation();
|
|
3424
3425
|
ZERO = [0, 0, 0];
|
|
3425
3426
|
EntityAnimationPlayer = class {
|
|
@@ -3436,25 +3437,45 @@ var init_EntityAnimationPlayer = __esm({
|
|
|
3436
3437
|
return this._time;
|
|
3437
3438
|
}
|
|
3438
3439
|
/**
|
|
3439
|
-
* Starts an animation on
|
|
3440
|
-
*
|
|
3440
|
+
* Starts an animation on matching named parts. Supplied baked poses are the baseline for offsets;
|
|
3441
|
+
* without them, the current pose is used. Stopping restores the pose from before playback.
|
|
3441
3442
|
*/
|
|
3442
|
-
play(layers, animation, options = {}) {
|
|
3443
|
+
play(layers, animation, options = {}, poses) {
|
|
3443
3444
|
this.stop();
|
|
3444
3445
|
this._animation = animation;
|
|
3445
3446
|
this._time = options.time ?? 0;
|
|
3446
3447
|
this.loop = options.loop ?? animation.loop;
|
|
3447
3448
|
this.speed = options.speed ?? 1;
|
|
3448
3449
|
for (const layer of layers) {
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
|
|
3450
|
+
const objects = [];
|
|
3451
|
+
if (poses) {
|
|
3452
|
+
layer.traverse((object) => {
|
|
3453
|
+
if (poses.has(object)) objects.push(object);
|
|
3454
|
+
});
|
|
3455
|
+
} else {
|
|
3456
|
+
for (const bone of Object.keys(animation.bones)) {
|
|
3457
|
+
const object = layer.getObjectByName(`group:${bone}`);
|
|
3458
|
+
if (object) objects.push(object);
|
|
3459
|
+
}
|
|
3460
|
+
}
|
|
3461
|
+
for (const object of objects) {
|
|
3462
|
+
const bone = object.name.slice("group:".length);
|
|
3463
|
+
const pose = poses?.get(object);
|
|
3464
|
+
this.parts.push({
|
|
3465
|
+
bone,
|
|
3466
|
+
object,
|
|
3467
|
+
position: object.position.clone(),
|
|
3468
|
+
rotation: object.rotation.clone(),
|
|
3469
|
+
scale: object.scale.clone(),
|
|
3470
|
+
basePosition: pose ? new import_three11.Vector3(...pose.offset) : object.position.clone(),
|
|
3471
|
+
baseRotation: pose ? new import_three11.Euler(...pose.rotation, "ZYX") : object.rotation.clone(),
|
|
3472
|
+
baseScale: pose ? new import_three11.Vector3(...pose.scale ?? [1, 1, 1]) : object.scale.clone()
|
|
3473
|
+
});
|
|
3453
3474
|
}
|
|
3454
3475
|
}
|
|
3455
3476
|
this.apply();
|
|
3456
3477
|
}
|
|
3457
|
-
/** Restores the
|
|
3478
|
+
/** Restores the poses from before playback. Returns whether an animation was active. */
|
|
3458
3479
|
stop() {
|
|
3459
3480
|
if (!this._animation) return false;
|
|
3460
3481
|
for (const part of this.parts) {
|
|
@@ -3483,10 +3504,10 @@ var init_EntityAnimationPlayer = __esm({
|
|
|
3483
3504
|
apply() {
|
|
3484
3505
|
const pose = sampleEntityAnimation(this._animation, this._time, this.loop);
|
|
3485
3506
|
for (const part of this.parts) {
|
|
3486
|
-
const { position = ZERO, rotation = ZERO, scale = ZERO } = pose[part.bone];
|
|
3487
|
-
part.object.position.set(part.
|
|
3488
|
-
part.object.rotation.set(part.
|
|
3489
|
-
part.object.scale.set(part.
|
|
3507
|
+
const { position = ZERO, rotation = ZERO, scale = ZERO } = pose[part.bone] ?? {};
|
|
3508
|
+
part.object.position.set(part.basePosition.x + position[0], part.basePosition.y + position[1], part.basePosition.z + position[2]);
|
|
3509
|
+
part.object.rotation.set(part.baseRotation.x + rotation[0], part.baseRotation.y + rotation[1], part.baseRotation.z + rotation[2], part.baseRotation.order);
|
|
3510
|
+
part.object.scale.set(part.baseScale.x + scale[0], part.baseScale.y + scale[1], part.baseScale.z + scale[2]);
|
|
3490
3511
|
}
|
|
3491
3512
|
}
|
|
3492
3513
|
};
|
|
@@ -3556,10 +3577,10 @@ var init_InstanceReference = __esm({
|
|
|
3556
3577
|
function isSceneObject(obj) {
|
|
3557
3578
|
return obj.isSceneObject;
|
|
3558
3579
|
}
|
|
3559
|
-
var
|
|
3580
|
+
var import_three12, import_ts_deepmerge3, p6, SceneObject;
|
|
3560
3581
|
var init_SceneObject = __esm({
|
|
3561
3582
|
"src/renderer/SceneObject.ts"() {
|
|
3562
|
-
|
|
3583
|
+
import_three12 = require("three");
|
|
3563
3584
|
init_Geometries();
|
|
3564
3585
|
init_UVMapper();
|
|
3565
3586
|
init_Axis();
|
|
@@ -3571,7 +3592,7 @@ var init_SceneObject = __esm({
|
|
|
3571
3592
|
import_ts_deepmerge3 = __toESM(require_dist());
|
|
3572
3593
|
init_log();
|
|
3573
3594
|
p6 = prefix("SceneObject");
|
|
3574
|
-
SceneObject = class _SceneObject extends
|
|
3595
|
+
SceneObject = class _SceneObject extends import_three12.Object3D {
|
|
3575
3596
|
constructor(options) {
|
|
3576
3597
|
super();
|
|
3577
3598
|
this.isSceneObject = true;
|
|
@@ -3623,7 +3644,7 @@ var init_SceneObject = __esm({
|
|
|
3623
3644
|
return group;
|
|
3624
3645
|
}
|
|
3625
3646
|
createGroup(name, x = 0, y = 0, z = 0, offsetAxis, offset = 0) {
|
|
3626
|
-
const obj = new
|
|
3647
|
+
const obj = new import_three12.Object3D();
|
|
3627
3648
|
if (name) {
|
|
3628
3649
|
obj.name = `group:${name}`;
|
|
3629
3650
|
}
|
|
@@ -3673,7 +3694,7 @@ var init_SceneObject = __esm({
|
|
|
3673
3694
|
return mesh;
|
|
3674
3695
|
}
|
|
3675
3696
|
createMesh(name, geometry, material, offsetAxis, offset = 0) {
|
|
3676
|
-
const mesh = new
|
|
3697
|
+
const mesh = new import_three12.Mesh(geometry, material);
|
|
3677
3698
|
if (name) {
|
|
3678
3699
|
mesh.name = `mesh:${name}`;
|
|
3679
3700
|
}
|
|
@@ -3685,7 +3706,7 @@ var init_SceneObject = __esm({
|
|
|
3685
3706
|
return mesh;
|
|
3686
3707
|
}
|
|
3687
3708
|
createInstancedMesh(name, geometry, material, count) {
|
|
3688
|
-
const mesh = new
|
|
3709
|
+
const mesh = new import_three12.InstancedMesh(geometry, material, count);
|
|
3689
3710
|
mesh.count = 0;
|
|
3690
3711
|
this.instanceMesh = mesh;
|
|
3691
3712
|
this._isInstanced = true;
|
|
@@ -3765,11 +3786,11 @@ var init_SceneObject = __esm({
|
|
|
3765
3786
|
this._instanceCounter = this.instanceReferences.size;
|
|
3766
3787
|
mesh.count = Math.max(mesh.count, index + 1);
|
|
3767
3788
|
if (mesh.instanceColor) {
|
|
3768
|
-
mesh.setColorAt(index, new
|
|
3789
|
+
mesh.setColorAt(index, new import_three12.Color(16777215));
|
|
3769
3790
|
mesh.instanceColor.needsUpdate = true;
|
|
3770
3791
|
}
|
|
3771
3792
|
if (this._scene) this._scene.stats.instanceCount++;
|
|
3772
|
-
this.setMatrixAt(index, new
|
|
3793
|
+
this.setMatrixAt(index, new import_three12.Matrix4());
|
|
3773
3794
|
return reference;
|
|
3774
3795
|
}
|
|
3775
3796
|
/** Returns the live reference for a raycast hit on this object's instance mesh. */
|
|
@@ -3782,7 +3803,7 @@ var init_SceneObject = __esm({
|
|
|
3782
3803
|
removeInstanceAt(index) {
|
|
3783
3804
|
if (!this.instanceReferences.has(index)) return;
|
|
3784
3805
|
const mesh = this.instanceMesh;
|
|
3785
|
-
this.setMatrixAt(index, new
|
|
3806
|
+
this.setMatrixAt(index, new import_three12.Matrix4().makeScale(0, 0, 0));
|
|
3786
3807
|
this.instanceReferences.delete(index);
|
|
3787
3808
|
this.freeInstanceIndices.push(index);
|
|
3788
3809
|
this._instanceCounter = this.instanceReferences.size;
|
|
@@ -3795,7 +3816,7 @@ var init_SceneObject = __esm({
|
|
|
3795
3816
|
const grow = (attribute, fill) => {
|
|
3796
3817
|
const array = new Float32Array(capacity * attribute.itemSize).fill(fill);
|
|
3797
3818
|
array.set(attribute.array);
|
|
3798
|
-
return new
|
|
3819
|
+
return new import_three12.InstancedBufferAttribute(array, attribute.itemSize, attribute.normalized, attribute.meshPerAttribute).setUsage(attribute.usage);
|
|
3799
3820
|
};
|
|
3800
3821
|
const matrix = grow(mesh.instanceMatrix, 0);
|
|
3801
3822
|
const color = mesh.instanceColor ? grow(mesh.instanceColor, 1) : null;
|
|
@@ -3812,7 +3833,7 @@ var init_SceneObject = __esm({
|
|
|
3812
3833
|
}
|
|
3813
3834
|
//</editor-fold>
|
|
3814
3835
|
//<editor-fold desc="TRANSFORMATION">
|
|
3815
|
-
getMatrixAt(index, matrix = new
|
|
3836
|
+
getMatrixAt(index, matrix = new import_three12.Matrix4()) {
|
|
3816
3837
|
if (!this.instanceReferences.has(index)) throw new MineRenderError("Instance is not active");
|
|
3817
3838
|
this.instanceMesh.getMatrixAt(index, matrix);
|
|
3818
3839
|
return matrix;
|
|
@@ -3828,16 +3849,16 @@ var init_SceneObject = __esm({
|
|
|
3828
3849
|
}
|
|
3829
3850
|
setPositionRotationScaleAt(index, position, rotation, scale) {
|
|
3830
3851
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3831
|
-
const oldPosition = new
|
|
3832
|
-
const oldRotation = new
|
|
3833
|
-
const oldScale = new
|
|
3834
|
-
const matrix = new
|
|
3852
|
+
const oldPosition = new import_three12.Vector3();
|
|
3853
|
+
const oldRotation = new import_three12.Quaternion();
|
|
3854
|
+
const oldScale = new import_three12.Vector3();
|
|
3855
|
+
const matrix = new import_three12.Matrix4();
|
|
3835
3856
|
if (!scale || !rotation || !position) {
|
|
3836
3857
|
this.getMatrixAt(index, matrix).decompose(oldPosition, oldRotation, oldScale);
|
|
3837
3858
|
}
|
|
3838
3859
|
matrix.compose(
|
|
3839
3860
|
position ? position : oldPosition,
|
|
3840
|
-
rotation ? new
|
|
3861
|
+
rotation ? new import_three12.Quaternion().setFromEuler(rotation) : oldRotation,
|
|
3841
3862
|
scale ? scale : oldScale
|
|
3842
3863
|
);
|
|
3843
3864
|
this.setMatrixAt(index, matrix);
|
|
@@ -3846,7 +3867,7 @@ var init_SceneObject = __esm({
|
|
|
3846
3867
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3847
3868
|
this.setPositionRotationScaleAt(index, position);
|
|
3848
3869
|
}
|
|
3849
|
-
getPositionAt(index, vector = new
|
|
3870
|
+
getPositionAt(index, vector = new import_three12.Vector3()) {
|
|
3850
3871
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3851
3872
|
const matrix = this.getMatrixAt(index);
|
|
3852
3873
|
vector.setFromMatrixPosition(matrix);
|
|
@@ -3856,17 +3877,17 @@ var init_SceneObject = __esm({
|
|
|
3856
3877
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3857
3878
|
this.setPositionRotationScaleAt(index, void 0, rotation, void 0);
|
|
3858
3879
|
}
|
|
3859
|
-
getRotationAt(index, euler = new
|
|
3880
|
+
getRotationAt(index, euler = new import_three12.Euler()) {
|
|
3860
3881
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3861
|
-
const rotation = new
|
|
3862
|
-
this.getMatrixAt(index).decompose(new
|
|
3882
|
+
const rotation = new import_three12.Quaternion();
|
|
3883
|
+
this.getMatrixAt(index).decompose(new import_three12.Vector3(), rotation, new import_three12.Vector3());
|
|
3863
3884
|
return euler.setFromQuaternion(rotation);
|
|
3864
3885
|
}
|
|
3865
3886
|
setScaleAt(index, scale) {
|
|
3866
3887
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3867
3888
|
this.setPositionRotationScaleAt(index, void 0, void 0, scale);
|
|
3868
3889
|
}
|
|
3869
|
-
getScaleAt(index, vector = new
|
|
3890
|
+
getScaleAt(index, vector = new import_three12.Vector3()) {
|
|
3870
3891
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3871
3892
|
const matrix = this.getMatrixAt(index);
|
|
3872
3893
|
vector.setFromMatrixScale(matrix);
|
|
@@ -3994,13 +4015,13 @@ var init_SceneObject = __esm({
|
|
|
3994
4015
|
function isEntityObject(obj) {
|
|
3995
4016
|
return obj.isEntityObject;
|
|
3996
4017
|
}
|
|
3997
|
-
var import_ts_deepmerge4,
|
|
4018
|
+
var import_ts_deepmerge4, import_three14, EntityObject;
|
|
3998
4019
|
var init_EntityObject = __esm({
|
|
3999
4020
|
"src/entity/scene/EntityObject.ts"() {
|
|
4000
4021
|
init_SceneObject();
|
|
4001
4022
|
init_Caching();
|
|
4002
4023
|
import_ts_deepmerge4 = __toESM(require_dist());
|
|
4003
|
-
|
|
4024
|
+
import_three14 = require("three");
|
|
4004
4025
|
init_Ticker();
|
|
4005
4026
|
init_model();
|
|
4006
4027
|
init_ModelTextures();
|
|
@@ -4021,7 +4042,8 @@ var init_EntityObject = __esm({
|
|
|
4021
4042
|
this.scrollMaterials = [];
|
|
4022
4043
|
/** Entity age in ticks, as vanilla's `ageInTicks`; drives the scrolling render modes. */
|
|
4023
4044
|
this.age = 0;
|
|
4024
|
-
this.
|
|
4045
|
+
this.animationPlayers = [];
|
|
4046
|
+
this.partPoses = /* @__PURE__ */ new Map();
|
|
4025
4047
|
this.options = (0, import_ts_deepmerge4.default)({}, _EntityObject.DEFAULT_OPTIONS, options ?? {});
|
|
4026
4048
|
this.addEventListener("added", () => this.updateScrollSubscription());
|
|
4027
4049
|
this.addEventListener("removed", () => this.updateScrollSubscription());
|
|
@@ -4041,7 +4063,8 @@ var init_EntityObject = __esm({
|
|
|
4041
4063
|
for (const geometry of this.geometries) geometry.dispose();
|
|
4042
4064
|
this.geometries.clear();
|
|
4043
4065
|
for (const dispose of this.disposeWireframes.splice(0)) dispose();
|
|
4044
|
-
this.
|
|
4066
|
+
for (const player of this.animationPlayers.splice(0)) player.clear();
|
|
4067
|
+
this.partPoses.clear();
|
|
4045
4068
|
super.disposeAndRemoveAllChildren();
|
|
4046
4069
|
}
|
|
4047
4070
|
clearScrollMaterials() {
|
|
@@ -4073,36 +4096,61 @@ var init_EntityObject = __esm({
|
|
|
4073
4096
|
this.notifyDirty();
|
|
4074
4097
|
}
|
|
4075
4098
|
//<editor-fold desc="ANIMATION">
|
|
4076
|
-
/** The
|
|
4099
|
+
/** The first active clip, until playback is stopped or the object is disposed. */
|
|
4077
4100
|
get animation() {
|
|
4078
|
-
return this.
|
|
4101
|
+
return this.animationPlayers[0]?.animation;
|
|
4102
|
+
}
|
|
4103
|
+
/** Clips playing together, each targeting a separate geometry layer. */
|
|
4104
|
+
get activeAnimations() {
|
|
4105
|
+
return this.animationPlayers.map((player) => player.animation);
|
|
4079
4106
|
}
|
|
4080
4107
|
/** Seconds since the animation started, before looping. */
|
|
4081
4108
|
get animationTime() {
|
|
4082
|
-
return this.
|
|
4109
|
+
return this.animationPlayers[0]?.time ?? 0;
|
|
4083
4110
|
}
|
|
4084
4111
|
/**
|
|
4085
|
-
*
|
|
4086
|
-
*
|
|
4112
|
+
* Plays a clip from {@link Entities.getAnimations}, replacing all active clips.
|
|
4113
|
+
* Offsets apply to the baked pose in the clip's layer (`main` by default), including repeated draws of that layer.
|
|
4087
4114
|
* The object owns no clock: call {@link advanceAnimation} per frame, or {@link setAnimationTime}.
|
|
4088
4115
|
*/
|
|
4089
4116
|
playAnimation(animation, options) {
|
|
4117
|
+
this.playAnimations([animation], options);
|
|
4118
|
+
}
|
|
4119
|
+
/** Plays one clip per selected geometry layer, with a shared clock and no blending between clips. */
|
|
4120
|
+
playAnimations(animations, options) {
|
|
4121
|
+
const targets = /* @__PURE__ */ new Set();
|
|
4122
|
+
const selections = animations.map((animation) => {
|
|
4123
|
+
const layer = animation.layer ?? "main";
|
|
4124
|
+
if (targets.has(layer)) throw new Error(`Multiple animations target layer "${layer}"`);
|
|
4125
|
+
targets.add(layer);
|
|
4126
|
+
const names = Object.keys(this.entityLayers).filter((name) => name.split("#")[0] === layer);
|
|
4127
|
+
if (!names.length) throw new Error(`Entity ${this.entity.id} has no selected animation layer "${layer}"`);
|
|
4128
|
+
return { animation, names };
|
|
4129
|
+
});
|
|
4090
4130
|
this.createMeshes();
|
|
4091
|
-
|
|
4092
|
-
|
|
4131
|
+
this.stopAnimation();
|
|
4132
|
+
for (const { animation, names } of selections) {
|
|
4133
|
+
const player = new EntityAnimationPlayer();
|
|
4134
|
+
player.play(names.map((name) => this.getLayerGroup(name)), animation, options, this.partPoses);
|
|
4135
|
+
this.animationPlayers.push(player);
|
|
4136
|
+
}
|
|
4093
4137
|
this.notifyDirty();
|
|
4094
4138
|
}
|
|
4095
|
-
/** Stops
|
|
4139
|
+
/** Stops all clips and restores the poses from before playback. */
|
|
4096
4140
|
stopAnimation() {
|
|
4097
|
-
|
|
4141
|
+
const players = this.animationPlayers.splice(0);
|
|
4142
|
+
for (const player of players) player.stop();
|
|
4143
|
+
if (players.length) this.notifyDirty();
|
|
4098
4144
|
}
|
|
4099
4145
|
/** Poses the object at an explicit time in seconds. Has no effect without an animation. */
|
|
4100
4146
|
setAnimationTime(seconds) {
|
|
4101
|
-
|
|
4147
|
+
for (const player of this.animationPlayers) player.setTime(seconds);
|
|
4148
|
+
if (this.animationPlayers.length) this.notifyDirty();
|
|
4102
4149
|
}
|
|
4103
4150
|
/** Advances the animation by a frame delta in seconds, scaled by its speed. Has no effect without an animation. */
|
|
4104
4151
|
advanceAnimation(deltaSeconds) {
|
|
4105
|
-
|
|
4152
|
+
for (const player of this.animationPlayers) player.advance(deltaSeconds);
|
|
4153
|
+
if (this.animationPlayers.length) this.notifyDirty();
|
|
4106
4154
|
}
|
|
4107
4155
|
//</editor-fold>
|
|
4108
4156
|
getLayerGroup(name) {
|
|
@@ -4134,14 +4182,14 @@ var init_EntityObject = __esm({
|
|
|
4134
4182
|
}
|
|
4135
4183
|
createMeshes(force = false) {
|
|
4136
4184
|
if (this.meshesCreated && !force) return;
|
|
4137
|
-
const modelRoot = new
|
|
4185
|
+
const modelRoot = new import_three14.Object3D();
|
|
4138
4186
|
const transform = this.options.flip === void 0 ? this.entity.transform : void 0;
|
|
4139
4187
|
if (transform) {
|
|
4140
4188
|
for (const op of transform) {
|
|
4141
|
-
const matrix = new
|
|
4189
|
+
const matrix = new import_three14.Matrix4();
|
|
4142
4190
|
if ("scale" in op) matrix.makeScale(...op.scale);
|
|
4143
4191
|
else if ("translate" in op) matrix.makeTranslation(...op.translate);
|
|
4144
|
-
else matrix.makeRotationFromEuler(new
|
|
4192
|
+
else matrix.makeRotationFromEuler(new import_three14.Euler(...op.rotate, "ZYX"));
|
|
4145
4193
|
modelRoot.matrix.multiply(matrix);
|
|
4146
4194
|
}
|
|
4147
4195
|
modelRoot.matrixAutoUpdate = false;
|
|
@@ -4162,6 +4210,7 @@ var init_EntityObject = __esm({
|
|
|
4162
4210
|
anchor.position.fromArray(part.pose.offset);
|
|
4163
4211
|
anchor.rotation.set(...part.pose.rotation, "ZYX");
|
|
4164
4212
|
anchor.scale.fromArray(part.pose.scale ?? [1, 1, 1]);
|
|
4213
|
+
this.partPoses.set(anchor, part.pose);
|
|
4165
4214
|
parent.add(anchor);
|
|
4166
4215
|
const size = part.texture ?? textureSize;
|
|
4167
4216
|
for (const cube of part.cubes) {
|
|
@@ -4197,7 +4246,7 @@ var init_EntityObject = __esm({
|
|
|
4197
4246
|
const tint = layer.tint === void 0 ? void 0 : this.options.tints?.[layer.tint];
|
|
4198
4247
|
const scroll = Materials.entityModeScroll(mode);
|
|
4199
4248
|
const assetKeyStr = this.getTextureKey(layer).serialize();
|
|
4200
|
-
const keyStr = `entity:${mode}:${tint === void 0 ? "" : new
|
|
4249
|
+
const keyStr = `entity:${mode}:${tint === void 0 ? "" : new import_three14.Color(tint).getHexString()}:${assetKeyStr}`;
|
|
4201
4250
|
let mat = scroll ? void 0 : Caching.materialCache.getIfPresent(keyStr);
|
|
4202
4251
|
if (!mat) {
|
|
4203
4252
|
const cachedAsset = Caching.textureAssetCache.getIfPresent(assetKeyStr);
|
|
@@ -4238,7 +4287,7 @@ function mergeBufferGeometries(geometries, useGroups = false) {
|
|
|
4238
4287
|
const attributes = {};
|
|
4239
4288
|
const morphAttributes = {};
|
|
4240
4289
|
const morphTargetsRelative = geometries[0].morphTargetsRelative;
|
|
4241
|
-
const mergedGeometry = new
|
|
4290
|
+
const mergedGeometry = new import_three21.BufferGeometry();
|
|
4242
4291
|
let offset = 0;
|
|
4243
4292
|
for (let i = 0; i < geometries.length; ++i) {
|
|
4244
4293
|
const geometry = geometries[i];
|
|
@@ -4362,7 +4411,7 @@ function mergeBufferAttributes(attributes) {
|
|
|
4362
4411
|
array.set(attributes[i].array, offset);
|
|
4363
4412
|
offset += attributes[i].array.length;
|
|
4364
4413
|
}
|
|
4365
|
-
return new
|
|
4414
|
+
return new import_three21.BufferAttribute(array, itemSize, normalized);
|
|
4366
4415
|
}
|
|
4367
4416
|
function interleaveAttributes(attributes) {
|
|
4368
4417
|
let TypedArray;
|
|
@@ -4378,7 +4427,7 @@ function interleaveAttributes(attributes) {
|
|
|
4378
4427
|
arrayLength += attribute.array.length;
|
|
4379
4428
|
stride += attribute.itemSize;
|
|
4380
4429
|
}
|
|
4381
|
-
const interleavedBuffer = new
|
|
4430
|
+
const interleavedBuffer = new import_three21.InterleavedBuffer(new TypedArray(arrayLength), stride);
|
|
4382
4431
|
let offset = 0;
|
|
4383
4432
|
const res = [];
|
|
4384
4433
|
const getters = ["getX", "getY", "getZ", "getW"];
|
|
@@ -4387,7 +4436,7 @@ function interleaveAttributes(attributes) {
|
|
|
4387
4436
|
const attribute = attributes[j];
|
|
4388
4437
|
const itemSize = attribute.itemSize;
|
|
4389
4438
|
const count = attribute.count;
|
|
4390
|
-
const iba = new
|
|
4439
|
+
const iba = new import_three21.InterleavedBufferAttribute(interleavedBuffer, itemSize, offset, attribute.normalized);
|
|
4391
4440
|
res.push(iba);
|
|
4392
4441
|
offset += itemSize;
|
|
4393
4442
|
for (let c = 0; c < count; c++) {
|
|
@@ -4471,13 +4520,13 @@ function mergeVertices(geometry, tolerance = 1e-4) {
|
|
|
4471
4520
|
const name = attributeNames[i];
|
|
4472
4521
|
const oldAttribute = geometry.getAttribute(name);
|
|
4473
4522
|
const buffer = new oldAttribute.array.constructor(attrArrays[name]);
|
|
4474
|
-
const attribute = new
|
|
4523
|
+
const attribute = new import_three21.BufferAttribute(buffer, oldAttribute.itemSize, oldAttribute.normalized);
|
|
4475
4524
|
result.setAttribute(name, attribute);
|
|
4476
4525
|
if (name in morphAttrsArrays) {
|
|
4477
4526
|
for (let j = 0; j < morphAttrsArrays[name].length; j++) {
|
|
4478
4527
|
const oldMorphAttribute = geometry.morphAttributes[name][j];
|
|
4479
4528
|
const buffer2 = new oldMorphAttribute.array.constructor(morphAttrsArrays[name][j]);
|
|
4480
|
-
const morphAttribute = new
|
|
4529
|
+
const morphAttribute = new import_three21.BufferAttribute(buffer2, oldMorphAttribute.itemSize, oldMorphAttribute.normalized);
|
|
4481
4530
|
result.morphAttributes[name][j] = morphAttribute;
|
|
4482
4531
|
}
|
|
4483
4532
|
}
|
|
@@ -4486,11 +4535,11 @@ function mergeVertices(geometry, tolerance = 1e-4) {
|
|
|
4486
4535
|
return result;
|
|
4487
4536
|
}
|
|
4488
4537
|
function toTrianglesDrawMode(geometry, drawMode) {
|
|
4489
|
-
if (drawMode ===
|
|
4538
|
+
if (drawMode === import_three21.TrianglesDrawMode) {
|
|
4490
4539
|
console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles.");
|
|
4491
4540
|
return geometry;
|
|
4492
4541
|
}
|
|
4493
|
-
if (drawMode ===
|
|
4542
|
+
if (drawMode === import_three21.TriangleFanDrawMode || drawMode === import_three21.TriangleStripDrawMode) {
|
|
4494
4543
|
let index = geometry.getIndex();
|
|
4495
4544
|
if (index === null) {
|
|
4496
4545
|
const indices = [];
|
|
@@ -4508,7 +4557,7 @@ function toTrianglesDrawMode(geometry, drawMode) {
|
|
|
4508
4557
|
}
|
|
4509
4558
|
const numberOfTriangles = index.count - 2;
|
|
4510
4559
|
const newIndices = [];
|
|
4511
|
-
if (drawMode ===
|
|
4560
|
+
if (drawMode === import_three21.TriangleFanDrawMode) {
|
|
4512
4561
|
for (let i = 1; i <= numberOfTriangles; i++) {
|
|
4513
4562
|
newIndices.push(index.getX(0));
|
|
4514
4563
|
newIndices.push(index.getX(i));
|
|
@@ -4544,15 +4593,15 @@ function computeMorphedAttributes(object) {
|
|
|
4544
4593
|
console.error("THREE.BufferGeometryUtils: Geometry is not of type BufferGeometry.");
|
|
4545
4594
|
return null;
|
|
4546
4595
|
}
|
|
4547
|
-
const _vA = new
|
|
4548
|
-
const _vB = new
|
|
4549
|
-
const _vC = new
|
|
4550
|
-
const _tempA = new
|
|
4551
|
-
const _tempB = new
|
|
4552
|
-
const _tempC = new
|
|
4553
|
-
const _morphA = new
|
|
4554
|
-
const _morphB = new
|
|
4555
|
-
const _morphC = new
|
|
4596
|
+
const _vA = new import_three21.Vector3();
|
|
4597
|
+
const _vB = new import_three21.Vector3();
|
|
4598
|
+
const _vC = new import_three21.Vector3();
|
|
4599
|
+
const _tempA = new import_three21.Vector3();
|
|
4600
|
+
const _tempB = new import_three21.Vector3();
|
|
4601
|
+
const _tempC = new import_three21.Vector3();
|
|
4602
|
+
const _morphA = new import_three21.Vector3();
|
|
4603
|
+
const _morphB = new import_three21.Vector3();
|
|
4604
|
+
const _morphC = new import_three21.Vector3();
|
|
4556
4605
|
function _calculateMorphedAttributeData(object2, material2, attribute, morphAttribute, morphTargetsRelative2, a2, b2, c2, modifiedAttributeArray) {
|
|
4557
4606
|
_vA.fromBufferAttribute(attribute, a2);
|
|
4558
4607
|
_vB.fromBufferAttribute(attribute, b2);
|
|
@@ -4747,8 +4796,8 @@ function computeMorphedAttributes(object) {
|
|
|
4747
4796
|
}
|
|
4748
4797
|
}
|
|
4749
4798
|
}
|
|
4750
|
-
const morphedPositionAttribute = new
|
|
4751
|
-
const morphedNormalAttribute = new
|
|
4799
|
+
const morphedPositionAttribute = new import_three21.Float32BufferAttribute(modifiedPosition, 3);
|
|
4800
|
+
const morphedNormalAttribute = new import_three21.Float32BufferAttribute(modifiedNormal, 3);
|
|
4752
4801
|
return {
|
|
4753
4802
|
positionAttribute,
|
|
4754
4803
|
normalAttribute,
|
|
@@ -4756,24 +4805,24 @@ function computeMorphedAttributes(object) {
|
|
|
4756
4805
|
morphedNormalAttribute
|
|
4757
4806
|
};
|
|
4758
4807
|
}
|
|
4759
|
-
var
|
|
4808
|
+
var import_three21;
|
|
4760
4809
|
var init_BufferGeometryUtils = __esm({
|
|
4761
4810
|
"src/three/BufferGeometryUtils.js"() {
|
|
4762
|
-
|
|
4811
|
+
import_three21 = require("three");
|
|
4763
4812
|
}
|
|
4764
4813
|
});
|
|
4765
4814
|
|
|
4766
4815
|
// src/model/ModelCulling.ts
|
|
4767
|
-
var
|
|
4816
|
+
var import_three22, ModelCulling;
|
|
4768
4817
|
var init_ModelCulling = __esm({
|
|
4769
4818
|
"src/model/ModelCulling.ts"() {
|
|
4770
|
-
|
|
4819
|
+
import_three22 = require("three");
|
|
4771
4820
|
init_CubeFace();
|
|
4772
4821
|
ModelCulling = class {
|
|
4773
4822
|
static toLocalMask(worldMask, rotation) {
|
|
4774
4823
|
let localMask = 0;
|
|
4775
4824
|
for (const [localFace, offset] of CUBE_FACE_OFFSETS.entries()) {
|
|
4776
|
-
const normal = new
|
|
4825
|
+
const normal = new import_three22.Vector3(...offset).applyEuler(rotation);
|
|
4777
4826
|
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);
|
|
4778
4827
|
if (worldFace < 0) return 0;
|
|
4779
4828
|
if (worldMask & 1 << worldFace) localMask |= 1 << localFace;
|
|
@@ -4806,10 +4855,10 @@ var init_ModelCulling = __esm({
|
|
|
4806
4855
|
});
|
|
4807
4856
|
|
|
4808
4857
|
// src/model/SpecialItems.ts
|
|
4809
|
-
var
|
|
4858
|
+
var import_three23, SpecialItems;
|
|
4810
4859
|
var init_SpecialItems = __esm({
|
|
4811
4860
|
"src/model/SpecialItems.ts"() {
|
|
4812
|
-
|
|
4861
|
+
import_three23 = require("three");
|
|
4813
4862
|
init_AssetKey();
|
|
4814
4863
|
init_Entities();
|
|
4815
4864
|
SpecialItems = class {
|
|
@@ -4837,7 +4886,7 @@ var init_SpecialItems = __esm({
|
|
|
4837
4886
|
case "minecraft:chest":
|
|
4838
4887
|
case "chest": {
|
|
4839
4888
|
const angle = -(special.openness ?? 0) * Math.PI / 2;
|
|
4840
|
-
const chest = await load("chest", texture(special.texture, "chest"), new
|
|
4889
|
+
const chest = await load("chest", texture(special.texture, "chest"), new import_three23.Matrix4(), {
|
|
4841
4890
|
lid: [angle, 0, 0],
|
|
4842
4891
|
lock: [angle, 0, 0]
|
|
4843
4892
|
});
|
|
@@ -4846,11 +4895,11 @@ var init_SpecialItems = __esm({
|
|
|
4846
4895
|
}
|
|
4847
4896
|
case "minecraft:bed":
|
|
4848
4897
|
case "bed": {
|
|
4849
|
-
const transform = new
|
|
4898
|
+
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));
|
|
4850
4899
|
const key = texture(special.texture, "bed");
|
|
4851
4900
|
return Promise.all([
|
|
4852
4901
|
load("bed_head", key, transform),
|
|
4853
|
-
load("bed_foot", key, new
|
|
4902
|
+
load("bed_foot", key, new import_three23.Matrix4().makeTranslation(0, 0, -16).multiply(transform))
|
|
4854
4903
|
]);
|
|
4855
4904
|
}
|
|
4856
4905
|
case "minecraft:head":
|
|
@@ -4875,7 +4924,7 @@ var init_SpecialItems = __esm({
|
|
|
4875
4924
|
return [await load(
|
|
4876
4925
|
id,
|
|
4877
4926
|
special.texture ? texture(special.texture, "") : void 0,
|
|
4878
|
-
new
|
|
4927
|
+
new import_three23.Matrix4().makeTranslation(8, 0, 8).multiply(new import_three23.Matrix4().makeScale(-1, -1, 1)),
|
|
4879
4928
|
rotations
|
|
4880
4929
|
)];
|
|
4881
4930
|
}
|
|
@@ -4918,17 +4967,98 @@ var init_GuiLight = __esm({
|
|
|
4918
4967
|
}
|
|
4919
4968
|
});
|
|
4920
4969
|
|
|
4970
|
+
// src/texture/Colormaps.ts
|
|
4971
|
+
var Colormaps;
|
|
4972
|
+
var init_Colormaps = __esm({
|
|
4973
|
+
"src/texture/Colormaps.ts"() {
|
|
4974
|
+
init_AssetKey();
|
|
4975
|
+
init_ModelTextures();
|
|
4976
|
+
init_Caching();
|
|
4977
|
+
init_MineRenderError();
|
|
4978
|
+
Colormaps = class {
|
|
4979
|
+
/** Samples the selected resource pack's grass colormap using Minecraft's climate coordinates. */
|
|
4980
|
+
static async grassColor(origin, temperature = 0.5, downfall = 1) {
|
|
4981
|
+
const key = AssetKey.parse("textures", "minecraft:colormap/grass", origin);
|
|
4982
|
+
const temp = Math.fround(temperature);
|
|
4983
|
+
const rain = Math.fround(downfall) * temp;
|
|
4984
|
+
const x = Math.floor((1 - temp) * 255), y = Math.floor((1 - rain) * 255);
|
|
4985
|
+
return await Caching.blockTintCache.get(`${key.serialize()}|${x},${y}`, async () => {
|
|
4986
|
+
const image = await ModelTextures.get(key);
|
|
4987
|
+
if (!image) throw new MineRenderError(`Missing grass colormap: ${key.toNamespacedString()}`);
|
|
4988
|
+
if (image.width !== 256 || image.height !== 256) {
|
|
4989
|
+
throw new MineRenderError("Grass colormaps must be 256 \xD7 256 pixels");
|
|
4990
|
+
}
|
|
4991
|
+
const [red, green, blue] = image.data.getImageData(x, y, 1, 1).data;
|
|
4992
|
+
return red << 16 | green << 8 | blue;
|
|
4993
|
+
});
|
|
4994
|
+
}
|
|
4995
|
+
};
|
|
4996
|
+
}
|
|
4997
|
+
});
|
|
4998
|
+
|
|
4999
|
+
// src/model/ItemTints.ts
|
|
5000
|
+
var ItemTints;
|
|
5001
|
+
var init_ItemTints = __esm({
|
|
5002
|
+
"src/model/ItemTints.ts"() {
|
|
5003
|
+
init_MineRenderError();
|
|
5004
|
+
init_Colormaps();
|
|
5005
|
+
ItemTints = class {
|
|
5006
|
+
/** Resolves preview colors from item definitions; explicit per-index colors take precedence. */
|
|
5007
|
+
static async get(model, tints) {
|
|
5008
|
+
const sources = model.tints;
|
|
5009
|
+
if (!sources?.length) return tints;
|
|
5010
|
+
const colors = { ...tints };
|
|
5011
|
+
await Promise.all(sources.map(async (source, index) => {
|
|
5012
|
+
if (colors[index] !== void 0) return;
|
|
5013
|
+
switch (source.type) {
|
|
5014
|
+
case "constant":
|
|
5015
|
+
case "minecraft:constant":
|
|
5016
|
+
colors[index] = this.rgb(source.value);
|
|
5017
|
+
break;
|
|
5018
|
+
case "grass":
|
|
5019
|
+
case "minecraft:grass":
|
|
5020
|
+
colors[index] = await Colormaps.grassColor(model.key, source.temperature, source.downfall);
|
|
5021
|
+
break;
|
|
5022
|
+
case "dye":
|
|
5023
|
+
case "minecraft:dye":
|
|
5024
|
+
case "potion":
|
|
5025
|
+
case "minecraft:potion":
|
|
5026
|
+
case "map_color":
|
|
5027
|
+
case "minecraft:map_color":
|
|
5028
|
+
case "firework":
|
|
5029
|
+
case "minecraft:firework":
|
|
5030
|
+
case "team":
|
|
5031
|
+
case "minecraft:team":
|
|
5032
|
+
case "custom_model_data":
|
|
5033
|
+
case "minecraft:custom_model_data":
|
|
5034
|
+
colors[index] = this.rgb(source.default);
|
|
5035
|
+
break;
|
|
5036
|
+
default:
|
|
5037
|
+
throw new MineRenderError(`Unsupported item tint source ${source.type}`);
|
|
5038
|
+
}
|
|
5039
|
+
}));
|
|
5040
|
+
return colors;
|
|
5041
|
+
}
|
|
5042
|
+
static rgb(color) {
|
|
5043
|
+
if (!Array.isArray(color)) return color & 16777215;
|
|
5044
|
+
const [red, green, blue] = color.map((channel) => Math.floor(Math.fround(Math.fround(channel) * 255)));
|
|
5045
|
+
return red << 16 | green << 8 | blue;
|
|
5046
|
+
}
|
|
5047
|
+
};
|
|
5048
|
+
}
|
|
5049
|
+
});
|
|
5050
|
+
|
|
4921
5051
|
// src/model/scene/ModelObject.ts
|
|
4922
5052
|
function isModelObject(obj) {
|
|
4923
5053
|
return obj.isModelObject;
|
|
4924
5054
|
}
|
|
4925
|
-
var
|
|
5055
|
+
var import_three24, import_ts_deepmerge5, p7, ModelObject;
|
|
4926
5056
|
var init_ModelObject = __esm({
|
|
4927
5057
|
"src/model/scene/ModelObject.ts"() {
|
|
4928
5058
|
init_SceneObject();
|
|
4929
5059
|
init_Materials();
|
|
4930
5060
|
init_UVMapper();
|
|
4931
|
-
|
|
5061
|
+
import_three24 = require("three");
|
|
4932
5062
|
init_BufferGeometryUtils();
|
|
4933
5063
|
init_model();
|
|
4934
5064
|
import_ts_deepmerge5 = __toESM(require_dist());
|
|
@@ -4940,6 +5070,7 @@ var init_ModelObject = __esm({
|
|
|
4940
5070
|
init_SpecialItems();
|
|
4941
5071
|
init_EntityObject();
|
|
4942
5072
|
init_GuiLight();
|
|
5073
|
+
init_ItemTints();
|
|
4943
5074
|
p7 = prefix("ModelObject");
|
|
4944
5075
|
ModelObject = class _ModelObject extends SceneObject {
|
|
4945
5076
|
constructor(originalModel, options) {
|
|
@@ -4958,11 +5089,12 @@ var init_ModelObject = __esm({
|
|
|
4958
5089
|
this.DEFAULT_OPTIONS = (0, import_ts_deepmerge5.default)({}, SceneObject.DEFAULT_OPTIONS, {});
|
|
4959
5090
|
}
|
|
4960
5091
|
async init() {
|
|
5092
|
+
this.options.tints = await ItemTints.get(this.originalModel, this.options.tints);
|
|
4961
5093
|
const special = this.originalModel.special;
|
|
4962
5094
|
if (special) {
|
|
4963
5095
|
const parts = await SpecialItems.getParts(special, this.originalModel.key?.root);
|
|
4964
|
-
const transform = this.options.displayPosition ? DisplayTransforms.getMatrix(this.originalModel.display, this.options.displayPosition) : new
|
|
4965
|
-
transform.multiply(new
|
|
5096
|
+
const transform = this.options.displayPosition ? DisplayTransforms.getMatrix(this.originalModel.display, this.options.displayPosition) : new import_three24.Matrix4();
|
|
5097
|
+
transform.multiply(new import_three24.Matrix4().makeTranslation(-8, -8, -8));
|
|
4966
5098
|
try {
|
|
4967
5099
|
for (const part of parts) {
|
|
4968
5100
|
const object = new EntityObject(part.model, { flip: false, wireframe: this.options.wireframe });
|
|
@@ -5024,7 +5156,7 @@ var init_ModelObject = __esm({
|
|
|
5024
5156
|
elGeo.clearGroups();
|
|
5025
5157
|
}
|
|
5026
5158
|
if (this.options.uvLockRotation) {
|
|
5027
|
-
UVMapper.lockUvs(elGeo, el.faces, this.atlas, new
|
|
5159
|
+
UVMapper.lockUvs(elGeo, el.faces, this.atlas, new import_three24.Euler(...this.options.uvLockRotation));
|
|
5028
5160
|
}
|
|
5029
5161
|
if (this.options.tints) {
|
|
5030
5162
|
const colors = new Float32Array(elGeo.getAttribute("position").count * 3).fill(1);
|
|
@@ -5033,19 +5165,19 @@ var init_ModelObject = __esm({
|
|
|
5033
5165
|
if (tintIndex === void 0 || tintIndex < 0) continue;
|
|
5034
5166
|
const tint = this.options.tints[tintIndex];
|
|
5035
5167
|
if (tint === void 0) continue;
|
|
5036
|
-
const color = new
|
|
5168
|
+
const color = new import_three24.Color(tint);
|
|
5037
5169
|
for (let vertex = 0; vertex < 4; vertex++) {
|
|
5038
5170
|
color.toArray(colors, (faceIndex * 4 + vertex) * 3);
|
|
5039
5171
|
}
|
|
5040
5172
|
}
|
|
5041
|
-
elGeo.setAttribute("color", new
|
|
5173
|
+
elGeo.setAttribute("color", new import_three24.BufferAttribute(colors, 3));
|
|
5042
5174
|
}
|
|
5043
|
-
elGeo.applyMatrix4(new
|
|
5044
|
-
elGeo.applyMatrix4(new
|
|
5175
|
+
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));
|
|
5176
|
+
elGeo.applyMatrix4(new import_three24.Matrix4().makeTranslation(el.from[0], el.from[1], el.from[2]));
|
|
5045
5177
|
if (el.rotation) {
|
|
5046
5178
|
applyElementRotation(el.rotation, elGeo);
|
|
5047
5179
|
}
|
|
5048
|
-
elGeo.applyMatrix4(new
|
|
5180
|
+
elGeo.applyMatrix4(new import_three24.Matrix4().makeTranslation(-8, -8, -8));
|
|
5049
5181
|
if (displayTransform) DisplayTransforms.apply(elGeo, displayTransform);
|
|
5050
5182
|
if (this.options.mergeMeshes) {
|
|
5051
5183
|
allGeos.push(elGeo);
|
|
@@ -5067,7 +5199,7 @@ var init_ModelObject = __esm({
|
|
|
5067
5199
|
if (allGeos.length > 0) {
|
|
5068
5200
|
combinedGeo = mergeBufferGeometries(allGeos);
|
|
5069
5201
|
} else {
|
|
5070
|
-
combinedGeo = new
|
|
5202
|
+
combinedGeo = new import_three24.BoxGeometry(16, 16, 16);
|
|
5071
5203
|
if (displayTransform) DisplayTransforms.apply(combinedGeo, displayTransform);
|
|
5072
5204
|
}
|
|
5073
5205
|
combinedGeo.computeBoundingBox();
|
|
@@ -5177,7 +5309,7 @@ function ownHeight(sample) {
|
|
|
5177
5309
|
return (level === 0 || level >= 8 ? 8 : 8 - level) / 9;
|
|
5178
5310
|
}
|
|
5179
5311
|
function createFluidGeometry(kind, sample) {
|
|
5180
|
-
const geometry = new
|
|
5312
|
+
const geometry = new import_three29.BufferGeometry();
|
|
5181
5313
|
const positions = [], normals = [], uvs = [], indices = [];
|
|
5182
5314
|
const self = sample(0, 0, 0);
|
|
5183
5315
|
const height = (x, z) => {
|
|
@@ -5276,16 +5408,16 @@ function createFluidGeometry(kind, sample) {
|
|
|
5276
5408
|
1
|
|
5277
5409
|
);
|
|
5278
5410
|
}
|
|
5279
|
-
geometry.setAttribute("position", new
|
|
5280
|
-
geometry.setAttribute("normal", new
|
|
5281
|
-
geometry.setAttribute("uv", new
|
|
5411
|
+
geometry.setAttribute("position", new import_three29.Float32BufferAttribute(positions, 3));
|
|
5412
|
+
geometry.setAttribute("normal", new import_three29.Float32BufferAttribute(normals, 3));
|
|
5413
|
+
geometry.setAttribute("uv", new import_three29.Float32BufferAttribute(uvs, 2));
|
|
5282
5414
|
geometry.setIndex(indices);
|
|
5283
5415
|
return geometry;
|
|
5284
5416
|
}
|
|
5285
|
-
var
|
|
5417
|
+
var import_three29, fluidRules, HORIZONTAL, EPSILON;
|
|
5286
5418
|
var init_FluidGeometry = __esm({
|
|
5287
5419
|
"src/model/fluid/FluidGeometry.ts"() {
|
|
5288
|
-
|
|
5420
|
+
import_three29 = require("three");
|
|
5289
5421
|
init_fluidBlocks();
|
|
5290
5422
|
fluidRules = fluidBlocks_default;
|
|
5291
5423
|
HORIZONTAL = [[0, -1], [0, 1], [-1, 0], [1, 0]];
|
|
@@ -5314,10 +5446,10 @@ function sampleFluid(kind, sample) {
|
|
|
5314
5446
|
}
|
|
5315
5447
|
return { key: key.join(""), sample: (x, y, z) => cells[(y + 1) * 9 + (z + 1) * 3 + x + 1] };
|
|
5316
5448
|
}
|
|
5317
|
-
var
|
|
5449
|
+
var import_three30, FluidModelObject;
|
|
5318
5450
|
var init_FluidModelObject = __esm({
|
|
5319
5451
|
"src/model/fluid/FluidModelObject.ts"() {
|
|
5320
|
-
|
|
5452
|
+
import_three30 = require("three");
|
|
5321
5453
|
init_AssetKey();
|
|
5322
5454
|
init_Materials();
|
|
5323
5455
|
init_ModelObject();
|
|
@@ -5350,10 +5482,10 @@ var init_FluidModelObject = __esm({
|
|
|
5350
5482
|
}
|
|
5351
5483
|
}
|
|
5352
5484
|
geometry.clearGroups();
|
|
5353
|
-
const color = new
|
|
5485
|
+
const color = new import_three30.Color(this.options.tints?.[0] ?? (this.kind === "water" ? 4159204 : 16777215));
|
|
5354
5486
|
const colors = new Float32Array(geometry.getAttribute("position").count * 3);
|
|
5355
5487
|
for (let i = 0; i < colors.length; i += 3) color.toArray(colors, i);
|
|
5356
|
-
geometry.setAttribute("color", new
|
|
5488
|
+
geometry.setAttribute("color", new import_three30.BufferAttribute(colors, 3));
|
|
5357
5489
|
geometry.computeBoundingBox();
|
|
5358
5490
|
geometry.computeBoundingSphere();
|
|
5359
5491
|
if (this.options.instanceMeshes) {
|
|
@@ -5367,7 +5499,7 @@ var init_FluidModelObject = __esm({
|
|
|
5367
5499
|
super.applyTextures();
|
|
5368
5500
|
this.iterateAllMeshes((mesh) => {
|
|
5369
5501
|
const material = mesh.material;
|
|
5370
|
-
material.side =
|
|
5502
|
+
material.side = import_three30.DoubleSide;
|
|
5371
5503
|
material.forceSinglePass = true;
|
|
5372
5504
|
material.depthWrite = !material.transparent;
|
|
5373
5505
|
});
|
|
@@ -5410,6 +5542,7 @@ __export(index_node_exports, {
|
|
|
5410
5542
|
CanvasImage: () => CanvasImage,
|
|
5411
5543
|
Chunk: () => Chunk,
|
|
5412
5544
|
ChunkData: () => ChunkData,
|
|
5545
|
+
Colormaps: () => Colormaps,
|
|
5413
5546
|
CubeFace: () => CubeFace,
|
|
5414
5547
|
CubeFaceIndex: () => CubeFaceIndex,
|
|
5415
5548
|
DEFAULT_ELEMENTS: () => DEFAULT_ELEMENTS,
|
|
@@ -5435,6 +5568,7 @@ __export(index_node_exports, {
|
|
|
5435
5568
|
ImageLoader: () => ImageLoader,
|
|
5436
5569
|
InstanceManager: () => InstanceManager,
|
|
5437
5570
|
InstanceReference: () => InstanceReference,
|
|
5571
|
+
ItemTints: () => ItemTints,
|
|
5438
5572
|
MapControls: () => MapControls,
|
|
5439
5573
|
Materials: () => Materials,
|
|
5440
5574
|
Meshes: () => Meshes,
|
|
@@ -5813,27 +5947,27 @@ init_EntityObject();
|
|
|
5813
5947
|
init_MineRenderError();
|
|
5814
5948
|
|
|
5815
5949
|
// src/export/SceneExporter.ts
|
|
5816
|
-
var
|
|
5950
|
+
var import_three20 = require("three");
|
|
5817
5951
|
|
|
5818
5952
|
// ../../node_modules/three/examples/jsm/exporters/OBJExporter.js
|
|
5819
|
-
var
|
|
5953
|
+
var import_three16 = require("three");
|
|
5820
5954
|
var OBJExporter = class {
|
|
5821
5955
|
parse(object) {
|
|
5822
5956
|
let output = "";
|
|
5823
5957
|
let indexVertex = 0;
|
|
5824
5958
|
let indexVertexUvs = 0;
|
|
5825
5959
|
let indexNormals = 0;
|
|
5826
|
-
const vertex = new
|
|
5827
|
-
const color = new
|
|
5828
|
-
const normal = new
|
|
5829
|
-
const uv = new
|
|
5960
|
+
const vertex = new import_three16.Vector3();
|
|
5961
|
+
const color = new import_three16.Color();
|
|
5962
|
+
const normal = new import_three16.Vector3();
|
|
5963
|
+
const uv = new import_three16.Vector2();
|
|
5830
5964
|
const face = [];
|
|
5831
5965
|
function parseMesh(mesh) {
|
|
5832
5966
|
let nbVertex = 0;
|
|
5833
5967
|
let nbNormals = 0;
|
|
5834
5968
|
let nbVertexUvs = 0;
|
|
5835
5969
|
const geometry = mesh.geometry;
|
|
5836
|
-
const normalMatrixWorld = new
|
|
5970
|
+
const normalMatrixWorld = new import_three16.Matrix3();
|
|
5837
5971
|
const vertices = geometry.getAttribute("position");
|
|
5838
5972
|
const normals = geometry.getAttribute("normal");
|
|
5839
5973
|
const uvs = geometry.getAttribute("uv");
|
|
@@ -5952,7 +6086,7 @@ var OBJExporter = class {
|
|
|
5952
6086
|
};
|
|
5953
6087
|
|
|
5954
6088
|
// ../../node_modules/three/examples/jsm/exporters/PLYExporter.js
|
|
5955
|
-
var
|
|
6089
|
+
var import_three17 = require("three");
|
|
5956
6090
|
var PLYExporter = class {
|
|
5957
6091
|
parse(object, onDone, options = {}) {
|
|
5958
6092
|
function traverseMeshes(cb) {
|
|
@@ -6009,7 +6143,7 @@ var PLYExporter = class {
|
|
|
6009
6143
|
includeIndices = false;
|
|
6010
6144
|
}
|
|
6011
6145
|
});
|
|
6012
|
-
const tempColor = new
|
|
6146
|
+
const tempColor = new import_three17.Color();
|
|
6013
6147
|
includeIndices = includeIndices && excludeAttributes.indexOf("index") === -1;
|
|
6014
6148
|
includeNormals = includeNormals && excludeAttributes.indexOf("normal") === -1;
|
|
6015
6149
|
includeColors = includeColors && excludeAttributes.indexOf("color") === -1;
|
|
@@ -6043,8 +6177,8 @@ property list uchar int vertex_index
|
|
|
6043
6177
|
`;
|
|
6044
6178
|
}
|
|
6045
6179
|
header += "end_header\n";
|
|
6046
|
-
const vertex = new
|
|
6047
|
-
const normalMatrixWorld = new
|
|
6180
|
+
const vertex = new import_three17.Vector3();
|
|
6181
|
+
const normalMatrixWorld = new import_three17.Matrix3();
|
|
6048
6182
|
let result = null;
|
|
6049
6183
|
if (options.binary === true) {
|
|
6050
6184
|
const headerBin = new TextEncoder().encode(header);
|
|
@@ -6218,18 +6352,18 @@ property list uchar int vertex_index
|
|
|
6218
6352
|
};
|
|
6219
6353
|
|
|
6220
6354
|
// ../../node_modules/three/examples/jsm/exporters/GLTFExporter.js
|
|
6221
|
-
var
|
|
6355
|
+
var import_three19 = require("three");
|
|
6222
6356
|
|
|
6223
6357
|
// ../../node_modules/three/examples/jsm/utils/TextureUtils.js
|
|
6224
|
-
var
|
|
6358
|
+
var import_three18 = require("three");
|
|
6225
6359
|
var _renderer;
|
|
6226
6360
|
var fullscreenQuadGeometry;
|
|
6227
6361
|
var fullscreenQuadMaterial;
|
|
6228
6362
|
var fullscreenQuad;
|
|
6229
6363
|
function decompress(texture, maxTextureSize = Infinity, renderer = null) {
|
|
6230
|
-
if (!fullscreenQuadGeometry) fullscreenQuadGeometry = new
|
|
6231
|
-
if (!fullscreenQuadMaterial) fullscreenQuadMaterial = new
|
|
6232
|
-
uniforms: { blitTexture: new
|
|
6364
|
+
if (!fullscreenQuadGeometry) fullscreenQuadGeometry = new import_three18.PlaneGeometry(2, 2, 1, 1);
|
|
6365
|
+
if (!fullscreenQuadMaterial) fullscreenQuadMaterial = new import_three18.ShaderMaterial({
|
|
6366
|
+
uniforms: { blitTexture: new import_three18.Uniform(texture) },
|
|
6233
6367
|
vertexShader: `
|
|
6234
6368
|
varying vec2 vUv;
|
|
6235
6369
|
void main(){
|
|
@@ -6251,22 +6385,22 @@ function decompress(texture, maxTextureSize = Infinity, renderer = null) {
|
|
|
6251
6385
|
}`
|
|
6252
6386
|
});
|
|
6253
6387
|
fullscreenQuadMaterial.uniforms.blitTexture.value = texture;
|
|
6254
|
-
fullscreenQuadMaterial.defines.IS_SRGB = texture.colorSpace ==
|
|
6388
|
+
fullscreenQuadMaterial.defines.IS_SRGB = texture.colorSpace == import_three18.SRGBColorSpace;
|
|
6255
6389
|
fullscreenQuadMaterial.needsUpdate = true;
|
|
6256
6390
|
if (!fullscreenQuad) {
|
|
6257
|
-
fullscreenQuad = new
|
|
6391
|
+
fullscreenQuad = new import_three18.Mesh(fullscreenQuadGeometry, fullscreenQuadMaterial);
|
|
6258
6392
|
fullscreenQuad.frustrumCulled = false;
|
|
6259
6393
|
}
|
|
6260
|
-
const _camera = new
|
|
6261
|
-
const _scene = new
|
|
6394
|
+
const _camera = new import_three18.PerspectiveCamera();
|
|
6395
|
+
const _scene = new import_three18.Scene();
|
|
6262
6396
|
_scene.add(fullscreenQuad);
|
|
6263
6397
|
if (!renderer) {
|
|
6264
|
-
renderer = _renderer = new
|
|
6398
|
+
renderer = _renderer = new import_three18.WebGLRenderer({ antialias: false });
|
|
6265
6399
|
}
|
|
6266
6400
|
renderer.setSize(Math.min(texture.image.width, maxTextureSize), Math.min(texture.image.height, maxTextureSize));
|
|
6267
6401
|
renderer.clear();
|
|
6268
6402
|
renderer.render(_scene, _camera);
|
|
6269
|
-
const readableTexture = new
|
|
6403
|
+
const readableTexture = new import_three18.Texture(renderer.domElement);
|
|
6270
6404
|
readableTexture.minFilter = texture.minFilter;
|
|
6271
6405
|
readableTexture.magFilter = texture.magFilter;
|
|
6272
6406
|
readableTexture.wrapS = texture.wrapS;
|
|
@@ -6412,22 +6546,22 @@ var WEBGL_CONSTANTS = {
|
|
|
6412
6546
|
};
|
|
6413
6547
|
var KHR_MESH_QUANTIZATION = "KHR_mesh_quantization";
|
|
6414
6548
|
var THREE_TO_WEBGL = {};
|
|
6415
|
-
THREE_TO_WEBGL[
|
|
6416
|
-
THREE_TO_WEBGL[
|
|
6417
|
-
THREE_TO_WEBGL[
|
|
6418
|
-
THREE_TO_WEBGL[
|
|
6419
|
-
THREE_TO_WEBGL[
|
|
6420
|
-
THREE_TO_WEBGL[
|
|
6421
|
-
THREE_TO_WEBGL[
|
|
6422
|
-
THREE_TO_WEBGL[
|
|
6423
|
-
THREE_TO_WEBGL[
|
|
6549
|
+
THREE_TO_WEBGL[import_three19.NearestFilter] = WEBGL_CONSTANTS.NEAREST;
|
|
6550
|
+
THREE_TO_WEBGL[import_three19.NearestMipmapNearestFilter] = WEBGL_CONSTANTS.NEAREST_MIPMAP_NEAREST;
|
|
6551
|
+
THREE_TO_WEBGL[import_three19.NearestMipmapLinearFilter] = WEBGL_CONSTANTS.NEAREST_MIPMAP_LINEAR;
|
|
6552
|
+
THREE_TO_WEBGL[import_three19.LinearFilter] = WEBGL_CONSTANTS.LINEAR;
|
|
6553
|
+
THREE_TO_WEBGL[import_three19.LinearMipmapNearestFilter] = WEBGL_CONSTANTS.LINEAR_MIPMAP_NEAREST;
|
|
6554
|
+
THREE_TO_WEBGL[import_three19.LinearMipmapLinearFilter] = WEBGL_CONSTANTS.LINEAR_MIPMAP_LINEAR;
|
|
6555
|
+
THREE_TO_WEBGL[import_three19.ClampToEdgeWrapping] = WEBGL_CONSTANTS.CLAMP_TO_EDGE;
|
|
6556
|
+
THREE_TO_WEBGL[import_three19.RepeatWrapping] = WEBGL_CONSTANTS.REPEAT;
|
|
6557
|
+
THREE_TO_WEBGL[import_three19.MirroredRepeatWrapping] = WEBGL_CONSTANTS.MIRRORED_REPEAT;
|
|
6424
6558
|
var PATH_PROPERTIES = {
|
|
6425
6559
|
scale: "scale",
|
|
6426
6560
|
position: "translation",
|
|
6427
6561
|
quaternion: "rotation",
|
|
6428
6562
|
morphTargetInfluences: "weights"
|
|
6429
6563
|
};
|
|
6430
|
-
var DEFAULT_SPECULAR_COLOR = new
|
|
6564
|
+
var DEFAULT_SPECULAR_COLOR = new import_three19.Color();
|
|
6431
6565
|
var GLB_HEADER_BYTES = 12;
|
|
6432
6566
|
var GLB_HEADER_MAGIC = 1179937895;
|
|
6433
6567
|
var GLB_VERSION = 2;
|
|
@@ -6461,7 +6595,7 @@ function getMinMax(attribute, start, count) {
|
|
|
6461
6595
|
else if (a === 2) value = attribute.getZ(i);
|
|
6462
6596
|
else if (a === 3) value = attribute.getW(i);
|
|
6463
6597
|
if (attribute.normalized === true) {
|
|
6464
|
-
value =
|
|
6598
|
+
value = import_three19.MathUtils.normalize(value, attribute.array);
|
|
6465
6599
|
}
|
|
6466
6600
|
}
|
|
6467
6601
|
output.min[a] = Math.min(output.min[a], value);
|
|
@@ -6667,7 +6801,7 @@ var GLTFWriter = class {
|
|
|
6667
6801
|
isNormalizedNormalAttribute(normal) {
|
|
6668
6802
|
const cache = this.cache;
|
|
6669
6803
|
if (cache.attributesNormalized.has(normal)) return false;
|
|
6670
|
-
const v = new
|
|
6804
|
+
const v = new import_three19.Vector3();
|
|
6671
6805
|
for (let i = 0, il = normal.count; i < il; i++) {
|
|
6672
6806
|
if (Math.abs(v.fromBufferAttribute(normal, i).length() - 1) > 5e-4) return false;
|
|
6673
6807
|
}
|
|
@@ -6684,7 +6818,7 @@ var GLTFWriter = class {
|
|
|
6684
6818
|
const cache = this.cache;
|
|
6685
6819
|
if (cache.attributesNormalized.has(normal)) return cache.attributesNormalized.get(normal);
|
|
6686
6820
|
const attribute = normal.clone();
|
|
6687
|
-
const v = new
|
|
6821
|
+
const v = new import_three19.Vector3();
|
|
6688
6822
|
for (let i = 0, il = attribute.count; i < il; i++) {
|
|
6689
6823
|
v.fromBufferAttribute(attribute, i);
|
|
6690
6824
|
if (v.x === 0 && v.y === 0 && v.z === 0) {
|
|
@@ -6728,7 +6862,7 @@ var GLTFWriter = class {
|
|
|
6728
6862
|
buildMetalRoughTexture(metalnessMap, roughnessMap) {
|
|
6729
6863
|
if (metalnessMap === roughnessMap) return metalnessMap;
|
|
6730
6864
|
function getEncodingConversion(map) {
|
|
6731
|
-
if (map.colorSpace ===
|
|
6865
|
+
if (map.colorSpace === import_three19.SRGBColorSpace) {
|
|
6732
6866
|
return function SRGBToLinear(c) {
|
|
6733
6867
|
return c < 0.04045 ? c * 0.0773993808 : Math.pow(c * 0.9478672986 + 0.0521327014, 2.4);
|
|
6734
6868
|
};
|
|
@@ -6738,10 +6872,10 @@ var GLTFWriter = class {
|
|
|
6738
6872
|
};
|
|
6739
6873
|
}
|
|
6740
6874
|
console.warn("THREE.GLTFExporter: Merged metalnessMap and roughnessMap textures.");
|
|
6741
|
-
if (metalnessMap instanceof
|
|
6875
|
+
if (metalnessMap instanceof import_three19.CompressedTexture) {
|
|
6742
6876
|
metalnessMap = decompress(metalnessMap);
|
|
6743
6877
|
}
|
|
6744
|
-
if (roughnessMap instanceof
|
|
6878
|
+
if (roughnessMap instanceof import_three19.CompressedTexture) {
|
|
6745
6879
|
roughnessMap = decompress(roughnessMap);
|
|
6746
6880
|
}
|
|
6747
6881
|
const metalness = metalnessMap ? metalnessMap.image : null;
|
|
@@ -6774,8 +6908,8 @@ var GLTFWriter = class {
|
|
|
6774
6908
|
context.putImageData(composite, 0, 0);
|
|
6775
6909
|
const reference = metalnessMap || roughnessMap;
|
|
6776
6910
|
const texture = reference.clone();
|
|
6777
|
-
texture.source = new
|
|
6778
|
-
texture.colorSpace =
|
|
6911
|
+
texture.source = new import_three19.Source(canvas);
|
|
6912
|
+
texture.colorSpace = import_three19.NoColorSpace;
|
|
6779
6913
|
texture.channel = (metalnessMap || roughnessMap).channel;
|
|
6780
6914
|
if (metalnessMap && roughnessMap && metalnessMap.channel !== roughnessMap.channel) {
|
|
6781
6915
|
console.warn("THREE.GLTFExporter: UV channels for metalnessMap and roughnessMap textures must match.");
|
|
@@ -6833,7 +6967,7 @@ var GLTFWriter = class {
|
|
|
6833
6967
|
else if (a === 2) value = attribute.getZ(i);
|
|
6834
6968
|
else if (a === 3) value = attribute.getW(i);
|
|
6835
6969
|
if (attribute.normalized === true) {
|
|
6836
|
-
value =
|
|
6970
|
+
value = import_three19.MathUtils.normalize(value, attribute.array);
|
|
6837
6971
|
}
|
|
6838
6972
|
}
|
|
6839
6973
|
if (componentType === WEBGL_CONSTANTS.FLOAT) {
|
|
@@ -6983,7 +7117,7 @@ var GLTFWriter = class {
|
|
|
6983
7117
|
ctx.scale(1, -1);
|
|
6984
7118
|
}
|
|
6985
7119
|
if (image.data !== void 0) {
|
|
6986
|
-
if (format !==
|
|
7120
|
+
if (format !== import_three19.RGBAFormat) {
|
|
6987
7121
|
console.error("GLTFExporter: Only RGBAFormat is supported.", format);
|
|
6988
7122
|
}
|
|
6989
7123
|
if (image.width > options.maxTextureSize || image.height > options.maxTextureSize) {
|
|
@@ -7052,7 +7186,7 @@ var GLTFWriter = class {
|
|
|
7052
7186
|
const json = this.json;
|
|
7053
7187
|
if (cache.textures.has(map)) return cache.textures.get(map);
|
|
7054
7188
|
if (!json.textures) json.textures = [];
|
|
7055
|
-
if (map instanceof
|
|
7189
|
+
if (map instanceof import_three19.CompressedTexture) {
|
|
7056
7190
|
map = decompress(map, options.maxTextureSize);
|
|
7057
7191
|
}
|
|
7058
7192
|
let mimeType = map.userData.mimeType;
|
|
@@ -7160,7 +7294,7 @@ var GLTFWriter = class {
|
|
|
7160
7294
|
materialDef.alphaCutoff = material.alphaTest;
|
|
7161
7295
|
}
|
|
7162
7296
|
}
|
|
7163
|
-
if (material.side ===
|
|
7297
|
+
if (material.side === import_three19.DoubleSide) materialDef.doubleSided = true;
|
|
7164
7298
|
if (material.name !== "") materialDef.name = material.name;
|
|
7165
7299
|
this.serializeUserData(material, materialDef);
|
|
7166
7300
|
this._invokeAll(function(ext) {
|
|
@@ -7234,7 +7368,7 @@ var GLTFWriter = class {
|
|
|
7234
7368
|
const array = attribute.array;
|
|
7235
7369
|
if (attributeName === "JOINTS_0" && !(array instanceof Uint16Array) && !(array instanceof Uint8Array)) {
|
|
7236
7370
|
console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.');
|
|
7237
|
-
modifiedAttribute = new
|
|
7371
|
+
modifiedAttribute = new import_three19.BufferAttribute(new Uint16Array(array), attribute.itemSize, attribute.normalized);
|
|
7238
7372
|
}
|
|
7239
7373
|
const accessor = this.processAccessor(modifiedAttribute || attribute, geometry);
|
|
7240
7374
|
if (accessor !== null) {
|
|
@@ -7394,7 +7528,7 @@ var GLTFWriter = class {
|
|
|
7394
7528
|
} else {
|
|
7395
7529
|
cameraDef.perspective = {
|
|
7396
7530
|
aspectRatio: camera.aspect,
|
|
7397
|
-
yfov:
|
|
7531
|
+
yfov: import_three19.MathUtils.degToRad(camera.fov),
|
|
7398
7532
|
zfar: camera.far <= 0 ? 1e-3 : camera.far,
|
|
7399
7533
|
znear: camera.near < 0 ? 0 : camera.near
|
|
7400
7534
|
};
|
|
@@ -7422,8 +7556,8 @@ var GLTFWriter = class {
|
|
|
7422
7556
|
const samplers = [];
|
|
7423
7557
|
for (let i = 0; i < tracks.length; ++i) {
|
|
7424
7558
|
const track = tracks[i];
|
|
7425
|
-
const trackBinding =
|
|
7426
|
-
let trackNode =
|
|
7559
|
+
const trackBinding = import_three19.PropertyBinding.parseTrackName(track.name);
|
|
7560
|
+
let trackNode = import_three19.PropertyBinding.findNode(root, trackBinding.nodeName);
|
|
7427
7561
|
const trackProperty = PATH_PROPERTIES[trackBinding.propertyName];
|
|
7428
7562
|
if (trackBinding.objectName === "bones") {
|
|
7429
7563
|
if (trackNode.isSkinnedMesh === true) {
|
|
@@ -7445,14 +7579,14 @@ var GLTFWriter = class {
|
|
|
7445
7579
|
if (track.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline === true) {
|
|
7446
7580
|
interpolation = "CUBICSPLINE";
|
|
7447
7581
|
outputItemSize /= 3;
|
|
7448
|
-
} else if (track.getInterpolation() ===
|
|
7582
|
+
} else if (track.getInterpolation() === import_three19.InterpolateDiscrete) {
|
|
7449
7583
|
interpolation = "STEP";
|
|
7450
7584
|
} else {
|
|
7451
7585
|
interpolation = "LINEAR";
|
|
7452
7586
|
}
|
|
7453
7587
|
samplers.push({
|
|
7454
|
-
input: this.processAccessor(new
|
|
7455
|
-
output: this.processAccessor(new
|
|
7588
|
+
input: this.processAccessor(new import_three19.BufferAttribute(track.times, inputItemSize)),
|
|
7589
|
+
output: this.processAccessor(new import_three19.BufferAttribute(track.values, outputItemSize)),
|
|
7456
7590
|
interpolation
|
|
7457
7591
|
});
|
|
7458
7592
|
channels.push({
|
|
@@ -7484,7 +7618,7 @@ var GLTFWriter = class {
|
|
|
7484
7618
|
if (rootJoint === void 0) return null;
|
|
7485
7619
|
const joints = [];
|
|
7486
7620
|
const inverseBindMatrices = new Float32Array(skeleton.bones.length * 16);
|
|
7487
|
-
const temporaryBoneInverse = new
|
|
7621
|
+
const temporaryBoneInverse = new import_three19.Matrix4();
|
|
7488
7622
|
for (let i = 0; i < skeleton.bones.length; ++i) {
|
|
7489
7623
|
joints.push(nodeMap.get(skeleton.bones[i]));
|
|
7490
7624
|
temporaryBoneInverse.copy(skeleton.boneInverses[i]);
|
|
@@ -7492,7 +7626,7 @@ var GLTFWriter = class {
|
|
|
7492
7626
|
}
|
|
7493
7627
|
if (json.skins === void 0) json.skins = [];
|
|
7494
7628
|
json.skins.push({
|
|
7495
|
-
inverseBindMatrices: this.processAccessor(new
|
|
7629
|
+
inverseBindMatrices: this.processAccessor(new import_three19.BufferAttribute(inverseBindMatrices, 16)),
|
|
7496
7630
|
joints,
|
|
7497
7631
|
skeleton: nodeMap.get(rootJoint)
|
|
7498
7632
|
});
|
|
@@ -7588,7 +7722,7 @@ var GLTFWriter = class {
|
|
|
7588
7722
|
* @param {Array} objects List of objects to process
|
|
7589
7723
|
*/
|
|
7590
7724
|
processObjects(objects) {
|
|
7591
|
-
const scene = new
|
|
7725
|
+
const scene = new import_three19.Scene();
|
|
7592
7726
|
scene.name = "AuxScene";
|
|
7593
7727
|
for (let i = 0; i < objects.length; i++) {
|
|
7594
7728
|
scene.children.push(objects[i]);
|
|
@@ -7606,7 +7740,7 @@ var GLTFWriter = class {
|
|
|
7606
7740
|
});
|
|
7607
7741
|
const objectsWithoutScene = [];
|
|
7608
7742
|
for (let i = 0; i < input.length; i++) {
|
|
7609
|
-
if (input[i] instanceof
|
|
7743
|
+
if (input[i] instanceof import_three19.Scene) {
|
|
7610
7744
|
this.processScene(input[i]);
|
|
7611
7745
|
} else {
|
|
7612
7746
|
objectsWithoutScene.push(input[i]);
|
|
@@ -7950,10 +8084,10 @@ var GLTFMeshGpuInstancing = class {
|
|
|
7950
8084
|
const translationAttr = new Float32Array(mesh.count * 3);
|
|
7951
8085
|
const rotationAttr = new Float32Array(mesh.count * 4);
|
|
7952
8086
|
const scaleAttr = new Float32Array(mesh.count * 3);
|
|
7953
|
-
const matrix = new
|
|
7954
|
-
const position = new
|
|
7955
|
-
const quaternion = new
|
|
7956
|
-
const scale = new
|
|
8087
|
+
const matrix = new import_three19.Matrix4();
|
|
8088
|
+
const position = new import_three19.Vector3();
|
|
8089
|
+
const quaternion = new import_three19.Quaternion();
|
|
8090
|
+
const scale = new import_three19.Vector3();
|
|
7957
8091
|
for (let i = 0; i < mesh.count; i++) {
|
|
7958
8092
|
mesh.getMatrixAt(i, matrix);
|
|
7959
8093
|
matrix.decompose(position, quaternion, scale);
|
|
@@ -7962,9 +8096,9 @@ var GLTFMeshGpuInstancing = class {
|
|
|
7962
8096
|
scale.toArray(scaleAttr, i * 3);
|
|
7963
8097
|
}
|
|
7964
8098
|
const attributes = {
|
|
7965
|
-
TRANSLATION: writer.processAccessor(new
|
|
7966
|
-
ROTATION: writer.processAccessor(new
|
|
7967
|
-
SCALE: writer.processAccessor(new
|
|
8099
|
+
TRANSLATION: writer.processAccessor(new import_three19.BufferAttribute(translationAttr, 3)),
|
|
8100
|
+
ROTATION: writer.processAccessor(new import_three19.BufferAttribute(rotationAttr, 4)),
|
|
8101
|
+
SCALE: writer.processAccessor(new import_three19.BufferAttribute(scaleAttr, 3))
|
|
7968
8102
|
};
|
|
7969
8103
|
if (mesh.instanceColor)
|
|
7970
8104
|
attributes._COLOR_0 = writer.processAccessor(mesh.instanceColor);
|
|
@@ -8029,8 +8163,8 @@ GLTFExporter.Utils = {
|
|
|
8029
8163
|
const sourceTracks = clip.tracks;
|
|
8030
8164
|
for (let i = 0; i < sourceTracks.length; ++i) {
|
|
8031
8165
|
let sourceTrack = sourceTracks[i];
|
|
8032
|
-
const sourceTrackBinding =
|
|
8033
|
-
const sourceTrackNode =
|
|
8166
|
+
const sourceTrackBinding = import_three19.PropertyBinding.parseTrackName(sourceTrack.name);
|
|
8167
|
+
const sourceTrackNode = import_three19.PropertyBinding.findNode(root, sourceTrackBinding.nodeName);
|
|
8034
8168
|
if (sourceTrackBinding.propertyName !== "morphTargetInfluences" || sourceTrackBinding.propertyIndex === void 0) {
|
|
8035
8169
|
tracks.push(sourceTrack);
|
|
8036
8170
|
continue;
|
|
@@ -8041,7 +8175,7 @@ GLTFExporter.Utils = {
|
|
|
8041
8175
|
}
|
|
8042
8176
|
console.warn("THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead.");
|
|
8043
8177
|
sourceTrack = sourceTrack.clone();
|
|
8044
|
-
sourceTrack.setInterpolation(
|
|
8178
|
+
sourceTrack.setInterpolation(import_three19.InterpolateLinear);
|
|
8045
8179
|
}
|
|
8046
8180
|
const targetCount = sourceTrackNode.morphTargetInfluences.length;
|
|
8047
8181
|
const targetIndex = sourceTrackNode.morphTargetDictionary[sourceTrackBinding.propertyIndex];
|
|
@@ -8124,10 +8258,10 @@ var SceneExporter = class {
|
|
|
8124
8258
|
}
|
|
8125
8259
|
};
|
|
8126
8260
|
function localMatrix(object) {
|
|
8127
|
-
return object.matrixAutoUpdate ? new
|
|
8261
|
+
return object.matrixAutoUpdate ? new import_three20.Matrix4().compose(object.position, object.quaternion, object.scale) : object.matrix.clone();
|
|
8128
8262
|
}
|
|
8129
8263
|
function createSnapshot(root, gltf, bakeColors = false) {
|
|
8130
|
-
const scene = new
|
|
8264
|
+
const scene = new import_three20.Scene();
|
|
8131
8265
|
const geometries = [];
|
|
8132
8266
|
const materials = [];
|
|
8133
8267
|
const textures = [];
|
|
@@ -8145,7 +8279,7 @@ function createSnapshot(root, gltf, bakeColors = false) {
|
|
|
8145
8279
|
if (!uniforms.map?.value?.isTexture || !uniforms.SHADE || !uniforms.BRIGHTNESS || !uniforms.EMISSIVE) {
|
|
8146
8280
|
throw new MineRenderError("glTF export does not support this custom ShaderMaterial");
|
|
8147
8281
|
}
|
|
8148
|
-
material = new
|
|
8282
|
+
material = new import_three20.MeshBasicMaterial({
|
|
8149
8283
|
map: uniforms.map.value,
|
|
8150
8284
|
vertexColors: source.vertexColors,
|
|
8151
8285
|
transparent: source.transparent,
|
|
@@ -8155,7 +8289,7 @@ function createSnapshot(root, gltf, bakeColors = false) {
|
|
|
8155
8289
|
});
|
|
8156
8290
|
material.name = source.name;
|
|
8157
8291
|
} else if (shader.isShaderMaterial) {
|
|
8158
|
-
material = new
|
|
8292
|
+
material = new import_three20.MeshBasicMaterial({ vertexColors: source.vertexColors });
|
|
8159
8293
|
material.name = source.name;
|
|
8160
8294
|
} else {
|
|
8161
8295
|
const copySource = Object.create(source);
|
|
@@ -8209,11 +8343,11 @@ function createSnapshot(root, gltf, bakeColors = false) {
|
|
|
8209
8343
|
const material = copyMaterial(sourceMaterial, geometry);
|
|
8210
8344
|
if (!sourceMaterial.vertexColors) geometry.deleteAttribute("color");
|
|
8211
8345
|
if (bakeColors || instanceColor) {
|
|
8212
|
-
const tint = (material.color ?? new
|
|
8346
|
+
const tint = (material.color ?? new import_three20.Color()).clone();
|
|
8213
8347
|
if (instanceColor) tint.multiply(instanceColor);
|
|
8214
8348
|
if (bakeColors) {
|
|
8215
8349
|
const original = geometry.getAttribute("color");
|
|
8216
|
-
const colors = new
|
|
8350
|
+
const colors = new import_three20.Float32BufferAttribute(new Float32Array(geometry.getAttribute("position").count * 3), 3);
|
|
8217
8351
|
for (let i = 0; i < colors.count; i++) {
|
|
8218
8352
|
colors.setXYZ(i, (original?.getX(i) ?? 1) * tint.r, (original?.getY(i) ?? 1) * tint.g, (original?.getZ(i) ?? 1) * tint.b);
|
|
8219
8353
|
}
|
|
@@ -8222,7 +8356,7 @@ function createSnapshot(root, gltf, bakeColors = false) {
|
|
|
8222
8356
|
material.color.copy(tint);
|
|
8223
8357
|
}
|
|
8224
8358
|
}
|
|
8225
|
-
const copy = new
|
|
8359
|
+
const copy = new import_three20.Mesh(geometry, material);
|
|
8226
8360
|
copy.name = mesh.name;
|
|
8227
8361
|
copy.renderOrder = mesh.renderOrder;
|
|
8228
8362
|
scene.add(copy);
|
|
@@ -8236,9 +8370,9 @@ function createSnapshot(root, gltf, bakeColors = false) {
|
|
|
8236
8370
|
const instanced = mesh;
|
|
8237
8371
|
if (instanced.isInstancedMesh) {
|
|
8238
8372
|
for (let i = 0; i < instanced.count; i++) {
|
|
8239
|
-
const matrix = new
|
|
8373
|
+
const matrix = new import_three20.Matrix4();
|
|
8240
8374
|
instanced.getMatrixAt(i, matrix);
|
|
8241
|
-
const color = instanced.instanceColor ? new
|
|
8375
|
+
const color = instanced.instanceColor ? new import_three20.Color().fromBufferAttribute(instanced.instanceColor, i) : void 0;
|
|
8242
8376
|
addMesh(mesh, world.clone().multiply(matrix), color);
|
|
8243
8377
|
}
|
|
8244
8378
|
} else {
|
|
@@ -8250,7 +8384,7 @@ function createSnapshot(root, gltf, bakeColors = false) {
|
|
|
8250
8384
|
try {
|
|
8251
8385
|
const ancestors = [];
|
|
8252
8386
|
for (let parent = root.parent; parent; parent = parent.parent) ancestors.unshift(parent);
|
|
8253
|
-
const world = new
|
|
8387
|
+
const world = new import_three20.Matrix4();
|
|
8254
8388
|
for (const ancestor of ancestors) {
|
|
8255
8389
|
if (!ancestor.visible) return { scene, dispose };
|
|
8256
8390
|
world.multiply(localMatrix(ancestor));
|
|
@@ -8264,7 +8398,7 @@ function createSnapshot(root, gltf, bakeColors = false) {
|
|
|
8264
8398
|
}
|
|
8265
8399
|
function selectAlphaMode(material, geometry) {
|
|
8266
8400
|
const texture = material.map;
|
|
8267
|
-
if (material.type !== "MeshBasicMaterial" || !material.transparent || !material.depthWrite || material.opacity !== 1 || material.alphaMap || !texture?.isDataTexture || texture.format !==
|
|
8401
|
+
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;
|
|
8268
8402
|
const uv = geometry.getAttribute(texture.channel === 0 ? "uv" : `uv${texture.channel}`);
|
|
8269
8403
|
const colors = geometry.getAttribute("color");
|
|
8270
8404
|
if (!uv || material.vertexColors && colors?.itemSize === 4) return;
|
|
@@ -8301,7 +8435,7 @@ function selectAlphaMode(material, geometry) {
|
|
|
8301
8435
|
}
|
|
8302
8436
|
function copyDataTexture(source) {
|
|
8303
8437
|
const image = source.image;
|
|
8304
|
-
if (source.format !==
|
|
8438
|
+
if (source.format !== import_three20.RGBAFormat || source.type !== import_three20.UnsignedByteType) {
|
|
8305
8439
|
throw new MineRenderError("glTF export requires RGBA unsigned-byte data textures");
|
|
8306
8440
|
}
|
|
8307
8441
|
const canvas = createCanvas2(image.width, image.height);
|
|
@@ -8312,8 +8446,8 @@ function copyDataTexture(source) {
|
|
|
8312
8446
|
context.putImageData(pixels, 0, 0);
|
|
8313
8447
|
const copySource = Object.create(source);
|
|
8314
8448
|
copySource.userData = {};
|
|
8315
|
-
copySource.source = new
|
|
8316
|
-
return new
|
|
8449
|
+
copySource.source = new import_three20.Source(canvas);
|
|
8450
|
+
return new import_three20.Texture().copy(copySource);
|
|
8317
8451
|
}
|
|
8318
8452
|
|
|
8319
8453
|
// src/gui/GuiHelper.ts
|
|
@@ -8383,7 +8517,7 @@ var GuiHelper = class {
|
|
|
8383
8517
|
};
|
|
8384
8518
|
|
|
8385
8519
|
// src/gui/scene/GuiObject.ts
|
|
8386
|
-
var
|
|
8520
|
+
var import_three25 = require("three");
|
|
8387
8521
|
init_AssetKey();
|
|
8388
8522
|
init_ModelTextures();
|
|
8389
8523
|
init_Models();
|
|
@@ -8399,7 +8533,7 @@ var GuiObject = class extends SceneObject {
|
|
|
8399
8533
|
this.textureLayers = textureLayers;
|
|
8400
8534
|
this.isGuiObject = true;
|
|
8401
8535
|
/** Local bounds in GUI pixels, with y growing down from the origin. */
|
|
8402
|
-
this.bounds = new
|
|
8536
|
+
this.bounds = new import_three25.Box2();
|
|
8403
8537
|
this.geometries = /* @__PURE__ */ new Set();
|
|
8404
8538
|
this.ownedMaterials = /* @__PURE__ */ new Set();
|
|
8405
8539
|
this.initialized = false;
|
|
@@ -8417,17 +8551,17 @@ var GuiObject = class extends SceneObject {
|
|
|
8417
8551
|
item.scale.set(width2 / 16, height2 / 16, width2 / 16);
|
|
8418
8552
|
item.updateWorldMatrix(true, true);
|
|
8419
8553
|
const inverse = this.matrixWorld.clone().invert();
|
|
8420
|
-
const bounds = new
|
|
8554
|
+
const bounds = new import_three25.Box3();
|
|
8421
8555
|
item.iterateAllMeshes((mesh2) => {
|
|
8422
8556
|
mesh2.geometry.computeBoundingBox();
|
|
8423
|
-
bounds.union(mesh2.geometry.boundingBox.clone().applyMatrix4(new
|
|
8557
|
+
bounds.union(mesh2.geometry.boundingBox.clone().applyMatrix4(new import_three25.Matrix4().multiplyMatrices(inverse, mesh2.matrixWorld)));
|
|
8424
8558
|
});
|
|
8425
8559
|
item.position.z = depth - bounds.min.z;
|
|
8426
8560
|
depth += bounds.max.z - bounds.min.z + 0.01;
|
|
8427
|
-
this.bounds.expandByPoint(new
|
|
8428
|
-
this.bounds.expandByPoint(new
|
|
8429
|
-
this.bounds.expandByPoint(new
|
|
8430
|
-
this.bounds.expandByPoint(new
|
|
8561
|
+
this.bounds.expandByPoint(new import_three25.Vector2(x, y));
|
|
8562
|
+
this.bounds.expandByPoint(new import_three25.Vector2(x + width2, y + height2));
|
|
8563
|
+
this.bounds.expandByPoint(new import_three25.Vector2(bounds.min.x, -bounds.max.y));
|
|
8564
|
+
this.bounds.expandByPoint(new import_three25.Vector2(bounds.max.x, -bounds.min.y));
|
|
8431
8565
|
continue;
|
|
8432
8566
|
}
|
|
8433
8567
|
const key = typeof layer.texture === "string" ? AssetKey.parse("textures", layer.texture) : layer.texture;
|
|
@@ -8435,7 +8569,7 @@ var GuiObject = class extends SceneObject {
|
|
|
8435
8569
|
const image = material.map.image;
|
|
8436
8570
|
const [cropX, cropY, cropWidth, cropHeight] = layer.crop ?? [0, 0, image.width, image.height];
|
|
8437
8571
|
const [width, height] = layer.size ?? [cropWidth, cropHeight];
|
|
8438
|
-
const geometry = new
|
|
8572
|
+
const geometry = new import_three25.PlaneGeometry(width, height);
|
|
8439
8573
|
this.geometries.add(geometry);
|
|
8440
8574
|
const uv = geometry.getAttribute("uv");
|
|
8441
8575
|
for (let i = 0; i < uv.count; i++) {
|
|
@@ -8445,13 +8579,13 @@ var GuiObject = class extends SceneObject {
|
|
|
8445
8579
|
1 - (cropY + (1 - uv.getY(i)) * cropHeight) / image.height
|
|
8446
8580
|
);
|
|
8447
8581
|
}
|
|
8448
|
-
const mesh = new
|
|
8582
|
+
const mesh = new import_three25.Mesh(geometry, material);
|
|
8449
8583
|
mesh.name = `mesh:${layer.name ?? index}`;
|
|
8450
8584
|
mesh.position.set(x + width / 2, -y - height / 2, depth);
|
|
8451
8585
|
mesh.renderOrder = index;
|
|
8452
8586
|
this.add(mesh);
|
|
8453
|
-
this.bounds.expandByPoint(new
|
|
8454
|
-
this.bounds.expandByPoint(new
|
|
8587
|
+
this.bounds.expandByPoint(new import_three25.Vector2(x, y));
|
|
8588
|
+
this.bounds.expandByPoint(new import_three25.Vector2(x + width, y + height));
|
|
8455
8589
|
depth += 0.01;
|
|
8456
8590
|
}
|
|
8457
8591
|
for (const child of this.children) child.position.z -= depth - 0.01;
|
|
@@ -8526,7 +8660,7 @@ function isGuiObject(obj) {
|
|
|
8526
8660
|
init_image();
|
|
8527
8661
|
|
|
8528
8662
|
// src/inspector/SceneInspector.ts
|
|
8529
|
-
var
|
|
8663
|
+
var import_three26 = require("three");
|
|
8530
8664
|
init_SceneObject();
|
|
8531
8665
|
init_util();
|
|
8532
8666
|
init_log();
|
|
@@ -8536,11 +8670,11 @@ var help = "<span>Ctrl/Cmd+Click to Select<br/></span><br/>";
|
|
|
8536
8670
|
var SceneInspector = class {
|
|
8537
8671
|
constructor(renderer) {
|
|
8538
8672
|
this.renderer = renderer;
|
|
8539
|
-
this.mouse = new
|
|
8673
|
+
this.mouse = new import_three26.Vector2();
|
|
8540
8674
|
this.listeners = new AbortController();
|
|
8541
8675
|
this.objectInfoContainer = document.createElement("div");
|
|
8542
8676
|
this.objectControlsContainer = document.createElement("div");
|
|
8543
|
-
this.raycaster = new
|
|
8677
|
+
this.raycaster = new import_three26.Raycaster();
|
|
8544
8678
|
this.init();
|
|
8545
8679
|
}
|
|
8546
8680
|
init() {
|
|
@@ -8935,6 +9069,7 @@ function isInstanceable(obj) {
|
|
|
8935
9069
|
init_DisplayPosition();
|
|
8936
9070
|
init_DisplayTransforms();
|
|
8937
9071
|
init_GuiLight();
|
|
9072
|
+
init_ItemTints();
|
|
8938
9073
|
init_Model();
|
|
8939
9074
|
init_ModelCulling();
|
|
8940
9075
|
init_ModelGenerator();
|
|
@@ -8942,7 +9077,7 @@ init_ModelMerger();
|
|
|
8942
9077
|
init_SpecialItems();
|
|
8943
9078
|
|
|
8944
9079
|
// src/model/block/BlockStateResolver.ts
|
|
8945
|
-
var
|
|
9080
|
+
var import_three28 = require("three");
|
|
8946
9081
|
init_BlockStates();
|
|
8947
9082
|
init_MineRenderError();
|
|
8948
9083
|
init_util();
|
|
@@ -9020,7 +9155,7 @@ var BlockStateResolver = class {
|
|
|
9020
9155
|
return variants[variants.length - 1];
|
|
9021
9156
|
}
|
|
9022
9157
|
static rotation(variant) {
|
|
9023
|
-
const rotation = new
|
|
9158
|
+
const rotation = new import_three28.Euler();
|
|
9024
9159
|
if (typeof variant.x !== "undefined") {
|
|
9025
9160
|
rotation.x = toRadians(clampRotationDegrees(variant.x));
|
|
9026
9161
|
}
|
|
@@ -9032,10 +9167,7 @@ var BlockStateResolver = class {
|
|
|
9032
9167
|
};
|
|
9033
9168
|
|
|
9034
9169
|
// src/model/block/BlockTints.ts
|
|
9035
|
-
|
|
9036
|
-
init_ModelTextures();
|
|
9037
|
-
init_Caching();
|
|
9038
|
-
init_MineRenderError();
|
|
9170
|
+
init_Colormaps();
|
|
9039
9171
|
|
|
9040
9172
|
// src/model/block/blockTints.json
|
|
9041
9173
|
var blockTints_default = {
|
|
@@ -9090,7 +9222,7 @@ var BlockTints = class {
|
|
|
9090
9222
|
color = rule.color;
|
|
9091
9223
|
break;
|
|
9092
9224
|
case "grass":
|
|
9093
|
-
color = await
|
|
9225
|
+
color = await Colormaps.grassColor(key);
|
|
9094
9226
|
break;
|
|
9095
9227
|
case "redstone": {
|
|
9096
9228
|
const power = Number(state.power ?? 0) / 15;
|
|
@@ -9108,18 +9240,6 @@ var BlockTints = class {
|
|
|
9108
9240
|
}
|
|
9109
9241
|
return { ...Object.fromEntries([...indices].map((index) => [index, color])), ...tints };
|
|
9110
9242
|
}
|
|
9111
|
-
static async grassColor(origin) {
|
|
9112
|
-
const key = AssetKey.parse("textures", "minecraft:colormap/grass", origin);
|
|
9113
|
-
return await Caching.blockTintCache.get(key.serialize(), async () => {
|
|
9114
|
-
const image = await ModelTextures.get(key);
|
|
9115
|
-
if (!image) throw new MineRenderError(`Missing grass colormap: ${key.toNamespacedString()}`);
|
|
9116
|
-
if (image.width !== 256 || image.height !== 256) {
|
|
9117
|
-
throw new MineRenderError("Grass colormaps must be 256 \xD7 256 pixels");
|
|
9118
|
-
}
|
|
9119
|
-
const [red, green, blue] = image.data.getImageData(127, 127, 1, 1).data;
|
|
9120
|
-
return red << 16 | green << 8 | blue;
|
|
9121
|
-
});
|
|
9122
|
-
}
|
|
9123
9243
|
};
|
|
9124
9244
|
|
|
9125
9245
|
// src/model/block/scene/BlockObject.ts
|
|
@@ -9127,7 +9247,7 @@ init_SceneObject();
|
|
|
9127
9247
|
init_ModelObject();
|
|
9128
9248
|
init_Models();
|
|
9129
9249
|
var import_ts_deepmerge6 = __toESM(require_dist());
|
|
9130
|
-
var
|
|
9250
|
+
var import_three31 = require("three");
|
|
9131
9251
|
init_MineRenderError();
|
|
9132
9252
|
init_InstanceReference();
|
|
9133
9253
|
init_AssetKey();
|
|
@@ -9149,7 +9269,7 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
9149
9269
|
this._models = [];
|
|
9150
9270
|
this._cullMask = 0;
|
|
9151
9271
|
this._entities = [];
|
|
9152
|
-
this._entityPlacement = new
|
|
9272
|
+
this._entityPlacement = new import_three31.Matrix4();
|
|
9153
9273
|
this._entityGeneration = 0;
|
|
9154
9274
|
this.options = (0, import_ts_deepmerge6.default)({}, _BlockObject.DEFAULT_OPTIONS, options ?? {});
|
|
9155
9275
|
}
|
|
@@ -9234,7 +9354,7 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
9234
9354
|
return true;
|
|
9235
9355
|
}
|
|
9236
9356
|
placeEntities() {
|
|
9237
|
-
const matrix = new
|
|
9357
|
+
const matrix = new import_three31.Matrix4().makeTranslation(this.position.x - 8, this.position.y - 8, this.position.z - 8).multiply(this._entityPlacement);
|
|
9238
9358
|
for (const entity of this._entities) {
|
|
9239
9359
|
matrix.decompose(entity.position, entity.quaternion, entity.scale);
|
|
9240
9360
|
}
|
|
@@ -9253,12 +9373,12 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
9253
9373
|
getModelCullMask(model, worldMask) {
|
|
9254
9374
|
const object = isInstanceReference(model) ? model.instanceable : model;
|
|
9255
9375
|
if (object.options.displayPosition) return 0;
|
|
9256
|
-
const position = new
|
|
9257
|
-
const rotation = new
|
|
9258
|
-
const scale = new
|
|
9376
|
+
const position = new import_three31.Vector3();
|
|
9377
|
+
const rotation = new import_three31.Quaternion();
|
|
9378
|
+
const scale = new import_three31.Vector3();
|
|
9259
9379
|
this.getModelMatrix(model).decompose(position, rotation, scale);
|
|
9260
|
-
if (position.distanceToSquared(this.position) > 1e-10 || scale.distanceToSquared(new
|
|
9261
|
-
return ModelCulling.toLocalMask(worldMask, new
|
|
9380
|
+
if (position.distanceToSquared(this.position) > 1e-10 || scale.distanceToSquared(new import_three31.Vector3(1, 1, 1)) > 1e-10) return 0;
|
|
9381
|
+
return ModelCulling.toLocalMask(worldMask, new import_three31.Euler().setFromQuaternion(rotation));
|
|
9262
9382
|
}
|
|
9263
9383
|
async setCullMask(worldMask) {
|
|
9264
9384
|
worldMask &= 63;
|
|
@@ -9320,7 +9440,7 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
9320
9440
|
() => new FluidModelObject2(kind, surface.sample, this.blockState.key, this.options)
|
|
9321
9441
|
);
|
|
9322
9442
|
const previous = this._fluidModel;
|
|
9323
|
-
const matrix = previous ? this.getModelMatrix(previous) : new
|
|
9443
|
+
const matrix = previous ? this.getModelMatrix(previous) : new import_three31.Matrix4().makeTranslation(...this.position.toArray());
|
|
9324
9444
|
if (isInstanceReference(replacement)) replacement.setMatrix(matrix);
|
|
9325
9445
|
else matrix.decompose(replacement.position, replacement.quaternion, replacement.scale);
|
|
9326
9446
|
this._models = this._models.filter((model) => model !== previous);
|
|
@@ -9458,7 +9578,7 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
9458
9578
|
setPositionRotationScaleAt(index, position, rotation, scale) {
|
|
9459
9579
|
super.setPositionRotationScaleAt(index, position, rotation, scale);
|
|
9460
9580
|
}
|
|
9461
|
-
getMatrixAt(index, matrix = new
|
|
9581
|
+
getMatrixAt(index, matrix = new import_three31.Matrix4()) {
|
|
9462
9582
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
9463
9583
|
const child = this._models[0];
|
|
9464
9584
|
if (child && isModelObject(child)) {
|
|
@@ -11325,7 +11445,7 @@ init_ModelObject();
|
|
|
11325
11445
|
init_nbt();
|
|
11326
11446
|
|
|
11327
11447
|
// src/renderer/MineRenderScene.ts
|
|
11328
|
-
var
|
|
11448
|
+
var import_three33 = require("three");
|
|
11329
11449
|
init_SceneObject();
|
|
11330
11450
|
var import_ts_deepmerge8 = __toESM(require_dist());
|
|
11331
11451
|
init_ModelObject();
|
|
@@ -12058,7 +12178,7 @@ var import_ts_deepmerge7 = __toESM(require_dist());
|
|
|
12058
12178
|
init_util();
|
|
12059
12179
|
|
|
12060
12180
|
// src/skin/SkinTextures.ts
|
|
12061
|
-
var
|
|
12181
|
+
var import_three32 = require("three");
|
|
12062
12182
|
init_Caching();
|
|
12063
12183
|
init_CacheKey();
|
|
12064
12184
|
init_MineRenderError();
|
|
@@ -12142,11 +12262,11 @@ var SkinTextures = class {
|
|
|
12142
12262
|
});
|
|
12143
12263
|
}
|
|
12144
12264
|
static createMaterial(pixels, width, height, transparent = true) {
|
|
12145
|
-
const texture = Textures.initTextureProps(new
|
|
12146
|
-
texture.colorSpace =
|
|
12265
|
+
const texture = Textures.initTextureProps(new import_three32.DataTexture(pixels, width, height));
|
|
12266
|
+
texture.colorSpace = import_three32.SRGBColorSpace;
|
|
12147
12267
|
texture.flipY = true;
|
|
12148
12268
|
texture.needsUpdate = true;
|
|
12149
|
-
return new
|
|
12269
|
+
return new import_three32.MeshBasicMaterial({ map: texture, transparent, side: transparent ? import_three32.DoubleSide : import_three32.FrontSide, alphaTest: transparent ? 0.1 : 0 });
|
|
12150
12270
|
}
|
|
12151
12271
|
static isSlim(image, scale) {
|
|
12152
12272
|
for (const [x, y] of [[46, 52], [54, 20]]) {
|
|
@@ -12375,7 +12495,8 @@ var SkinObject = class extends SceneObject {
|
|
|
12375
12495
|
|
|
12376
12496
|
// src/renderer/MineRenderScene.ts
|
|
12377
12497
|
init_EntityObject();
|
|
12378
|
-
|
|
12498
|
+
init_ItemTints();
|
|
12499
|
+
var MineRenderScene = class _MineRenderScene extends import_three33.Scene {
|
|
12379
12500
|
constructor(options) {
|
|
12380
12501
|
super();
|
|
12381
12502
|
this.isMineRenderScene = true;
|
|
@@ -12470,6 +12591,7 @@ var MineRenderScene = class _MineRenderScene extends import_three32.Scene {
|
|
|
12470
12591
|
}
|
|
12471
12592
|
}
|
|
12472
12593
|
async addModel(model, options, parent = this) {
|
|
12594
|
+
options = { ...options, tints: await ItemTints.get(model, options?.tints) };
|
|
12473
12595
|
return this.addSceneObject(model, () => new ModelObject(model, options), options, parent);
|
|
12474
12596
|
}
|
|
12475
12597
|
async addBlock(blockState, options, parent = this) {
|
|
@@ -12503,7 +12625,7 @@ function isMineRenderScene(obj) {
|
|
|
12503
12625
|
}
|
|
12504
12626
|
|
|
12505
12627
|
// src/renderer/Renderer.ts
|
|
12506
|
-
var
|
|
12628
|
+
var import_three35 = require("three");
|
|
12507
12629
|
var import_ts_deepmerge9 = __toESM(require_dist());
|
|
12508
12630
|
var import_stats = __toESM(require("stats.js"));
|
|
12509
12631
|
var import_postprocessing = require("postprocessing");
|
|
@@ -12512,11 +12634,11 @@ init_Model();
|
|
|
12512
12634
|
init_three();
|
|
12513
12635
|
|
|
12514
12636
|
// src/three/OrbitControls.js
|
|
12515
|
-
var
|
|
12637
|
+
var import_three34 = require("three");
|
|
12516
12638
|
var _changeEvent = { type: "change" };
|
|
12517
12639
|
var _startEvent = { type: "start" };
|
|
12518
12640
|
var _endEvent = { type: "end" };
|
|
12519
|
-
var OrbitControls = class extends
|
|
12641
|
+
var OrbitControls = class extends import_three34.EventDispatcher {
|
|
12520
12642
|
constructor(object, domElement) {
|
|
12521
12643
|
super();
|
|
12522
12644
|
if (domElement === void 0) console.warn('THREE.OrbitControls: The second parameter "domElement" is now mandatory.');
|
|
@@ -12525,7 +12647,7 @@ var OrbitControls = class extends import_three33.EventDispatcher {
|
|
|
12525
12647
|
this.domElement = domElement;
|
|
12526
12648
|
this.domElement.style.touchAction = "none";
|
|
12527
12649
|
this.enabled = true;
|
|
12528
|
-
this.target = new
|
|
12650
|
+
this.target = new import_three34.Vector3();
|
|
12529
12651
|
this.minDistance = 0;
|
|
12530
12652
|
this.maxDistance = Infinity;
|
|
12531
12653
|
this.minZoom = 0;
|
|
@@ -12547,8 +12669,8 @@ var OrbitControls = class extends import_three33.EventDispatcher {
|
|
|
12547
12669
|
this.autoRotate = false;
|
|
12548
12670
|
this.autoRotateSpeed = 2;
|
|
12549
12671
|
this.keys = { LEFT: "ArrowLeft", UP: "ArrowUp", RIGHT: "ArrowRight", BOTTOM: "ArrowDown" };
|
|
12550
|
-
this.mouseButtons = { LEFT:
|
|
12551
|
-
this.touches = { ONE:
|
|
12672
|
+
this.mouseButtons = { LEFT: import_three34.MOUSE.ROTATE, MIDDLE: import_three34.MOUSE.DOLLY, RIGHT: import_three34.MOUSE.PAN };
|
|
12673
|
+
this.touches = { ONE: import_three34.TOUCH.ROTATE, TWO: import_three34.TOUCH.DOLLY_PAN };
|
|
12552
12674
|
this.target0 = this.target.clone();
|
|
12553
12675
|
this.position0 = this.object.position.clone();
|
|
12554
12676
|
this.zoom0 = this.object.zoom;
|
|
@@ -12577,11 +12699,11 @@ var OrbitControls = class extends import_three33.EventDispatcher {
|
|
|
12577
12699
|
state = STATE.NONE;
|
|
12578
12700
|
};
|
|
12579
12701
|
this.update = function() {
|
|
12580
|
-
const offset = new
|
|
12581
|
-
const quat = new
|
|
12702
|
+
const offset = new import_three34.Vector3();
|
|
12703
|
+
const quat = new import_three34.Quaternion().setFromUnitVectors(object.up, new import_three34.Vector3(0, 1, 0));
|
|
12582
12704
|
const quatInverse = quat.clone().invert();
|
|
12583
|
-
const lastPosition = new
|
|
12584
|
-
const lastQuaternion = new
|
|
12705
|
+
const lastPosition = new import_three34.Vector3();
|
|
12706
|
+
const lastQuaternion = new import_three34.Quaternion();
|
|
12585
12707
|
const twoPI = 2 * Math.PI;
|
|
12586
12708
|
return function update() {
|
|
12587
12709
|
const position = scope.object.position;
|
|
@@ -12667,20 +12789,20 @@ var OrbitControls = class extends import_three33.EventDispatcher {
|
|
|
12667
12789
|
};
|
|
12668
12790
|
let state = STATE.NONE;
|
|
12669
12791
|
const EPS = 1e-6;
|
|
12670
|
-
const spherical = new
|
|
12671
|
-
const sphericalDelta = new
|
|
12792
|
+
const spherical = new import_three34.Spherical();
|
|
12793
|
+
const sphericalDelta = new import_three34.Spherical();
|
|
12672
12794
|
let scale = 1;
|
|
12673
|
-
const panOffset = new
|
|
12795
|
+
const panOffset = new import_three34.Vector3();
|
|
12674
12796
|
let zoomChanged = false;
|
|
12675
|
-
const rotateStart = new
|
|
12676
|
-
const rotateEnd = new
|
|
12677
|
-
const rotateDelta = new
|
|
12678
|
-
const panStart = new
|
|
12679
|
-
const panEnd = new
|
|
12680
|
-
const panDelta = new
|
|
12681
|
-
const dollyStart = new
|
|
12682
|
-
const dollyEnd = new
|
|
12683
|
-
const dollyDelta = new
|
|
12797
|
+
const rotateStart = new import_three34.Vector2();
|
|
12798
|
+
const rotateEnd = new import_three34.Vector2();
|
|
12799
|
+
const rotateDelta = new import_three34.Vector2();
|
|
12800
|
+
const panStart = new import_three34.Vector2();
|
|
12801
|
+
const panEnd = new import_three34.Vector2();
|
|
12802
|
+
const panDelta = new import_three34.Vector2();
|
|
12803
|
+
const dollyStart = new import_three34.Vector2();
|
|
12804
|
+
const dollyEnd = new import_three34.Vector2();
|
|
12805
|
+
const dollyDelta = new import_three34.Vector2();
|
|
12684
12806
|
const pointers = [];
|
|
12685
12807
|
const pointerPositions = {};
|
|
12686
12808
|
function getAutoRotationAngle() {
|
|
@@ -12696,7 +12818,7 @@ var OrbitControls = class extends import_three33.EventDispatcher {
|
|
|
12696
12818
|
sphericalDelta.phi -= angle;
|
|
12697
12819
|
}
|
|
12698
12820
|
const panLeft = function() {
|
|
12699
|
-
const v = new
|
|
12821
|
+
const v = new import_three34.Vector3();
|
|
12700
12822
|
return function panLeft2(distance, objectMatrix) {
|
|
12701
12823
|
v.setFromMatrixColumn(objectMatrix, 0);
|
|
12702
12824
|
v.multiplyScalar(-distance);
|
|
@@ -12704,7 +12826,7 @@ var OrbitControls = class extends import_three33.EventDispatcher {
|
|
|
12704
12826
|
};
|
|
12705
12827
|
}();
|
|
12706
12828
|
const panUp = function() {
|
|
12707
|
-
const v = new
|
|
12829
|
+
const v = new import_three34.Vector3();
|
|
12708
12830
|
return function panUp2(distance, objectMatrix) {
|
|
12709
12831
|
if (scope.screenSpacePanning === true) {
|
|
12710
12832
|
v.setFromMatrixColumn(objectMatrix, 1);
|
|
@@ -12717,7 +12839,7 @@ var OrbitControls = class extends import_three33.EventDispatcher {
|
|
|
12717
12839
|
};
|
|
12718
12840
|
}();
|
|
12719
12841
|
const pan = function() {
|
|
12720
|
-
const offset = new
|
|
12842
|
+
const offset = new import_three34.Vector3();
|
|
12721
12843
|
return function pan2(deltaX, deltaY) {
|
|
12722
12844
|
const element = scope.domElement;
|
|
12723
12845
|
if (scope.object.isPerspectiveCamera) {
|
|
@@ -12966,12 +13088,12 @@ var OrbitControls = class extends import_three33.EventDispatcher {
|
|
|
12966
13088
|
mouseAction = -1;
|
|
12967
13089
|
}
|
|
12968
13090
|
switch (mouseAction) {
|
|
12969
|
-
case
|
|
13091
|
+
case import_three34.MOUSE.DOLLY:
|
|
12970
13092
|
if (scope.enableZoom === false) return;
|
|
12971
13093
|
handleMouseDownDolly(event);
|
|
12972
13094
|
state = STATE.DOLLY;
|
|
12973
13095
|
break;
|
|
12974
|
-
case
|
|
13096
|
+
case import_three34.MOUSE.ROTATE:
|
|
12975
13097
|
if (event.ctrlKey || event.metaKey || event.shiftKey) {
|
|
12976
13098
|
if (scope.enablePan === false) return;
|
|
12977
13099
|
handleMouseDownPan(event);
|
|
@@ -12982,7 +13104,7 @@ var OrbitControls = class extends import_three33.EventDispatcher {
|
|
|
12982
13104
|
state = STATE.ROTATE;
|
|
12983
13105
|
}
|
|
12984
13106
|
break;
|
|
12985
|
-
case
|
|
13107
|
+
case import_three34.MOUSE.PAN:
|
|
12986
13108
|
if (event.ctrlKey || event.metaKey || event.shiftKey) {
|
|
12987
13109
|
if (scope.enableRotate === false) return;
|
|
12988
13110
|
handleMouseDownRotate(event);
|
|
@@ -13038,12 +13160,12 @@ var OrbitControls = class extends import_three33.EventDispatcher {
|
|
|
13038
13160
|
switch (pointers.length) {
|
|
13039
13161
|
case 1:
|
|
13040
13162
|
switch (scope.touches.ONE) {
|
|
13041
|
-
case
|
|
13163
|
+
case import_three34.TOUCH.ROTATE:
|
|
13042
13164
|
if (scope.enableRotate === false) return;
|
|
13043
13165
|
handleTouchStartRotate();
|
|
13044
13166
|
state = STATE.TOUCH_ROTATE;
|
|
13045
13167
|
break;
|
|
13046
|
-
case
|
|
13168
|
+
case import_three34.TOUCH.PAN:
|
|
13047
13169
|
if (scope.enablePan === false) return;
|
|
13048
13170
|
handleTouchStartPan();
|
|
13049
13171
|
state = STATE.TOUCH_PAN;
|
|
@@ -13054,12 +13176,12 @@ var OrbitControls = class extends import_three33.EventDispatcher {
|
|
|
13054
13176
|
break;
|
|
13055
13177
|
case 2:
|
|
13056
13178
|
switch (scope.touches.TWO) {
|
|
13057
|
-
case
|
|
13179
|
+
case import_three34.TOUCH.DOLLY_PAN:
|
|
13058
13180
|
if (scope.enableZoom === false && scope.enablePan === false) return;
|
|
13059
13181
|
handleTouchStartDollyPan();
|
|
13060
13182
|
state = STATE.TOUCH_DOLLY_PAN;
|
|
13061
13183
|
break;
|
|
13062
|
-
case
|
|
13184
|
+
case import_three34.TOUCH.DOLLY_ROTATE:
|
|
13063
13185
|
if (scope.enableZoom === false && scope.enableRotate === false) return;
|
|
13064
13186
|
handleTouchStartDollyRotate();
|
|
13065
13187
|
state = STATE.TOUCH_DOLLY_ROTATE;
|
|
@@ -13126,7 +13248,7 @@ var OrbitControls = class extends import_three33.EventDispatcher {
|
|
|
13126
13248
|
function trackPointer(event) {
|
|
13127
13249
|
let position = pointerPositions[event.pointerId];
|
|
13128
13250
|
if (position === void 0) {
|
|
13129
|
-
position = new
|
|
13251
|
+
position = new import_three34.Vector2();
|
|
13130
13252
|
pointerPositions[event.pointerId] = position;
|
|
13131
13253
|
}
|
|
13132
13254
|
position.set(event.pageX, event.pageY);
|
|
@@ -13146,10 +13268,10 @@ var MapControls = class extends OrbitControls {
|
|
|
13146
13268
|
constructor(object, domElement) {
|
|
13147
13269
|
super(object, domElement);
|
|
13148
13270
|
this.screenSpacePanning = false;
|
|
13149
|
-
this.mouseButtons.LEFT =
|
|
13150
|
-
this.mouseButtons.RIGHT =
|
|
13151
|
-
this.touches.ONE =
|
|
13152
|
-
this.touches.TWO =
|
|
13271
|
+
this.mouseButtons.LEFT = import_three34.MOUSE.PAN;
|
|
13272
|
+
this.mouseButtons.RIGHT = import_three34.MOUSE.ROTATE;
|
|
13273
|
+
this.touches.ONE = import_three34.TOUCH.PAN;
|
|
13274
|
+
this.touches.TWO = import_three34.TOUCH.DOLLY_ROTATE;
|
|
13153
13275
|
}
|
|
13154
13276
|
};
|
|
13155
13277
|
|
|
@@ -13208,8 +13330,8 @@ var Renderer = class _Renderer {
|
|
|
13208
13330
|
top: void 0,
|
|
13209
13331
|
bottom: void 0
|
|
13210
13332
|
},
|
|
13211
|
-
position: new
|
|
13212
|
-
lookingAt: new
|
|
13333
|
+
position: new import_three35.Vector3(50, 50, 50),
|
|
13334
|
+
lookingAt: new import_three35.Vector3(0, 0, 0)
|
|
13213
13335
|
},
|
|
13214
13336
|
render: {
|
|
13215
13337
|
fpsLimit: 60,
|
|
@@ -13240,14 +13362,14 @@ var Renderer = class _Renderer {
|
|
|
13240
13362
|
switch (this.options.camera.type) {
|
|
13241
13363
|
case "perspective":
|
|
13242
13364
|
default:
|
|
13243
|
-
return new
|
|
13365
|
+
return new import_three35.PerspectiveCamera(
|
|
13244
13366
|
this.options.camera.perspective.fov,
|
|
13245
13367
|
this.options.camera.perspective.aspect ?? this.viewWidth / this.viewHeight,
|
|
13246
13368
|
this.options.camera.near,
|
|
13247
13369
|
this.options.camera.far
|
|
13248
13370
|
);
|
|
13249
13371
|
case "orthographic":
|
|
13250
|
-
return new
|
|
13372
|
+
return new import_three35.OrthographicCamera(
|
|
13251
13373
|
this.options.camera.orthographic.left ?? this.viewWidth / -2,
|
|
13252
13374
|
this.options.camera.orthographic.right ?? this.viewWidth / 2,
|
|
13253
13375
|
this.options.camera.orthographic.top ?? this.viewHeight / 2,
|
|
@@ -13258,7 +13380,7 @@ var Renderer = class _Renderer {
|
|
|
13258
13380
|
}
|
|
13259
13381
|
}
|
|
13260
13382
|
createRenderer() {
|
|
13261
|
-
const renderer = new
|
|
13383
|
+
const renderer = new import_three35.WebGLRenderer({
|
|
13262
13384
|
antialias: this.options.render.antialias,
|
|
13263
13385
|
alpha: true,
|
|
13264
13386
|
powerPreference: "high-performance",
|
|
@@ -13266,8 +13388,8 @@ var Renderer = class _Renderer {
|
|
|
13266
13388
|
});
|
|
13267
13389
|
renderer.setClearColor(0, 0);
|
|
13268
13390
|
renderer.shadowMap.enabled = true;
|
|
13269
|
-
renderer.shadowMap.type =
|
|
13270
|
-
renderer.outputColorSpace =
|
|
13391
|
+
renderer.shadowMap.type = import_three35.PCFSoftShadowMap;
|
|
13392
|
+
renderer.outputColorSpace = import_three35.SRGBColorSpace;
|
|
13271
13393
|
renderer.setPixelRatio(this.options.render.pixelRatio ?? 1);
|
|
13272
13394
|
renderer.setSize(this.viewWidth, this.viewHeight);
|
|
13273
13395
|
return renderer;
|
|
@@ -13302,20 +13424,20 @@ var Renderer = class _Renderer {
|
|
|
13302
13424
|
window["__THREE_DEVTOOLS__"].dispatchEvent(new CustomEvent("observe", { detail: this.scene }));
|
|
13303
13425
|
}
|
|
13304
13426
|
if (this.options.debug.grid) {
|
|
13305
|
-
const gridHelper = new
|
|
13427
|
+
const gridHelper = new import_three35.GridHelper(128, 16);
|
|
13306
13428
|
this._debugHelpers.push(gridHelper);
|
|
13307
13429
|
this.scene.add(gridHelper);
|
|
13308
|
-
const gridHelper2 = new
|
|
13430
|
+
const gridHelper2 = new import_three35.GridHelper(128, 16);
|
|
13309
13431
|
this._debugHelpers.push(gridHelper2);
|
|
13310
13432
|
gridHelper2.rotation.x = 90 * (Math.PI / 180);
|
|
13311
13433
|
this.scene.add(gridHelper2);
|
|
13312
|
-
const gridHelper3 = new
|
|
13434
|
+
const gridHelper3 = new import_three35.GridHelper(128, 16);
|
|
13313
13435
|
this._debugHelpers.push(gridHelper3);
|
|
13314
13436
|
gridHelper3.rotation.z = 90 * (Math.PI / 180);
|
|
13315
13437
|
this.scene.add(gridHelper3);
|
|
13316
13438
|
}
|
|
13317
13439
|
if (this.options.debug.axes) {
|
|
13318
|
-
const axesHelper = new
|
|
13440
|
+
const axesHelper = new import_three35.AxesHelper(64);
|
|
13319
13441
|
this._debugHelpers.push(axesHelper);
|
|
13320
13442
|
this.scene.add(axesHelper);
|
|
13321
13443
|
}
|
|
@@ -13732,6 +13854,7 @@ var Skins = class {
|
|
|
13732
13854
|
};
|
|
13733
13855
|
|
|
13734
13856
|
// src/texture/index.ts
|
|
13857
|
+
init_Colormaps();
|
|
13735
13858
|
init_TextureAtlas();
|
|
13736
13859
|
init_TextureLoader();
|
|
13737
13860
|
init_Textures();
|
|
@@ -14000,12 +14123,12 @@ var AnvilParser = class {
|
|
|
14000
14123
|
};
|
|
14001
14124
|
|
|
14002
14125
|
// src/world/Chunk.ts
|
|
14003
|
-
var
|
|
14126
|
+
var import_three40 = require("three");
|
|
14004
14127
|
init_BlockStates();
|
|
14005
14128
|
init_AssetKey();
|
|
14006
14129
|
|
|
14007
14130
|
// src/world/MineRenderWorld.ts
|
|
14008
|
-
var
|
|
14131
|
+
var import_three38 = require("three");
|
|
14009
14132
|
init_Model();
|
|
14010
14133
|
init_BatchedExecutor();
|
|
14011
14134
|
init_AssetKey();
|
|
@@ -14013,7 +14136,7 @@ init_BlockStates();
|
|
|
14013
14136
|
init_CubeFace();
|
|
14014
14137
|
|
|
14015
14138
|
// src/world/SectionModels.ts
|
|
14016
|
-
var
|
|
14139
|
+
var import_three37 = require("three");
|
|
14017
14140
|
init_AssetKey();
|
|
14018
14141
|
init_Models();
|
|
14019
14142
|
init_CubeFace();
|
|
@@ -14079,12 +14202,12 @@ var SectionModels = class {
|
|
|
14079
14202
|
});
|
|
14080
14203
|
await object.init();
|
|
14081
14204
|
const geometry = object.children[0].geometry;
|
|
14082
|
-
geometry.applyMatrix4(new
|
|
14205
|
+
geometry.applyMatrix4(new import_three37.Matrix4().makeRotationFromEuler(rotation));
|
|
14083
14206
|
object.clear();
|
|
14084
14207
|
const cullFaces = CUBE_FACES.map((face) => {
|
|
14085
14208
|
const local = CUBE_FACES.findIndex((name) => name === atlas.model.elements[0].faces[face]?.cullface);
|
|
14086
14209
|
if (local < 0) return 0;
|
|
14087
|
-
const normal = new
|
|
14210
|
+
const normal = new import_three37.Vector3(...CUBE_FACE_OFFSETS[local]).applyEuler(rotation);
|
|
14088
14211
|
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);
|
|
14089
14212
|
return 1 << world;
|
|
14090
14213
|
});
|
|
@@ -14114,20 +14237,20 @@ var MineRenderWorld = class {
|
|
|
14114
14237
|
}
|
|
14115
14238
|
getBlockAt(posOrX, y, z) {
|
|
14116
14239
|
if (typeof posOrX == "number") {
|
|
14117
|
-
return this.getBlockAt(new
|
|
14240
|
+
return this.getBlockAt(new import_three38.Vector3(posOrX, y, z));
|
|
14118
14241
|
}
|
|
14119
14242
|
if (isTripleArray(posOrX)) {
|
|
14120
|
-
return this.getBlockAt(new
|
|
14243
|
+
return this.getBlockAt(new import_three38.Vector3(posOrX[0], posOrX[1], posOrX[2]));
|
|
14121
14244
|
}
|
|
14122
14245
|
this.validatePosBounds(posOrX);
|
|
14123
14246
|
return this.getChunkAt(posOrX)?.getBlockAt(posOrX);
|
|
14124
14247
|
}
|
|
14125
14248
|
async setBlockAt(posOrX, yOrBlock, z, block) {
|
|
14126
14249
|
if (typeof posOrX == "number") {
|
|
14127
|
-
return this.setBlockAt(new
|
|
14250
|
+
return this.setBlockAt(new import_three38.Vector3(posOrX, yOrBlock, z), block);
|
|
14128
14251
|
}
|
|
14129
14252
|
if (isTripleArray(posOrX)) {
|
|
14130
|
-
return this.setBlockAt(new
|
|
14253
|
+
return this.setBlockAt(new import_three38.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
|
|
14131
14254
|
}
|
|
14132
14255
|
return this.placeBlock(posOrX, yOrBlock);
|
|
14133
14256
|
}
|
|
@@ -14148,7 +14271,7 @@ var MineRenderWorld = class {
|
|
|
14148
14271
|
const collect = async (positions2) => {
|
|
14149
14272
|
for (const pos of positions2) changes.set(pos.toArray().join(","), pos);
|
|
14150
14273
|
};
|
|
14151
|
-
const place = (block) => this.placeBlock(new
|
|
14274
|
+
const place = (block) => this.placeBlock(new import_three38.Vector3(...block.position), block, collect);
|
|
14152
14275
|
const keys = /* @__PURE__ */ new Map();
|
|
14153
14276
|
for (const block of multiblock.blocks) {
|
|
14154
14277
|
if (Chunk.isAir(block)) continue;
|
|
@@ -14226,13 +14349,13 @@ var MineRenderWorld = class {
|
|
|
14226
14349
|
for (const pos of positions) {
|
|
14227
14350
|
this.pendingCulling.set(pos.toArray().join(","), pos.clone());
|
|
14228
14351
|
for (const offset of CUBE_FACE_OFFSETS) {
|
|
14229
|
-
const neighbor = pos.clone().add(new
|
|
14352
|
+
const neighbor = pos.clone().add(new import_three38.Vector3(...offset));
|
|
14230
14353
|
this.pendingCulling.set(neighbor.toArray().join(","), neighbor);
|
|
14231
14354
|
}
|
|
14232
14355
|
for (let y = -1; y <= 1; y++) {
|
|
14233
14356
|
for (let z = -1; z <= 1; z++) {
|
|
14234
14357
|
for (let x = -1; x <= 1; x++) {
|
|
14235
|
-
const neighbor = pos.clone().add(new
|
|
14358
|
+
const neighbor = pos.clone().add(new import_three38.Vector3(x, y, z));
|
|
14236
14359
|
if (this.getBlockAt(neighbor)?.object?.fluidKind) {
|
|
14237
14360
|
this.pendingCulling.set(neighbor.toArray().join(","), neighbor);
|
|
14238
14361
|
}
|
|
@@ -14254,7 +14377,7 @@ var MineRenderWorld = class {
|
|
|
14254
14377
|
if (!block) continue;
|
|
14255
14378
|
if (block.object?.fluidKind) {
|
|
14256
14379
|
await block.object.updateFluid((x, y, z) => {
|
|
14257
|
-
const neighbor = pos.clone().add(new
|
|
14380
|
+
const neighbor = pos.clone().add(new import_three38.Vector3(x, y, z));
|
|
14258
14381
|
const section = this.getChunkAt(neighbor);
|
|
14259
14382
|
const object = section?.getBlockAt(neighbor)?.object;
|
|
14260
14383
|
return {
|
|
@@ -14266,7 +14389,7 @@ var MineRenderWorld = class {
|
|
|
14266
14389
|
}
|
|
14267
14390
|
let mask = 0;
|
|
14268
14391
|
for (const [face, offset] of CUBE_FACE_OFFSETS.entries()) {
|
|
14269
|
-
const neighbor = pos.clone().add(new
|
|
14392
|
+
const neighbor = pos.clone().add(new import_three38.Vector3(...offset));
|
|
14270
14393
|
if (this.getChunkAt(neighbor)?.isOccludingAt(neighbor)) {
|
|
14271
14394
|
mask |= 1 << face;
|
|
14272
14395
|
}
|
|
@@ -14300,14 +14423,14 @@ var MineRenderWorld = class {
|
|
|
14300
14423
|
return this._chunks.get(this.worldPosToChunkKey(pos));
|
|
14301
14424
|
}
|
|
14302
14425
|
static worldToScenePosition(pos) {
|
|
14303
|
-
return new
|
|
14426
|
+
return new import_three38.Vector3(
|
|
14304
14427
|
pos.x * 16,
|
|
14305
14428
|
pos.y * 16,
|
|
14306
14429
|
pos.z * 16
|
|
14307
14430
|
);
|
|
14308
14431
|
}
|
|
14309
14432
|
static sceneToWorldPosition(pos) {
|
|
14310
|
-
return new
|
|
14433
|
+
return new import_three38.Vector3(
|
|
14311
14434
|
pos.x / 16,
|
|
14312
14435
|
pos.y / 16,
|
|
14313
14436
|
pos.z / 16
|
|
@@ -14330,10 +14453,10 @@ var MineRenderWorld = class {
|
|
|
14330
14453
|
init_Model();
|
|
14331
14454
|
|
|
14332
14455
|
// src/world/SectionMesh.ts
|
|
14333
|
-
var
|
|
14456
|
+
var import_three39 = require("three");
|
|
14334
14457
|
init_CanvasCompat();
|
|
14335
14458
|
init_Materials();
|
|
14336
|
-
var SectionMesh = class _SectionMesh extends
|
|
14459
|
+
var SectionMesh = class _SectionMesh extends import_three39.Group {
|
|
14337
14460
|
constructor() {
|
|
14338
14461
|
super(...arguments);
|
|
14339
14462
|
this.ownedMeshes = [];
|
|
@@ -14406,18 +14529,18 @@ var SectionMesh = class _SectionMesh extends import_three38.Group {
|
|
|
14406
14529
|
for (let corner = 0; corner < 6; corner++) indices.push(start + sourceIndices.getX(face * 6 + corner) - face * 4);
|
|
14407
14530
|
}
|
|
14408
14531
|
}
|
|
14409
|
-
const geometry = new
|
|
14410
|
-
geometry.setAttribute("position", new
|
|
14411
|
-
geometry.setAttribute("normal", new
|
|
14412
|
-
geometry.setAttribute("uv", new
|
|
14413
|
-
geometry.setAttribute("color", new
|
|
14532
|
+
const geometry = new import_three39.BufferGeometry();
|
|
14533
|
+
geometry.setAttribute("position", new import_three39.Float32BufferAttribute(positions, 3));
|
|
14534
|
+
geometry.setAttribute("normal", new import_three39.Float32BufferAttribute(normals, 3));
|
|
14535
|
+
geometry.setAttribute("uv", new import_three39.Float32BufferAttribute(uvs, 2));
|
|
14536
|
+
geometry.setAttribute("color", new import_three39.Float32BufferAttribute(colors, 3));
|
|
14414
14537
|
geometry.setIndex(indices);
|
|
14415
14538
|
geometry.computeBoundingBox();
|
|
14416
14539
|
geometry.computeBoundingSphere();
|
|
14417
14540
|
const material = Materials.createShadedCanvasMaterial(canvas, false);
|
|
14418
14541
|
material.vertexColors = true;
|
|
14419
14542
|
const texture = material.uniforms?.map?.value ?? material.map;
|
|
14420
|
-
const mesh = new
|
|
14543
|
+
const mesh = new import_three39.Mesh(geometry, material);
|
|
14421
14544
|
section.add(mesh);
|
|
14422
14545
|
section.ownedMeshes.push({ mesh, texture });
|
|
14423
14546
|
}
|
|
@@ -14451,10 +14574,10 @@ var Chunk = class _Chunk {
|
|
|
14451
14574
|
}
|
|
14452
14575
|
getBlockAt(posOrX, y, z) {
|
|
14453
14576
|
if (typeof posOrX == "number") {
|
|
14454
|
-
return this.getBlockAt(new
|
|
14577
|
+
return this.getBlockAt(new import_three40.Vector3(posOrX, y, z));
|
|
14455
14578
|
}
|
|
14456
14579
|
if (isTripleArray(posOrX)) {
|
|
14457
|
-
return this.getBlockAt(new
|
|
14580
|
+
return this.getBlockAt(new import_three40.Vector3(posOrX[0], posOrX[1], posOrX[2]));
|
|
14458
14581
|
}
|
|
14459
14582
|
const pos = this.worldPosToChunkPos(posOrX);
|
|
14460
14583
|
const index = _Chunk.chunkPosToBlockIndex(pos);
|
|
@@ -14462,10 +14585,10 @@ var Chunk = class _Chunk {
|
|
|
14462
14585
|
}
|
|
14463
14586
|
async setBlockAt(posOrX, yOrBlock, z, block) {
|
|
14464
14587
|
if (typeof posOrX == "number") {
|
|
14465
|
-
return this.setBlockAt(new
|
|
14588
|
+
return this.setBlockAt(new import_three40.Vector3(posOrX, yOrBlock, z), block);
|
|
14466
14589
|
}
|
|
14467
14590
|
if (isTripleArray(posOrX)) {
|
|
14468
|
-
return this.setBlockAt(new
|
|
14591
|
+
return this.setBlockAt(new import_three40.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
|
|
14469
14592
|
}
|
|
14470
14593
|
const worldPos = posOrX;
|
|
14471
14594
|
const pos = this.worldPosToChunkPos(worldPos);
|
|
@@ -14551,7 +14674,7 @@ var Chunk = class _Chunk {
|
|
|
14551
14674
|
}
|
|
14552
14675
|
async clear(onBlocksChanged = this.onBlocksChanged) {
|
|
14553
14676
|
const positions = [...this.renderedBlocks.keys()].map((index) => this.chunkPosToWorldPos(
|
|
14554
|
-
new
|
|
14677
|
+
new import_three40.Vector3(index % 16, Math.floor(index / 256), Math.floor(index / 16) % 16)
|
|
14555
14678
|
));
|
|
14556
14679
|
for (const info of this.renderedBlocks.values()) info.object?.removeFromScene();
|
|
14557
14680
|
this.sectionBlocks.clear();
|
|
@@ -14575,14 +14698,14 @@ var Chunk = class _Chunk {
|
|
|
14575
14698
|
return pos.y * 16 * 16 + pos.z * 16 + pos.x;
|
|
14576
14699
|
}
|
|
14577
14700
|
worldPosToChunkPos(pos) {
|
|
14578
|
-
return new
|
|
14701
|
+
return new import_three40.Vector3(
|
|
14579
14702
|
pos.x - this.x * 16,
|
|
14580
14703
|
pos.y - this.y * 16,
|
|
14581
14704
|
pos.z - this.z * 16
|
|
14582
14705
|
);
|
|
14583
14706
|
}
|
|
14584
14707
|
chunkPosToWorldPos(pos) {
|
|
14585
|
-
return new
|
|
14708
|
+
return new import_three40.Vector3(
|
|
14586
14709
|
this.x * 16 + pos.x,
|
|
14587
14710
|
this.y * 16 + pos.y,
|
|
14588
14711
|
this.z * 16 + pos.z
|
|
@@ -14617,6 +14740,7 @@ var Chunk = class _Chunk {
|
|
|
14617
14740
|
CanvasImage,
|
|
14618
14741
|
Chunk,
|
|
14619
14742
|
ChunkData,
|
|
14743
|
+
Colormaps,
|
|
14620
14744
|
CubeFace,
|
|
14621
14745
|
CubeFaceIndex,
|
|
14622
14746
|
DEFAULT_ELEMENTS,
|
|
@@ -14642,6 +14766,7 @@ var Chunk = class _Chunk {
|
|
|
14642
14766
|
ImageLoader,
|
|
14643
14767
|
InstanceManager,
|
|
14644
14768
|
InstanceReference,
|
|
14769
|
+
ItemTints,
|
|
14645
14770
|
MapControls,
|
|
14646
14771
|
Materials,
|
|
14647
14772
|
Meshes,
|