minerender 2.1.0-alpha.61 → 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 +18 -11
- package/dist/browser/index.d.ts +18 -11
- package/dist/browser/index.js +349 -300
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +151 -102
- package/dist/browser/index.mjs.map +1 -1
- package/dist/bundle.js +77 -28
- package/dist/bundle.js.map +1 -1
- package/dist/node/index.d.mts +18 -11
- package/dist/node/index.d.ts +18 -11
- package/dist/node/index.js +349 -300
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +151 -102
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/browser/index.js
CHANGED
|
@@ -3238,11 +3238,11 @@ var init_Entities = __esm({
|
|
|
3238
3238
|
return { ...layers[names[0]], id: model.id, layers, ...model.transform && { transform: model.transform } };
|
|
3239
3239
|
}
|
|
3240
3240
|
/**
|
|
3241
|
-
*
|
|
3241
|
+
* Native and sampled vanilla clips by name, or undefined when the model or selected version has none.
|
|
3242
3242
|
*/
|
|
3243
3243
|
static async getAnimations(modelKey) {
|
|
3244
3244
|
const path = isAssetKey(modelKey) ? modelKey.getFullPath() : modelKey.path;
|
|
3245
|
-
const key = new AssetKey(modelKey.namespace, path, void 0, void 0, "entity-models/animations", ".json");
|
|
3245
|
+
const key = new AssetKey(modelKey.namespace, path, void 0, void 0, "entity-models/animations", ".json", isAssetKey(modelKey) ? modelKey.root : void 0);
|
|
3246
3246
|
const file = await Caching.entityAnimationCache.get(key.serialize(), () => AssetLoader.get(key, "json" /* JSON */));
|
|
3247
3247
|
return file?.animations;
|
|
3248
3248
|
}
|
|
@@ -3292,7 +3292,7 @@ function sampleEntityKeyframes(keyframes, time) {
|
|
|
3292
3292
|
let low = 0, high = keyframes.length;
|
|
3293
3293
|
while (low < high) {
|
|
3294
3294
|
const middle = low + high >>> 1;
|
|
3295
|
-
if (time
|
|
3295
|
+
if (time < keyframes[middle].time) high = middle;
|
|
3296
3296
|
else low = middle + 1;
|
|
3297
3297
|
}
|
|
3298
3298
|
const a = Math.max(0, low - 1);
|
|
@@ -3331,9 +3331,10 @@ var init_EntityAnimation = __esm({
|
|
|
3331
3331
|
});
|
|
3332
3332
|
|
|
3333
3333
|
// src/entity/scene/EntityAnimationPlayer.ts
|
|
3334
|
-
var ZERO, EntityAnimationPlayer;
|
|
3334
|
+
var import_three11, ZERO, EntityAnimationPlayer;
|
|
3335
3335
|
var init_EntityAnimationPlayer = __esm({
|
|
3336
3336
|
"src/entity/scene/EntityAnimationPlayer.ts"() {
|
|
3337
|
+
import_three11 = require("three");
|
|
3337
3338
|
init_EntityAnimation();
|
|
3338
3339
|
ZERO = [0, 0, 0];
|
|
3339
3340
|
EntityAnimationPlayer = class {
|
|
@@ -3350,25 +3351,45 @@ var init_EntityAnimationPlayer = __esm({
|
|
|
3350
3351
|
return this._time;
|
|
3351
3352
|
}
|
|
3352
3353
|
/**
|
|
3353
|
-
* Starts an animation on
|
|
3354
|
-
*
|
|
3354
|
+
* Starts an animation on matching named parts. Supplied baked poses are the baseline for offsets;
|
|
3355
|
+
* without them, the current pose is used. Stopping restores the pose from before playback.
|
|
3355
3356
|
*/
|
|
3356
|
-
play(layers, animation, options = {}) {
|
|
3357
|
+
play(layers, animation, options = {}, poses) {
|
|
3357
3358
|
this.stop();
|
|
3358
3359
|
this._animation = animation;
|
|
3359
3360
|
this._time = options.time ?? 0;
|
|
3360
3361
|
this.loop = options.loop ?? animation.loop;
|
|
3361
3362
|
this.speed = options.speed ?? 1;
|
|
3362
3363
|
for (const layer of layers) {
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3364
|
+
const objects = [];
|
|
3365
|
+
if (poses) {
|
|
3366
|
+
layer.traverse((object) => {
|
|
3367
|
+
if (poses.has(object)) objects.push(object);
|
|
3368
|
+
});
|
|
3369
|
+
} else {
|
|
3370
|
+
for (const bone of Object.keys(animation.bones)) {
|
|
3371
|
+
const object = layer.getObjectByName(`group:${bone}`);
|
|
3372
|
+
if (object) objects.push(object);
|
|
3373
|
+
}
|
|
3374
|
+
}
|
|
3375
|
+
for (const object of objects) {
|
|
3376
|
+
const bone = object.name.slice("group:".length);
|
|
3377
|
+
const pose = poses?.get(object);
|
|
3378
|
+
this.parts.push({
|
|
3379
|
+
bone,
|
|
3380
|
+
object,
|
|
3381
|
+
position: object.position.clone(),
|
|
3382
|
+
rotation: object.rotation.clone(),
|
|
3383
|
+
scale: object.scale.clone(),
|
|
3384
|
+
basePosition: pose ? new import_three11.Vector3(...pose.offset) : object.position.clone(),
|
|
3385
|
+
baseRotation: pose ? new import_three11.Euler(...pose.rotation, "ZYX") : object.rotation.clone(),
|
|
3386
|
+
baseScale: pose ? new import_three11.Vector3(...pose.scale ?? [1, 1, 1]) : object.scale.clone()
|
|
3387
|
+
});
|
|
3367
3388
|
}
|
|
3368
3389
|
}
|
|
3369
3390
|
this.apply();
|
|
3370
3391
|
}
|
|
3371
|
-
/** Restores the
|
|
3392
|
+
/** Restores the poses from before playback. Returns whether an animation was active. */
|
|
3372
3393
|
stop() {
|
|
3373
3394
|
if (!this._animation) return false;
|
|
3374
3395
|
for (const part of this.parts) {
|
|
@@ -3397,10 +3418,10 @@ var init_EntityAnimationPlayer = __esm({
|
|
|
3397
3418
|
apply() {
|
|
3398
3419
|
const pose = sampleEntityAnimation(this._animation, this._time, this.loop);
|
|
3399
3420
|
for (const part of this.parts) {
|
|
3400
|
-
const { position = ZERO, rotation = ZERO, scale = ZERO } = pose[part.bone];
|
|
3401
|
-
part.object.position.set(part.
|
|
3402
|
-
part.object.rotation.set(part.
|
|
3403
|
-
part.object.scale.set(part.
|
|
3421
|
+
const { position = ZERO, rotation = ZERO, scale = ZERO } = pose[part.bone] ?? {};
|
|
3422
|
+
part.object.position.set(part.basePosition.x + position[0], part.basePosition.y + position[1], part.basePosition.z + position[2]);
|
|
3423
|
+
part.object.rotation.set(part.baseRotation.x + rotation[0], part.baseRotation.y + rotation[1], part.baseRotation.z + rotation[2], part.baseRotation.order);
|
|
3424
|
+
part.object.scale.set(part.baseScale.x + scale[0], part.baseScale.y + scale[1], part.baseScale.z + scale[2]);
|
|
3404
3425
|
}
|
|
3405
3426
|
}
|
|
3406
3427
|
};
|
|
@@ -3470,10 +3491,10 @@ var init_InstanceReference = __esm({
|
|
|
3470
3491
|
function isSceneObject(obj) {
|
|
3471
3492
|
return obj.isSceneObject;
|
|
3472
3493
|
}
|
|
3473
|
-
var
|
|
3494
|
+
var import_three12, import_ts_deepmerge3, p6, _SceneObject, SceneObject;
|
|
3474
3495
|
var init_SceneObject = __esm({
|
|
3475
3496
|
"src/renderer/SceneObject.ts"() {
|
|
3476
|
-
|
|
3497
|
+
import_three12 = require("three");
|
|
3477
3498
|
init_Geometries();
|
|
3478
3499
|
init_UVMapper();
|
|
3479
3500
|
init_Axis();
|
|
@@ -3485,7 +3506,7 @@ var init_SceneObject = __esm({
|
|
|
3485
3506
|
import_ts_deepmerge3 = __toESM(require_dist());
|
|
3486
3507
|
init_log();
|
|
3487
3508
|
p6 = prefix("SceneObject");
|
|
3488
|
-
_SceneObject = class _SceneObject extends
|
|
3509
|
+
_SceneObject = class _SceneObject extends import_three12.Object3D {
|
|
3489
3510
|
constructor(options) {
|
|
3490
3511
|
super();
|
|
3491
3512
|
this.isSceneObject = true;
|
|
@@ -3529,7 +3550,7 @@ var init_SceneObject = __esm({
|
|
|
3529
3550
|
return group;
|
|
3530
3551
|
}
|
|
3531
3552
|
createGroup(name, x = 0, y = 0, z = 0, offsetAxis, offset = 0) {
|
|
3532
|
-
const obj = new
|
|
3553
|
+
const obj = new import_three12.Object3D();
|
|
3533
3554
|
if (name) {
|
|
3534
3555
|
obj.name = `group:${name}`;
|
|
3535
3556
|
}
|
|
@@ -3579,7 +3600,7 @@ var init_SceneObject = __esm({
|
|
|
3579
3600
|
return mesh;
|
|
3580
3601
|
}
|
|
3581
3602
|
createMesh(name, geometry, material, offsetAxis, offset = 0) {
|
|
3582
|
-
const mesh = new
|
|
3603
|
+
const mesh = new import_three12.Mesh(geometry, material);
|
|
3583
3604
|
if (name) {
|
|
3584
3605
|
mesh.name = `mesh:${name}`;
|
|
3585
3606
|
}
|
|
@@ -3591,7 +3612,7 @@ var init_SceneObject = __esm({
|
|
|
3591
3612
|
return mesh;
|
|
3592
3613
|
}
|
|
3593
3614
|
createInstancedMesh(name, geometry, material, count) {
|
|
3594
|
-
const mesh = new
|
|
3615
|
+
const mesh = new import_three12.InstancedMesh(geometry, material, count);
|
|
3595
3616
|
mesh.count = 0;
|
|
3596
3617
|
this.instanceMesh = mesh;
|
|
3597
3618
|
this._isInstanced = true;
|
|
@@ -3671,11 +3692,11 @@ var init_SceneObject = __esm({
|
|
|
3671
3692
|
this._instanceCounter = this.instanceReferences.size;
|
|
3672
3693
|
mesh.count = Math.max(mesh.count, index + 1);
|
|
3673
3694
|
if (mesh.instanceColor) {
|
|
3674
|
-
mesh.setColorAt(index, new
|
|
3695
|
+
mesh.setColorAt(index, new import_three12.Color(16777215));
|
|
3675
3696
|
mesh.instanceColor.needsUpdate = true;
|
|
3676
3697
|
}
|
|
3677
3698
|
if (this._scene) this._scene.stats.instanceCount++;
|
|
3678
|
-
this.setMatrixAt(index, new
|
|
3699
|
+
this.setMatrixAt(index, new import_three12.Matrix4());
|
|
3679
3700
|
return reference;
|
|
3680
3701
|
}
|
|
3681
3702
|
/** Returns the live reference for a raycast hit on this object's instance mesh. */
|
|
@@ -3688,7 +3709,7 @@ var init_SceneObject = __esm({
|
|
|
3688
3709
|
removeInstanceAt(index) {
|
|
3689
3710
|
if (!this.instanceReferences.has(index)) return;
|
|
3690
3711
|
const mesh = this.instanceMesh;
|
|
3691
|
-
this.setMatrixAt(index, new
|
|
3712
|
+
this.setMatrixAt(index, new import_three12.Matrix4().makeScale(0, 0, 0));
|
|
3692
3713
|
this.instanceReferences.delete(index);
|
|
3693
3714
|
this.freeInstanceIndices.push(index);
|
|
3694
3715
|
this._instanceCounter = this.instanceReferences.size;
|
|
@@ -3701,7 +3722,7 @@ var init_SceneObject = __esm({
|
|
|
3701
3722
|
const grow = (attribute, fill) => {
|
|
3702
3723
|
const array = new Float32Array(capacity * attribute.itemSize).fill(fill);
|
|
3703
3724
|
array.set(attribute.array);
|
|
3704
|
-
return new
|
|
3725
|
+
return new import_three12.InstancedBufferAttribute(array, attribute.itemSize, attribute.normalized, attribute.meshPerAttribute).setUsage(attribute.usage);
|
|
3705
3726
|
};
|
|
3706
3727
|
const matrix = grow(mesh.instanceMatrix, 0);
|
|
3707
3728
|
const color = mesh.instanceColor ? grow(mesh.instanceColor, 1) : null;
|
|
@@ -3718,7 +3739,7 @@ var init_SceneObject = __esm({
|
|
|
3718
3739
|
}
|
|
3719
3740
|
//</editor-fold>
|
|
3720
3741
|
//<editor-fold desc="TRANSFORMATION">
|
|
3721
|
-
getMatrixAt(index, matrix = new
|
|
3742
|
+
getMatrixAt(index, matrix = new import_three12.Matrix4()) {
|
|
3722
3743
|
if (!this.instanceReferences.has(index)) throw new MineRenderError("Instance is not active");
|
|
3723
3744
|
this.instanceMesh.getMatrixAt(index, matrix);
|
|
3724
3745
|
return matrix;
|
|
@@ -3734,16 +3755,16 @@ var init_SceneObject = __esm({
|
|
|
3734
3755
|
}
|
|
3735
3756
|
setPositionRotationScaleAt(index, position, rotation, scale) {
|
|
3736
3757
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3737
|
-
const oldPosition = new
|
|
3738
|
-
const oldRotation = new
|
|
3739
|
-
const oldScale = new
|
|
3740
|
-
const matrix = new
|
|
3758
|
+
const oldPosition = new import_three12.Vector3();
|
|
3759
|
+
const oldRotation = new import_three12.Quaternion();
|
|
3760
|
+
const oldScale = new import_three12.Vector3();
|
|
3761
|
+
const matrix = new import_three12.Matrix4();
|
|
3741
3762
|
if (!scale || !rotation || !position) {
|
|
3742
3763
|
this.getMatrixAt(index, matrix).decompose(oldPosition, oldRotation, oldScale);
|
|
3743
3764
|
}
|
|
3744
3765
|
matrix.compose(
|
|
3745
3766
|
position ? position : oldPosition,
|
|
3746
|
-
rotation ? new
|
|
3767
|
+
rotation ? new import_three12.Quaternion().setFromEuler(rotation) : oldRotation,
|
|
3747
3768
|
scale ? scale : oldScale
|
|
3748
3769
|
);
|
|
3749
3770
|
this.setMatrixAt(index, matrix);
|
|
@@ -3752,7 +3773,7 @@ var init_SceneObject = __esm({
|
|
|
3752
3773
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3753
3774
|
this.setPositionRotationScaleAt(index, position);
|
|
3754
3775
|
}
|
|
3755
|
-
getPositionAt(index, vector = new
|
|
3776
|
+
getPositionAt(index, vector = new import_three12.Vector3()) {
|
|
3756
3777
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3757
3778
|
const matrix = this.getMatrixAt(index);
|
|
3758
3779
|
vector.setFromMatrixPosition(matrix);
|
|
@@ -3762,17 +3783,17 @@ var init_SceneObject = __esm({
|
|
|
3762
3783
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3763
3784
|
this.setPositionRotationScaleAt(index, void 0, rotation, void 0);
|
|
3764
3785
|
}
|
|
3765
|
-
getRotationAt(index, euler = new
|
|
3786
|
+
getRotationAt(index, euler = new import_three12.Euler()) {
|
|
3766
3787
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3767
|
-
const rotation = new
|
|
3768
|
-
this.getMatrixAt(index).decompose(new
|
|
3788
|
+
const rotation = new import_three12.Quaternion();
|
|
3789
|
+
this.getMatrixAt(index).decompose(new import_three12.Vector3(), rotation, new import_three12.Vector3());
|
|
3769
3790
|
return euler.setFromQuaternion(rotation);
|
|
3770
3791
|
}
|
|
3771
3792
|
setScaleAt(index, scale) {
|
|
3772
3793
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3773
3794
|
this.setPositionRotationScaleAt(index, void 0, void 0, scale);
|
|
3774
3795
|
}
|
|
3775
|
-
getScaleAt(index, vector = new
|
|
3796
|
+
getScaleAt(index, vector = new import_three12.Vector3()) {
|
|
3776
3797
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3777
3798
|
const matrix = this.getMatrixAt(index);
|
|
3778
3799
|
vector.setFromMatrixScale(matrix);
|
|
@@ -3907,13 +3928,13 @@ var init_SceneObject = __esm({
|
|
|
3907
3928
|
function isEntityObject(obj) {
|
|
3908
3929
|
return obj.isEntityObject;
|
|
3909
3930
|
}
|
|
3910
|
-
var import_ts_deepmerge4,
|
|
3931
|
+
var import_ts_deepmerge4, import_three14, _EntityObject, EntityObject;
|
|
3911
3932
|
var init_EntityObject = __esm({
|
|
3912
3933
|
"src/entity/scene/EntityObject.ts"() {
|
|
3913
3934
|
init_SceneObject();
|
|
3914
3935
|
init_Caching();
|
|
3915
3936
|
import_ts_deepmerge4 = __toESM(require_dist());
|
|
3916
|
-
|
|
3937
|
+
import_three14 = require("three");
|
|
3917
3938
|
init_Ticker();
|
|
3918
3939
|
init_model();
|
|
3919
3940
|
init_ModelTextures();
|
|
@@ -3934,7 +3955,8 @@ var init_EntityObject = __esm({
|
|
|
3934
3955
|
this.scrollMaterials = [];
|
|
3935
3956
|
/** Entity age in ticks, as vanilla's `ageInTicks`; drives the scrolling render modes. */
|
|
3936
3957
|
this.age = 0;
|
|
3937
|
-
this.
|
|
3958
|
+
this.animationPlayers = [];
|
|
3959
|
+
this.partPoses = /* @__PURE__ */ new Map();
|
|
3938
3960
|
this.options = (0, import_ts_deepmerge4.default)({}, _EntityObject.DEFAULT_OPTIONS, options ?? {});
|
|
3939
3961
|
this.addEventListener("added", () => this.updateScrollSubscription());
|
|
3940
3962
|
this.addEventListener("removed", () => this.updateScrollSubscription());
|
|
@@ -3951,7 +3973,8 @@ var init_EntityObject = __esm({
|
|
|
3951
3973
|
for (const geometry of this.geometries) geometry.dispose();
|
|
3952
3974
|
this.geometries.clear();
|
|
3953
3975
|
for (const dispose of this.disposeWireframes.splice(0)) dispose();
|
|
3954
|
-
this.
|
|
3976
|
+
for (const player of this.animationPlayers.splice(0)) player.clear();
|
|
3977
|
+
this.partPoses.clear();
|
|
3955
3978
|
super.disposeAndRemoveAllChildren();
|
|
3956
3979
|
}
|
|
3957
3980
|
clearScrollMaterials() {
|
|
@@ -3983,36 +4006,61 @@ var init_EntityObject = __esm({
|
|
|
3983
4006
|
this.notifyDirty();
|
|
3984
4007
|
}
|
|
3985
4008
|
//<editor-fold desc="ANIMATION">
|
|
3986
|
-
/** The
|
|
4009
|
+
/** The first active clip, until playback is stopped or the object is disposed. */
|
|
3987
4010
|
get animation() {
|
|
3988
|
-
return this.
|
|
4011
|
+
return this.animationPlayers[0]?.animation;
|
|
4012
|
+
}
|
|
4013
|
+
/** Clips playing together, each targeting a separate geometry layer. */
|
|
4014
|
+
get activeAnimations() {
|
|
4015
|
+
return this.animationPlayers.map((player) => player.animation);
|
|
3989
4016
|
}
|
|
3990
4017
|
/** Seconds since the animation started, before looping. */
|
|
3991
4018
|
get animationTime() {
|
|
3992
|
-
return this.
|
|
4019
|
+
return this.animationPlayers[0]?.time ?? 0;
|
|
3993
4020
|
}
|
|
3994
4021
|
/**
|
|
3995
|
-
*
|
|
3996
|
-
*
|
|
4022
|
+
* Plays a clip from {@link Entities.getAnimations}, replacing all active clips.
|
|
4023
|
+
* Offsets apply to the baked pose in the clip's layer (`main` by default), including repeated draws of that layer.
|
|
3997
4024
|
* The object owns no clock: call {@link advanceAnimation} per frame, or {@link setAnimationTime}.
|
|
3998
4025
|
*/
|
|
3999
4026
|
playAnimation(animation, options) {
|
|
4027
|
+
this.playAnimations([animation], options);
|
|
4028
|
+
}
|
|
4029
|
+
/** Plays one clip per selected geometry layer, with a shared clock and no blending between clips. */
|
|
4030
|
+
playAnimations(animations, options) {
|
|
4031
|
+
const targets = /* @__PURE__ */ new Set();
|
|
4032
|
+
const selections = animations.map((animation) => {
|
|
4033
|
+
const layer = animation.layer ?? "main";
|
|
4034
|
+
if (targets.has(layer)) throw new Error(`Multiple animations target layer "${layer}"`);
|
|
4035
|
+
targets.add(layer);
|
|
4036
|
+
const names = Object.keys(this.entityLayers).filter((name) => name.split("#")[0] === layer);
|
|
4037
|
+
if (!names.length) throw new Error(`Entity ${this.entity.id} has no selected animation layer "${layer}"`);
|
|
4038
|
+
return { animation, names };
|
|
4039
|
+
});
|
|
4000
4040
|
this.createMeshes();
|
|
4001
|
-
|
|
4002
|
-
|
|
4041
|
+
this.stopAnimation();
|
|
4042
|
+
for (const { animation, names } of selections) {
|
|
4043
|
+
const player = new EntityAnimationPlayer();
|
|
4044
|
+
player.play(names.map((name) => this.getLayerGroup(name)), animation, options, this.partPoses);
|
|
4045
|
+
this.animationPlayers.push(player);
|
|
4046
|
+
}
|
|
4003
4047
|
this.notifyDirty();
|
|
4004
4048
|
}
|
|
4005
|
-
/** Stops
|
|
4049
|
+
/** Stops all clips and restores the poses from before playback. */
|
|
4006
4050
|
stopAnimation() {
|
|
4007
|
-
|
|
4051
|
+
const players = this.animationPlayers.splice(0);
|
|
4052
|
+
for (const player of players) player.stop();
|
|
4053
|
+
if (players.length) this.notifyDirty();
|
|
4008
4054
|
}
|
|
4009
4055
|
/** Poses the object at an explicit time in seconds. Has no effect without an animation. */
|
|
4010
4056
|
setAnimationTime(seconds) {
|
|
4011
|
-
|
|
4057
|
+
for (const player of this.animationPlayers) player.setTime(seconds);
|
|
4058
|
+
if (this.animationPlayers.length) this.notifyDirty();
|
|
4012
4059
|
}
|
|
4013
4060
|
/** Advances the animation by a frame delta in seconds, scaled by its speed. Has no effect without an animation. */
|
|
4014
4061
|
advanceAnimation(deltaSeconds) {
|
|
4015
|
-
|
|
4062
|
+
for (const player of this.animationPlayers) player.advance(deltaSeconds);
|
|
4063
|
+
if (this.animationPlayers.length) this.notifyDirty();
|
|
4016
4064
|
}
|
|
4017
4065
|
//</editor-fold>
|
|
4018
4066
|
getLayerGroup(name) {
|
|
@@ -4044,14 +4092,14 @@ var init_EntityObject = __esm({
|
|
|
4044
4092
|
}
|
|
4045
4093
|
createMeshes(force = false) {
|
|
4046
4094
|
if (this.meshesCreated && !force) return;
|
|
4047
|
-
const modelRoot = new
|
|
4095
|
+
const modelRoot = new import_three14.Object3D();
|
|
4048
4096
|
const transform = this.options.flip === void 0 ? this.entity.transform : void 0;
|
|
4049
4097
|
if (transform) {
|
|
4050
4098
|
for (const op of transform) {
|
|
4051
|
-
const matrix = new
|
|
4099
|
+
const matrix = new import_three14.Matrix4();
|
|
4052
4100
|
if ("scale" in op) matrix.makeScale(...op.scale);
|
|
4053
4101
|
else if ("translate" in op) matrix.makeTranslation(...op.translate);
|
|
4054
|
-
else matrix.makeRotationFromEuler(new
|
|
4102
|
+
else matrix.makeRotationFromEuler(new import_three14.Euler(...op.rotate, "ZYX"));
|
|
4055
4103
|
modelRoot.matrix.multiply(matrix);
|
|
4056
4104
|
}
|
|
4057
4105
|
modelRoot.matrixAutoUpdate = false;
|
|
@@ -4072,6 +4120,7 @@ var init_EntityObject = __esm({
|
|
|
4072
4120
|
anchor.position.fromArray(part.pose.offset);
|
|
4073
4121
|
anchor.rotation.set(...part.pose.rotation, "ZYX");
|
|
4074
4122
|
anchor.scale.fromArray(part.pose.scale ?? [1, 1, 1]);
|
|
4123
|
+
this.partPoses.set(anchor, part.pose);
|
|
4075
4124
|
parent.add(anchor);
|
|
4076
4125
|
const size = part.texture ?? textureSize;
|
|
4077
4126
|
for (const cube of part.cubes) {
|
|
@@ -4107,7 +4156,7 @@ var init_EntityObject = __esm({
|
|
|
4107
4156
|
const tint = layer.tint === void 0 ? void 0 : this.options.tints?.[layer.tint];
|
|
4108
4157
|
const scroll = Materials.entityModeScroll(mode);
|
|
4109
4158
|
const assetKeyStr = this.getTextureKey(layer).serialize();
|
|
4110
|
-
const keyStr = `entity:${mode}:${tint === void 0 ? "" : new
|
|
4159
|
+
const keyStr = `entity:${mode}:${tint === void 0 ? "" : new import_three14.Color(tint).getHexString()}:${assetKeyStr}`;
|
|
4111
4160
|
let mat = scroll ? void 0 : Caching.materialCache.getIfPresent(keyStr);
|
|
4112
4161
|
if (!mat) {
|
|
4113
4162
|
const cachedAsset = Caching.textureAssetCache.getIfPresent(assetKeyStr);
|
|
@@ -4150,7 +4199,7 @@ function mergeBufferGeometries(geometries, useGroups = false) {
|
|
|
4150
4199
|
const attributes = {};
|
|
4151
4200
|
const morphAttributes = {};
|
|
4152
4201
|
const morphTargetsRelative = geometries[0].morphTargetsRelative;
|
|
4153
|
-
const mergedGeometry = new
|
|
4202
|
+
const mergedGeometry = new import_three21.BufferGeometry();
|
|
4154
4203
|
let offset = 0;
|
|
4155
4204
|
for (let i = 0; i < geometries.length; ++i) {
|
|
4156
4205
|
const geometry = geometries[i];
|
|
@@ -4274,7 +4323,7 @@ function mergeBufferAttributes(attributes) {
|
|
|
4274
4323
|
array.set(attributes[i].array, offset);
|
|
4275
4324
|
offset += attributes[i].array.length;
|
|
4276
4325
|
}
|
|
4277
|
-
return new
|
|
4326
|
+
return new import_three21.BufferAttribute(array, itemSize, normalized);
|
|
4278
4327
|
}
|
|
4279
4328
|
function interleaveAttributes(attributes) {
|
|
4280
4329
|
let TypedArray;
|
|
@@ -4290,7 +4339,7 @@ function interleaveAttributes(attributes) {
|
|
|
4290
4339
|
arrayLength += attribute.array.length;
|
|
4291
4340
|
stride += attribute.itemSize;
|
|
4292
4341
|
}
|
|
4293
|
-
const interleavedBuffer = new
|
|
4342
|
+
const interleavedBuffer = new import_three21.InterleavedBuffer(new TypedArray(arrayLength), stride);
|
|
4294
4343
|
let offset = 0;
|
|
4295
4344
|
const res = [];
|
|
4296
4345
|
const getters = ["getX", "getY", "getZ", "getW"];
|
|
@@ -4299,7 +4348,7 @@ function interleaveAttributes(attributes) {
|
|
|
4299
4348
|
const attribute = attributes[j];
|
|
4300
4349
|
const itemSize = attribute.itemSize;
|
|
4301
4350
|
const count = attribute.count;
|
|
4302
|
-
const iba = new
|
|
4351
|
+
const iba = new import_three21.InterleavedBufferAttribute(interleavedBuffer, itemSize, offset, attribute.normalized);
|
|
4303
4352
|
res.push(iba);
|
|
4304
4353
|
offset += itemSize;
|
|
4305
4354
|
for (let c = 0; c < count; c++) {
|
|
@@ -4383,13 +4432,13 @@ function mergeVertices(geometry, tolerance = 1e-4) {
|
|
|
4383
4432
|
const name = attributeNames[i];
|
|
4384
4433
|
const oldAttribute = geometry.getAttribute(name);
|
|
4385
4434
|
const buffer = new oldAttribute.array.constructor(attrArrays[name]);
|
|
4386
|
-
const attribute = new
|
|
4435
|
+
const attribute = new import_three21.BufferAttribute(buffer, oldAttribute.itemSize, oldAttribute.normalized);
|
|
4387
4436
|
result.setAttribute(name, attribute);
|
|
4388
4437
|
if (name in morphAttrsArrays) {
|
|
4389
4438
|
for (let j = 0; j < morphAttrsArrays[name].length; j++) {
|
|
4390
4439
|
const oldMorphAttribute = geometry.morphAttributes[name][j];
|
|
4391
4440
|
const buffer2 = new oldMorphAttribute.array.constructor(morphAttrsArrays[name][j]);
|
|
4392
|
-
const morphAttribute = new
|
|
4441
|
+
const morphAttribute = new import_three21.BufferAttribute(buffer2, oldMorphAttribute.itemSize, oldMorphAttribute.normalized);
|
|
4393
4442
|
result.morphAttributes[name][j] = morphAttribute;
|
|
4394
4443
|
}
|
|
4395
4444
|
}
|
|
@@ -4398,11 +4447,11 @@ function mergeVertices(geometry, tolerance = 1e-4) {
|
|
|
4398
4447
|
return result;
|
|
4399
4448
|
}
|
|
4400
4449
|
function toTrianglesDrawMode(geometry, drawMode) {
|
|
4401
|
-
if (drawMode ===
|
|
4450
|
+
if (drawMode === import_three21.TrianglesDrawMode) {
|
|
4402
4451
|
console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles.");
|
|
4403
4452
|
return geometry;
|
|
4404
4453
|
}
|
|
4405
|
-
if (drawMode ===
|
|
4454
|
+
if (drawMode === import_three21.TriangleFanDrawMode || drawMode === import_three21.TriangleStripDrawMode) {
|
|
4406
4455
|
let index = geometry.getIndex();
|
|
4407
4456
|
if (index === null) {
|
|
4408
4457
|
const indices = [];
|
|
@@ -4420,7 +4469,7 @@ function toTrianglesDrawMode(geometry, drawMode) {
|
|
|
4420
4469
|
}
|
|
4421
4470
|
const numberOfTriangles = index.count - 2;
|
|
4422
4471
|
const newIndices = [];
|
|
4423
|
-
if (drawMode ===
|
|
4472
|
+
if (drawMode === import_three21.TriangleFanDrawMode) {
|
|
4424
4473
|
for (let i = 1; i <= numberOfTriangles; i++) {
|
|
4425
4474
|
newIndices.push(index.getX(0));
|
|
4426
4475
|
newIndices.push(index.getX(i));
|
|
@@ -4456,15 +4505,15 @@ function computeMorphedAttributes(object) {
|
|
|
4456
4505
|
console.error("THREE.BufferGeometryUtils: Geometry is not of type BufferGeometry.");
|
|
4457
4506
|
return null;
|
|
4458
4507
|
}
|
|
4459
|
-
const _vA = new
|
|
4460
|
-
const _vB = new
|
|
4461
|
-
const _vC = new
|
|
4462
|
-
const _tempA = new
|
|
4463
|
-
const _tempB = new
|
|
4464
|
-
const _tempC = new
|
|
4465
|
-
const _morphA = new
|
|
4466
|
-
const _morphB = new
|
|
4467
|
-
const _morphC = new
|
|
4508
|
+
const _vA = new import_three21.Vector3();
|
|
4509
|
+
const _vB = new import_three21.Vector3();
|
|
4510
|
+
const _vC = new import_three21.Vector3();
|
|
4511
|
+
const _tempA = new import_three21.Vector3();
|
|
4512
|
+
const _tempB = new import_three21.Vector3();
|
|
4513
|
+
const _tempC = new import_three21.Vector3();
|
|
4514
|
+
const _morphA = new import_three21.Vector3();
|
|
4515
|
+
const _morphB = new import_three21.Vector3();
|
|
4516
|
+
const _morphC = new import_three21.Vector3();
|
|
4468
4517
|
function _calculateMorphedAttributeData(object2, material2, attribute, morphAttribute, morphTargetsRelative2, a2, b2, c2, modifiedAttributeArray) {
|
|
4469
4518
|
_vA.fromBufferAttribute(attribute, a2);
|
|
4470
4519
|
_vB.fromBufferAttribute(attribute, b2);
|
|
@@ -4659,8 +4708,8 @@ function computeMorphedAttributes(object) {
|
|
|
4659
4708
|
}
|
|
4660
4709
|
}
|
|
4661
4710
|
}
|
|
4662
|
-
const morphedPositionAttribute = new
|
|
4663
|
-
const morphedNormalAttribute = new
|
|
4711
|
+
const morphedPositionAttribute = new import_three21.Float32BufferAttribute(modifiedPosition, 3);
|
|
4712
|
+
const morphedNormalAttribute = new import_three21.Float32BufferAttribute(modifiedNormal, 3);
|
|
4664
4713
|
return {
|
|
4665
4714
|
positionAttribute,
|
|
4666
4715
|
normalAttribute,
|
|
@@ -4668,24 +4717,24 @@ function computeMorphedAttributes(object) {
|
|
|
4668
4717
|
morphedNormalAttribute
|
|
4669
4718
|
};
|
|
4670
4719
|
}
|
|
4671
|
-
var
|
|
4720
|
+
var import_three21;
|
|
4672
4721
|
var init_BufferGeometryUtils = __esm({
|
|
4673
4722
|
"src/three/BufferGeometryUtils.js"() {
|
|
4674
|
-
|
|
4723
|
+
import_three21 = require("three");
|
|
4675
4724
|
}
|
|
4676
4725
|
});
|
|
4677
4726
|
|
|
4678
4727
|
// src/model/ModelCulling.ts
|
|
4679
|
-
var
|
|
4728
|
+
var import_three22, ModelCulling;
|
|
4680
4729
|
var init_ModelCulling = __esm({
|
|
4681
4730
|
"src/model/ModelCulling.ts"() {
|
|
4682
|
-
|
|
4731
|
+
import_three22 = require("three");
|
|
4683
4732
|
init_CubeFace();
|
|
4684
4733
|
ModelCulling = class {
|
|
4685
4734
|
static toLocalMask(worldMask, rotation) {
|
|
4686
4735
|
let localMask = 0;
|
|
4687
4736
|
for (const [localFace, offset] of CUBE_FACE_OFFSETS.entries()) {
|
|
4688
|
-
const normal = new
|
|
4737
|
+
const normal = new import_three22.Vector3(...offset).applyEuler(rotation);
|
|
4689
4738
|
const worldFace = CUBE_FACE_OFFSETS.findIndex(([x, y, z]) => Math.abs(normal.x - x) < 1e-6 && Math.abs(normal.y - y) < 1e-6 && Math.abs(normal.z - z) < 1e-6);
|
|
4690
4739
|
if (worldFace < 0) return 0;
|
|
4691
4740
|
if (worldMask & 1 << worldFace) localMask |= 1 << localFace;
|
|
@@ -4718,10 +4767,10 @@ var init_ModelCulling = __esm({
|
|
|
4718
4767
|
});
|
|
4719
4768
|
|
|
4720
4769
|
// src/model/SpecialItems.ts
|
|
4721
|
-
var
|
|
4770
|
+
var import_three23, SpecialItems;
|
|
4722
4771
|
var init_SpecialItems = __esm({
|
|
4723
4772
|
"src/model/SpecialItems.ts"() {
|
|
4724
|
-
|
|
4773
|
+
import_three23 = require("three");
|
|
4725
4774
|
init_AssetKey();
|
|
4726
4775
|
init_Entities();
|
|
4727
4776
|
SpecialItems = class {
|
|
@@ -4749,7 +4798,7 @@ var init_SpecialItems = __esm({
|
|
|
4749
4798
|
case "minecraft:chest":
|
|
4750
4799
|
case "chest": {
|
|
4751
4800
|
const angle = -(special.openness ?? 0) * Math.PI / 2;
|
|
4752
|
-
const chest = await load("chest", texture(special.texture, "chest"), new
|
|
4801
|
+
const chest = await load("chest", texture(special.texture, "chest"), new import_three23.Matrix4(), {
|
|
4753
4802
|
lid: [angle, 0, 0],
|
|
4754
4803
|
lock: [angle, 0, 0]
|
|
4755
4804
|
});
|
|
@@ -4758,11 +4807,11 @@ var init_SpecialItems = __esm({
|
|
|
4758
4807
|
}
|
|
4759
4808
|
case "minecraft:bed":
|
|
4760
4809
|
case "bed": {
|
|
4761
|
-
const transform = new
|
|
4810
|
+
const transform = new import_three23.Matrix4().makeTranslation(0, 9, 0).multiply(new import_three23.Matrix4().makeRotationX(Math.PI / 2)).multiply(new import_three23.Matrix4().makeTranslation(8, 8, 8)).multiply(new import_three23.Matrix4().makeRotationZ(Math.PI)).multiply(new import_three23.Matrix4().makeTranslation(-8, -8, -8));
|
|
4762
4811
|
const key = texture(special.texture, "bed");
|
|
4763
4812
|
return Promise.all([
|
|
4764
4813
|
load("bed_head", key, transform),
|
|
4765
|
-
load("bed_foot", key, new
|
|
4814
|
+
load("bed_foot", key, new import_three23.Matrix4().makeTranslation(0, 0, -16).multiply(transform))
|
|
4766
4815
|
]);
|
|
4767
4816
|
}
|
|
4768
4817
|
case "minecraft:head":
|
|
@@ -4787,7 +4836,7 @@ var init_SpecialItems = __esm({
|
|
|
4787
4836
|
return [await load(
|
|
4788
4837
|
id,
|
|
4789
4838
|
special.texture ? texture(special.texture, "") : void 0,
|
|
4790
|
-
new
|
|
4839
|
+
new import_three23.Matrix4().makeTranslation(8, 0, 8).multiply(new import_three23.Matrix4().makeScale(-1, -1, 1)),
|
|
4791
4840
|
rotations
|
|
4792
4841
|
)];
|
|
4793
4842
|
}
|
|
@@ -4915,13 +4964,13 @@ var init_ItemTints = __esm({
|
|
|
4915
4964
|
function isModelObject(obj) {
|
|
4916
4965
|
return obj.isModelObject;
|
|
4917
4966
|
}
|
|
4918
|
-
var
|
|
4967
|
+
var import_three24, import_ts_deepmerge5, p7, _ModelObject, ModelObject;
|
|
4919
4968
|
var init_ModelObject = __esm({
|
|
4920
4969
|
"src/model/scene/ModelObject.ts"() {
|
|
4921
4970
|
init_SceneObject();
|
|
4922
4971
|
init_Materials();
|
|
4923
4972
|
init_UVMapper();
|
|
4924
|
-
|
|
4973
|
+
import_three24 = require("three");
|
|
4925
4974
|
init_BufferGeometryUtils();
|
|
4926
4975
|
init_model();
|
|
4927
4976
|
import_ts_deepmerge5 = __toESM(require_dist());
|
|
@@ -4953,8 +5002,8 @@ var init_ModelObject = __esm({
|
|
|
4953
5002
|
const special = this.originalModel.special;
|
|
4954
5003
|
if (special) {
|
|
4955
5004
|
const parts = await SpecialItems.getParts(special, this.originalModel.key?.root);
|
|
4956
|
-
const transform = this.options.displayPosition ? DisplayTransforms.getMatrix(this.originalModel.display, this.options.displayPosition) : new
|
|
4957
|
-
transform.multiply(new
|
|
5005
|
+
const transform = this.options.displayPosition ? DisplayTransforms.getMatrix(this.originalModel.display, this.options.displayPosition) : new import_three24.Matrix4();
|
|
5006
|
+
transform.multiply(new import_three24.Matrix4().makeTranslation(-8, -8, -8));
|
|
4958
5007
|
try {
|
|
4959
5008
|
for (const part of parts) {
|
|
4960
5009
|
const object = new EntityObject(part.model, { flip: false, wireframe: this.options.wireframe });
|
|
@@ -5016,7 +5065,7 @@ var init_ModelObject = __esm({
|
|
|
5016
5065
|
elGeo.clearGroups();
|
|
5017
5066
|
}
|
|
5018
5067
|
if (this.options.uvLockRotation) {
|
|
5019
|
-
UVMapper.lockUvs(elGeo, el.faces, this.atlas, new
|
|
5068
|
+
UVMapper.lockUvs(elGeo, el.faces, this.atlas, new import_three24.Euler(...this.options.uvLockRotation));
|
|
5020
5069
|
}
|
|
5021
5070
|
if (this.options.tints) {
|
|
5022
5071
|
const colors = new Float32Array(elGeo.getAttribute("position").count * 3).fill(1);
|
|
@@ -5025,19 +5074,19 @@ var init_ModelObject = __esm({
|
|
|
5025
5074
|
if (tintIndex === void 0 || tintIndex < 0) continue;
|
|
5026
5075
|
const tint = this.options.tints[tintIndex];
|
|
5027
5076
|
if (tint === void 0) continue;
|
|
5028
|
-
const color = new
|
|
5077
|
+
const color = new import_three24.Color(tint);
|
|
5029
5078
|
for (let vertex = 0; vertex < 4; vertex++) {
|
|
5030
5079
|
color.toArray(colors, (faceIndex * 4 + vertex) * 3);
|
|
5031
5080
|
}
|
|
5032
5081
|
}
|
|
5033
|
-
elGeo.setAttribute("color", new
|
|
5082
|
+
elGeo.setAttribute("color", new import_three24.BufferAttribute(colors, 3));
|
|
5034
5083
|
}
|
|
5035
|
-
elGeo.applyMatrix4(new
|
|
5036
|
-
elGeo.applyMatrix4(new
|
|
5084
|
+
elGeo.applyMatrix4(new import_three24.Matrix4().makeTranslation((el.to[0] - el.from[0]) / 2, (el.to[1] - el.from[1]) / 2, (el.to[2] - el.from[2]) / 2));
|
|
5085
|
+
elGeo.applyMatrix4(new import_three24.Matrix4().makeTranslation(el.from[0], el.from[1], el.from[2]));
|
|
5037
5086
|
if (el.rotation) {
|
|
5038
5087
|
applyElementRotation(el.rotation, elGeo);
|
|
5039
5088
|
}
|
|
5040
|
-
elGeo.applyMatrix4(new
|
|
5089
|
+
elGeo.applyMatrix4(new import_three24.Matrix4().makeTranslation(-8, -8, -8));
|
|
5041
5090
|
if (displayTransform) DisplayTransforms.apply(elGeo, displayTransform);
|
|
5042
5091
|
if (this.options.mergeMeshes) {
|
|
5043
5092
|
allGeos.push(elGeo);
|
|
@@ -5059,7 +5108,7 @@ var init_ModelObject = __esm({
|
|
|
5059
5108
|
if (allGeos.length > 0) {
|
|
5060
5109
|
combinedGeo = mergeBufferGeometries(allGeos);
|
|
5061
5110
|
} else {
|
|
5062
|
-
combinedGeo = new
|
|
5111
|
+
combinedGeo = new import_three24.BoxGeometry(16, 16, 16);
|
|
5063
5112
|
if (displayTransform) DisplayTransforms.apply(combinedGeo, displayTransform);
|
|
5064
5113
|
}
|
|
5065
5114
|
combinedGeo.computeBoundingBox();
|
|
@@ -5171,7 +5220,7 @@ function ownHeight(sample) {
|
|
|
5171
5220
|
return (level === 0 || level >= 8 ? 8 : 8 - level) / 9;
|
|
5172
5221
|
}
|
|
5173
5222
|
function createFluidGeometry(kind, sample) {
|
|
5174
|
-
const geometry = new
|
|
5223
|
+
const geometry = new import_three29.BufferGeometry();
|
|
5175
5224
|
const positions = [], normals = [], uvs = [], indices = [];
|
|
5176
5225
|
const self = sample(0, 0, 0);
|
|
5177
5226
|
const height = (x, z) => {
|
|
@@ -5270,16 +5319,16 @@ function createFluidGeometry(kind, sample) {
|
|
|
5270
5319
|
1
|
|
5271
5320
|
);
|
|
5272
5321
|
}
|
|
5273
|
-
geometry.setAttribute("position", new
|
|
5274
|
-
geometry.setAttribute("normal", new
|
|
5275
|
-
geometry.setAttribute("uv", new
|
|
5322
|
+
geometry.setAttribute("position", new import_three29.Float32BufferAttribute(positions, 3));
|
|
5323
|
+
geometry.setAttribute("normal", new import_three29.Float32BufferAttribute(normals, 3));
|
|
5324
|
+
geometry.setAttribute("uv", new import_three29.Float32BufferAttribute(uvs, 2));
|
|
5276
5325
|
geometry.setIndex(indices);
|
|
5277
5326
|
return geometry;
|
|
5278
5327
|
}
|
|
5279
|
-
var
|
|
5328
|
+
var import_three29, fluidRules, HORIZONTAL, EPSILON;
|
|
5280
5329
|
var init_FluidGeometry = __esm({
|
|
5281
5330
|
"src/model/fluid/FluidGeometry.ts"() {
|
|
5282
|
-
|
|
5331
|
+
import_three29 = require("three");
|
|
5283
5332
|
init_fluidBlocks();
|
|
5284
5333
|
fluidRules = fluidBlocks_default;
|
|
5285
5334
|
HORIZONTAL = [[0, -1], [0, 1], [-1, 0], [1, 0]];
|
|
@@ -5308,10 +5357,10 @@ function sampleFluid(kind, sample) {
|
|
|
5308
5357
|
}
|
|
5309
5358
|
return { key: key.join(""), sample: (x, y, z) => cells[(y + 1) * 9 + (z + 1) * 3 + x + 1] };
|
|
5310
5359
|
}
|
|
5311
|
-
var
|
|
5360
|
+
var import_three30, FluidModelObject;
|
|
5312
5361
|
var init_FluidModelObject = __esm({
|
|
5313
5362
|
"src/model/fluid/FluidModelObject.ts"() {
|
|
5314
|
-
|
|
5363
|
+
import_three30 = require("three");
|
|
5315
5364
|
init_AssetKey();
|
|
5316
5365
|
init_Materials();
|
|
5317
5366
|
init_ModelObject();
|
|
@@ -5344,10 +5393,10 @@ var init_FluidModelObject = __esm({
|
|
|
5344
5393
|
}
|
|
5345
5394
|
}
|
|
5346
5395
|
geometry.clearGroups();
|
|
5347
|
-
const color = new
|
|
5396
|
+
const color = new import_three30.Color(this.options.tints?.[0] ?? (this.kind === "water" ? 4159204 : 16777215));
|
|
5348
5397
|
const colors = new Float32Array(geometry.getAttribute("position").count * 3);
|
|
5349
5398
|
for (let i = 0; i < colors.length; i += 3) color.toArray(colors, i);
|
|
5350
|
-
geometry.setAttribute("color", new
|
|
5399
|
+
geometry.setAttribute("color", new import_three30.BufferAttribute(colors, 3));
|
|
5351
5400
|
geometry.computeBoundingBox();
|
|
5352
5401
|
geometry.computeBoundingSphere();
|
|
5353
5402
|
if (this.options.instanceMeshes) {
|
|
@@ -5361,7 +5410,7 @@ var init_FluidModelObject = __esm({
|
|
|
5361
5410
|
super.applyTextures();
|
|
5362
5411
|
this.iterateAllMeshes((mesh) => {
|
|
5363
5412
|
const material = mesh.material;
|
|
5364
|
-
material.side =
|
|
5413
|
+
material.side = import_three30.DoubleSide;
|
|
5365
5414
|
material.forceSinglePass = true;
|
|
5366
5415
|
material.depthWrite = !material.transparent;
|
|
5367
5416
|
});
|
|
@@ -5848,27 +5897,27 @@ init_EntityObject();
|
|
|
5848
5897
|
init_MineRenderError();
|
|
5849
5898
|
|
|
5850
5899
|
// src/export/SceneExporter.ts
|
|
5851
|
-
var
|
|
5900
|
+
var import_three20 = require("three");
|
|
5852
5901
|
|
|
5853
5902
|
// ../../node_modules/three/examples/jsm/exporters/OBJExporter.js
|
|
5854
|
-
var
|
|
5903
|
+
var import_three16 = require("three");
|
|
5855
5904
|
var OBJExporter = class {
|
|
5856
5905
|
parse(object) {
|
|
5857
5906
|
let output = "";
|
|
5858
5907
|
let indexVertex = 0;
|
|
5859
5908
|
let indexVertexUvs = 0;
|
|
5860
5909
|
let indexNormals = 0;
|
|
5861
|
-
const vertex = new
|
|
5862
|
-
const color = new
|
|
5863
|
-
const normal = new
|
|
5864
|
-
const uv = new
|
|
5910
|
+
const vertex = new import_three16.Vector3();
|
|
5911
|
+
const color = new import_three16.Color();
|
|
5912
|
+
const normal = new import_three16.Vector3();
|
|
5913
|
+
const uv = new import_three16.Vector2();
|
|
5865
5914
|
const face = [];
|
|
5866
5915
|
function parseMesh(mesh) {
|
|
5867
5916
|
let nbVertex = 0;
|
|
5868
5917
|
let nbNormals = 0;
|
|
5869
5918
|
let nbVertexUvs = 0;
|
|
5870
5919
|
const geometry = mesh.geometry;
|
|
5871
|
-
const normalMatrixWorld = new
|
|
5920
|
+
const normalMatrixWorld = new import_three16.Matrix3();
|
|
5872
5921
|
const vertices = geometry.getAttribute("position");
|
|
5873
5922
|
const normals = geometry.getAttribute("normal");
|
|
5874
5923
|
const uvs = geometry.getAttribute("uv");
|
|
@@ -5987,7 +6036,7 @@ var OBJExporter = class {
|
|
|
5987
6036
|
};
|
|
5988
6037
|
|
|
5989
6038
|
// ../../node_modules/three/examples/jsm/exporters/PLYExporter.js
|
|
5990
|
-
var
|
|
6039
|
+
var import_three17 = require("three");
|
|
5991
6040
|
var PLYExporter = class {
|
|
5992
6041
|
parse(object, onDone, options = {}) {
|
|
5993
6042
|
function traverseMeshes(cb) {
|
|
@@ -6044,7 +6093,7 @@ var PLYExporter = class {
|
|
|
6044
6093
|
includeIndices = false;
|
|
6045
6094
|
}
|
|
6046
6095
|
});
|
|
6047
|
-
const tempColor = new
|
|
6096
|
+
const tempColor = new import_three17.Color();
|
|
6048
6097
|
includeIndices = includeIndices && excludeAttributes.indexOf("index") === -1;
|
|
6049
6098
|
includeNormals = includeNormals && excludeAttributes.indexOf("normal") === -1;
|
|
6050
6099
|
includeColors = includeColors && excludeAttributes.indexOf("color") === -1;
|
|
@@ -6078,8 +6127,8 @@ property list uchar int vertex_index
|
|
|
6078
6127
|
`;
|
|
6079
6128
|
}
|
|
6080
6129
|
header += "end_header\n";
|
|
6081
|
-
const vertex = new
|
|
6082
|
-
const normalMatrixWorld = new
|
|
6130
|
+
const vertex = new import_three17.Vector3();
|
|
6131
|
+
const normalMatrixWorld = new import_three17.Matrix3();
|
|
6083
6132
|
let result = null;
|
|
6084
6133
|
if (options.binary === true) {
|
|
6085
6134
|
const headerBin = new TextEncoder().encode(header);
|
|
@@ -6253,18 +6302,18 @@ property list uchar int vertex_index
|
|
|
6253
6302
|
};
|
|
6254
6303
|
|
|
6255
6304
|
// ../../node_modules/three/examples/jsm/exporters/GLTFExporter.js
|
|
6256
|
-
var
|
|
6305
|
+
var import_three19 = require("three");
|
|
6257
6306
|
|
|
6258
6307
|
// ../../node_modules/three/examples/jsm/utils/TextureUtils.js
|
|
6259
|
-
var
|
|
6308
|
+
var import_three18 = require("three");
|
|
6260
6309
|
var _renderer;
|
|
6261
6310
|
var fullscreenQuadGeometry;
|
|
6262
6311
|
var fullscreenQuadMaterial;
|
|
6263
6312
|
var fullscreenQuad;
|
|
6264
6313
|
function decompress(texture, maxTextureSize = Infinity, renderer = null) {
|
|
6265
|
-
if (!fullscreenQuadGeometry) fullscreenQuadGeometry = new
|
|
6266
|
-
if (!fullscreenQuadMaterial) fullscreenQuadMaterial = new
|
|
6267
|
-
uniforms: { blitTexture: new
|
|
6314
|
+
if (!fullscreenQuadGeometry) fullscreenQuadGeometry = new import_three18.PlaneGeometry(2, 2, 1, 1);
|
|
6315
|
+
if (!fullscreenQuadMaterial) fullscreenQuadMaterial = new import_three18.ShaderMaterial({
|
|
6316
|
+
uniforms: { blitTexture: new import_three18.Uniform(texture) },
|
|
6268
6317
|
vertexShader: `
|
|
6269
6318
|
varying vec2 vUv;
|
|
6270
6319
|
void main(){
|
|
@@ -6286,22 +6335,22 @@ function decompress(texture, maxTextureSize = Infinity, renderer = null) {
|
|
|
6286
6335
|
}`
|
|
6287
6336
|
});
|
|
6288
6337
|
fullscreenQuadMaterial.uniforms.blitTexture.value = texture;
|
|
6289
|
-
fullscreenQuadMaterial.defines.IS_SRGB = texture.colorSpace ==
|
|
6338
|
+
fullscreenQuadMaterial.defines.IS_SRGB = texture.colorSpace == import_three18.SRGBColorSpace;
|
|
6290
6339
|
fullscreenQuadMaterial.needsUpdate = true;
|
|
6291
6340
|
if (!fullscreenQuad) {
|
|
6292
|
-
fullscreenQuad = new
|
|
6341
|
+
fullscreenQuad = new import_three18.Mesh(fullscreenQuadGeometry, fullscreenQuadMaterial);
|
|
6293
6342
|
fullscreenQuad.frustrumCulled = false;
|
|
6294
6343
|
}
|
|
6295
|
-
const _camera = new
|
|
6296
|
-
const _scene = new
|
|
6344
|
+
const _camera = new import_three18.PerspectiveCamera();
|
|
6345
|
+
const _scene = new import_three18.Scene();
|
|
6297
6346
|
_scene.add(fullscreenQuad);
|
|
6298
6347
|
if (!renderer) {
|
|
6299
|
-
renderer = _renderer = new
|
|
6348
|
+
renderer = _renderer = new import_three18.WebGLRenderer({ antialias: false });
|
|
6300
6349
|
}
|
|
6301
6350
|
renderer.setSize(Math.min(texture.image.width, maxTextureSize), Math.min(texture.image.height, maxTextureSize));
|
|
6302
6351
|
renderer.clear();
|
|
6303
6352
|
renderer.render(_scene, _camera);
|
|
6304
|
-
const readableTexture = new
|
|
6353
|
+
const readableTexture = new import_three18.Texture(renderer.domElement);
|
|
6305
6354
|
readableTexture.minFilter = texture.minFilter;
|
|
6306
6355
|
readableTexture.magFilter = texture.magFilter;
|
|
6307
6356
|
readableTexture.wrapS = texture.wrapS;
|
|
@@ -6447,22 +6496,22 @@ var WEBGL_CONSTANTS = {
|
|
|
6447
6496
|
};
|
|
6448
6497
|
var KHR_MESH_QUANTIZATION = "KHR_mesh_quantization";
|
|
6449
6498
|
var THREE_TO_WEBGL = {};
|
|
6450
|
-
THREE_TO_WEBGL[
|
|
6451
|
-
THREE_TO_WEBGL[
|
|
6452
|
-
THREE_TO_WEBGL[
|
|
6453
|
-
THREE_TO_WEBGL[
|
|
6454
|
-
THREE_TO_WEBGL[
|
|
6455
|
-
THREE_TO_WEBGL[
|
|
6456
|
-
THREE_TO_WEBGL[
|
|
6457
|
-
THREE_TO_WEBGL[
|
|
6458
|
-
THREE_TO_WEBGL[
|
|
6499
|
+
THREE_TO_WEBGL[import_three19.NearestFilter] = WEBGL_CONSTANTS.NEAREST;
|
|
6500
|
+
THREE_TO_WEBGL[import_three19.NearestMipmapNearestFilter] = WEBGL_CONSTANTS.NEAREST_MIPMAP_NEAREST;
|
|
6501
|
+
THREE_TO_WEBGL[import_three19.NearestMipmapLinearFilter] = WEBGL_CONSTANTS.NEAREST_MIPMAP_LINEAR;
|
|
6502
|
+
THREE_TO_WEBGL[import_three19.LinearFilter] = WEBGL_CONSTANTS.LINEAR;
|
|
6503
|
+
THREE_TO_WEBGL[import_three19.LinearMipmapNearestFilter] = WEBGL_CONSTANTS.LINEAR_MIPMAP_NEAREST;
|
|
6504
|
+
THREE_TO_WEBGL[import_three19.LinearMipmapLinearFilter] = WEBGL_CONSTANTS.LINEAR_MIPMAP_LINEAR;
|
|
6505
|
+
THREE_TO_WEBGL[import_three19.ClampToEdgeWrapping] = WEBGL_CONSTANTS.CLAMP_TO_EDGE;
|
|
6506
|
+
THREE_TO_WEBGL[import_three19.RepeatWrapping] = WEBGL_CONSTANTS.REPEAT;
|
|
6507
|
+
THREE_TO_WEBGL[import_three19.MirroredRepeatWrapping] = WEBGL_CONSTANTS.MIRRORED_REPEAT;
|
|
6459
6508
|
var PATH_PROPERTIES = {
|
|
6460
6509
|
scale: "scale",
|
|
6461
6510
|
position: "translation",
|
|
6462
6511
|
quaternion: "rotation",
|
|
6463
6512
|
morphTargetInfluences: "weights"
|
|
6464
6513
|
};
|
|
6465
|
-
var DEFAULT_SPECULAR_COLOR = new
|
|
6514
|
+
var DEFAULT_SPECULAR_COLOR = new import_three19.Color();
|
|
6466
6515
|
var GLB_HEADER_BYTES = 12;
|
|
6467
6516
|
var GLB_HEADER_MAGIC = 1179937895;
|
|
6468
6517
|
var GLB_VERSION = 2;
|
|
@@ -6496,7 +6545,7 @@ function getMinMax(attribute, start, count) {
|
|
|
6496
6545
|
else if (a === 2) value = attribute.getZ(i);
|
|
6497
6546
|
else if (a === 3) value = attribute.getW(i);
|
|
6498
6547
|
if (attribute.normalized === true) {
|
|
6499
|
-
value =
|
|
6548
|
+
value = import_three19.MathUtils.normalize(value, attribute.array);
|
|
6500
6549
|
}
|
|
6501
6550
|
}
|
|
6502
6551
|
output.min[a] = Math.min(output.min[a], value);
|
|
@@ -6702,7 +6751,7 @@ var GLTFWriter = class {
|
|
|
6702
6751
|
isNormalizedNormalAttribute(normal) {
|
|
6703
6752
|
const cache = this.cache;
|
|
6704
6753
|
if (cache.attributesNormalized.has(normal)) return false;
|
|
6705
|
-
const v = new
|
|
6754
|
+
const v = new import_three19.Vector3();
|
|
6706
6755
|
for (let i = 0, il = normal.count; i < il; i++) {
|
|
6707
6756
|
if (Math.abs(v.fromBufferAttribute(normal, i).length() - 1) > 5e-4) return false;
|
|
6708
6757
|
}
|
|
@@ -6719,7 +6768,7 @@ var GLTFWriter = class {
|
|
|
6719
6768
|
const cache = this.cache;
|
|
6720
6769
|
if (cache.attributesNormalized.has(normal)) return cache.attributesNormalized.get(normal);
|
|
6721
6770
|
const attribute = normal.clone();
|
|
6722
|
-
const v = new
|
|
6771
|
+
const v = new import_three19.Vector3();
|
|
6723
6772
|
for (let i = 0, il = attribute.count; i < il; i++) {
|
|
6724
6773
|
v.fromBufferAttribute(attribute, i);
|
|
6725
6774
|
if (v.x === 0 && v.y === 0 && v.z === 0) {
|
|
@@ -6763,7 +6812,7 @@ var GLTFWriter = class {
|
|
|
6763
6812
|
buildMetalRoughTexture(metalnessMap, roughnessMap) {
|
|
6764
6813
|
if (metalnessMap === roughnessMap) return metalnessMap;
|
|
6765
6814
|
function getEncodingConversion(map) {
|
|
6766
|
-
if (map.colorSpace ===
|
|
6815
|
+
if (map.colorSpace === import_three19.SRGBColorSpace) {
|
|
6767
6816
|
return function SRGBToLinear(c) {
|
|
6768
6817
|
return c < 0.04045 ? c * 0.0773993808 : Math.pow(c * 0.9478672986 + 0.0521327014, 2.4);
|
|
6769
6818
|
};
|
|
@@ -6773,10 +6822,10 @@ var GLTFWriter = class {
|
|
|
6773
6822
|
};
|
|
6774
6823
|
}
|
|
6775
6824
|
console.warn("THREE.GLTFExporter: Merged metalnessMap and roughnessMap textures.");
|
|
6776
|
-
if (metalnessMap instanceof
|
|
6825
|
+
if (metalnessMap instanceof import_three19.CompressedTexture) {
|
|
6777
6826
|
metalnessMap = decompress(metalnessMap);
|
|
6778
6827
|
}
|
|
6779
|
-
if (roughnessMap instanceof
|
|
6828
|
+
if (roughnessMap instanceof import_three19.CompressedTexture) {
|
|
6780
6829
|
roughnessMap = decompress(roughnessMap);
|
|
6781
6830
|
}
|
|
6782
6831
|
const metalness = metalnessMap ? metalnessMap.image : null;
|
|
@@ -6809,8 +6858,8 @@ var GLTFWriter = class {
|
|
|
6809
6858
|
context.putImageData(composite, 0, 0);
|
|
6810
6859
|
const reference = metalnessMap || roughnessMap;
|
|
6811
6860
|
const texture = reference.clone();
|
|
6812
|
-
texture.source = new
|
|
6813
|
-
texture.colorSpace =
|
|
6861
|
+
texture.source = new import_three19.Source(canvas);
|
|
6862
|
+
texture.colorSpace = import_three19.NoColorSpace;
|
|
6814
6863
|
texture.channel = (metalnessMap || roughnessMap).channel;
|
|
6815
6864
|
if (metalnessMap && roughnessMap && metalnessMap.channel !== roughnessMap.channel) {
|
|
6816
6865
|
console.warn("THREE.GLTFExporter: UV channels for metalnessMap and roughnessMap textures must match.");
|
|
@@ -6868,7 +6917,7 @@ var GLTFWriter = class {
|
|
|
6868
6917
|
else if (a === 2) value = attribute.getZ(i);
|
|
6869
6918
|
else if (a === 3) value = attribute.getW(i);
|
|
6870
6919
|
if (attribute.normalized === true) {
|
|
6871
|
-
value =
|
|
6920
|
+
value = import_three19.MathUtils.normalize(value, attribute.array);
|
|
6872
6921
|
}
|
|
6873
6922
|
}
|
|
6874
6923
|
if (componentType === WEBGL_CONSTANTS.FLOAT) {
|
|
@@ -7018,7 +7067,7 @@ var GLTFWriter = class {
|
|
|
7018
7067
|
ctx.scale(1, -1);
|
|
7019
7068
|
}
|
|
7020
7069
|
if (image.data !== void 0) {
|
|
7021
|
-
if (format !==
|
|
7070
|
+
if (format !== import_three19.RGBAFormat) {
|
|
7022
7071
|
console.error("GLTFExporter: Only RGBAFormat is supported.", format);
|
|
7023
7072
|
}
|
|
7024
7073
|
if (image.width > options.maxTextureSize || image.height > options.maxTextureSize) {
|
|
@@ -7087,7 +7136,7 @@ var GLTFWriter = class {
|
|
|
7087
7136
|
const json = this.json;
|
|
7088
7137
|
if (cache.textures.has(map)) return cache.textures.get(map);
|
|
7089
7138
|
if (!json.textures) json.textures = [];
|
|
7090
|
-
if (map instanceof
|
|
7139
|
+
if (map instanceof import_three19.CompressedTexture) {
|
|
7091
7140
|
map = decompress(map, options.maxTextureSize);
|
|
7092
7141
|
}
|
|
7093
7142
|
let mimeType = map.userData.mimeType;
|
|
@@ -7195,7 +7244,7 @@ var GLTFWriter = class {
|
|
|
7195
7244
|
materialDef.alphaCutoff = material.alphaTest;
|
|
7196
7245
|
}
|
|
7197
7246
|
}
|
|
7198
|
-
if (material.side ===
|
|
7247
|
+
if (material.side === import_three19.DoubleSide) materialDef.doubleSided = true;
|
|
7199
7248
|
if (material.name !== "") materialDef.name = material.name;
|
|
7200
7249
|
this.serializeUserData(material, materialDef);
|
|
7201
7250
|
this._invokeAll(function(ext) {
|
|
@@ -7269,7 +7318,7 @@ var GLTFWriter = class {
|
|
|
7269
7318
|
const array = attribute.array;
|
|
7270
7319
|
if (attributeName === "JOINTS_0" && !(array instanceof Uint16Array) && !(array instanceof Uint8Array)) {
|
|
7271
7320
|
console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.');
|
|
7272
|
-
modifiedAttribute = new
|
|
7321
|
+
modifiedAttribute = new import_three19.BufferAttribute(new Uint16Array(array), attribute.itemSize, attribute.normalized);
|
|
7273
7322
|
}
|
|
7274
7323
|
const accessor = this.processAccessor(modifiedAttribute || attribute, geometry);
|
|
7275
7324
|
if (accessor !== null) {
|
|
@@ -7429,7 +7478,7 @@ var GLTFWriter = class {
|
|
|
7429
7478
|
} else {
|
|
7430
7479
|
cameraDef.perspective = {
|
|
7431
7480
|
aspectRatio: camera.aspect,
|
|
7432
|
-
yfov:
|
|
7481
|
+
yfov: import_three19.MathUtils.degToRad(camera.fov),
|
|
7433
7482
|
zfar: camera.far <= 0 ? 1e-3 : camera.far,
|
|
7434
7483
|
znear: camera.near < 0 ? 0 : camera.near
|
|
7435
7484
|
};
|
|
@@ -7457,8 +7506,8 @@ var GLTFWriter = class {
|
|
|
7457
7506
|
const samplers = [];
|
|
7458
7507
|
for (let i = 0; i < tracks.length; ++i) {
|
|
7459
7508
|
const track = tracks[i];
|
|
7460
|
-
const trackBinding =
|
|
7461
|
-
let trackNode =
|
|
7509
|
+
const trackBinding = import_three19.PropertyBinding.parseTrackName(track.name);
|
|
7510
|
+
let trackNode = import_three19.PropertyBinding.findNode(root, trackBinding.nodeName);
|
|
7462
7511
|
const trackProperty = PATH_PROPERTIES[trackBinding.propertyName];
|
|
7463
7512
|
if (trackBinding.objectName === "bones") {
|
|
7464
7513
|
if (trackNode.isSkinnedMesh === true) {
|
|
@@ -7480,14 +7529,14 @@ var GLTFWriter = class {
|
|
|
7480
7529
|
if (track.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline === true) {
|
|
7481
7530
|
interpolation = "CUBICSPLINE";
|
|
7482
7531
|
outputItemSize /= 3;
|
|
7483
|
-
} else if (track.getInterpolation() ===
|
|
7532
|
+
} else if (track.getInterpolation() === import_three19.InterpolateDiscrete) {
|
|
7484
7533
|
interpolation = "STEP";
|
|
7485
7534
|
} else {
|
|
7486
7535
|
interpolation = "LINEAR";
|
|
7487
7536
|
}
|
|
7488
7537
|
samplers.push({
|
|
7489
|
-
input: this.processAccessor(new
|
|
7490
|
-
output: this.processAccessor(new
|
|
7538
|
+
input: this.processAccessor(new import_three19.BufferAttribute(track.times, inputItemSize)),
|
|
7539
|
+
output: this.processAccessor(new import_three19.BufferAttribute(track.values, outputItemSize)),
|
|
7491
7540
|
interpolation
|
|
7492
7541
|
});
|
|
7493
7542
|
channels.push({
|
|
@@ -7519,7 +7568,7 @@ var GLTFWriter = class {
|
|
|
7519
7568
|
if (rootJoint === void 0) return null;
|
|
7520
7569
|
const joints = [];
|
|
7521
7570
|
const inverseBindMatrices = new Float32Array(skeleton.bones.length * 16);
|
|
7522
|
-
const temporaryBoneInverse = new
|
|
7571
|
+
const temporaryBoneInverse = new import_three19.Matrix4();
|
|
7523
7572
|
for (let i = 0; i < skeleton.bones.length; ++i) {
|
|
7524
7573
|
joints.push(nodeMap.get(skeleton.bones[i]));
|
|
7525
7574
|
temporaryBoneInverse.copy(skeleton.boneInverses[i]);
|
|
@@ -7527,7 +7576,7 @@ var GLTFWriter = class {
|
|
|
7527
7576
|
}
|
|
7528
7577
|
if (json.skins === void 0) json.skins = [];
|
|
7529
7578
|
json.skins.push({
|
|
7530
|
-
inverseBindMatrices: this.processAccessor(new
|
|
7579
|
+
inverseBindMatrices: this.processAccessor(new import_three19.BufferAttribute(inverseBindMatrices, 16)),
|
|
7531
7580
|
joints,
|
|
7532
7581
|
skeleton: nodeMap.get(rootJoint)
|
|
7533
7582
|
});
|
|
@@ -7623,7 +7672,7 @@ var GLTFWriter = class {
|
|
|
7623
7672
|
* @param {Array} objects List of objects to process
|
|
7624
7673
|
*/
|
|
7625
7674
|
processObjects(objects) {
|
|
7626
|
-
const scene = new
|
|
7675
|
+
const scene = new import_three19.Scene();
|
|
7627
7676
|
scene.name = "AuxScene";
|
|
7628
7677
|
for (let i = 0; i < objects.length; i++) {
|
|
7629
7678
|
scene.children.push(objects[i]);
|
|
@@ -7641,7 +7690,7 @@ var GLTFWriter = class {
|
|
|
7641
7690
|
});
|
|
7642
7691
|
const objectsWithoutScene = [];
|
|
7643
7692
|
for (let i = 0; i < input.length; i++) {
|
|
7644
|
-
if (input[i] instanceof
|
|
7693
|
+
if (input[i] instanceof import_three19.Scene) {
|
|
7645
7694
|
this.processScene(input[i]);
|
|
7646
7695
|
} else {
|
|
7647
7696
|
objectsWithoutScene.push(input[i]);
|
|
@@ -7985,10 +8034,10 @@ var GLTFMeshGpuInstancing = class {
|
|
|
7985
8034
|
const translationAttr = new Float32Array(mesh.count * 3);
|
|
7986
8035
|
const rotationAttr = new Float32Array(mesh.count * 4);
|
|
7987
8036
|
const scaleAttr = new Float32Array(mesh.count * 3);
|
|
7988
|
-
const matrix = new
|
|
7989
|
-
const position = new
|
|
7990
|
-
const quaternion = new
|
|
7991
|
-
const scale = new
|
|
8037
|
+
const matrix = new import_three19.Matrix4();
|
|
8038
|
+
const position = new import_three19.Vector3();
|
|
8039
|
+
const quaternion = new import_three19.Quaternion();
|
|
8040
|
+
const scale = new import_three19.Vector3();
|
|
7992
8041
|
for (let i = 0; i < mesh.count; i++) {
|
|
7993
8042
|
mesh.getMatrixAt(i, matrix);
|
|
7994
8043
|
matrix.decompose(position, quaternion, scale);
|
|
@@ -7997,9 +8046,9 @@ var GLTFMeshGpuInstancing = class {
|
|
|
7997
8046
|
scale.toArray(scaleAttr, i * 3);
|
|
7998
8047
|
}
|
|
7999
8048
|
const attributes = {
|
|
8000
|
-
TRANSLATION: writer.processAccessor(new
|
|
8001
|
-
ROTATION: writer.processAccessor(new
|
|
8002
|
-
SCALE: writer.processAccessor(new
|
|
8049
|
+
TRANSLATION: writer.processAccessor(new import_three19.BufferAttribute(translationAttr, 3)),
|
|
8050
|
+
ROTATION: writer.processAccessor(new import_three19.BufferAttribute(rotationAttr, 4)),
|
|
8051
|
+
SCALE: writer.processAccessor(new import_three19.BufferAttribute(scaleAttr, 3))
|
|
8003
8052
|
};
|
|
8004
8053
|
if (mesh.instanceColor)
|
|
8005
8054
|
attributes._COLOR_0 = writer.processAccessor(mesh.instanceColor);
|
|
@@ -8064,8 +8113,8 @@ GLTFExporter.Utils = {
|
|
|
8064
8113
|
const sourceTracks = clip.tracks;
|
|
8065
8114
|
for (let i = 0; i < sourceTracks.length; ++i) {
|
|
8066
8115
|
let sourceTrack = sourceTracks[i];
|
|
8067
|
-
const sourceTrackBinding =
|
|
8068
|
-
const sourceTrackNode =
|
|
8116
|
+
const sourceTrackBinding = import_three19.PropertyBinding.parseTrackName(sourceTrack.name);
|
|
8117
|
+
const sourceTrackNode = import_three19.PropertyBinding.findNode(root, sourceTrackBinding.nodeName);
|
|
8069
8118
|
if (sourceTrackBinding.propertyName !== "morphTargetInfluences" || sourceTrackBinding.propertyIndex === void 0) {
|
|
8070
8119
|
tracks.push(sourceTrack);
|
|
8071
8120
|
continue;
|
|
@@ -8076,7 +8125,7 @@ GLTFExporter.Utils = {
|
|
|
8076
8125
|
}
|
|
8077
8126
|
console.warn("THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead.");
|
|
8078
8127
|
sourceTrack = sourceTrack.clone();
|
|
8079
|
-
sourceTrack.setInterpolation(
|
|
8128
|
+
sourceTrack.setInterpolation(import_three19.InterpolateLinear);
|
|
8080
8129
|
}
|
|
8081
8130
|
const targetCount = sourceTrackNode.morphTargetInfluences.length;
|
|
8082
8131
|
const targetIndex = sourceTrackNode.morphTargetDictionary[sourceTrackBinding.propertyIndex];
|
|
@@ -8159,10 +8208,10 @@ var SceneExporter = class {
|
|
|
8159
8208
|
}
|
|
8160
8209
|
};
|
|
8161
8210
|
function localMatrix(object) {
|
|
8162
|
-
return object.matrixAutoUpdate ? new
|
|
8211
|
+
return object.matrixAutoUpdate ? new import_three20.Matrix4().compose(object.position, object.quaternion, object.scale) : object.matrix.clone();
|
|
8163
8212
|
}
|
|
8164
8213
|
function createSnapshot(root, gltf, bakeColors = false) {
|
|
8165
|
-
const scene = new
|
|
8214
|
+
const scene = new import_three20.Scene();
|
|
8166
8215
|
const geometries = [];
|
|
8167
8216
|
const materials = [];
|
|
8168
8217
|
const textures = [];
|
|
@@ -8180,7 +8229,7 @@ function createSnapshot(root, gltf, bakeColors = false) {
|
|
|
8180
8229
|
if (!uniforms.map?.value?.isTexture || !uniforms.SHADE || !uniforms.BRIGHTNESS || !uniforms.EMISSIVE) {
|
|
8181
8230
|
throw new MineRenderError("glTF export does not support this custom ShaderMaterial");
|
|
8182
8231
|
}
|
|
8183
|
-
material = new
|
|
8232
|
+
material = new import_three20.MeshBasicMaterial({
|
|
8184
8233
|
map: uniforms.map.value,
|
|
8185
8234
|
vertexColors: source.vertexColors,
|
|
8186
8235
|
transparent: source.transparent,
|
|
@@ -8190,7 +8239,7 @@ function createSnapshot(root, gltf, bakeColors = false) {
|
|
|
8190
8239
|
});
|
|
8191
8240
|
material.name = source.name;
|
|
8192
8241
|
} else if (shader.isShaderMaterial) {
|
|
8193
|
-
material = new
|
|
8242
|
+
material = new import_three20.MeshBasicMaterial({ vertexColors: source.vertexColors });
|
|
8194
8243
|
material.name = source.name;
|
|
8195
8244
|
} else {
|
|
8196
8245
|
const copySource = Object.create(source);
|
|
@@ -8244,11 +8293,11 @@ function createSnapshot(root, gltf, bakeColors = false) {
|
|
|
8244
8293
|
const material = copyMaterial(sourceMaterial, geometry);
|
|
8245
8294
|
if (!sourceMaterial.vertexColors) geometry.deleteAttribute("color");
|
|
8246
8295
|
if (bakeColors || instanceColor) {
|
|
8247
|
-
const tint = (material.color ?? new
|
|
8296
|
+
const tint = (material.color ?? new import_three20.Color()).clone();
|
|
8248
8297
|
if (instanceColor) tint.multiply(instanceColor);
|
|
8249
8298
|
if (bakeColors) {
|
|
8250
8299
|
const original = geometry.getAttribute("color");
|
|
8251
|
-
const colors = new
|
|
8300
|
+
const colors = new import_three20.Float32BufferAttribute(new Float32Array(geometry.getAttribute("position").count * 3), 3);
|
|
8252
8301
|
for (let i = 0; i < colors.count; i++) {
|
|
8253
8302
|
colors.setXYZ(i, (original?.getX(i) ?? 1) * tint.r, (original?.getY(i) ?? 1) * tint.g, (original?.getZ(i) ?? 1) * tint.b);
|
|
8254
8303
|
}
|
|
@@ -8257,7 +8306,7 @@ function createSnapshot(root, gltf, bakeColors = false) {
|
|
|
8257
8306
|
material.color.copy(tint);
|
|
8258
8307
|
}
|
|
8259
8308
|
}
|
|
8260
|
-
const copy = new
|
|
8309
|
+
const copy = new import_three20.Mesh(geometry, material);
|
|
8261
8310
|
copy.name = mesh.name;
|
|
8262
8311
|
copy.renderOrder = mesh.renderOrder;
|
|
8263
8312
|
scene.add(copy);
|
|
@@ -8271,9 +8320,9 @@ function createSnapshot(root, gltf, bakeColors = false) {
|
|
|
8271
8320
|
const instanced = mesh;
|
|
8272
8321
|
if (instanced.isInstancedMesh) {
|
|
8273
8322
|
for (let i = 0; i < instanced.count; i++) {
|
|
8274
|
-
const matrix = new
|
|
8323
|
+
const matrix = new import_three20.Matrix4();
|
|
8275
8324
|
instanced.getMatrixAt(i, matrix);
|
|
8276
|
-
const color = instanced.instanceColor ? new
|
|
8325
|
+
const color = instanced.instanceColor ? new import_three20.Color().fromBufferAttribute(instanced.instanceColor, i) : void 0;
|
|
8277
8326
|
addMesh(mesh, world.clone().multiply(matrix), color);
|
|
8278
8327
|
}
|
|
8279
8328
|
} else {
|
|
@@ -8285,7 +8334,7 @@ function createSnapshot(root, gltf, bakeColors = false) {
|
|
|
8285
8334
|
try {
|
|
8286
8335
|
const ancestors = [];
|
|
8287
8336
|
for (let parent = root.parent; parent; parent = parent.parent) ancestors.unshift(parent);
|
|
8288
|
-
const world = new
|
|
8337
|
+
const world = new import_three20.Matrix4();
|
|
8289
8338
|
for (const ancestor of ancestors) {
|
|
8290
8339
|
if (!ancestor.visible) return { scene, dispose };
|
|
8291
8340
|
world.multiply(localMatrix(ancestor));
|
|
@@ -8299,7 +8348,7 @@ function createSnapshot(root, gltf, bakeColors = false) {
|
|
|
8299
8348
|
}
|
|
8300
8349
|
function selectAlphaMode(material, geometry) {
|
|
8301
8350
|
const texture = material.map;
|
|
8302
|
-
if (material.type !== "MeshBasicMaterial" || !material.transparent || !material.depthWrite || material.opacity !== 1 || material.alphaMap || !texture?.isDataTexture || texture.format !==
|
|
8351
|
+
if (material.type !== "MeshBasicMaterial" || !material.transparent || !material.depthWrite || material.opacity !== 1 || material.alphaMap || !texture?.isDataTexture || texture.format !== import_three20.RGBAFormat || texture.type !== import_three20.UnsignedByteType || texture.wrapS !== import_three20.ClampToEdgeWrapping || texture.wrapT !== import_three20.ClampToEdgeWrapping || texture.magFilter !== import_three20.NearestFilter || texture.minFilter !== import_three20.NearestFilter || texture.anisotropy > 1 || texture.offset.x !== 0 || texture.offset.y !== 0 || texture.repeat.x !== 1 || texture.repeat.y !== 1 || texture.rotation !== 0 || !texture.matrixAutoUpdate && !texture.matrix.elements.every((value, i) => value === (i % 4 === 0 ? 1 : 0))) return;
|
|
8303
8352
|
const uv = geometry.getAttribute(texture.channel === 0 ? "uv" : `uv${texture.channel}`);
|
|
8304
8353
|
const colors = geometry.getAttribute("color");
|
|
8305
8354
|
if (!uv || material.vertexColors && colors?.itemSize === 4) return;
|
|
@@ -8336,7 +8385,7 @@ function selectAlphaMode(material, geometry) {
|
|
|
8336
8385
|
}
|
|
8337
8386
|
function copyDataTexture(source) {
|
|
8338
8387
|
const image = source.image;
|
|
8339
|
-
if (source.format !==
|
|
8388
|
+
if (source.format !== import_three20.RGBAFormat || source.type !== import_three20.UnsignedByteType) {
|
|
8340
8389
|
throw new MineRenderError("glTF export requires RGBA unsigned-byte data textures");
|
|
8341
8390
|
}
|
|
8342
8391
|
const canvas = createCanvas(image.width, image.height);
|
|
@@ -8347,8 +8396,8 @@ function copyDataTexture(source) {
|
|
|
8347
8396
|
context.putImageData(pixels, 0, 0);
|
|
8348
8397
|
const copySource = Object.create(source);
|
|
8349
8398
|
copySource.userData = {};
|
|
8350
|
-
copySource.source = new
|
|
8351
|
-
return new
|
|
8399
|
+
copySource.source = new import_three20.Source(canvas);
|
|
8400
|
+
return new import_three20.Texture().copy(copySource);
|
|
8352
8401
|
}
|
|
8353
8402
|
|
|
8354
8403
|
// src/gui/GuiHelper.ts
|
|
@@ -8418,7 +8467,7 @@ var GuiHelper = class {
|
|
|
8418
8467
|
};
|
|
8419
8468
|
|
|
8420
8469
|
// src/gui/scene/GuiObject.ts
|
|
8421
|
-
var
|
|
8470
|
+
var import_three25 = require("three");
|
|
8422
8471
|
init_AssetKey();
|
|
8423
8472
|
init_ModelTextures();
|
|
8424
8473
|
init_Models();
|
|
@@ -8434,7 +8483,7 @@ var GuiObject = class extends SceneObject {
|
|
|
8434
8483
|
this.textureLayers = textureLayers;
|
|
8435
8484
|
this.isGuiObject = true;
|
|
8436
8485
|
/** Local bounds in GUI pixels, with y growing down from the origin. */
|
|
8437
|
-
this.bounds = new
|
|
8486
|
+
this.bounds = new import_three25.Box2();
|
|
8438
8487
|
this.geometries = /* @__PURE__ */ new Set();
|
|
8439
8488
|
this.ownedMaterials = /* @__PURE__ */ new Set();
|
|
8440
8489
|
this.initialized = false;
|
|
@@ -8452,17 +8501,17 @@ var GuiObject = class extends SceneObject {
|
|
|
8452
8501
|
item.scale.set(width2 / 16, height2 / 16, width2 / 16);
|
|
8453
8502
|
item.updateWorldMatrix(true, true);
|
|
8454
8503
|
const inverse = this.matrixWorld.clone().invert();
|
|
8455
|
-
const bounds = new
|
|
8504
|
+
const bounds = new import_three25.Box3();
|
|
8456
8505
|
item.iterateAllMeshes((mesh2) => {
|
|
8457
8506
|
mesh2.geometry.computeBoundingBox();
|
|
8458
|
-
bounds.union(mesh2.geometry.boundingBox.clone().applyMatrix4(new
|
|
8507
|
+
bounds.union(mesh2.geometry.boundingBox.clone().applyMatrix4(new import_three25.Matrix4().multiplyMatrices(inverse, mesh2.matrixWorld)));
|
|
8459
8508
|
});
|
|
8460
8509
|
item.position.z = depth - bounds.min.z;
|
|
8461
8510
|
depth += bounds.max.z - bounds.min.z + 0.01;
|
|
8462
|
-
this.bounds.expandByPoint(new
|
|
8463
|
-
this.bounds.expandByPoint(new
|
|
8464
|
-
this.bounds.expandByPoint(new
|
|
8465
|
-
this.bounds.expandByPoint(new
|
|
8511
|
+
this.bounds.expandByPoint(new import_three25.Vector2(x, y));
|
|
8512
|
+
this.bounds.expandByPoint(new import_three25.Vector2(x + width2, y + height2));
|
|
8513
|
+
this.bounds.expandByPoint(new import_three25.Vector2(bounds.min.x, -bounds.max.y));
|
|
8514
|
+
this.bounds.expandByPoint(new import_three25.Vector2(bounds.max.x, -bounds.min.y));
|
|
8466
8515
|
continue;
|
|
8467
8516
|
}
|
|
8468
8517
|
const key = typeof layer.texture === "string" ? AssetKey.parse("textures", layer.texture) : layer.texture;
|
|
@@ -8470,7 +8519,7 @@ var GuiObject = class extends SceneObject {
|
|
|
8470
8519
|
const image = material.map.image;
|
|
8471
8520
|
const [cropX, cropY, cropWidth, cropHeight] = layer.crop ?? [0, 0, image.width, image.height];
|
|
8472
8521
|
const [width, height] = layer.size ?? [cropWidth, cropHeight];
|
|
8473
|
-
const geometry = new
|
|
8522
|
+
const geometry = new import_three25.PlaneGeometry(width, height);
|
|
8474
8523
|
this.geometries.add(geometry);
|
|
8475
8524
|
const uv = geometry.getAttribute("uv");
|
|
8476
8525
|
for (let i = 0; i < uv.count; i++) {
|
|
@@ -8480,13 +8529,13 @@ var GuiObject = class extends SceneObject {
|
|
|
8480
8529
|
1 - (cropY + (1 - uv.getY(i)) * cropHeight) / image.height
|
|
8481
8530
|
);
|
|
8482
8531
|
}
|
|
8483
|
-
const mesh = new
|
|
8532
|
+
const mesh = new import_three25.Mesh(geometry, material);
|
|
8484
8533
|
mesh.name = `mesh:${layer.name ?? index}`;
|
|
8485
8534
|
mesh.position.set(x + width / 2, -y - height / 2, depth);
|
|
8486
8535
|
mesh.renderOrder = index;
|
|
8487
8536
|
this.add(mesh);
|
|
8488
|
-
this.bounds.expandByPoint(new
|
|
8489
|
-
this.bounds.expandByPoint(new
|
|
8537
|
+
this.bounds.expandByPoint(new import_three25.Vector2(x, y));
|
|
8538
|
+
this.bounds.expandByPoint(new import_three25.Vector2(x + width, y + height));
|
|
8490
8539
|
depth += 0.01;
|
|
8491
8540
|
}
|
|
8492
8541
|
for (const child of this.children) child.position.z -= depth - 0.01;
|
|
@@ -8561,7 +8610,7 @@ function isGuiObject(obj) {
|
|
|
8561
8610
|
init_image();
|
|
8562
8611
|
|
|
8563
8612
|
// src/inspector/SceneInspector.ts
|
|
8564
|
-
var
|
|
8613
|
+
var import_three26 = require("three");
|
|
8565
8614
|
init_SceneObject();
|
|
8566
8615
|
init_util();
|
|
8567
8616
|
init_log();
|
|
@@ -8571,11 +8620,11 @@ var help = "<span>Ctrl/Cmd+Click to Select<br/></span><br/>";
|
|
|
8571
8620
|
var SceneInspector = class {
|
|
8572
8621
|
constructor(renderer) {
|
|
8573
8622
|
this.renderer = renderer;
|
|
8574
|
-
this.mouse = new
|
|
8623
|
+
this.mouse = new import_three26.Vector2();
|
|
8575
8624
|
this.listeners = new AbortController();
|
|
8576
8625
|
this.objectInfoContainer = document.createElement("div");
|
|
8577
8626
|
this.objectControlsContainer = document.createElement("div");
|
|
8578
|
-
this.raycaster = new
|
|
8627
|
+
this.raycaster = new import_three26.Raycaster();
|
|
8579
8628
|
this.init();
|
|
8580
8629
|
}
|
|
8581
8630
|
init() {
|
|
@@ -8978,7 +9027,7 @@ init_ModelMerger();
|
|
|
8978
9027
|
init_SpecialItems();
|
|
8979
9028
|
|
|
8980
9029
|
// src/model/block/BlockStateResolver.ts
|
|
8981
|
-
var
|
|
9030
|
+
var import_three28 = require("three");
|
|
8982
9031
|
init_BlockStates();
|
|
8983
9032
|
init_MineRenderError();
|
|
8984
9033
|
init_util();
|
|
@@ -9056,7 +9105,7 @@ var BlockStateResolver = class {
|
|
|
9056
9105
|
return variants[variants.length - 1];
|
|
9057
9106
|
}
|
|
9058
9107
|
static rotation(variant) {
|
|
9059
|
-
const rotation = new
|
|
9108
|
+
const rotation = new import_three28.Euler();
|
|
9060
9109
|
if (typeof variant.x !== "undefined") {
|
|
9061
9110
|
rotation.x = toRadians(clampRotationDegrees(variant.x));
|
|
9062
9111
|
}
|
|
@@ -9148,7 +9197,7 @@ init_SceneObject();
|
|
|
9148
9197
|
init_ModelObject();
|
|
9149
9198
|
init_Models();
|
|
9150
9199
|
var import_ts_deepmerge6 = __toESM(require_dist());
|
|
9151
|
-
var
|
|
9200
|
+
var import_three31 = require("three");
|
|
9152
9201
|
init_MineRenderError();
|
|
9153
9202
|
init_InstanceReference();
|
|
9154
9203
|
init_AssetKey();
|
|
@@ -9170,7 +9219,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
9170
9219
|
this._models = [];
|
|
9171
9220
|
this._cullMask = 0;
|
|
9172
9221
|
this._entities = [];
|
|
9173
|
-
this._entityPlacement = new
|
|
9222
|
+
this._entityPlacement = new import_three31.Matrix4();
|
|
9174
9223
|
this._entityGeneration = 0;
|
|
9175
9224
|
this.options = (0, import_ts_deepmerge6.default)({}, _BlockObject.DEFAULT_OPTIONS, options ?? {});
|
|
9176
9225
|
}
|
|
@@ -9250,7 +9299,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
9250
9299
|
return true;
|
|
9251
9300
|
}
|
|
9252
9301
|
placeEntities() {
|
|
9253
|
-
const matrix = new
|
|
9302
|
+
const matrix = new import_three31.Matrix4().makeTranslation(this.position.x - 8, this.position.y - 8, this.position.z - 8).multiply(this._entityPlacement);
|
|
9254
9303
|
for (const entity of this._entities) {
|
|
9255
9304
|
matrix.decompose(entity.position, entity.quaternion, entity.scale);
|
|
9256
9305
|
}
|
|
@@ -9269,12 +9318,12 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
9269
9318
|
getModelCullMask(model, worldMask) {
|
|
9270
9319
|
const object = isInstanceReference(model) ? model.instanceable : model;
|
|
9271
9320
|
if (object.options.displayPosition) return 0;
|
|
9272
|
-
const position = new
|
|
9273
|
-
const rotation = new
|
|
9274
|
-
const scale = new
|
|
9321
|
+
const position = new import_three31.Vector3();
|
|
9322
|
+
const rotation = new import_three31.Quaternion();
|
|
9323
|
+
const scale = new import_three31.Vector3();
|
|
9275
9324
|
this.getModelMatrix(model).decompose(position, rotation, scale);
|
|
9276
|
-
if (position.distanceToSquared(this.position) > 1e-10 || scale.distanceToSquared(new
|
|
9277
|
-
return ModelCulling.toLocalMask(worldMask, new
|
|
9325
|
+
if (position.distanceToSquared(this.position) > 1e-10 || scale.distanceToSquared(new import_three31.Vector3(1, 1, 1)) > 1e-10) return 0;
|
|
9326
|
+
return ModelCulling.toLocalMask(worldMask, new import_three31.Euler().setFromQuaternion(rotation));
|
|
9278
9327
|
}
|
|
9279
9328
|
async setCullMask(worldMask) {
|
|
9280
9329
|
worldMask &= 63;
|
|
@@ -9336,7 +9385,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
9336
9385
|
() => new FluidModelObject2(kind, surface.sample, this.blockState.key, this.options)
|
|
9337
9386
|
);
|
|
9338
9387
|
const previous = this._fluidModel;
|
|
9339
|
-
const matrix = previous ? this.getModelMatrix(previous) : new
|
|
9388
|
+
const matrix = previous ? this.getModelMatrix(previous) : new import_three31.Matrix4().makeTranslation(...this.position.toArray());
|
|
9340
9389
|
if (isInstanceReference(replacement)) replacement.setMatrix(matrix);
|
|
9341
9390
|
else matrix.decompose(replacement.position, replacement.quaternion, replacement.scale);
|
|
9342
9391
|
this._models = this._models.filter((model) => model !== previous);
|
|
@@ -9474,7 +9523,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
9474
9523
|
setPositionRotationScaleAt(index, position, rotation, scale) {
|
|
9475
9524
|
super.setPositionRotationScaleAt(index, position, rotation, scale);
|
|
9476
9525
|
}
|
|
9477
|
-
getMatrixAt(index, matrix = new
|
|
9526
|
+
getMatrixAt(index, matrix = new import_three31.Matrix4()) {
|
|
9478
9527
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
9479
9528
|
const child = this._models[0];
|
|
9480
9529
|
if (child && isModelObject(child)) {
|
|
@@ -11345,7 +11394,7 @@ init_ModelObject();
|
|
|
11345
11394
|
init_nbt();
|
|
11346
11395
|
|
|
11347
11396
|
// src/renderer/MineRenderScene.ts
|
|
11348
|
-
var
|
|
11397
|
+
var import_three33 = require("three");
|
|
11349
11398
|
init_SceneObject();
|
|
11350
11399
|
var import_ts_deepmerge8 = __toESM(require_dist());
|
|
11351
11400
|
init_ModelObject();
|
|
@@ -12078,7 +12127,7 @@ var import_ts_deepmerge7 = __toESM(require_dist());
|
|
|
12078
12127
|
init_util();
|
|
12079
12128
|
|
|
12080
12129
|
// src/skin/SkinTextures.ts
|
|
12081
|
-
var
|
|
12130
|
+
var import_three32 = require("three");
|
|
12082
12131
|
init_Caching();
|
|
12083
12132
|
init_CacheKey();
|
|
12084
12133
|
init_MineRenderError();
|
|
@@ -12162,11 +12211,11 @@ var SkinTextures = class {
|
|
|
12162
12211
|
});
|
|
12163
12212
|
}
|
|
12164
12213
|
static createMaterial(pixels, width, height, transparent = true) {
|
|
12165
|
-
const texture = Textures.initTextureProps(new
|
|
12166
|
-
texture.colorSpace =
|
|
12214
|
+
const texture = Textures.initTextureProps(new import_three32.DataTexture(pixels, width, height));
|
|
12215
|
+
texture.colorSpace = import_three32.SRGBColorSpace;
|
|
12167
12216
|
texture.flipY = true;
|
|
12168
12217
|
texture.needsUpdate = true;
|
|
12169
|
-
return new
|
|
12218
|
+
return new import_three32.MeshBasicMaterial({ map: texture, transparent, side: transparent ? import_three32.DoubleSide : import_three32.FrontSide, alphaTest: transparent ? 0.1 : 0 });
|
|
12170
12219
|
}
|
|
12171
12220
|
static isSlim(image, scale) {
|
|
12172
12221
|
for (const [x, y] of [[46, 52], [54, 20]]) {
|
|
@@ -12396,7 +12445,7 @@ var SkinObject = class extends SceneObject {
|
|
|
12396
12445
|
// src/renderer/MineRenderScene.ts
|
|
12397
12446
|
init_EntityObject();
|
|
12398
12447
|
init_ItemTints();
|
|
12399
|
-
var _MineRenderScene = class _MineRenderScene extends
|
|
12448
|
+
var _MineRenderScene = class _MineRenderScene extends import_three33.Scene {
|
|
12400
12449
|
constructor(options) {
|
|
12401
12450
|
super();
|
|
12402
12451
|
this.isMineRenderScene = true;
|
|
@@ -12524,7 +12573,7 @@ function isMineRenderScene(obj) {
|
|
|
12524
12573
|
}
|
|
12525
12574
|
|
|
12526
12575
|
// src/renderer/Renderer.ts
|
|
12527
|
-
var
|
|
12576
|
+
var import_three35 = require("three");
|
|
12528
12577
|
var import_ts_deepmerge9 = __toESM(require_dist());
|
|
12529
12578
|
var import_stats = __toESM(require("stats.js"));
|
|
12530
12579
|
var import_postprocessing = require("postprocessing");
|
|
@@ -12533,11 +12582,11 @@ init_Model();
|
|
|
12533
12582
|
init_three();
|
|
12534
12583
|
|
|
12535
12584
|
// src/three/OrbitControls.js
|
|
12536
|
-
var
|
|
12585
|
+
var import_three34 = require("three");
|
|
12537
12586
|
var _changeEvent = { type: "change" };
|
|
12538
12587
|
var _startEvent = { type: "start" };
|
|
12539
12588
|
var _endEvent = { type: "end" };
|
|
12540
|
-
var OrbitControls = class extends
|
|
12589
|
+
var OrbitControls = class extends import_three34.EventDispatcher {
|
|
12541
12590
|
constructor(object, domElement) {
|
|
12542
12591
|
super();
|
|
12543
12592
|
if (domElement === void 0) console.warn('THREE.OrbitControls: The second parameter "domElement" is now mandatory.');
|
|
@@ -12546,7 +12595,7 @@ var OrbitControls = class extends import_three33.EventDispatcher {
|
|
|
12546
12595
|
this.domElement = domElement;
|
|
12547
12596
|
this.domElement.style.touchAction = "none";
|
|
12548
12597
|
this.enabled = true;
|
|
12549
|
-
this.target = new
|
|
12598
|
+
this.target = new import_three34.Vector3();
|
|
12550
12599
|
this.minDistance = 0;
|
|
12551
12600
|
this.maxDistance = Infinity;
|
|
12552
12601
|
this.minZoom = 0;
|
|
@@ -12568,8 +12617,8 @@ var OrbitControls = class extends import_three33.EventDispatcher {
|
|
|
12568
12617
|
this.autoRotate = false;
|
|
12569
12618
|
this.autoRotateSpeed = 2;
|
|
12570
12619
|
this.keys = { LEFT: "ArrowLeft", UP: "ArrowUp", RIGHT: "ArrowRight", BOTTOM: "ArrowDown" };
|
|
12571
|
-
this.mouseButtons = { LEFT:
|
|
12572
|
-
this.touches = { ONE:
|
|
12620
|
+
this.mouseButtons = { LEFT: import_three34.MOUSE.ROTATE, MIDDLE: import_three34.MOUSE.DOLLY, RIGHT: import_three34.MOUSE.PAN };
|
|
12621
|
+
this.touches = { ONE: import_three34.TOUCH.ROTATE, TWO: import_three34.TOUCH.DOLLY_PAN };
|
|
12573
12622
|
this.target0 = this.target.clone();
|
|
12574
12623
|
this.position0 = this.object.position.clone();
|
|
12575
12624
|
this.zoom0 = this.object.zoom;
|
|
@@ -12598,11 +12647,11 @@ var OrbitControls = class extends import_three33.EventDispatcher {
|
|
|
12598
12647
|
state = STATE.NONE;
|
|
12599
12648
|
};
|
|
12600
12649
|
this.update = function() {
|
|
12601
|
-
const offset = new
|
|
12602
|
-
const quat = new
|
|
12650
|
+
const offset = new import_three34.Vector3();
|
|
12651
|
+
const quat = new import_three34.Quaternion().setFromUnitVectors(object.up, new import_three34.Vector3(0, 1, 0));
|
|
12603
12652
|
const quatInverse = quat.clone().invert();
|
|
12604
|
-
const lastPosition = new
|
|
12605
|
-
const lastQuaternion = new
|
|
12653
|
+
const lastPosition = new import_three34.Vector3();
|
|
12654
|
+
const lastQuaternion = new import_three34.Quaternion();
|
|
12606
12655
|
const twoPI = 2 * Math.PI;
|
|
12607
12656
|
return function update() {
|
|
12608
12657
|
const position = scope.object.position;
|
|
@@ -12688,20 +12737,20 @@ var OrbitControls = class extends import_three33.EventDispatcher {
|
|
|
12688
12737
|
};
|
|
12689
12738
|
let state = STATE.NONE;
|
|
12690
12739
|
const EPS = 1e-6;
|
|
12691
|
-
const spherical = new
|
|
12692
|
-
const sphericalDelta = new
|
|
12740
|
+
const spherical = new import_three34.Spherical();
|
|
12741
|
+
const sphericalDelta = new import_three34.Spherical();
|
|
12693
12742
|
let scale = 1;
|
|
12694
|
-
const panOffset = new
|
|
12743
|
+
const panOffset = new import_three34.Vector3();
|
|
12695
12744
|
let zoomChanged = false;
|
|
12696
|
-
const rotateStart = new
|
|
12697
|
-
const rotateEnd = new
|
|
12698
|
-
const rotateDelta = new
|
|
12699
|
-
const panStart = new
|
|
12700
|
-
const panEnd = new
|
|
12701
|
-
const panDelta = new
|
|
12702
|
-
const dollyStart = new
|
|
12703
|
-
const dollyEnd = new
|
|
12704
|
-
const dollyDelta = new
|
|
12745
|
+
const rotateStart = new import_three34.Vector2();
|
|
12746
|
+
const rotateEnd = new import_three34.Vector2();
|
|
12747
|
+
const rotateDelta = new import_three34.Vector2();
|
|
12748
|
+
const panStart = new import_three34.Vector2();
|
|
12749
|
+
const panEnd = new import_three34.Vector2();
|
|
12750
|
+
const panDelta = new import_three34.Vector2();
|
|
12751
|
+
const dollyStart = new import_three34.Vector2();
|
|
12752
|
+
const dollyEnd = new import_three34.Vector2();
|
|
12753
|
+
const dollyDelta = new import_three34.Vector2();
|
|
12705
12754
|
const pointers = [];
|
|
12706
12755
|
const pointerPositions = {};
|
|
12707
12756
|
function getAutoRotationAngle() {
|
|
@@ -12717,7 +12766,7 @@ var OrbitControls = class extends import_three33.EventDispatcher {
|
|
|
12717
12766
|
sphericalDelta.phi -= angle;
|
|
12718
12767
|
}
|
|
12719
12768
|
const panLeft = function() {
|
|
12720
|
-
const v = new
|
|
12769
|
+
const v = new import_three34.Vector3();
|
|
12721
12770
|
return function panLeft2(distance, objectMatrix) {
|
|
12722
12771
|
v.setFromMatrixColumn(objectMatrix, 0);
|
|
12723
12772
|
v.multiplyScalar(-distance);
|
|
@@ -12725,7 +12774,7 @@ var OrbitControls = class extends import_three33.EventDispatcher {
|
|
|
12725
12774
|
};
|
|
12726
12775
|
}();
|
|
12727
12776
|
const panUp = function() {
|
|
12728
|
-
const v = new
|
|
12777
|
+
const v = new import_three34.Vector3();
|
|
12729
12778
|
return function panUp2(distance, objectMatrix) {
|
|
12730
12779
|
if (scope.screenSpacePanning === true) {
|
|
12731
12780
|
v.setFromMatrixColumn(objectMatrix, 1);
|
|
@@ -12738,7 +12787,7 @@ var OrbitControls = class extends import_three33.EventDispatcher {
|
|
|
12738
12787
|
};
|
|
12739
12788
|
}();
|
|
12740
12789
|
const pan = function() {
|
|
12741
|
-
const offset = new
|
|
12790
|
+
const offset = new import_three34.Vector3();
|
|
12742
12791
|
return function pan2(deltaX, deltaY) {
|
|
12743
12792
|
const element = scope.domElement;
|
|
12744
12793
|
if (scope.object.isPerspectiveCamera) {
|
|
@@ -12987,12 +13036,12 @@ var OrbitControls = class extends import_three33.EventDispatcher {
|
|
|
12987
13036
|
mouseAction = -1;
|
|
12988
13037
|
}
|
|
12989
13038
|
switch (mouseAction) {
|
|
12990
|
-
case
|
|
13039
|
+
case import_three34.MOUSE.DOLLY:
|
|
12991
13040
|
if (scope.enableZoom === false) return;
|
|
12992
13041
|
handleMouseDownDolly(event);
|
|
12993
13042
|
state = STATE.DOLLY;
|
|
12994
13043
|
break;
|
|
12995
|
-
case
|
|
13044
|
+
case import_three34.MOUSE.ROTATE:
|
|
12996
13045
|
if (event.ctrlKey || event.metaKey || event.shiftKey) {
|
|
12997
13046
|
if (scope.enablePan === false) return;
|
|
12998
13047
|
handleMouseDownPan(event);
|
|
@@ -13003,7 +13052,7 @@ var OrbitControls = class extends import_three33.EventDispatcher {
|
|
|
13003
13052
|
state = STATE.ROTATE;
|
|
13004
13053
|
}
|
|
13005
13054
|
break;
|
|
13006
|
-
case
|
|
13055
|
+
case import_three34.MOUSE.PAN:
|
|
13007
13056
|
if (event.ctrlKey || event.metaKey || event.shiftKey) {
|
|
13008
13057
|
if (scope.enableRotate === false) return;
|
|
13009
13058
|
handleMouseDownRotate(event);
|
|
@@ -13059,12 +13108,12 @@ var OrbitControls = class extends import_three33.EventDispatcher {
|
|
|
13059
13108
|
switch (pointers.length) {
|
|
13060
13109
|
case 1:
|
|
13061
13110
|
switch (scope.touches.ONE) {
|
|
13062
|
-
case
|
|
13111
|
+
case import_three34.TOUCH.ROTATE:
|
|
13063
13112
|
if (scope.enableRotate === false) return;
|
|
13064
13113
|
handleTouchStartRotate();
|
|
13065
13114
|
state = STATE.TOUCH_ROTATE;
|
|
13066
13115
|
break;
|
|
13067
|
-
case
|
|
13116
|
+
case import_three34.TOUCH.PAN:
|
|
13068
13117
|
if (scope.enablePan === false) return;
|
|
13069
13118
|
handleTouchStartPan();
|
|
13070
13119
|
state = STATE.TOUCH_PAN;
|
|
@@ -13075,12 +13124,12 @@ var OrbitControls = class extends import_three33.EventDispatcher {
|
|
|
13075
13124
|
break;
|
|
13076
13125
|
case 2:
|
|
13077
13126
|
switch (scope.touches.TWO) {
|
|
13078
|
-
case
|
|
13127
|
+
case import_three34.TOUCH.DOLLY_PAN:
|
|
13079
13128
|
if (scope.enableZoom === false && scope.enablePan === false) return;
|
|
13080
13129
|
handleTouchStartDollyPan();
|
|
13081
13130
|
state = STATE.TOUCH_DOLLY_PAN;
|
|
13082
13131
|
break;
|
|
13083
|
-
case
|
|
13132
|
+
case import_three34.TOUCH.DOLLY_ROTATE:
|
|
13084
13133
|
if (scope.enableZoom === false && scope.enableRotate === false) return;
|
|
13085
13134
|
handleTouchStartDollyRotate();
|
|
13086
13135
|
state = STATE.TOUCH_DOLLY_ROTATE;
|
|
@@ -13147,7 +13196,7 @@ var OrbitControls = class extends import_three33.EventDispatcher {
|
|
|
13147
13196
|
function trackPointer(event) {
|
|
13148
13197
|
let position = pointerPositions[event.pointerId];
|
|
13149
13198
|
if (position === void 0) {
|
|
13150
|
-
position = new
|
|
13199
|
+
position = new import_three34.Vector2();
|
|
13151
13200
|
pointerPositions[event.pointerId] = position;
|
|
13152
13201
|
}
|
|
13153
13202
|
position.set(event.pageX, event.pageY);
|
|
@@ -13167,10 +13216,10 @@ var MapControls = class extends OrbitControls {
|
|
|
13167
13216
|
constructor(object, domElement) {
|
|
13168
13217
|
super(object, domElement);
|
|
13169
13218
|
this.screenSpacePanning = false;
|
|
13170
|
-
this.mouseButtons.LEFT =
|
|
13171
|
-
this.mouseButtons.RIGHT =
|
|
13172
|
-
this.touches.ONE =
|
|
13173
|
-
this.touches.TWO =
|
|
13219
|
+
this.mouseButtons.LEFT = import_three34.MOUSE.PAN;
|
|
13220
|
+
this.mouseButtons.RIGHT = import_three34.MOUSE.ROTATE;
|
|
13221
|
+
this.touches.ONE = import_three34.TOUCH.PAN;
|
|
13222
|
+
this.touches.TWO = import_three34.TOUCH.DOLLY_ROTATE;
|
|
13174
13223
|
}
|
|
13175
13224
|
};
|
|
13176
13225
|
|
|
@@ -13221,14 +13270,14 @@ var _Renderer = class _Renderer {
|
|
|
13221
13270
|
switch (this.options.camera.type) {
|
|
13222
13271
|
case "perspective":
|
|
13223
13272
|
default:
|
|
13224
|
-
return new
|
|
13273
|
+
return new import_three35.PerspectiveCamera(
|
|
13225
13274
|
this.options.camera.perspective.fov,
|
|
13226
13275
|
this.options.camera.perspective.aspect ?? this.viewWidth / this.viewHeight,
|
|
13227
13276
|
this.options.camera.near,
|
|
13228
13277
|
this.options.camera.far
|
|
13229
13278
|
);
|
|
13230
13279
|
case "orthographic":
|
|
13231
|
-
return new
|
|
13280
|
+
return new import_three35.OrthographicCamera(
|
|
13232
13281
|
this.options.camera.orthographic.left ?? this.viewWidth / -2,
|
|
13233
13282
|
this.options.camera.orthographic.right ?? this.viewWidth / 2,
|
|
13234
13283
|
this.options.camera.orthographic.top ?? this.viewHeight / 2,
|
|
@@ -13239,7 +13288,7 @@ var _Renderer = class _Renderer {
|
|
|
13239
13288
|
}
|
|
13240
13289
|
}
|
|
13241
13290
|
createRenderer() {
|
|
13242
|
-
const renderer = new
|
|
13291
|
+
const renderer = new import_three35.WebGLRenderer({
|
|
13243
13292
|
antialias: this.options.render.antialias,
|
|
13244
13293
|
alpha: true,
|
|
13245
13294
|
powerPreference: "high-performance",
|
|
@@ -13247,8 +13296,8 @@ var _Renderer = class _Renderer {
|
|
|
13247
13296
|
});
|
|
13248
13297
|
renderer.setClearColor(0, 0);
|
|
13249
13298
|
renderer.shadowMap.enabled = true;
|
|
13250
|
-
renderer.shadowMap.type =
|
|
13251
|
-
renderer.outputColorSpace =
|
|
13299
|
+
renderer.shadowMap.type = import_three35.PCFSoftShadowMap;
|
|
13300
|
+
renderer.outputColorSpace = import_three35.SRGBColorSpace;
|
|
13252
13301
|
renderer.setPixelRatio(this.options.render.pixelRatio ?? 1);
|
|
13253
13302
|
renderer.setSize(this.viewWidth, this.viewHeight);
|
|
13254
13303
|
return renderer;
|
|
@@ -13283,20 +13332,20 @@ var _Renderer = class _Renderer {
|
|
|
13283
13332
|
window["__THREE_DEVTOOLS__"].dispatchEvent(new CustomEvent("observe", { detail: this.scene }));
|
|
13284
13333
|
}
|
|
13285
13334
|
if (this.options.debug.grid) {
|
|
13286
|
-
const gridHelper = new
|
|
13335
|
+
const gridHelper = new import_three35.GridHelper(128, 16);
|
|
13287
13336
|
this._debugHelpers.push(gridHelper);
|
|
13288
13337
|
this.scene.add(gridHelper);
|
|
13289
|
-
const gridHelper2 = new
|
|
13338
|
+
const gridHelper2 = new import_three35.GridHelper(128, 16);
|
|
13290
13339
|
this._debugHelpers.push(gridHelper2);
|
|
13291
13340
|
gridHelper2.rotation.x = 90 * (Math.PI / 180);
|
|
13292
13341
|
this.scene.add(gridHelper2);
|
|
13293
|
-
const gridHelper3 = new
|
|
13342
|
+
const gridHelper3 = new import_three35.GridHelper(128, 16);
|
|
13294
13343
|
this._debugHelpers.push(gridHelper3);
|
|
13295
13344
|
gridHelper3.rotation.z = 90 * (Math.PI / 180);
|
|
13296
13345
|
this.scene.add(gridHelper3);
|
|
13297
13346
|
}
|
|
13298
13347
|
if (this.options.debug.axes) {
|
|
13299
|
-
const axesHelper = new
|
|
13348
|
+
const axesHelper = new import_three35.AxesHelper(64);
|
|
13300
13349
|
this._debugHelpers.push(axesHelper);
|
|
13301
13350
|
this.scene.add(axesHelper);
|
|
13302
13351
|
}
|
|
@@ -13555,8 +13604,8 @@ _Renderer.DEFAULT_OPTIONS = (0, import_ts_deepmerge9.default)({}, {
|
|
|
13555
13604
|
top: void 0,
|
|
13556
13605
|
bottom: void 0
|
|
13557
13606
|
},
|
|
13558
|
-
position: new
|
|
13559
|
-
lookingAt: new
|
|
13607
|
+
position: new import_three35.Vector3(50, 50, 50),
|
|
13608
|
+
lookingAt: new import_three35.Vector3(0, 0, 0)
|
|
13560
13609
|
},
|
|
13561
13610
|
render: {
|
|
13562
13611
|
fpsLimit: 60,
|
|
@@ -14021,12 +14070,12 @@ var AnvilParser = class {
|
|
|
14021
14070
|
};
|
|
14022
14071
|
|
|
14023
14072
|
// src/world/Chunk.ts
|
|
14024
|
-
var
|
|
14073
|
+
var import_three40 = require("three");
|
|
14025
14074
|
init_BlockStates();
|
|
14026
14075
|
init_AssetKey();
|
|
14027
14076
|
|
|
14028
14077
|
// src/world/MineRenderWorld.ts
|
|
14029
|
-
var
|
|
14078
|
+
var import_three38 = require("three");
|
|
14030
14079
|
init_Model();
|
|
14031
14080
|
init_BatchedExecutor();
|
|
14032
14081
|
init_AssetKey();
|
|
@@ -14034,7 +14083,7 @@ init_BlockStates();
|
|
|
14034
14083
|
init_CubeFace();
|
|
14035
14084
|
|
|
14036
14085
|
// src/world/SectionModels.ts
|
|
14037
|
-
var
|
|
14086
|
+
var import_three37 = require("three");
|
|
14038
14087
|
init_AssetKey();
|
|
14039
14088
|
init_Models();
|
|
14040
14089
|
init_CubeFace();
|
|
@@ -14100,12 +14149,12 @@ var SectionModels = class {
|
|
|
14100
14149
|
});
|
|
14101
14150
|
await object.init();
|
|
14102
14151
|
const geometry = object.children[0].geometry;
|
|
14103
|
-
geometry.applyMatrix4(new
|
|
14152
|
+
geometry.applyMatrix4(new import_three37.Matrix4().makeRotationFromEuler(rotation));
|
|
14104
14153
|
object.clear();
|
|
14105
14154
|
const cullFaces = CUBE_FACES.map((face) => {
|
|
14106
14155
|
const local = CUBE_FACES.findIndex((name) => name === atlas.model.elements[0].faces[face]?.cullface);
|
|
14107
14156
|
if (local < 0) return 0;
|
|
14108
|
-
const normal = new
|
|
14157
|
+
const normal = new import_three37.Vector3(...CUBE_FACE_OFFSETS[local]).applyEuler(rotation);
|
|
14109
14158
|
const world = CUBE_FACE_OFFSETS.findIndex(([x, y, z]) => Math.abs(normal.x - x) < 1e-6 && Math.abs(normal.y - y) < 1e-6 && Math.abs(normal.z - z) < 1e-6);
|
|
14110
14159
|
return 1 << world;
|
|
14111
14160
|
});
|
|
@@ -14135,20 +14184,20 @@ var MineRenderWorld = class {
|
|
|
14135
14184
|
}
|
|
14136
14185
|
getBlockAt(posOrX, y, z) {
|
|
14137
14186
|
if (typeof posOrX == "number") {
|
|
14138
|
-
return this.getBlockAt(new
|
|
14187
|
+
return this.getBlockAt(new import_three38.Vector3(posOrX, y, z));
|
|
14139
14188
|
}
|
|
14140
14189
|
if (isTripleArray(posOrX)) {
|
|
14141
|
-
return this.getBlockAt(new
|
|
14190
|
+
return this.getBlockAt(new import_three38.Vector3(posOrX[0], posOrX[1], posOrX[2]));
|
|
14142
14191
|
}
|
|
14143
14192
|
this.validatePosBounds(posOrX);
|
|
14144
14193
|
return this.getChunkAt(posOrX)?.getBlockAt(posOrX);
|
|
14145
14194
|
}
|
|
14146
14195
|
async setBlockAt(posOrX, yOrBlock, z, block) {
|
|
14147
14196
|
if (typeof posOrX == "number") {
|
|
14148
|
-
return this.setBlockAt(new
|
|
14197
|
+
return this.setBlockAt(new import_three38.Vector3(posOrX, yOrBlock, z), block);
|
|
14149
14198
|
}
|
|
14150
14199
|
if (isTripleArray(posOrX)) {
|
|
14151
|
-
return this.setBlockAt(new
|
|
14200
|
+
return this.setBlockAt(new import_three38.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
|
|
14152
14201
|
}
|
|
14153
14202
|
return this.placeBlock(posOrX, yOrBlock);
|
|
14154
14203
|
}
|
|
@@ -14169,7 +14218,7 @@ var MineRenderWorld = class {
|
|
|
14169
14218
|
const collect = async (positions2) => {
|
|
14170
14219
|
for (const pos of positions2) changes.set(pos.toArray().join(","), pos);
|
|
14171
14220
|
};
|
|
14172
|
-
const place = (block) => this.placeBlock(new
|
|
14221
|
+
const place = (block) => this.placeBlock(new import_three38.Vector3(...block.position), block, collect);
|
|
14173
14222
|
const keys = /* @__PURE__ */ new Map();
|
|
14174
14223
|
for (const block of multiblock.blocks) {
|
|
14175
14224
|
if (Chunk.isAir(block)) continue;
|
|
@@ -14247,13 +14296,13 @@ var MineRenderWorld = class {
|
|
|
14247
14296
|
for (const pos of positions) {
|
|
14248
14297
|
this.pendingCulling.set(pos.toArray().join(","), pos.clone());
|
|
14249
14298
|
for (const offset of CUBE_FACE_OFFSETS) {
|
|
14250
|
-
const neighbor = pos.clone().add(new
|
|
14299
|
+
const neighbor = pos.clone().add(new import_three38.Vector3(...offset));
|
|
14251
14300
|
this.pendingCulling.set(neighbor.toArray().join(","), neighbor);
|
|
14252
14301
|
}
|
|
14253
14302
|
for (let y = -1; y <= 1; y++) {
|
|
14254
14303
|
for (let z = -1; z <= 1; z++) {
|
|
14255
14304
|
for (let x = -1; x <= 1; x++) {
|
|
14256
|
-
const neighbor = pos.clone().add(new
|
|
14305
|
+
const neighbor = pos.clone().add(new import_three38.Vector3(x, y, z));
|
|
14257
14306
|
if (this.getBlockAt(neighbor)?.object?.fluidKind) {
|
|
14258
14307
|
this.pendingCulling.set(neighbor.toArray().join(","), neighbor);
|
|
14259
14308
|
}
|
|
@@ -14275,7 +14324,7 @@ var MineRenderWorld = class {
|
|
|
14275
14324
|
if (!block) continue;
|
|
14276
14325
|
if (block.object?.fluidKind) {
|
|
14277
14326
|
await block.object.updateFluid((x, y, z) => {
|
|
14278
|
-
const neighbor = pos.clone().add(new
|
|
14327
|
+
const neighbor = pos.clone().add(new import_three38.Vector3(x, y, z));
|
|
14279
14328
|
const section = this.getChunkAt(neighbor);
|
|
14280
14329
|
const object = section?.getBlockAt(neighbor)?.object;
|
|
14281
14330
|
return {
|
|
@@ -14287,7 +14336,7 @@ var MineRenderWorld = class {
|
|
|
14287
14336
|
}
|
|
14288
14337
|
let mask = 0;
|
|
14289
14338
|
for (const [face, offset] of CUBE_FACE_OFFSETS.entries()) {
|
|
14290
|
-
const neighbor = pos.clone().add(new
|
|
14339
|
+
const neighbor = pos.clone().add(new import_three38.Vector3(...offset));
|
|
14291
14340
|
if (this.getChunkAt(neighbor)?.isOccludingAt(neighbor)) {
|
|
14292
14341
|
mask |= 1 << face;
|
|
14293
14342
|
}
|
|
@@ -14321,14 +14370,14 @@ var MineRenderWorld = class {
|
|
|
14321
14370
|
return this._chunks.get(this.worldPosToChunkKey(pos));
|
|
14322
14371
|
}
|
|
14323
14372
|
static worldToScenePosition(pos) {
|
|
14324
|
-
return new
|
|
14373
|
+
return new import_three38.Vector3(
|
|
14325
14374
|
pos.x * 16,
|
|
14326
14375
|
pos.y * 16,
|
|
14327
14376
|
pos.z * 16
|
|
14328
14377
|
);
|
|
14329
14378
|
}
|
|
14330
14379
|
static sceneToWorldPosition(pos) {
|
|
14331
|
-
return new
|
|
14380
|
+
return new import_three38.Vector3(
|
|
14332
14381
|
pos.x / 16,
|
|
14333
14382
|
pos.y / 16,
|
|
14334
14383
|
pos.z / 16
|
|
@@ -14351,10 +14400,10 @@ var MineRenderWorld = class {
|
|
|
14351
14400
|
init_Model();
|
|
14352
14401
|
|
|
14353
14402
|
// src/world/SectionMesh.ts
|
|
14354
|
-
var
|
|
14403
|
+
var import_three39 = require("three");
|
|
14355
14404
|
init_CanvasCompat();
|
|
14356
14405
|
init_Materials();
|
|
14357
|
-
var SectionMesh = class _SectionMesh extends
|
|
14406
|
+
var SectionMesh = class _SectionMesh extends import_three39.Group {
|
|
14358
14407
|
constructor() {
|
|
14359
14408
|
super(...arguments);
|
|
14360
14409
|
this.ownedMeshes = [];
|
|
@@ -14427,18 +14476,18 @@ var SectionMesh = class _SectionMesh extends import_three38.Group {
|
|
|
14427
14476
|
for (let corner = 0; corner < 6; corner++) indices.push(start + sourceIndices.getX(face * 6 + corner) - face * 4);
|
|
14428
14477
|
}
|
|
14429
14478
|
}
|
|
14430
|
-
const geometry = new
|
|
14431
|
-
geometry.setAttribute("position", new
|
|
14432
|
-
geometry.setAttribute("normal", new
|
|
14433
|
-
geometry.setAttribute("uv", new
|
|
14434
|
-
geometry.setAttribute("color", new
|
|
14479
|
+
const geometry = new import_three39.BufferGeometry();
|
|
14480
|
+
geometry.setAttribute("position", new import_three39.Float32BufferAttribute(positions, 3));
|
|
14481
|
+
geometry.setAttribute("normal", new import_three39.Float32BufferAttribute(normals, 3));
|
|
14482
|
+
geometry.setAttribute("uv", new import_three39.Float32BufferAttribute(uvs, 2));
|
|
14483
|
+
geometry.setAttribute("color", new import_three39.Float32BufferAttribute(colors, 3));
|
|
14435
14484
|
geometry.setIndex(indices);
|
|
14436
14485
|
geometry.computeBoundingBox();
|
|
14437
14486
|
geometry.computeBoundingSphere();
|
|
14438
14487
|
const material = Materials.createShadedCanvasMaterial(canvas, false);
|
|
14439
14488
|
material.vertexColors = true;
|
|
14440
14489
|
const texture = material.uniforms?.map?.value ?? material.map;
|
|
14441
|
-
const mesh = new
|
|
14490
|
+
const mesh = new import_three39.Mesh(geometry, material);
|
|
14442
14491
|
section.add(mesh);
|
|
14443
14492
|
section.ownedMeshes.push({ mesh, texture });
|
|
14444
14493
|
}
|
|
@@ -14472,10 +14521,10 @@ var Chunk = class _Chunk {
|
|
|
14472
14521
|
}
|
|
14473
14522
|
getBlockAt(posOrX, y, z) {
|
|
14474
14523
|
if (typeof posOrX == "number") {
|
|
14475
|
-
return this.getBlockAt(new
|
|
14524
|
+
return this.getBlockAt(new import_three40.Vector3(posOrX, y, z));
|
|
14476
14525
|
}
|
|
14477
14526
|
if (isTripleArray(posOrX)) {
|
|
14478
|
-
return this.getBlockAt(new
|
|
14527
|
+
return this.getBlockAt(new import_three40.Vector3(posOrX[0], posOrX[1], posOrX[2]));
|
|
14479
14528
|
}
|
|
14480
14529
|
const pos = this.worldPosToChunkPos(posOrX);
|
|
14481
14530
|
const index = _Chunk.chunkPosToBlockIndex(pos);
|
|
@@ -14483,10 +14532,10 @@ var Chunk = class _Chunk {
|
|
|
14483
14532
|
}
|
|
14484
14533
|
async setBlockAt(posOrX, yOrBlock, z, block) {
|
|
14485
14534
|
if (typeof posOrX == "number") {
|
|
14486
|
-
return this.setBlockAt(new
|
|
14535
|
+
return this.setBlockAt(new import_three40.Vector3(posOrX, yOrBlock, z), block);
|
|
14487
14536
|
}
|
|
14488
14537
|
if (isTripleArray(posOrX)) {
|
|
14489
|
-
return this.setBlockAt(new
|
|
14538
|
+
return this.setBlockAt(new import_three40.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
|
|
14490
14539
|
}
|
|
14491
14540
|
const worldPos = posOrX;
|
|
14492
14541
|
const pos = this.worldPosToChunkPos(worldPos);
|
|
@@ -14572,7 +14621,7 @@ var Chunk = class _Chunk {
|
|
|
14572
14621
|
}
|
|
14573
14622
|
async clear(onBlocksChanged = this.onBlocksChanged) {
|
|
14574
14623
|
const positions = [...this.renderedBlocks.keys()].map((index) => this.chunkPosToWorldPos(
|
|
14575
|
-
new
|
|
14624
|
+
new import_three40.Vector3(index % 16, Math.floor(index / 256), Math.floor(index / 16) % 16)
|
|
14576
14625
|
));
|
|
14577
14626
|
for (const info of this.renderedBlocks.values()) info.object?.removeFromScene();
|
|
14578
14627
|
this.sectionBlocks.clear();
|
|
@@ -14596,14 +14645,14 @@ var Chunk = class _Chunk {
|
|
|
14596
14645
|
return pos.y * 16 * 16 + pos.z * 16 + pos.x;
|
|
14597
14646
|
}
|
|
14598
14647
|
worldPosToChunkPos(pos) {
|
|
14599
|
-
return new
|
|
14648
|
+
return new import_three40.Vector3(
|
|
14600
14649
|
pos.x - this.x * 16,
|
|
14601
14650
|
pos.y - this.y * 16,
|
|
14602
14651
|
pos.z - this.z * 16
|
|
14603
14652
|
);
|
|
14604
14653
|
}
|
|
14605
14654
|
chunkPosToWorldPos(pos) {
|
|
14606
|
-
return new
|
|
14655
|
+
return new import_three40.Vector3(
|
|
14607
14656
|
this.x * 16 + pos.x,
|
|
14608
14657
|
this.y * 16 + pos.y,
|
|
14609
14658
|
this.z * 16 + pos.z
|