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.mjs
CHANGED
|
@@ -3236,11 +3236,11 @@ var init_Entities = __esm({
|
|
|
3236
3236
|
return { ...layers[names[0]], id: model.id, layers, ...model.transform && { transform: model.transform } };
|
|
3237
3237
|
}
|
|
3238
3238
|
/**
|
|
3239
|
-
*
|
|
3239
|
+
* Native and sampled vanilla clips by name, or undefined when the model or selected version has none.
|
|
3240
3240
|
*/
|
|
3241
3241
|
static async getAnimations(modelKey) {
|
|
3242
3242
|
const path = isAssetKey(modelKey) ? modelKey.getFullPath() : modelKey.path;
|
|
3243
|
-
const key = new AssetKey(modelKey.namespace, path, void 0, void 0, "entity-models/animations", ".json");
|
|
3243
|
+
const key = new AssetKey(modelKey.namespace, path, void 0, void 0, "entity-models/animations", ".json", isAssetKey(modelKey) ? modelKey.root : void 0);
|
|
3244
3244
|
const file = await Caching.entityAnimationCache.get(key.serialize(), () => AssetLoader.get(key, "json" /* JSON */));
|
|
3245
3245
|
return file?.animations;
|
|
3246
3246
|
}
|
|
@@ -3290,7 +3290,7 @@ function sampleEntityKeyframes(keyframes, time) {
|
|
|
3290
3290
|
let low = 0, high = keyframes.length;
|
|
3291
3291
|
while (low < high) {
|
|
3292
3292
|
const middle = low + high >>> 1;
|
|
3293
|
-
if (time
|
|
3293
|
+
if (time < keyframes[middle].time) high = middle;
|
|
3294
3294
|
else low = middle + 1;
|
|
3295
3295
|
}
|
|
3296
3296
|
const a = Math.max(0, low - 1);
|
|
@@ -3329,6 +3329,7 @@ var init_EntityAnimation = __esm({
|
|
|
3329
3329
|
});
|
|
3330
3330
|
|
|
3331
3331
|
// src/entity/scene/EntityAnimationPlayer.ts
|
|
3332
|
+
import { Euler as Euler3, Vector3 as Vector35 } from "three";
|
|
3332
3333
|
var ZERO, EntityAnimationPlayer;
|
|
3333
3334
|
var init_EntityAnimationPlayer = __esm({
|
|
3334
3335
|
"src/entity/scene/EntityAnimationPlayer.ts"() {
|
|
@@ -3348,25 +3349,45 @@ var init_EntityAnimationPlayer = __esm({
|
|
|
3348
3349
|
return this._time;
|
|
3349
3350
|
}
|
|
3350
3351
|
/**
|
|
3351
|
-
* Starts an animation on
|
|
3352
|
-
*
|
|
3352
|
+
* Starts an animation on matching named parts. Supplied baked poses are the baseline for offsets;
|
|
3353
|
+
* without them, the current pose is used. Stopping restores the pose from before playback.
|
|
3353
3354
|
*/
|
|
3354
|
-
play(layers, animation, options = {}) {
|
|
3355
|
+
play(layers, animation, options = {}, poses) {
|
|
3355
3356
|
this.stop();
|
|
3356
3357
|
this._animation = animation;
|
|
3357
3358
|
this._time = options.time ?? 0;
|
|
3358
3359
|
this.loop = options.loop ?? animation.loop;
|
|
3359
3360
|
this.speed = options.speed ?? 1;
|
|
3360
3361
|
for (const layer of layers) {
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3362
|
+
const objects = [];
|
|
3363
|
+
if (poses) {
|
|
3364
|
+
layer.traverse((object) => {
|
|
3365
|
+
if (poses.has(object)) objects.push(object);
|
|
3366
|
+
});
|
|
3367
|
+
} else {
|
|
3368
|
+
for (const bone of Object.keys(animation.bones)) {
|
|
3369
|
+
const object = layer.getObjectByName(`group:${bone}`);
|
|
3370
|
+
if (object) objects.push(object);
|
|
3371
|
+
}
|
|
3372
|
+
}
|
|
3373
|
+
for (const object of objects) {
|
|
3374
|
+
const bone = object.name.slice("group:".length);
|
|
3375
|
+
const pose = poses?.get(object);
|
|
3376
|
+
this.parts.push({
|
|
3377
|
+
bone,
|
|
3378
|
+
object,
|
|
3379
|
+
position: object.position.clone(),
|
|
3380
|
+
rotation: object.rotation.clone(),
|
|
3381
|
+
scale: object.scale.clone(),
|
|
3382
|
+
basePosition: pose ? new Vector35(...pose.offset) : object.position.clone(),
|
|
3383
|
+
baseRotation: pose ? new Euler3(...pose.rotation, "ZYX") : object.rotation.clone(),
|
|
3384
|
+
baseScale: pose ? new Vector35(...pose.scale ?? [1, 1, 1]) : object.scale.clone()
|
|
3385
|
+
});
|
|
3365
3386
|
}
|
|
3366
3387
|
}
|
|
3367
3388
|
this.apply();
|
|
3368
3389
|
}
|
|
3369
|
-
/** Restores the
|
|
3390
|
+
/** Restores the poses from before playback. Returns whether an animation was active. */
|
|
3370
3391
|
stop() {
|
|
3371
3392
|
if (!this._animation) return false;
|
|
3372
3393
|
for (const part of this.parts) {
|
|
@@ -3395,10 +3416,10 @@ var init_EntityAnimationPlayer = __esm({
|
|
|
3395
3416
|
apply() {
|
|
3396
3417
|
const pose = sampleEntityAnimation(this._animation, this._time, this.loop);
|
|
3397
3418
|
for (const part of this.parts) {
|
|
3398
|
-
const { position = ZERO, rotation = ZERO, scale = ZERO } = pose[part.bone];
|
|
3399
|
-
part.object.position.set(part.
|
|
3400
|
-
part.object.rotation.set(part.
|
|
3401
|
-
part.object.scale.set(part.
|
|
3419
|
+
const { position = ZERO, rotation = ZERO, scale = ZERO } = pose[part.bone] ?? {};
|
|
3420
|
+
part.object.position.set(part.basePosition.x + position[0], part.basePosition.y + position[1], part.basePosition.z + position[2]);
|
|
3421
|
+
part.object.rotation.set(part.baseRotation.x + rotation[0], part.baseRotation.y + rotation[1], part.baseRotation.z + rotation[2], part.baseRotation.order);
|
|
3422
|
+
part.object.scale.set(part.baseScale.x + scale[0], part.baseScale.y + scale[1], part.baseScale.z + scale[2]);
|
|
3402
3423
|
}
|
|
3403
3424
|
}
|
|
3404
3425
|
};
|
|
@@ -3465,7 +3486,7 @@ var init_InstanceReference = __esm({
|
|
|
3465
3486
|
});
|
|
3466
3487
|
|
|
3467
3488
|
// src/renderer/SceneObject.ts
|
|
3468
|
-
import { Color as Color2, Euler as
|
|
3489
|
+
import { Color as Color2, Euler as Euler4, InstancedBufferAttribute, InstancedMesh, MathUtils, Matrix4 as Matrix44, Mesh as Mesh3, Object3D as Object3D2, Quaternion as Quaternion3, Vector3 as Vector36 } from "three";
|
|
3469
3490
|
function isSceneObject(obj) {
|
|
3470
3491
|
return obj.isSceneObject;
|
|
3471
3492
|
}
|
|
@@ -3732,9 +3753,9 @@ var init_SceneObject = __esm({
|
|
|
3732
3753
|
}
|
|
3733
3754
|
setPositionRotationScaleAt(index, position, rotation, scale) {
|
|
3734
3755
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3735
|
-
const oldPosition = new
|
|
3756
|
+
const oldPosition = new Vector36();
|
|
3736
3757
|
const oldRotation = new Quaternion3();
|
|
3737
|
-
const oldScale = new
|
|
3758
|
+
const oldScale = new Vector36();
|
|
3738
3759
|
const matrix = new Matrix44();
|
|
3739
3760
|
if (!scale || !rotation || !position) {
|
|
3740
3761
|
this.getMatrixAt(index, matrix).decompose(oldPosition, oldRotation, oldScale);
|
|
@@ -3750,7 +3771,7 @@ var init_SceneObject = __esm({
|
|
|
3750
3771
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3751
3772
|
this.setPositionRotationScaleAt(index, position);
|
|
3752
3773
|
}
|
|
3753
|
-
getPositionAt(index, vector = new
|
|
3774
|
+
getPositionAt(index, vector = new Vector36()) {
|
|
3754
3775
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3755
3776
|
const matrix = this.getMatrixAt(index);
|
|
3756
3777
|
vector.setFromMatrixPosition(matrix);
|
|
@@ -3760,17 +3781,17 @@ var init_SceneObject = __esm({
|
|
|
3760
3781
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3761
3782
|
this.setPositionRotationScaleAt(index, void 0, rotation, void 0);
|
|
3762
3783
|
}
|
|
3763
|
-
getRotationAt(index, euler = new
|
|
3784
|
+
getRotationAt(index, euler = new Euler4()) {
|
|
3764
3785
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3765
3786
|
const rotation = new Quaternion3();
|
|
3766
|
-
this.getMatrixAt(index).decompose(new
|
|
3787
|
+
this.getMatrixAt(index).decompose(new Vector36(), rotation, new Vector36());
|
|
3767
3788
|
return euler.setFromQuaternion(rotation);
|
|
3768
3789
|
}
|
|
3769
3790
|
setScaleAt(index, scale) {
|
|
3770
3791
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3771
3792
|
this.setPositionRotationScaleAt(index, void 0, void 0, scale);
|
|
3772
3793
|
}
|
|
3773
|
-
getScaleAt(index, vector = new
|
|
3794
|
+
getScaleAt(index, vector = new Vector36()) {
|
|
3774
3795
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3775
3796
|
const matrix = this.getMatrixAt(index);
|
|
3776
3797
|
vector.setFromMatrixScale(matrix);
|
|
@@ -3902,7 +3923,7 @@ var init_SceneObject = __esm({
|
|
|
3902
3923
|
});
|
|
3903
3924
|
|
|
3904
3925
|
// src/entity/scene/EntityObject.ts
|
|
3905
|
-
import { Color as Color3, Euler as
|
|
3926
|
+
import { Color as Color3, Euler as Euler5, Matrix4 as Matrix45, Object3D as Object3D3 } from "three";
|
|
3906
3927
|
function isEntityObject(obj) {
|
|
3907
3928
|
return obj.isEntityObject;
|
|
3908
3929
|
}
|
|
@@ -3932,7 +3953,8 @@ var init_EntityObject = __esm({
|
|
|
3932
3953
|
this.scrollMaterials = [];
|
|
3933
3954
|
/** Entity age in ticks, as vanilla's `ageInTicks`; drives the scrolling render modes. */
|
|
3934
3955
|
this.age = 0;
|
|
3935
|
-
this.
|
|
3956
|
+
this.animationPlayers = [];
|
|
3957
|
+
this.partPoses = /* @__PURE__ */ new Map();
|
|
3936
3958
|
this.options = (0, import_ts_deepmerge4.default)({}, _EntityObject.DEFAULT_OPTIONS, options ?? {});
|
|
3937
3959
|
this.addEventListener("added", () => this.updateScrollSubscription());
|
|
3938
3960
|
this.addEventListener("removed", () => this.updateScrollSubscription());
|
|
@@ -3949,7 +3971,8 @@ var init_EntityObject = __esm({
|
|
|
3949
3971
|
for (const geometry of this.geometries) geometry.dispose();
|
|
3950
3972
|
this.geometries.clear();
|
|
3951
3973
|
for (const dispose of this.disposeWireframes.splice(0)) dispose();
|
|
3952
|
-
this.
|
|
3974
|
+
for (const player of this.animationPlayers.splice(0)) player.clear();
|
|
3975
|
+
this.partPoses.clear();
|
|
3953
3976
|
super.disposeAndRemoveAllChildren();
|
|
3954
3977
|
}
|
|
3955
3978
|
clearScrollMaterials() {
|
|
@@ -3981,36 +4004,61 @@ var init_EntityObject = __esm({
|
|
|
3981
4004
|
this.notifyDirty();
|
|
3982
4005
|
}
|
|
3983
4006
|
//<editor-fold desc="ANIMATION">
|
|
3984
|
-
/** The
|
|
4007
|
+
/** The first active clip, until playback is stopped or the object is disposed. */
|
|
3985
4008
|
get animation() {
|
|
3986
|
-
return this.
|
|
4009
|
+
return this.animationPlayers[0]?.animation;
|
|
4010
|
+
}
|
|
4011
|
+
/** Clips playing together, each targeting a separate geometry layer. */
|
|
4012
|
+
get activeAnimations() {
|
|
4013
|
+
return this.animationPlayers.map((player) => player.animation);
|
|
3987
4014
|
}
|
|
3988
4015
|
/** Seconds since the animation started, before looping. */
|
|
3989
4016
|
get animationTime() {
|
|
3990
|
-
return this.
|
|
4017
|
+
return this.animationPlayers[0]?.time ?? 0;
|
|
3991
4018
|
}
|
|
3992
4019
|
/**
|
|
3993
|
-
*
|
|
3994
|
-
*
|
|
4020
|
+
* Plays a clip from {@link Entities.getAnimations}, replacing all active clips.
|
|
4021
|
+
* Offsets apply to the baked pose in the clip's layer (`main` by default), including repeated draws of that layer.
|
|
3995
4022
|
* The object owns no clock: call {@link advanceAnimation} per frame, or {@link setAnimationTime}.
|
|
3996
4023
|
*/
|
|
3997
4024
|
playAnimation(animation, options) {
|
|
4025
|
+
this.playAnimations([animation], options);
|
|
4026
|
+
}
|
|
4027
|
+
/** Plays one clip per selected geometry layer, with a shared clock and no blending between clips. */
|
|
4028
|
+
playAnimations(animations, options) {
|
|
4029
|
+
const targets = /* @__PURE__ */ new Set();
|
|
4030
|
+
const selections = animations.map((animation) => {
|
|
4031
|
+
const layer = animation.layer ?? "main";
|
|
4032
|
+
if (targets.has(layer)) throw new Error(`Multiple animations target layer "${layer}"`);
|
|
4033
|
+
targets.add(layer);
|
|
4034
|
+
const names = Object.keys(this.entityLayers).filter((name) => name.split("#")[0] === layer);
|
|
4035
|
+
if (!names.length) throw new Error(`Entity ${this.entity.id} has no selected animation layer "${layer}"`);
|
|
4036
|
+
return { animation, names };
|
|
4037
|
+
});
|
|
3998
4038
|
this.createMeshes();
|
|
3999
|
-
|
|
4000
|
-
|
|
4039
|
+
this.stopAnimation();
|
|
4040
|
+
for (const { animation, names } of selections) {
|
|
4041
|
+
const player = new EntityAnimationPlayer();
|
|
4042
|
+
player.play(names.map((name) => this.getLayerGroup(name)), animation, options, this.partPoses);
|
|
4043
|
+
this.animationPlayers.push(player);
|
|
4044
|
+
}
|
|
4001
4045
|
this.notifyDirty();
|
|
4002
4046
|
}
|
|
4003
|
-
/** Stops
|
|
4047
|
+
/** Stops all clips and restores the poses from before playback. */
|
|
4004
4048
|
stopAnimation() {
|
|
4005
|
-
|
|
4049
|
+
const players = this.animationPlayers.splice(0);
|
|
4050
|
+
for (const player of players) player.stop();
|
|
4051
|
+
if (players.length) this.notifyDirty();
|
|
4006
4052
|
}
|
|
4007
4053
|
/** Poses the object at an explicit time in seconds. Has no effect without an animation. */
|
|
4008
4054
|
setAnimationTime(seconds) {
|
|
4009
|
-
|
|
4055
|
+
for (const player of this.animationPlayers) player.setTime(seconds);
|
|
4056
|
+
if (this.animationPlayers.length) this.notifyDirty();
|
|
4010
4057
|
}
|
|
4011
4058
|
/** Advances the animation by a frame delta in seconds, scaled by its speed. Has no effect without an animation. */
|
|
4012
4059
|
advanceAnimation(deltaSeconds) {
|
|
4013
|
-
|
|
4060
|
+
for (const player of this.animationPlayers) player.advance(deltaSeconds);
|
|
4061
|
+
if (this.animationPlayers.length) this.notifyDirty();
|
|
4014
4062
|
}
|
|
4015
4063
|
//</editor-fold>
|
|
4016
4064
|
getLayerGroup(name) {
|
|
@@ -4049,7 +4097,7 @@ var init_EntityObject = __esm({
|
|
|
4049
4097
|
const matrix = new Matrix45();
|
|
4050
4098
|
if ("scale" in op) matrix.makeScale(...op.scale);
|
|
4051
4099
|
else if ("translate" in op) matrix.makeTranslation(...op.translate);
|
|
4052
|
-
else matrix.makeRotationFromEuler(new
|
|
4100
|
+
else matrix.makeRotationFromEuler(new Euler5(...op.rotate, "ZYX"));
|
|
4053
4101
|
modelRoot.matrix.multiply(matrix);
|
|
4054
4102
|
}
|
|
4055
4103
|
modelRoot.matrixAutoUpdate = false;
|
|
@@ -4070,6 +4118,7 @@ var init_EntityObject = __esm({
|
|
|
4070
4118
|
anchor.position.fromArray(part.pose.offset);
|
|
4071
4119
|
anchor.rotation.set(...part.pose.rotation, "ZYX");
|
|
4072
4120
|
anchor.scale.fromArray(part.pose.scale ?? [1, 1, 1]);
|
|
4121
|
+
this.partPoses.set(anchor, part.pose);
|
|
4073
4122
|
parent.add(anchor);
|
|
4074
4123
|
const size = part.texture ?? textureSize;
|
|
4075
4124
|
for (const cube of part.cubes) {
|
|
@@ -4146,7 +4195,7 @@ import {
|
|
|
4146
4195
|
TriangleFanDrawMode,
|
|
4147
4196
|
TriangleStripDrawMode,
|
|
4148
4197
|
TrianglesDrawMode,
|
|
4149
|
-
Vector3 as
|
|
4198
|
+
Vector3 as Vector310
|
|
4150
4199
|
} from "three";
|
|
4151
4200
|
function computeTangents(geometry) {
|
|
4152
4201
|
geometry.computeTangents();
|
|
@@ -4465,15 +4514,15 @@ function computeMorphedAttributes(object) {
|
|
|
4465
4514
|
console.error("THREE.BufferGeometryUtils: Geometry is not of type BufferGeometry.");
|
|
4466
4515
|
return null;
|
|
4467
4516
|
}
|
|
4468
|
-
const _vA = new
|
|
4469
|
-
const _vB = new
|
|
4470
|
-
const _vC = new
|
|
4471
|
-
const _tempA = new
|
|
4472
|
-
const _tempB = new
|
|
4473
|
-
const _tempC = new
|
|
4474
|
-
const _morphA = new
|
|
4475
|
-
const _morphB = new
|
|
4476
|
-
const _morphC = new
|
|
4517
|
+
const _vA = new Vector310();
|
|
4518
|
+
const _vB = new Vector310();
|
|
4519
|
+
const _vC = new Vector310();
|
|
4520
|
+
const _tempA = new Vector310();
|
|
4521
|
+
const _tempB = new Vector310();
|
|
4522
|
+
const _tempC = new Vector310();
|
|
4523
|
+
const _morphA = new Vector310();
|
|
4524
|
+
const _morphB = new Vector310();
|
|
4525
|
+
const _morphC = new Vector310();
|
|
4477
4526
|
function _calculateMorphedAttributeData(object2, material2, attribute, morphAttribute, morphTargetsRelative2, a2, b2, c2, modifiedAttributeArray) {
|
|
4478
4527
|
_vA.fromBufferAttribute(attribute, a2);
|
|
4479
4528
|
_vB.fromBufferAttribute(attribute, b2);
|
|
@@ -4683,7 +4732,7 @@ var init_BufferGeometryUtils = __esm({
|
|
|
4683
4732
|
});
|
|
4684
4733
|
|
|
4685
4734
|
// src/model/ModelCulling.ts
|
|
4686
|
-
import { Vector3 as
|
|
4735
|
+
import { Vector3 as Vector311 } from "three";
|
|
4687
4736
|
var ModelCulling;
|
|
4688
4737
|
var init_ModelCulling = __esm({
|
|
4689
4738
|
"src/model/ModelCulling.ts"() {
|
|
@@ -4692,7 +4741,7 @@ var init_ModelCulling = __esm({
|
|
|
4692
4741
|
static toLocalMask(worldMask, rotation) {
|
|
4693
4742
|
let localMask = 0;
|
|
4694
4743
|
for (const [localFace, offset] of CUBE_FACE_OFFSETS.entries()) {
|
|
4695
|
-
const normal = new
|
|
4744
|
+
const normal = new Vector311(...offset).applyEuler(rotation);
|
|
4696
4745
|
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);
|
|
4697
4746
|
if (worldFace < 0) return 0;
|
|
4698
4747
|
if (worldMask & 1 << worldFace) localMask |= 1 << localFace;
|
|
@@ -4919,7 +4968,7 @@ var init_ItemTints = __esm({
|
|
|
4919
4968
|
});
|
|
4920
4969
|
|
|
4921
4970
|
// src/model/scene/ModelObject.ts
|
|
4922
|
-
import { BoxGeometry as BoxGeometry5, BufferAttribute as BufferAttribute5, Color as Color8, Euler as
|
|
4971
|
+
import { BoxGeometry as BoxGeometry5, BufferAttribute as BufferAttribute5, Color as Color8, Euler as Euler7, Matrix4 as Matrix49 } from "three";
|
|
4923
4972
|
function isModelObject(obj) {
|
|
4924
4973
|
return obj.isModelObject;
|
|
4925
4974
|
}
|
|
@@ -5023,7 +5072,7 @@ var init_ModelObject = __esm({
|
|
|
5023
5072
|
elGeo.clearGroups();
|
|
5024
5073
|
}
|
|
5025
5074
|
if (this.options.uvLockRotation) {
|
|
5026
|
-
UVMapper.lockUvs(elGeo, el.faces, this.atlas, new
|
|
5075
|
+
UVMapper.lockUvs(elGeo, el.faces, this.atlas, new Euler7(...this.options.uvLockRotation));
|
|
5027
5076
|
}
|
|
5028
5077
|
if (this.options.tints) {
|
|
5029
5078
|
const colors = new Float32Array(elGeo.getAttribute("position").count * 3).fill(1);
|
|
@@ -5684,7 +5733,7 @@ import {
|
|
|
5684
5733
|
Color as Color4,
|
|
5685
5734
|
Matrix3,
|
|
5686
5735
|
Vector2 as Vector22,
|
|
5687
|
-
Vector3 as
|
|
5736
|
+
Vector3 as Vector37
|
|
5688
5737
|
} from "three";
|
|
5689
5738
|
var OBJExporter = class {
|
|
5690
5739
|
parse(object) {
|
|
@@ -5692,9 +5741,9 @@ var OBJExporter = class {
|
|
|
5692
5741
|
let indexVertex = 0;
|
|
5693
5742
|
let indexVertexUvs = 0;
|
|
5694
5743
|
let indexNormals = 0;
|
|
5695
|
-
const vertex = new
|
|
5744
|
+
const vertex = new Vector37();
|
|
5696
5745
|
const color = new Color4();
|
|
5697
|
-
const normal = new
|
|
5746
|
+
const normal = new Vector37();
|
|
5698
5747
|
const uv = new Vector22();
|
|
5699
5748
|
const face = [];
|
|
5700
5749
|
function parseMesh(mesh) {
|
|
@@ -5823,7 +5872,7 @@ var OBJExporter = class {
|
|
|
5823
5872
|
// ../../node_modules/three/examples/jsm/exporters/PLYExporter.js
|
|
5824
5873
|
import {
|
|
5825
5874
|
Matrix3 as Matrix32,
|
|
5826
|
-
Vector3 as
|
|
5875
|
+
Vector3 as Vector38,
|
|
5827
5876
|
Color as Color5
|
|
5828
5877
|
} from "three";
|
|
5829
5878
|
var PLYExporter = class {
|
|
@@ -5916,7 +5965,7 @@ property list uchar int vertex_index
|
|
|
5916
5965
|
`;
|
|
5917
5966
|
}
|
|
5918
5967
|
header += "end_header\n";
|
|
5919
|
-
const vertex = new
|
|
5968
|
+
const vertex = new Vector38();
|
|
5920
5969
|
const normalMatrixWorld = new Matrix32();
|
|
5921
5970
|
let result = null;
|
|
5922
5971
|
if (options.binary === true) {
|
|
@@ -6115,7 +6164,7 @@ import {
|
|
|
6115
6164
|
Source,
|
|
6116
6165
|
SRGBColorSpace as SRGBColorSpace4,
|
|
6117
6166
|
CompressedTexture,
|
|
6118
|
-
Vector3 as
|
|
6167
|
+
Vector3 as Vector39,
|
|
6119
6168
|
Quaternion as Quaternion4
|
|
6120
6169
|
} from "three";
|
|
6121
6170
|
|
|
@@ -6576,7 +6625,7 @@ var GLTFWriter = class {
|
|
|
6576
6625
|
isNormalizedNormalAttribute(normal) {
|
|
6577
6626
|
const cache = this.cache;
|
|
6578
6627
|
if (cache.attributesNormalized.has(normal)) return false;
|
|
6579
|
-
const v = new
|
|
6628
|
+
const v = new Vector39();
|
|
6580
6629
|
for (let i = 0, il = normal.count; i < il; i++) {
|
|
6581
6630
|
if (Math.abs(v.fromBufferAttribute(normal, i).length() - 1) > 5e-4) return false;
|
|
6582
6631
|
}
|
|
@@ -6593,7 +6642,7 @@ var GLTFWriter = class {
|
|
|
6593
6642
|
const cache = this.cache;
|
|
6594
6643
|
if (cache.attributesNormalized.has(normal)) return cache.attributesNormalized.get(normal);
|
|
6595
6644
|
const attribute = normal.clone();
|
|
6596
|
-
const v = new
|
|
6645
|
+
const v = new Vector39();
|
|
6597
6646
|
for (let i = 0, il = attribute.count; i < il; i++) {
|
|
6598
6647
|
v.fromBufferAttribute(attribute, i);
|
|
6599
6648
|
if (v.x === 0 && v.y === 0 && v.z === 0) {
|
|
@@ -7860,9 +7909,9 @@ var GLTFMeshGpuInstancing = class {
|
|
|
7860
7909
|
const rotationAttr = new Float32Array(mesh.count * 4);
|
|
7861
7910
|
const scaleAttr = new Float32Array(mesh.count * 3);
|
|
7862
7911
|
const matrix = new Matrix46();
|
|
7863
|
-
const position = new
|
|
7912
|
+
const position = new Vector39();
|
|
7864
7913
|
const quaternion = new Quaternion4();
|
|
7865
|
-
const scale = new
|
|
7914
|
+
const scale = new Vector39();
|
|
7866
7915
|
for (let i = 0; i < mesh.count; i++) {
|
|
7867
7916
|
mesh.getMatrixAt(i, matrix);
|
|
7868
7917
|
matrix.decompose(position, quaternion, scale);
|
|
@@ -8855,7 +8904,7 @@ init_SpecialItems();
|
|
|
8855
8904
|
init_BlockStates();
|
|
8856
8905
|
init_MineRenderError();
|
|
8857
8906
|
init_util();
|
|
8858
|
-
import { Euler as
|
|
8907
|
+
import { Euler as Euler8 } from "three";
|
|
8859
8908
|
function matchesCondition(condition, state) {
|
|
8860
8909
|
return Object.entries(condition).every(([key, value]) => {
|
|
8861
8910
|
if (Array.isArray(value)) {
|
|
@@ -8930,7 +8979,7 @@ var BlockStateResolver = class {
|
|
|
8930
8979
|
return variants[variants.length - 1];
|
|
8931
8980
|
}
|
|
8932
8981
|
static rotation(variant) {
|
|
8933
|
-
const rotation = new
|
|
8982
|
+
const rotation = new Euler8();
|
|
8934
8983
|
if (typeof variant.x !== "undefined") {
|
|
8935
8984
|
rotation.x = toRadians(clampRotationDegrees(variant.x));
|
|
8936
8985
|
}
|
|
@@ -9025,7 +9074,7 @@ var import_ts_deepmerge6 = __toESM(require_dist());
|
|
|
9025
9074
|
init_MineRenderError();
|
|
9026
9075
|
init_InstanceReference();
|
|
9027
9076
|
init_AssetKey();
|
|
9028
|
-
import { Euler as
|
|
9077
|
+
import { Euler as Euler9, Matrix4 as Matrix411, Quaternion as Quaternion5, Vector3 as Vector312 } from "three";
|
|
9029
9078
|
init_ModelCulling();
|
|
9030
9079
|
init_FluidGeometry();
|
|
9031
9080
|
init_Entities();
|
|
@@ -9143,12 +9192,12 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
9143
9192
|
getModelCullMask(model, worldMask) {
|
|
9144
9193
|
const object = isInstanceReference(model) ? model.instanceable : model;
|
|
9145
9194
|
if (object.options.displayPosition) return 0;
|
|
9146
|
-
const position = new
|
|
9195
|
+
const position = new Vector312();
|
|
9147
9196
|
const rotation = new Quaternion5();
|
|
9148
|
-
const scale = new
|
|
9197
|
+
const scale = new Vector312();
|
|
9149
9198
|
this.getModelMatrix(model).decompose(position, rotation, scale);
|
|
9150
|
-
if (position.distanceToSquared(this.position) > 1e-10 || scale.distanceToSquared(new
|
|
9151
|
-
return ModelCulling.toLocalMask(worldMask, new
|
|
9199
|
+
if (position.distanceToSquared(this.position) > 1e-10 || scale.distanceToSquared(new Vector312(1, 1, 1)) > 1e-10) return 0;
|
|
9200
|
+
return ModelCulling.toLocalMask(worldMask, new Euler9().setFromQuaternion(rotation));
|
|
9152
9201
|
}
|
|
9153
9202
|
async setCullMask(worldMask) {
|
|
9154
9203
|
worldMask &= 63;
|
|
@@ -12398,7 +12447,7 @@ function isMineRenderScene(obj) {
|
|
|
12398
12447
|
}
|
|
12399
12448
|
|
|
12400
12449
|
// src/renderer/Renderer.ts
|
|
12401
|
-
import { AxesHelper as AxesHelper2, GridHelper, OrthographicCamera, PCFSoftShadowMap, PerspectiveCamera as PerspectiveCamera2, SRGBColorSpace as SRGBColorSpace6, Vector3 as
|
|
12450
|
+
import { AxesHelper as AxesHelper2, GridHelper, OrthographicCamera, PCFSoftShadowMap, PerspectiveCamera as PerspectiveCamera2, SRGBColorSpace as SRGBColorSpace6, Vector3 as Vector314, WebGLRenderer as WebGLRenderer2 } from "three";
|
|
12402
12451
|
var import_ts_deepmerge9 = __toESM(require_dist());
|
|
12403
12452
|
init_util();
|
|
12404
12453
|
init_Model();
|
|
@@ -12414,7 +12463,7 @@ import {
|
|
|
12414
12463
|
Spherical,
|
|
12415
12464
|
TOUCH,
|
|
12416
12465
|
Vector2 as Vector25,
|
|
12417
|
-
Vector3 as
|
|
12466
|
+
Vector3 as Vector313
|
|
12418
12467
|
} from "three";
|
|
12419
12468
|
var _changeEvent = { type: "change" };
|
|
12420
12469
|
var _startEvent = { type: "start" };
|
|
@@ -12428,7 +12477,7 @@ var OrbitControls = class extends EventDispatcher {
|
|
|
12428
12477
|
this.domElement = domElement;
|
|
12429
12478
|
this.domElement.style.touchAction = "none";
|
|
12430
12479
|
this.enabled = true;
|
|
12431
|
-
this.target = new
|
|
12480
|
+
this.target = new Vector313();
|
|
12432
12481
|
this.minDistance = 0;
|
|
12433
12482
|
this.maxDistance = Infinity;
|
|
12434
12483
|
this.minZoom = 0;
|
|
@@ -12480,10 +12529,10 @@ var OrbitControls = class extends EventDispatcher {
|
|
|
12480
12529
|
state = STATE.NONE;
|
|
12481
12530
|
};
|
|
12482
12531
|
this.update = function() {
|
|
12483
|
-
const offset = new
|
|
12484
|
-
const quat = new Quaternion6().setFromUnitVectors(object.up, new
|
|
12532
|
+
const offset = new Vector313();
|
|
12533
|
+
const quat = new Quaternion6().setFromUnitVectors(object.up, new Vector313(0, 1, 0));
|
|
12485
12534
|
const quatInverse = quat.clone().invert();
|
|
12486
|
-
const lastPosition = new
|
|
12535
|
+
const lastPosition = new Vector313();
|
|
12487
12536
|
const lastQuaternion = new Quaternion6();
|
|
12488
12537
|
const twoPI = 2 * Math.PI;
|
|
12489
12538
|
return function update() {
|
|
@@ -12573,7 +12622,7 @@ var OrbitControls = class extends EventDispatcher {
|
|
|
12573
12622
|
const spherical = new Spherical();
|
|
12574
12623
|
const sphericalDelta = new Spherical();
|
|
12575
12624
|
let scale = 1;
|
|
12576
|
-
const panOffset = new
|
|
12625
|
+
const panOffset = new Vector313();
|
|
12577
12626
|
let zoomChanged = false;
|
|
12578
12627
|
const rotateStart = new Vector25();
|
|
12579
12628
|
const rotateEnd = new Vector25();
|
|
@@ -12599,7 +12648,7 @@ var OrbitControls = class extends EventDispatcher {
|
|
|
12599
12648
|
sphericalDelta.phi -= angle;
|
|
12600
12649
|
}
|
|
12601
12650
|
const panLeft = function() {
|
|
12602
|
-
const v = new
|
|
12651
|
+
const v = new Vector313();
|
|
12603
12652
|
return function panLeft2(distance, objectMatrix) {
|
|
12604
12653
|
v.setFromMatrixColumn(objectMatrix, 0);
|
|
12605
12654
|
v.multiplyScalar(-distance);
|
|
@@ -12607,7 +12656,7 @@ var OrbitControls = class extends EventDispatcher {
|
|
|
12607
12656
|
};
|
|
12608
12657
|
}();
|
|
12609
12658
|
const panUp = function() {
|
|
12610
|
-
const v = new
|
|
12659
|
+
const v = new Vector313();
|
|
12611
12660
|
return function panUp2(distance, objectMatrix) {
|
|
12612
12661
|
if (scope.screenSpacePanning === true) {
|
|
12613
12662
|
v.setFromMatrixColumn(objectMatrix, 1);
|
|
@@ -12620,7 +12669,7 @@ var OrbitControls = class extends EventDispatcher {
|
|
|
12620
12669
|
};
|
|
12621
12670
|
}();
|
|
12622
12671
|
const pan = function() {
|
|
12623
|
-
const offset = new
|
|
12672
|
+
const offset = new Vector313();
|
|
12624
12673
|
return function pan2(deltaX, deltaY) {
|
|
12625
12674
|
const element = scope.domElement;
|
|
12626
12675
|
if (scope.object.isPerspectiveCamera) {
|
|
@@ -13437,8 +13486,8 @@ _Renderer.DEFAULT_OPTIONS = (0, import_ts_deepmerge9.default)({}, {
|
|
|
13437
13486
|
top: void 0,
|
|
13438
13487
|
bottom: void 0
|
|
13439
13488
|
},
|
|
13440
|
-
position: new
|
|
13441
|
-
lookingAt: new
|
|
13489
|
+
position: new Vector314(50, 50, 50),
|
|
13490
|
+
lookingAt: new Vector314(0, 0, 0)
|
|
13442
13491
|
},
|
|
13443
13492
|
render: {
|
|
13444
13493
|
fpsLimit: 60,
|
|
@@ -13903,13 +13952,13 @@ var AnvilParser = class {
|
|
|
13903
13952
|
};
|
|
13904
13953
|
|
|
13905
13954
|
// src/world/Chunk.ts
|
|
13906
|
-
import { Vector3 as
|
|
13955
|
+
import { Vector3 as Vector317 } from "three";
|
|
13907
13956
|
init_BlockStates();
|
|
13908
13957
|
init_AssetKey();
|
|
13909
13958
|
|
|
13910
13959
|
// src/world/MineRenderWorld.ts
|
|
13911
13960
|
init_Model();
|
|
13912
|
-
import { Vector3 as
|
|
13961
|
+
import { Vector3 as Vector316 } from "three";
|
|
13913
13962
|
init_BatchedExecutor();
|
|
13914
13963
|
init_AssetKey();
|
|
13915
13964
|
init_BlockStates();
|
|
@@ -13919,7 +13968,7 @@ init_CubeFace();
|
|
|
13919
13968
|
init_AssetKey();
|
|
13920
13969
|
init_Models();
|
|
13921
13970
|
init_CubeFace();
|
|
13922
|
-
import { Matrix4 as Matrix412, Vector3 as
|
|
13971
|
+
import { Matrix4 as Matrix412, Vector3 as Vector315 } from "three";
|
|
13923
13972
|
init_ModelCulling();
|
|
13924
13973
|
init_ModelObject();
|
|
13925
13974
|
init_UVMapper();
|
|
@@ -13987,7 +14036,7 @@ var SectionModels = class {
|
|
|
13987
14036
|
const cullFaces = CUBE_FACES.map((face) => {
|
|
13988
14037
|
const local = CUBE_FACES.findIndex((name) => name === atlas.model.elements[0].faces[face]?.cullface);
|
|
13989
14038
|
if (local < 0) return 0;
|
|
13990
|
-
const normal = new
|
|
14039
|
+
const normal = new Vector315(...CUBE_FACE_OFFSETS[local]).applyEuler(rotation);
|
|
13991
14040
|
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);
|
|
13992
14041
|
return 1 << world;
|
|
13993
14042
|
});
|
|
@@ -14017,20 +14066,20 @@ var MineRenderWorld = class {
|
|
|
14017
14066
|
}
|
|
14018
14067
|
getBlockAt(posOrX, y, z) {
|
|
14019
14068
|
if (typeof posOrX == "number") {
|
|
14020
|
-
return this.getBlockAt(new
|
|
14069
|
+
return this.getBlockAt(new Vector316(posOrX, y, z));
|
|
14021
14070
|
}
|
|
14022
14071
|
if (isTripleArray(posOrX)) {
|
|
14023
|
-
return this.getBlockAt(new
|
|
14072
|
+
return this.getBlockAt(new Vector316(posOrX[0], posOrX[1], posOrX[2]));
|
|
14024
14073
|
}
|
|
14025
14074
|
this.validatePosBounds(posOrX);
|
|
14026
14075
|
return this.getChunkAt(posOrX)?.getBlockAt(posOrX);
|
|
14027
14076
|
}
|
|
14028
14077
|
async setBlockAt(posOrX, yOrBlock, z, block) {
|
|
14029
14078
|
if (typeof posOrX == "number") {
|
|
14030
|
-
return this.setBlockAt(new
|
|
14079
|
+
return this.setBlockAt(new Vector316(posOrX, yOrBlock, z), block);
|
|
14031
14080
|
}
|
|
14032
14081
|
if (isTripleArray(posOrX)) {
|
|
14033
|
-
return this.setBlockAt(new
|
|
14082
|
+
return this.setBlockAt(new Vector316(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
|
|
14034
14083
|
}
|
|
14035
14084
|
return this.placeBlock(posOrX, yOrBlock);
|
|
14036
14085
|
}
|
|
@@ -14051,7 +14100,7 @@ var MineRenderWorld = class {
|
|
|
14051
14100
|
const collect = async (positions2) => {
|
|
14052
14101
|
for (const pos of positions2) changes.set(pos.toArray().join(","), pos);
|
|
14053
14102
|
};
|
|
14054
|
-
const place = (block) => this.placeBlock(new
|
|
14103
|
+
const place = (block) => this.placeBlock(new Vector316(...block.position), block, collect);
|
|
14055
14104
|
const keys = /* @__PURE__ */ new Map();
|
|
14056
14105
|
for (const block of multiblock.blocks) {
|
|
14057
14106
|
if (Chunk.isAir(block)) continue;
|
|
@@ -14129,13 +14178,13 @@ var MineRenderWorld = class {
|
|
|
14129
14178
|
for (const pos of positions) {
|
|
14130
14179
|
this.pendingCulling.set(pos.toArray().join(","), pos.clone());
|
|
14131
14180
|
for (const offset of CUBE_FACE_OFFSETS) {
|
|
14132
|
-
const neighbor = pos.clone().add(new
|
|
14181
|
+
const neighbor = pos.clone().add(new Vector316(...offset));
|
|
14133
14182
|
this.pendingCulling.set(neighbor.toArray().join(","), neighbor);
|
|
14134
14183
|
}
|
|
14135
14184
|
for (let y = -1; y <= 1; y++) {
|
|
14136
14185
|
for (let z = -1; z <= 1; z++) {
|
|
14137
14186
|
for (let x = -1; x <= 1; x++) {
|
|
14138
|
-
const neighbor = pos.clone().add(new
|
|
14187
|
+
const neighbor = pos.clone().add(new Vector316(x, y, z));
|
|
14139
14188
|
if (this.getBlockAt(neighbor)?.object?.fluidKind) {
|
|
14140
14189
|
this.pendingCulling.set(neighbor.toArray().join(","), neighbor);
|
|
14141
14190
|
}
|
|
@@ -14157,7 +14206,7 @@ var MineRenderWorld = class {
|
|
|
14157
14206
|
if (!block) continue;
|
|
14158
14207
|
if (block.object?.fluidKind) {
|
|
14159
14208
|
await block.object.updateFluid((x, y, z) => {
|
|
14160
|
-
const neighbor = pos.clone().add(new
|
|
14209
|
+
const neighbor = pos.clone().add(new Vector316(x, y, z));
|
|
14161
14210
|
const section = this.getChunkAt(neighbor);
|
|
14162
14211
|
const object = section?.getBlockAt(neighbor)?.object;
|
|
14163
14212
|
return {
|
|
@@ -14169,7 +14218,7 @@ var MineRenderWorld = class {
|
|
|
14169
14218
|
}
|
|
14170
14219
|
let mask = 0;
|
|
14171
14220
|
for (const [face, offset] of CUBE_FACE_OFFSETS.entries()) {
|
|
14172
|
-
const neighbor = pos.clone().add(new
|
|
14221
|
+
const neighbor = pos.clone().add(new Vector316(...offset));
|
|
14173
14222
|
if (this.getChunkAt(neighbor)?.isOccludingAt(neighbor)) {
|
|
14174
14223
|
mask |= 1 << face;
|
|
14175
14224
|
}
|
|
@@ -14203,14 +14252,14 @@ var MineRenderWorld = class {
|
|
|
14203
14252
|
return this._chunks.get(this.worldPosToChunkKey(pos));
|
|
14204
14253
|
}
|
|
14205
14254
|
static worldToScenePosition(pos) {
|
|
14206
|
-
return new
|
|
14255
|
+
return new Vector316(
|
|
14207
14256
|
pos.x * 16,
|
|
14208
14257
|
pos.y * 16,
|
|
14209
14258
|
pos.z * 16
|
|
14210
14259
|
);
|
|
14211
14260
|
}
|
|
14212
14261
|
static sceneToWorldPosition(pos) {
|
|
14213
|
-
return new
|
|
14262
|
+
return new Vector316(
|
|
14214
14263
|
pos.x / 16,
|
|
14215
14264
|
pos.y / 16,
|
|
14216
14265
|
pos.z / 16
|
|
@@ -14354,10 +14403,10 @@ var Chunk = class _Chunk {
|
|
|
14354
14403
|
}
|
|
14355
14404
|
getBlockAt(posOrX, y, z) {
|
|
14356
14405
|
if (typeof posOrX == "number") {
|
|
14357
|
-
return this.getBlockAt(new
|
|
14406
|
+
return this.getBlockAt(new Vector317(posOrX, y, z));
|
|
14358
14407
|
}
|
|
14359
14408
|
if (isTripleArray(posOrX)) {
|
|
14360
|
-
return this.getBlockAt(new
|
|
14409
|
+
return this.getBlockAt(new Vector317(posOrX[0], posOrX[1], posOrX[2]));
|
|
14361
14410
|
}
|
|
14362
14411
|
const pos = this.worldPosToChunkPos(posOrX);
|
|
14363
14412
|
const index = _Chunk.chunkPosToBlockIndex(pos);
|
|
@@ -14365,10 +14414,10 @@ var Chunk = class _Chunk {
|
|
|
14365
14414
|
}
|
|
14366
14415
|
async setBlockAt(posOrX, yOrBlock, z, block) {
|
|
14367
14416
|
if (typeof posOrX == "number") {
|
|
14368
|
-
return this.setBlockAt(new
|
|
14417
|
+
return this.setBlockAt(new Vector317(posOrX, yOrBlock, z), block);
|
|
14369
14418
|
}
|
|
14370
14419
|
if (isTripleArray(posOrX)) {
|
|
14371
|
-
return this.setBlockAt(new
|
|
14420
|
+
return this.setBlockAt(new Vector317(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
|
|
14372
14421
|
}
|
|
14373
14422
|
const worldPos = posOrX;
|
|
14374
14423
|
const pos = this.worldPosToChunkPos(worldPos);
|
|
@@ -14454,7 +14503,7 @@ var Chunk = class _Chunk {
|
|
|
14454
14503
|
}
|
|
14455
14504
|
async clear(onBlocksChanged = this.onBlocksChanged) {
|
|
14456
14505
|
const positions = [...this.renderedBlocks.keys()].map((index) => this.chunkPosToWorldPos(
|
|
14457
|
-
new
|
|
14506
|
+
new Vector317(index % 16, Math.floor(index / 256), Math.floor(index / 16) % 16)
|
|
14458
14507
|
));
|
|
14459
14508
|
for (const info of this.renderedBlocks.values()) info.object?.removeFromScene();
|
|
14460
14509
|
this.sectionBlocks.clear();
|
|
@@ -14478,14 +14527,14 @@ var Chunk = class _Chunk {
|
|
|
14478
14527
|
return pos.y * 16 * 16 + pos.z * 16 + pos.x;
|
|
14479
14528
|
}
|
|
14480
14529
|
worldPosToChunkPos(pos) {
|
|
14481
|
-
return new
|
|
14530
|
+
return new Vector317(
|
|
14482
14531
|
pos.x - this.x * 16,
|
|
14483
14532
|
pos.y - this.y * 16,
|
|
14484
14533
|
pos.z - this.z * 16
|
|
14485
14534
|
);
|
|
14486
14535
|
}
|
|
14487
14536
|
chunkPosToWorldPos(pos) {
|
|
14488
|
-
return new
|
|
14537
|
+
return new Vector317(
|
|
14489
14538
|
this.x * 16 + pos.x,
|
|
14490
14539
|
this.y * 16 + pos.y,
|
|
14491
14540
|
this.z * 16 + pos.z
|