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/node/index.mjs
CHANGED
|
@@ -3322,11 +3322,11 @@ var init_Entities = __esm({
|
|
|
3322
3322
|
return { ...layers[names[0]], id: model.id, layers, ...model.transform && { transform: model.transform } };
|
|
3323
3323
|
}
|
|
3324
3324
|
/**
|
|
3325
|
-
*
|
|
3325
|
+
* Native and sampled vanilla clips by name, or undefined when the model or selected version has none.
|
|
3326
3326
|
*/
|
|
3327
3327
|
static async getAnimations(modelKey) {
|
|
3328
3328
|
const path = isAssetKey(modelKey) ? modelKey.getFullPath() : modelKey.path;
|
|
3329
|
-
const key = new AssetKey(modelKey.namespace, path, void 0, void 0, "entity-models/animations", ".json");
|
|
3329
|
+
const key = new AssetKey(modelKey.namespace, path, void 0, void 0, "entity-models/animations", ".json", isAssetKey(modelKey) ? modelKey.root : void 0);
|
|
3330
3330
|
const file = await Caching.entityAnimationCache.get(key.serialize(), () => AssetLoader.get(key, "json" /* JSON */));
|
|
3331
3331
|
return file?.animations;
|
|
3332
3332
|
}
|
|
@@ -3376,7 +3376,7 @@ function sampleEntityKeyframes(keyframes, time) {
|
|
|
3376
3376
|
let low = 0, high = keyframes.length;
|
|
3377
3377
|
while (low < high) {
|
|
3378
3378
|
const middle = low + high >>> 1;
|
|
3379
|
-
if (time
|
|
3379
|
+
if (time < keyframes[middle].time) high = middle;
|
|
3380
3380
|
else low = middle + 1;
|
|
3381
3381
|
}
|
|
3382
3382
|
const a = Math.max(0, low - 1);
|
|
@@ -3415,6 +3415,7 @@ var init_EntityAnimation = __esm({
|
|
|
3415
3415
|
});
|
|
3416
3416
|
|
|
3417
3417
|
// src/entity/scene/EntityAnimationPlayer.ts
|
|
3418
|
+
import { Euler as Euler3, Vector3 as Vector35 } from "three";
|
|
3418
3419
|
var ZERO, EntityAnimationPlayer;
|
|
3419
3420
|
var init_EntityAnimationPlayer = __esm({
|
|
3420
3421
|
"src/entity/scene/EntityAnimationPlayer.ts"() {
|
|
@@ -3434,25 +3435,45 @@ var init_EntityAnimationPlayer = __esm({
|
|
|
3434
3435
|
return this._time;
|
|
3435
3436
|
}
|
|
3436
3437
|
/**
|
|
3437
|
-
* Starts an animation on
|
|
3438
|
-
*
|
|
3438
|
+
* Starts an animation on matching named parts. Supplied baked poses are the baseline for offsets;
|
|
3439
|
+
* without them, the current pose is used. Stopping restores the pose from before playback.
|
|
3439
3440
|
*/
|
|
3440
|
-
play(layers, animation, options = {}) {
|
|
3441
|
+
play(layers, animation, options = {}, poses) {
|
|
3441
3442
|
this.stop();
|
|
3442
3443
|
this._animation = animation;
|
|
3443
3444
|
this._time = options.time ?? 0;
|
|
3444
3445
|
this.loop = options.loop ?? animation.loop;
|
|
3445
3446
|
this.speed = options.speed ?? 1;
|
|
3446
3447
|
for (const layer of layers) {
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3448
|
+
const objects = [];
|
|
3449
|
+
if (poses) {
|
|
3450
|
+
layer.traverse((object) => {
|
|
3451
|
+
if (poses.has(object)) objects.push(object);
|
|
3452
|
+
});
|
|
3453
|
+
} else {
|
|
3454
|
+
for (const bone of Object.keys(animation.bones)) {
|
|
3455
|
+
const object = layer.getObjectByName(`group:${bone}`);
|
|
3456
|
+
if (object) objects.push(object);
|
|
3457
|
+
}
|
|
3458
|
+
}
|
|
3459
|
+
for (const object of objects) {
|
|
3460
|
+
const bone = object.name.slice("group:".length);
|
|
3461
|
+
const pose = poses?.get(object);
|
|
3462
|
+
this.parts.push({
|
|
3463
|
+
bone,
|
|
3464
|
+
object,
|
|
3465
|
+
position: object.position.clone(),
|
|
3466
|
+
rotation: object.rotation.clone(),
|
|
3467
|
+
scale: object.scale.clone(),
|
|
3468
|
+
basePosition: pose ? new Vector35(...pose.offset) : object.position.clone(),
|
|
3469
|
+
baseRotation: pose ? new Euler3(...pose.rotation, "ZYX") : object.rotation.clone(),
|
|
3470
|
+
baseScale: pose ? new Vector35(...pose.scale ?? [1, 1, 1]) : object.scale.clone()
|
|
3471
|
+
});
|
|
3451
3472
|
}
|
|
3452
3473
|
}
|
|
3453
3474
|
this.apply();
|
|
3454
3475
|
}
|
|
3455
|
-
/** Restores the
|
|
3476
|
+
/** Restores the poses from before playback. Returns whether an animation was active. */
|
|
3456
3477
|
stop() {
|
|
3457
3478
|
if (!this._animation) return false;
|
|
3458
3479
|
for (const part of this.parts) {
|
|
@@ -3481,10 +3502,10 @@ var init_EntityAnimationPlayer = __esm({
|
|
|
3481
3502
|
apply() {
|
|
3482
3503
|
const pose = sampleEntityAnimation(this._animation, this._time, this.loop);
|
|
3483
3504
|
for (const part of this.parts) {
|
|
3484
|
-
const { position = ZERO, rotation = ZERO, scale = ZERO } = pose[part.bone];
|
|
3485
|
-
part.object.position.set(part.
|
|
3486
|
-
part.object.rotation.set(part.
|
|
3487
|
-
part.object.scale.set(part.
|
|
3505
|
+
const { position = ZERO, rotation = ZERO, scale = ZERO } = pose[part.bone] ?? {};
|
|
3506
|
+
part.object.position.set(part.basePosition.x + position[0], part.basePosition.y + position[1], part.basePosition.z + position[2]);
|
|
3507
|
+
part.object.rotation.set(part.baseRotation.x + rotation[0], part.baseRotation.y + rotation[1], part.baseRotation.z + rotation[2], part.baseRotation.order);
|
|
3508
|
+
part.object.scale.set(part.baseScale.x + scale[0], part.baseScale.y + scale[1], part.baseScale.z + scale[2]);
|
|
3488
3509
|
}
|
|
3489
3510
|
}
|
|
3490
3511
|
};
|
|
@@ -3551,7 +3572,7 @@ var init_InstanceReference = __esm({
|
|
|
3551
3572
|
});
|
|
3552
3573
|
|
|
3553
3574
|
// src/renderer/SceneObject.ts
|
|
3554
|
-
import { Color as Color2, Euler as
|
|
3575
|
+
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";
|
|
3555
3576
|
function isSceneObject(obj) {
|
|
3556
3577
|
return obj.isSceneObject;
|
|
3557
3578
|
}
|
|
@@ -3826,9 +3847,9 @@ var init_SceneObject = __esm({
|
|
|
3826
3847
|
}
|
|
3827
3848
|
setPositionRotationScaleAt(index, position, rotation, scale) {
|
|
3828
3849
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3829
|
-
const oldPosition = new
|
|
3850
|
+
const oldPosition = new Vector36();
|
|
3830
3851
|
const oldRotation = new Quaternion3();
|
|
3831
|
-
const oldScale = new
|
|
3852
|
+
const oldScale = new Vector36();
|
|
3832
3853
|
const matrix = new Matrix44();
|
|
3833
3854
|
if (!scale || !rotation || !position) {
|
|
3834
3855
|
this.getMatrixAt(index, matrix).decompose(oldPosition, oldRotation, oldScale);
|
|
@@ -3844,7 +3865,7 @@ var init_SceneObject = __esm({
|
|
|
3844
3865
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3845
3866
|
this.setPositionRotationScaleAt(index, position);
|
|
3846
3867
|
}
|
|
3847
|
-
getPositionAt(index, vector = new
|
|
3868
|
+
getPositionAt(index, vector = new Vector36()) {
|
|
3848
3869
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3849
3870
|
const matrix = this.getMatrixAt(index);
|
|
3850
3871
|
vector.setFromMatrixPosition(matrix);
|
|
@@ -3854,17 +3875,17 @@ var init_SceneObject = __esm({
|
|
|
3854
3875
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3855
3876
|
this.setPositionRotationScaleAt(index, void 0, rotation, void 0);
|
|
3856
3877
|
}
|
|
3857
|
-
getRotationAt(index, euler = new
|
|
3878
|
+
getRotationAt(index, euler = new Euler4()) {
|
|
3858
3879
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3859
3880
|
const rotation = new Quaternion3();
|
|
3860
|
-
this.getMatrixAt(index).decompose(new
|
|
3881
|
+
this.getMatrixAt(index).decompose(new Vector36(), rotation, new Vector36());
|
|
3861
3882
|
return euler.setFromQuaternion(rotation);
|
|
3862
3883
|
}
|
|
3863
3884
|
setScaleAt(index, scale) {
|
|
3864
3885
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3865
3886
|
this.setPositionRotationScaleAt(index, void 0, void 0, scale);
|
|
3866
3887
|
}
|
|
3867
|
-
getScaleAt(index, vector = new
|
|
3888
|
+
getScaleAt(index, vector = new Vector36()) {
|
|
3868
3889
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3869
3890
|
const matrix = this.getMatrixAt(index);
|
|
3870
3891
|
vector.setFromMatrixScale(matrix);
|
|
@@ -3989,7 +4010,7 @@ var init_SceneObject = __esm({
|
|
|
3989
4010
|
});
|
|
3990
4011
|
|
|
3991
4012
|
// src/entity/scene/EntityObject.ts
|
|
3992
|
-
import { Color as Color3, Euler as
|
|
4013
|
+
import { Color as Color3, Euler as Euler5, Matrix4 as Matrix45, Object3D as Object3D3 } from "three";
|
|
3993
4014
|
function isEntityObject(obj) {
|
|
3994
4015
|
return obj.isEntityObject;
|
|
3995
4016
|
}
|
|
@@ -4019,7 +4040,8 @@ var init_EntityObject = __esm({
|
|
|
4019
4040
|
this.scrollMaterials = [];
|
|
4020
4041
|
/** Entity age in ticks, as vanilla's `ageInTicks`; drives the scrolling render modes. */
|
|
4021
4042
|
this.age = 0;
|
|
4022
|
-
this.
|
|
4043
|
+
this.animationPlayers = [];
|
|
4044
|
+
this.partPoses = /* @__PURE__ */ new Map();
|
|
4023
4045
|
this.options = (0, import_ts_deepmerge4.default)({}, _EntityObject.DEFAULT_OPTIONS, options ?? {});
|
|
4024
4046
|
this.addEventListener("added", () => this.updateScrollSubscription());
|
|
4025
4047
|
this.addEventListener("removed", () => this.updateScrollSubscription());
|
|
@@ -4039,7 +4061,8 @@ var init_EntityObject = __esm({
|
|
|
4039
4061
|
for (const geometry of this.geometries) geometry.dispose();
|
|
4040
4062
|
this.geometries.clear();
|
|
4041
4063
|
for (const dispose of this.disposeWireframes.splice(0)) dispose();
|
|
4042
|
-
this.
|
|
4064
|
+
for (const player of this.animationPlayers.splice(0)) player.clear();
|
|
4065
|
+
this.partPoses.clear();
|
|
4043
4066
|
super.disposeAndRemoveAllChildren();
|
|
4044
4067
|
}
|
|
4045
4068
|
clearScrollMaterials() {
|
|
@@ -4071,36 +4094,61 @@ var init_EntityObject = __esm({
|
|
|
4071
4094
|
this.notifyDirty();
|
|
4072
4095
|
}
|
|
4073
4096
|
//<editor-fold desc="ANIMATION">
|
|
4074
|
-
/** The
|
|
4097
|
+
/** The first active clip, until playback is stopped or the object is disposed. */
|
|
4075
4098
|
get animation() {
|
|
4076
|
-
return this.
|
|
4099
|
+
return this.animationPlayers[0]?.animation;
|
|
4100
|
+
}
|
|
4101
|
+
/** Clips playing together, each targeting a separate geometry layer. */
|
|
4102
|
+
get activeAnimations() {
|
|
4103
|
+
return this.animationPlayers.map((player) => player.animation);
|
|
4077
4104
|
}
|
|
4078
4105
|
/** Seconds since the animation started, before looping. */
|
|
4079
4106
|
get animationTime() {
|
|
4080
|
-
return this.
|
|
4107
|
+
return this.animationPlayers[0]?.time ?? 0;
|
|
4081
4108
|
}
|
|
4082
4109
|
/**
|
|
4083
|
-
*
|
|
4084
|
-
*
|
|
4110
|
+
* Plays a clip from {@link Entities.getAnimations}, replacing all active clips.
|
|
4111
|
+
* Offsets apply to the baked pose in the clip's layer (`main` by default), including repeated draws of that layer.
|
|
4085
4112
|
* The object owns no clock: call {@link advanceAnimation} per frame, or {@link setAnimationTime}.
|
|
4086
4113
|
*/
|
|
4087
4114
|
playAnimation(animation, options) {
|
|
4115
|
+
this.playAnimations([animation], options);
|
|
4116
|
+
}
|
|
4117
|
+
/** Plays one clip per selected geometry layer, with a shared clock and no blending between clips. */
|
|
4118
|
+
playAnimations(animations, options) {
|
|
4119
|
+
const targets = /* @__PURE__ */ new Set();
|
|
4120
|
+
const selections = animations.map((animation) => {
|
|
4121
|
+
const layer = animation.layer ?? "main";
|
|
4122
|
+
if (targets.has(layer)) throw new Error(`Multiple animations target layer "${layer}"`);
|
|
4123
|
+
targets.add(layer);
|
|
4124
|
+
const names = Object.keys(this.entityLayers).filter((name) => name.split("#")[0] === layer);
|
|
4125
|
+
if (!names.length) throw new Error(`Entity ${this.entity.id} has no selected animation layer "${layer}"`);
|
|
4126
|
+
return { animation, names };
|
|
4127
|
+
});
|
|
4088
4128
|
this.createMeshes();
|
|
4089
|
-
|
|
4090
|
-
|
|
4129
|
+
this.stopAnimation();
|
|
4130
|
+
for (const { animation, names } of selections) {
|
|
4131
|
+
const player = new EntityAnimationPlayer();
|
|
4132
|
+
player.play(names.map((name) => this.getLayerGroup(name)), animation, options, this.partPoses);
|
|
4133
|
+
this.animationPlayers.push(player);
|
|
4134
|
+
}
|
|
4091
4135
|
this.notifyDirty();
|
|
4092
4136
|
}
|
|
4093
|
-
/** Stops
|
|
4137
|
+
/** Stops all clips and restores the poses from before playback. */
|
|
4094
4138
|
stopAnimation() {
|
|
4095
|
-
|
|
4139
|
+
const players = this.animationPlayers.splice(0);
|
|
4140
|
+
for (const player of players) player.stop();
|
|
4141
|
+
if (players.length) this.notifyDirty();
|
|
4096
4142
|
}
|
|
4097
4143
|
/** Poses the object at an explicit time in seconds. Has no effect without an animation. */
|
|
4098
4144
|
setAnimationTime(seconds) {
|
|
4099
|
-
|
|
4145
|
+
for (const player of this.animationPlayers) player.setTime(seconds);
|
|
4146
|
+
if (this.animationPlayers.length) this.notifyDirty();
|
|
4100
4147
|
}
|
|
4101
4148
|
/** Advances the animation by a frame delta in seconds, scaled by its speed. Has no effect without an animation. */
|
|
4102
4149
|
advanceAnimation(deltaSeconds) {
|
|
4103
|
-
|
|
4150
|
+
for (const player of this.animationPlayers) player.advance(deltaSeconds);
|
|
4151
|
+
if (this.animationPlayers.length) this.notifyDirty();
|
|
4104
4152
|
}
|
|
4105
4153
|
//</editor-fold>
|
|
4106
4154
|
getLayerGroup(name) {
|
|
@@ -4139,7 +4187,7 @@ var init_EntityObject = __esm({
|
|
|
4139
4187
|
const matrix = new Matrix45();
|
|
4140
4188
|
if ("scale" in op) matrix.makeScale(...op.scale);
|
|
4141
4189
|
else if ("translate" in op) matrix.makeTranslation(...op.translate);
|
|
4142
|
-
else matrix.makeRotationFromEuler(new
|
|
4190
|
+
else matrix.makeRotationFromEuler(new Euler5(...op.rotate, "ZYX"));
|
|
4143
4191
|
modelRoot.matrix.multiply(matrix);
|
|
4144
4192
|
}
|
|
4145
4193
|
modelRoot.matrixAutoUpdate = false;
|
|
@@ -4160,6 +4208,7 @@ var init_EntityObject = __esm({
|
|
|
4160
4208
|
anchor.position.fromArray(part.pose.offset);
|
|
4161
4209
|
anchor.rotation.set(...part.pose.rotation, "ZYX");
|
|
4162
4210
|
anchor.scale.fromArray(part.pose.scale ?? [1, 1, 1]);
|
|
4211
|
+
this.partPoses.set(anchor, part.pose);
|
|
4163
4212
|
parent.add(anchor);
|
|
4164
4213
|
const size = part.texture ?? textureSize;
|
|
4165
4214
|
for (const cube of part.cubes) {
|
|
@@ -4234,7 +4283,7 @@ import {
|
|
|
4234
4283
|
TriangleFanDrawMode,
|
|
4235
4284
|
TriangleStripDrawMode,
|
|
4236
4285
|
TrianglesDrawMode,
|
|
4237
|
-
Vector3 as
|
|
4286
|
+
Vector3 as Vector310
|
|
4238
4287
|
} from "three";
|
|
4239
4288
|
function computeTangents(geometry) {
|
|
4240
4289
|
geometry.computeTangents();
|
|
@@ -4553,15 +4602,15 @@ function computeMorphedAttributes(object) {
|
|
|
4553
4602
|
console.error("THREE.BufferGeometryUtils: Geometry is not of type BufferGeometry.");
|
|
4554
4603
|
return null;
|
|
4555
4604
|
}
|
|
4556
|
-
const _vA = new
|
|
4557
|
-
const _vB = new
|
|
4558
|
-
const _vC = new
|
|
4559
|
-
const _tempA = new
|
|
4560
|
-
const _tempB = new
|
|
4561
|
-
const _tempC = new
|
|
4562
|
-
const _morphA = new
|
|
4563
|
-
const _morphB = new
|
|
4564
|
-
const _morphC = new
|
|
4605
|
+
const _vA = new Vector310();
|
|
4606
|
+
const _vB = new Vector310();
|
|
4607
|
+
const _vC = new Vector310();
|
|
4608
|
+
const _tempA = new Vector310();
|
|
4609
|
+
const _tempB = new Vector310();
|
|
4610
|
+
const _tempC = new Vector310();
|
|
4611
|
+
const _morphA = new Vector310();
|
|
4612
|
+
const _morphB = new Vector310();
|
|
4613
|
+
const _morphC = new Vector310();
|
|
4565
4614
|
function _calculateMorphedAttributeData(object2, material2, attribute, morphAttribute, morphTargetsRelative2, a2, b2, c2, modifiedAttributeArray) {
|
|
4566
4615
|
_vA.fromBufferAttribute(attribute, a2);
|
|
4567
4616
|
_vB.fromBufferAttribute(attribute, b2);
|
|
@@ -4771,7 +4820,7 @@ var init_BufferGeometryUtils = __esm({
|
|
|
4771
4820
|
});
|
|
4772
4821
|
|
|
4773
4822
|
// src/model/ModelCulling.ts
|
|
4774
|
-
import { Vector3 as
|
|
4823
|
+
import { Vector3 as Vector311 } from "three";
|
|
4775
4824
|
var ModelCulling;
|
|
4776
4825
|
var init_ModelCulling = __esm({
|
|
4777
4826
|
"src/model/ModelCulling.ts"() {
|
|
@@ -4780,7 +4829,7 @@ var init_ModelCulling = __esm({
|
|
|
4780
4829
|
static toLocalMask(worldMask, rotation) {
|
|
4781
4830
|
let localMask = 0;
|
|
4782
4831
|
for (const [localFace, offset] of CUBE_FACE_OFFSETS.entries()) {
|
|
4783
|
-
const normal = new
|
|
4832
|
+
const normal = new Vector311(...offset).applyEuler(rotation);
|
|
4784
4833
|
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);
|
|
4785
4834
|
if (worldFace < 0) return 0;
|
|
4786
4835
|
if (worldMask & 1 << worldFace) localMask |= 1 << localFace;
|
|
@@ -5007,7 +5056,7 @@ var init_ItemTints = __esm({
|
|
|
5007
5056
|
});
|
|
5008
5057
|
|
|
5009
5058
|
// src/model/scene/ModelObject.ts
|
|
5010
|
-
import { BoxGeometry as BoxGeometry5, BufferAttribute as BufferAttribute5, Color as Color8, Euler as
|
|
5059
|
+
import { BoxGeometry as BoxGeometry5, BufferAttribute as BufferAttribute5, Color as Color8, Euler as Euler7, Matrix4 as Matrix49 } from "three";
|
|
5011
5060
|
function isModelObject(obj) {
|
|
5012
5061
|
return obj.isModelObject;
|
|
5013
5062
|
}
|
|
@@ -5114,7 +5163,7 @@ var init_ModelObject = __esm({
|
|
|
5114
5163
|
elGeo.clearGroups();
|
|
5115
5164
|
}
|
|
5116
5165
|
if (this.options.uvLockRotation) {
|
|
5117
|
-
UVMapper.lockUvs(elGeo, el.faces, this.atlas, new
|
|
5166
|
+
UVMapper.lockUvs(elGeo, el.faces, this.atlas, new Euler7(...this.options.uvLockRotation));
|
|
5118
5167
|
}
|
|
5119
5168
|
if (this.options.tints) {
|
|
5120
5169
|
const colors = new Float32Array(elGeo.getAttribute("position").count * 3).fill(1);
|
|
@@ -5735,7 +5784,7 @@ import {
|
|
|
5735
5784
|
Color as Color4,
|
|
5736
5785
|
Matrix3,
|
|
5737
5786
|
Vector2 as Vector22,
|
|
5738
|
-
Vector3 as
|
|
5787
|
+
Vector3 as Vector37
|
|
5739
5788
|
} from "three";
|
|
5740
5789
|
var OBJExporter = class {
|
|
5741
5790
|
parse(object) {
|
|
@@ -5743,9 +5792,9 @@ var OBJExporter = class {
|
|
|
5743
5792
|
let indexVertex = 0;
|
|
5744
5793
|
let indexVertexUvs = 0;
|
|
5745
5794
|
let indexNormals = 0;
|
|
5746
|
-
const vertex = new
|
|
5795
|
+
const vertex = new Vector37();
|
|
5747
5796
|
const color = new Color4();
|
|
5748
|
-
const normal = new
|
|
5797
|
+
const normal = new Vector37();
|
|
5749
5798
|
const uv = new Vector22();
|
|
5750
5799
|
const face = [];
|
|
5751
5800
|
function parseMesh(mesh) {
|
|
@@ -5874,7 +5923,7 @@ var OBJExporter = class {
|
|
|
5874
5923
|
// ../../node_modules/three/examples/jsm/exporters/PLYExporter.js
|
|
5875
5924
|
import {
|
|
5876
5925
|
Matrix3 as Matrix32,
|
|
5877
|
-
Vector3 as
|
|
5926
|
+
Vector3 as Vector38,
|
|
5878
5927
|
Color as Color5
|
|
5879
5928
|
} from "three";
|
|
5880
5929
|
var PLYExporter = class {
|
|
@@ -5967,7 +6016,7 @@ property list uchar int vertex_index
|
|
|
5967
6016
|
`;
|
|
5968
6017
|
}
|
|
5969
6018
|
header += "end_header\n";
|
|
5970
|
-
const vertex = new
|
|
6019
|
+
const vertex = new Vector38();
|
|
5971
6020
|
const normalMatrixWorld = new Matrix32();
|
|
5972
6021
|
let result = null;
|
|
5973
6022
|
if (options.binary === true) {
|
|
@@ -6166,7 +6215,7 @@ import {
|
|
|
6166
6215
|
Source,
|
|
6167
6216
|
SRGBColorSpace as SRGBColorSpace4,
|
|
6168
6217
|
CompressedTexture,
|
|
6169
|
-
Vector3 as
|
|
6218
|
+
Vector3 as Vector39,
|
|
6170
6219
|
Quaternion as Quaternion4
|
|
6171
6220
|
} from "three";
|
|
6172
6221
|
|
|
@@ -6627,7 +6676,7 @@ var GLTFWriter = class {
|
|
|
6627
6676
|
isNormalizedNormalAttribute(normal) {
|
|
6628
6677
|
const cache = this.cache;
|
|
6629
6678
|
if (cache.attributesNormalized.has(normal)) return false;
|
|
6630
|
-
const v = new
|
|
6679
|
+
const v = new Vector39();
|
|
6631
6680
|
for (let i = 0, il = normal.count; i < il; i++) {
|
|
6632
6681
|
if (Math.abs(v.fromBufferAttribute(normal, i).length() - 1) > 5e-4) return false;
|
|
6633
6682
|
}
|
|
@@ -6644,7 +6693,7 @@ var GLTFWriter = class {
|
|
|
6644
6693
|
const cache = this.cache;
|
|
6645
6694
|
if (cache.attributesNormalized.has(normal)) return cache.attributesNormalized.get(normal);
|
|
6646
6695
|
const attribute = normal.clone();
|
|
6647
|
-
const v = new
|
|
6696
|
+
const v = new Vector39();
|
|
6648
6697
|
for (let i = 0, il = attribute.count; i < il; i++) {
|
|
6649
6698
|
v.fromBufferAttribute(attribute, i);
|
|
6650
6699
|
if (v.x === 0 && v.y === 0 && v.z === 0) {
|
|
@@ -7911,9 +7960,9 @@ var GLTFMeshGpuInstancing = class {
|
|
|
7911
7960
|
const rotationAttr = new Float32Array(mesh.count * 4);
|
|
7912
7961
|
const scaleAttr = new Float32Array(mesh.count * 3);
|
|
7913
7962
|
const matrix = new Matrix46();
|
|
7914
|
-
const position = new
|
|
7963
|
+
const position = new Vector39();
|
|
7915
7964
|
const quaternion = new Quaternion4();
|
|
7916
|
-
const scale = new
|
|
7965
|
+
const scale = new Vector39();
|
|
7917
7966
|
for (let i = 0; i < mesh.count; i++) {
|
|
7918
7967
|
mesh.getMatrixAt(i, matrix);
|
|
7919
7968
|
matrix.decompose(position, quaternion, scale);
|
|
@@ -8906,7 +8955,7 @@ init_SpecialItems();
|
|
|
8906
8955
|
init_BlockStates();
|
|
8907
8956
|
init_MineRenderError();
|
|
8908
8957
|
init_util();
|
|
8909
|
-
import { Euler as
|
|
8958
|
+
import { Euler as Euler8 } from "three";
|
|
8910
8959
|
function matchesCondition(condition, state) {
|
|
8911
8960
|
return Object.entries(condition).every(([key, value]) => {
|
|
8912
8961
|
if (Array.isArray(value)) {
|
|
@@ -8981,7 +9030,7 @@ var BlockStateResolver = class {
|
|
|
8981
9030
|
return variants[variants.length - 1];
|
|
8982
9031
|
}
|
|
8983
9032
|
static rotation(variant) {
|
|
8984
|
-
const rotation = new
|
|
9033
|
+
const rotation = new Euler8();
|
|
8985
9034
|
if (typeof variant.x !== "undefined") {
|
|
8986
9035
|
rotation.x = toRadians(clampRotationDegrees(variant.x));
|
|
8987
9036
|
}
|
|
@@ -9076,7 +9125,7 @@ var import_ts_deepmerge6 = __toESM(require_dist());
|
|
|
9076
9125
|
init_MineRenderError();
|
|
9077
9126
|
init_InstanceReference();
|
|
9078
9127
|
init_AssetKey();
|
|
9079
|
-
import { Euler as
|
|
9128
|
+
import { Euler as Euler9, Matrix4 as Matrix411, Quaternion as Quaternion5, Vector3 as Vector312 } from "three";
|
|
9080
9129
|
init_ModelCulling();
|
|
9081
9130
|
init_FluidGeometry();
|
|
9082
9131
|
init_Entities();
|
|
@@ -9199,12 +9248,12 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
9199
9248
|
getModelCullMask(model, worldMask) {
|
|
9200
9249
|
const object = isInstanceReference(model) ? model.instanceable : model;
|
|
9201
9250
|
if (object.options.displayPosition) return 0;
|
|
9202
|
-
const position = new
|
|
9251
|
+
const position = new Vector312();
|
|
9203
9252
|
const rotation = new Quaternion5();
|
|
9204
|
-
const scale = new
|
|
9253
|
+
const scale = new Vector312();
|
|
9205
9254
|
this.getModelMatrix(model).decompose(position, rotation, scale);
|
|
9206
|
-
if (position.distanceToSquared(this.position) > 1e-10 || scale.distanceToSquared(new
|
|
9207
|
-
return ModelCulling.toLocalMask(worldMask, new
|
|
9255
|
+
if (position.distanceToSquared(this.position) > 1e-10 || scale.distanceToSquared(new Vector312(1, 1, 1)) > 1e-10) return 0;
|
|
9256
|
+
return ModelCulling.toLocalMask(worldMask, new Euler9().setFromQuaternion(rotation));
|
|
9208
9257
|
}
|
|
9209
9258
|
async setCullMask(worldMask) {
|
|
9210
9259
|
worldMask &= 63;
|
|
@@ -12451,7 +12500,7 @@ function isMineRenderScene(obj) {
|
|
|
12451
12500
|
}
|
|
12452
12501
|
|
|
12453
12502
|
// src/renderer/Renderer.ts
|
|
12454
|
-
import { AxesHelper as AxesHelper2, GridHelper, OrthographicCamera, PCFSoftShadowMap, PerspectiveCamera as PerspectiveCamera2, SRGBColorSpace as SRGBColorSpace6, Vector3 as
|
|
12503
|
+
import { AxesHelper as AxesHelper2, GridHelper, OrthographicCamera, PCFSoftShadowMap, PerspectiveCamera as PerspectiveCamera2, SRGBColorSpace as SRGBColorSpace6, Vector3 as Vector314, WebGLRenderer as WebGLRenderer2 } from "three";
|
|
12455
12504
|
var import_ts_deepmerge9 = __toESM(require_dist());
|
|
12456
12505
|
init_util();
|
|
12457
12506
|
init_Model();
|
|
@@ -12467,7 +12516,7 @@ import {
|
|
|
12467
12516
|
Spherical,
|
|
12468
12517
|
TOUCH,
|
|
12469
12518
|
Vector2 as Vector25,
|
|
12470
|
-
Vector3 as
|
|
12519
|
+
Vector3 as Vector313
|
|
12471
12520
|
} from "three";
|
|
12472
12521
|
var _changeEvent = { type: "change" };
|
|
12473
12522
|
var _startEvent = { type: "start" };
|
|
@@ -12481,7 +12530,7 @@ var OrbitControls = class extends EventDispatcher {
|
|
|
12481
12530
|
this.domElement = domElement;
|
|
12482
12531
|
this.domElement.style.touchAction = "none";
|
|
12483
12532
|
this.enabled = true;
|
|
12484
|
-
this.target = new
|
|
12533
|
+
this.target = new Vector313();
|
|
12485
12534
|
this.minDistance = 0;
|
|
12486
12535
|
this.maxDistance = Infinity;
|
|
12487
12536
|
this.minZoom = 0;
|
|
@@ -12533,10 +12582,10 @@ var OrbitControls = class extends EventDispatcher {
|
|
|
12533
12582
|
state = STATE.NONE;
|
|
12534
12583
|
};
|
|
12535
12584
|
this.update = function() {
|
|
12536
|
-
const offset = new
|
|
12537
|
-
const quat = new Quaternion6().setFromUnitVectors(object.up, new
|
|
12585
|
+
const offset = new Vector313();
|
|
12586
|
+
const quat = new Quaternion6().setFromUnitVectors(object.up, new Vector313(0, 1, 0));
|
|
12538
12587
|
const quatInverse = quat.clone().invert();
|
|
12539
|
-
const lastPosition = new
|
|
12588
|
+
const lastPosition = new Vector313();
|
|
12540
12589
|
const lastQuaternion = new Quaternion6();
|
|
12541
12590
|
const twoPI = 2 * Math.PI;
|
|
12542
12591
|
return function update() {
|
|
@@ -12626,7 +12675,7 @@ var OrbitControls = class extends EventDispatcher {
|
|
|
12626
12675
|
const spherical = new Spherical();
|
|
12627
12676
|
const sphericalDelta = new Spherical();
|
|
12628
12677
|
let scale = 1;
|
|
12629
|
-
const panOffset = new
|
|
12678
|
+
const panOffset = new Vector313();
|
|
12630
12679
|
let zoomChanged = false;
|
|
12631
12680
|
const rotateStart = new Vector25();
|
|
12632
12681
|
const rotateEnd = new Vector25();
|
|
@@ -12652,7 +12701,7 @@ var OrbitControls = class extends EventDispatcher {
|
|
|
12652
12701
|
sphericalDelta.phi -= angle;
|
|
12653
12702
|
}
|
|
12654
12703
|
const panLeft = function() {
|
|
12655
|
-
const v = new
|
|
12704
|
+
const v = new Vector313();
|
|
12656
12705
|
return function panLeft2(distance, objectMatrix) {
|
|
12657
12706
|
v.setFromMatrixColumn(objectMatrix, 0);
|
|
12658
12707
|
v.multiplyScalar(-distance);
|
|
@@ -12660,7 +12709,7 @@ var OrbitControls = class extends EventDispatcher {
|
|
|
12660
12709
|
};
|
|
12661
12710
|
}();
|
|
12662
12711
|
const panUp = function() {
|
|
12663
|
-
const v = new
|
|
12712
|
+
const v = new Vector313();
|
|
12664
12713
|
return function panUp2(distance, objectMatrix) {
|
|
12665
12714
|
if (scope.screenSpacePanning === true) {
|
|
12666
12715
|
v.setFromMatrixColumn(objectMatrix, 1);
|
|
@@ -12673,7 +12722,7 @@ var OrbitControls = class extends EventDispatcher {
|
|
|
12673
12722
|
};
|
|
12674
12723
|
}();
|
|
12675
12724
|
const pan = function() {
|
|
12676
|
-
const offset = new
|
|
12725
|
+
const offset = new Vector313();
|
|
12677
12726
|
return function pan2(deltaX, deltaY) {
|
|
12678
12727
|
const element = scope.domElement;
|
|
12679
12728
|
if (scope.object.isPerspectiveCamera) {
|
|
@@ -13164,8 +13213,8 @@ var Renderer = class _Renderer {
|
|
|
13164
13213
|
top: void 0,
|
|
13165
13214
|
bottom: void 0
|
|
13166
13215
|
},
|
|
13167
|
-
position: new
|
|
13168
|
-
lookingAt: new
|
|
13216
|
+
position: new Vector314(50, 50, 50),
|
|
13217
|
+
lookingAt: new Vector314(0, 0, 0)
|
|
13169
13218
|
},
|
|
13170
13219
|
render: {
|
|
13171
13220
|
fpsLimit: 60,
|
|
@@ -13957,13 +14006,13 @@ var AnvilParser = class {
|
|
|
13957
14006
|
};
|
|
13958
14007
|
|
|
13959
14008
|
// src/world/Chunk.ts
|
|
13960
|
-
import { Vector3 as
|
|
14009
|
+
import { Vector3 as Vector317 } from "three";
|
|
13961
14010
|
init_BlockStates();
|
|
13962
14011
|
init_AssetKey();
|
|
13963
14012
|
|
|
13964
14013
|
// src/world/MineRenderWorld.ts
|
|
13965
14014
|
init_Model();
|
|
13966
|
-
import { Vector3 as
|
|
14015
|
+
import { Vector3 as Vector316 } from "three";
|
|
13967
14016
|
init_BatchedExecutor();
|
|
13968
14017
|
init_AssetKey();
|
|
13969
14018
|
init_BlockStates();
|
|
@@ -13973,7 +14022,7 @@ init_CubeFace();
|
|
|
13973
14022
|
init_AssetKey();
|
|
13974
14023
|
init_Models();
|
|
13975
14024
|
init_CubeFace();
|
|
13976
|
-
import { Matrix4 as Matrix412, Vector3 as
|
|
14025
|
+
import { Matrix4 as Matrix412, Vector3 as Vector315 } from "three";
|
|
13977
14026
|
init_ModelCulling();
|
|
13978
14027
|
init_ModelObject();
|
|
13979
14028
|
init_UVMapper();
|
|
@@ -14041,7 +14090,7 @@ var SectionModels = class {
|
|
|
14041
14090
|
const cullFaces = CUBE_FACES.map((face) => {
|
|
14042
14091
|
const local = CUBE_FACES.findIndex((name) => name === atlas.model.elements[0].faces[face]?.cullface);
|
|
14043
14092
|
if (local < 0) return 0;
|
|
14044
|
-
const normal = new
|
|
14093
|
+
const normal = new Vector315(...CUBE_FACE_OFFSETS[local]).applyEuler(rotation);
|
|
14045
14094
|
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);
|
|
14046
14095
|
return 1 << world;
|
|
14047
14096
|
});
|
|
@@ -14071,20 +14120,20 @@ var MineRenderWorld = class {
|
|
|
14071
14120
|
}
|
|
14072
14121
|
getBlockAt(posOrX, y, z) {
|
|
14073
14122
|
if (typeof posOrX == "number") {
|
|
14074
|
-
return this.getBlockAt(new
|
|
14123
|
+
return this.getBlockAt(new Vector316(posOrX, y, z));
|
|
14075
14124
|
}
|
|
14076
14125
|
if (isTripleArray(posOrX)) {
|
|
14077
|
-
return this.getBlockAt(new
|
|
14126
|
+
return this.getBlockAt(new Vector316(posOrX[0], posOrX[1], posOrX[2]));
|
|
14078
14127
|
}
|
|
14079
14128
|
this.validatePosBounds(posOrX);
|
|
14080
14129
|
return this.getChunkAt(posOrX)?.getBlockAt(posOrX);
|
|
14081
14130
|
}
|
|
14082
14131
|
async setBlockAt(posOrX, yOrBlock, z, block) {
|
|
14083
14132
|
if (typeof posOrX == "number") {
|
|
14084
|
-
return this.setBlockAt(new
|
|
14133
|
+
return this.setBlockAt(new Vector316(posOrX, yOrBlock, z), block);
|
|
14085
14134
|
}
|
|
14086
14135
|
if (isTripleArray(posOrX)) {
|
|
14087
|
-
return this.setBlockAt(new
|
|
14136
|
+
return this.setBlockAt(new Vector316(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
|
|
14088
14137
|
}
|
|
14089
14138
|
return this.placeBlock(posOrX, yOrBlock);
|
|
14090
14139
|
}
|
|
@@ -14105,7 +14154,7 @@ var MineRenderWorld = class {
|
|
|
14105
14154
|
const collect = async (positions2) => {
|
|
14106
14155
|
for (const pos of positions2) changes.set(pos.toArray().join(","), pos);
|
|
14107
14156
|
};
|
|
14108
|
-
const place = (block) => this.placeBlock(new
|
|
14157
|
+
const place = (block) => this.placeBlock(new Vector316(...block.position), block, collect);
|
|
14109
14158
|
const keys = /* @__PURE__ */ new Map();
|
|
14110
14159
|
for (const block of multiblock.blocks) {
|
|
14111
14160
|
if (Chunk.isAir(block)) continue;
|
|
@@ -14183,13 +14232,13 @@ var MineRenderWorld = class {
|
|
|
14183
14232
|
for (const pos of positions) {
|
|
14184
14233
|
this.pendingCulling.set(pos.toArray().join(","), pos.clone());
|
|
14185
14234
|
for (const offset of CUBE_FACE_OFFSETS) {
|
|
14186
|
-
const neighbor = pos.clone().add(new
|
|
14235
|
+
const neighbor = pos.clone().add(new Vector316(...offset));
|
|
14187
14236
|
this.pendingCulling.set(neighbor.toArray().join(","), neighbor);
|
|
14188
14237
|
}
|
|
14189
14238
|
for (let y = -1; y <= 1; y++) {
|
|
14190
14239
|
for (let z = -1; z <= 1; z++) {
|
|
14191
14240
|
for (let x = -1; x <= 1; x++) {
|
|
14192
|
-
const neighbor = pos.clone().add(new
|
|
14241
|
+
const neighbor = pos.clone().add(new Vector316(x, y, z));
|
|
14193
14242
|
if (this.getBlockAt(neighbor)?.object?.fluidKind) {
|
|
14194
14243
|
this.pendingCulling.set(neighbor.toArray().join(","), neighbor);
|
|
14195
14244
|
}
|
|
@@ -14211,7 +14260,7 @@ var MineRenderWorld = class {
|
|
|
14211
14260
|
if (!block) continue;
|
|
14212
14261
|
if (block.object?.fluidKind) {
|
|
14213
14262
|
await block.object.updateFluid((x, y, z) => {
|
|
14214
|
-
const neighbor = pos.clone().add(new
|
|
14263
|
+
const neighbor = pos.clone().add(new Vector316(x, y, z));
|
|
14215
14264
|
const section = this.getChunkAt(neighbor);
|
|
14216
14265
|
const object = section?.getBlockAt(neighbor)?.object;
|
|
14217
14266
|
return {
|
|
@@ -14223,7 +14272,7 @@ var MineRenderWorld = class {
|
|
|
14223
14272
|
}
|
|
14224
14273
|
let mask = 0;
|
|
14225
14274
|
for (const [face, offset] of CUBE_FACE_OFFSETS.entries()) {
|
|
14226
|
-
const neighbor = pos.clone().add(new
|
|
14275
|
+
const neighbor = pos.clone().add(new Vector316(...offset));
|
|
14227
14276
|
if (this.getChunkAt(neighbor)?.isOccludingAt(neighbor)) {
|
|
14228
14277
|
mask |= 1 << face;
|
|
14229
14278
|
}
|
|
@@ -14257,14 +14306,14 @@ var MineRenderWorld = class {
|
|
|
14257
14306
|
return this._chunks.get(this.worldPosToChunkKey(pos));
|
|
14258
14307
|
}
|
|
14259
14308
|
static worldToScenePosition(pos) {
|
|
14260
|
-
return new
|
|
14309
|
+
return new Vector316(
|
|
14261
14310
|
pos.x * 16,
|
|
14262
14311
|
pos.y * 16,
|
|
14263
14312
|
pos.z * 16
|
|
14264
14313
|
);
|
|
14265
14314
|
}
|
|
14266
14315
|
static sceneToWorldPosition(pos) {
|
|
14267
|
-
return new
|
|
14316
|
+
return new Vector316(
|
|
14268
14317
|
pos.x / 16,
|
|
14269
14318
|
pos.y / 16,
|
|
14270
14319
|
pos.z / 16
|
|
@@ -14408,10 +14457,10 @@ var Chunk = class _Chunk {
|
|
|
14408
14457
|
}
|
|
14409
14458
|
getBlockAt(posOrX, y, z) {
|
|
14410
14459
|
if (typeof posOrX == "number") {
|
|
14411
|
-
return this.getBlockAt(new
|
|
14460
|
+
return this.getBlockAt(new Vector317(posOrX, y, z));
|
|
14412
14461
|
}
|
|
14413
14462
|
if (isTripleArray(posOrX)) {
|
|
14414
|
-
return this.getBlockAt(new
|
|
14463
|
+
return this.getBlockAt(new Vector317(posOrX[0], posOrX[1], posOrX[2]));
|
|
14415
14464
|
}
|
|
14416
14465
|
const pos = this.worldPosToChunkPos(posOrX);
|
|
14417
14466
|
const index = _Chunk.chunkPosToBlockIndex(pos);
|
|
@@ -14419,10 +14468,10 @@ var Chunk = class _Chunk {
|
|
|
14419
14468
|
}
|
|
14420
14469
|
async setBlockAt(posOrX, yOrBlock, z, block) {
|
|
14421
14470
|
if (typeof posOrX == "number") {
|
|
14422
|
-
return this.setBlockAt(new
|
|
14471
|
+
return this.setBlockAt(new Vector317(posOrX, yOrBlock, z), block);
|
|
14423
14472
|
}
|
|
14424
14473
|
if (isTripleArray(posOrX)) {
|
|
14425
|
-
return this.setBlockAt(new
|
|
14474
|
+
return this.setBlockAt(new Vector317(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
|
|
14426
14475
|
}
|
|
14427
14476
|
const worldPos = posOrX;
|
|
14428
14477
|
const pos = this.worldPosToChunkPos(worldPos);
|
|
@@ -14508,7 +14557,7 @@ var Chunk = class _Chunk {
|
|
|
14508
14557
|
}
|
|
14509
14558
|
async clear(onBlocksChanged = this.onBlocksChanged) {
|
|
14510
14559
|
const positions = [...this.renderedBlocks.keys()].map((index) => this.chunkPosToWorldPos(
|
|
14511
|
-
new
|
|
14560
|
+
new Vector317(index % 16, Math.floor(index / 256), Math.floor(index / 16) % 16)
|
|
14512
14561
|
));
|
|
14513
14562
|
for (const info of this.renderedBlocks.values()) info.object?.removeFromScene();
|
|
14514
14563
|
this.sectionBlocks.clear();
|
|
@@ -14532,14 +14581,14 @@ var Chunk = class _Chunk {
|
|
|
14532
14581
|
return pos.y * 16 * 16 + pos.z * 16 + pos.x;
|
|
14533
14582
|
}
|
|
14534
14583
|
worldPosToChunkPos(pos) {
|
|
14535
|
-
return new
|
|
14584
|
+
return new Vector317(
|
|
14536
14585
|
pos.x - this.x * 16,
|
|
14537
14586
|
pos.y - this.y * 16,
|
|
14538
14587
|
pos.z - this.z * 16
|
|
14539
14588
|
);
|
|
14540
14589
|
}
|
|
14541
14590
|
chunkPosToWorldPos(pos) {
|
|
14542
|
-
return new
|
|
14591
|
+
return new Vector317(
|
|
14543
14592
|
this.x * 16 + pos.x,
|
|
14544
14593
|
this.y * 16 + pos.y,
|
|
14545
14594
|
this.z * 16 + pos.z
|