minerender 2.1.0-alpha.60 → 2.1.0-alpha.62
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/index.d.mts +47 -13
- package/dist/browser/index.d.ts +47 -13
- package/dist/browser/index.js +443 -320
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +245 -122
- package/dist/browser/index.mjs.map +1 -1
- package/dist/bundle.js +177 -48
- package/dist/bundle.js.map +1 -1
- package/dist/node/index.d.mts +47 -13
- package/dist/node/index.d.ts +47 -13
- package/dist/node/index.js +445 -320
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +245 -122
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/node/index.mjs
CHANGED
|
@@ -1500,7 +1500,7 @@ var init_Models = __esm({
|
|
|
1500
1500
|
}
|
|
1501
1501
|
static async getItemModel(key) {
|
|
1502
1502
|
const itemKey = new AssetKey(key.namespace, key.path, "items", void 0, key.rootType, ".json", key.root);
|
|
1503
|
-
const model = await this.PERSISTENT_CACHE.getOrLoad(AssetLoader.persistentKey(itemKey.serialize())
|
|
1503
|
+
const model = await this.PERSISTENT_CACHE.getOrLoad(`item-v2:${AssetLoader.persistentKey(itemKey.serialize())}`, async () => {
|
|
1504
1504
|
const result = await AssetLoader.getFirst([itemKey, key], "json" /* JSON */);
|
|
1505
1505
|
if (!result) return void 0;
|
|
1506
1506
|
if (result.key.assetType !== "items") return { ...result.asset, key };
|
|
@@ -1509,7 +1509,7 @@ var init_Models = __esm({
|
|
|
1509
1509
|
modelKey.root = key.root;
|
|
1510
1510
|
const model2 = await this.getRaw(modelKey);
|
|
1511
1511
|
if (!model2) throw new Error(`Item ${key.toNamespacedString()} references missing model ${selected.model}`);
|
|
1512
|
-
return selected.special
|
|
1512
|
+
return { ...model2, ...selected.special && { special: selected.special }, ...selected.tints && { tints: selected.tints } };
|
|
1513
1513
|
});
|
|
1514
1514
|
return model ? { ...model, key: Object.assign(new AssetKey("", ""), model.key) } : void 0;
|
|
1515
1515
|
}
|
|
@@ -1520,7 +1520,7 @@ var init_Models = __esm({
|
|
|
1520
1520
|
}
|
|
1521
1521
|
switch (node.type.replace(/^minecraft:/, "")) {
|
|
1522
1522
|
case "model":
|
|
1523
|
-
if (typeof node.model === "string" && node.model) return { model: node.model };
|
|
1523
|
+
if (typeof node.model === "string" && node.model) return { model: node.model, tints: node.tints };
|
|
1524
1524
|
break;
|
|
1525
1525
|
case "special": {
|
|
1526
1526
|
if (!node.base || !node.model || typeof node.model !== "object") break;
|
|
@@ -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;
|
|
@@ -4925,8 +4974,89 @@ var init_GuiLight = __esm({
|
|
|
4925
4974
|
}
|
|
4926
4975
|
});
|
|
4927
4976
|
|
|
4977
|
+
// src/texture/Colormaps.ts
|
|
4978
|
+
var Colormaps;
|
|
4979
|
+
var init_Colormaps = __esm({
|
|
4980
|
+
"src/texture/Colormaps.ts"() {
|
|
4981
|
+
init_AssetKey();
|
|
4982
|
+
init_ModelTextures();
|
|
4983
|
+
init_Caching();
|
|
4984
|
+
init_MineRenderError();
|
|
4985
|
+
Colormaps = class {
|
|
4986
|
+
/** Samples the selected resource pack's grass colormap using Minecraft's climate coordinates. */
|
|
4987
|
+
static async grassColor(origin, temperature = 0.5, downfall = 1) {
|
|
4988
|
+
const key = AssetKey.parse("textures", "minecraft:colormap/grass", origin);
|
|
4989
|
+
const temp = Math.fround(temperature);
|
|
4990
|
+
const rain = Math.fround(downfall) * temp;
|
|
4991
|
+
const x = Math.floor((1 - temp) * 255), y = Math.floor((1 - rain) * 255);
|
|
4992
|
+
return await Caching.blockTintCache.get(`${key.serialize()}|${x},${y}`, async () => {
|
|
4993
|
+
const image = await ModelTextures.get(key);
|
|
4994
|
+
if (!image) throw new MineRenderError(`Missing grass colormap: ${key.toNamespacedString()}`);
|
|
4995
|
+
if (image.width !== 256 || image.height !== 256) {
|
|
4996
|
+
throw new MineRenderError("Grass colormaps must be 256 \xD7 256 pixels");
|
|
4997
|
+
}
|
|
4998
|
+
const [red, green, blue] = image.data.getImageData(x, y, 1, 1).data;
|
|
4999
|
+
return red << 16 | green << 8 | blue;
|
|
5000
|
+
});
|
|
5001
|
+
}
|
|
5002
|
+
};
|
|
5003
|
+
}
|
|
5004
|
+
});
|
|
5005
|
+
|
|
5006
|
+
// src/model/ItemTints.ts
|
|
5007
|
+
var ItemTints;
|
|
5008
|
+
var init_ItemTints = __esm({
|
|
5009
|
+
"src/model/ItemTints.ts"() {
|
|
5010
|
+
init_MineRenderError();
|
|
5011
|
+
init_Colormaps();
|
|
5012
|
+
ItemTints = class {
|
|
5013
|
+
/** Resolves preview colors from item definitions; explicit per-index colors take precedence. */
|
|
5014
|
+
static async get(model, tints) {
|
|
5015
|
+
const sources = model.tints;
|
|
5016
|
+
if (!sources?.length) return tints;
|
|
5017
|
+
const colors = { ...tints };
|
|
5018
|
+
await Promise.all(sources.map(async (source, index) => {
|
|
5019
|
+
if (colors[index] !== void 0) return;
|
|
5020
|
+
switch (source.type) {
|
|
5021
|
+
case "constant":
|
|
5022
|
+
case "minecraft:constant":
|
|
5023
|
+
colors[index] = this.rgb(source.value);
|
|
5024
|
+
break;
|
|
5025
|
+
case "grass":
|
|
5026
|
+
case "minecraft:grass":
|
|
5027
|
+
colors[index] = await Colormaps.grassColor(model.key, source.temperature, source.downfall);
|
|
5028
|
+
break;
|
|
5029
|
+
case "dye":
|
|
5030
|
+
case "minecraft:dye":
|
|
5031
|
+
case "potion":
|
|
5032
|
+
case "minecraft:potion":
|
|
5033
|
+
case "map_color":
|
|
5034
|
+
case "minecraft:map_color":
|
|
5035
|
+
case "firework":
|
|
5036
|
+
case "minecraft:firework":
|
|
5037
|
+
case "team":
|
|
5038
|
+
case "minecraft:team":
|
|
5039
|
+
case "custom_model_data":
|
|
5040
|
+
case "minecraft:custom_model_data":
|
|
5041
|
+
colors[index] = this.rgb(source.default);
|
|
5042
|
+
break;
|
|
5043
|
+
default:
|
|
5044
|
+
throw new MineRenderError(`Unsupported item tint source ${source.type}`);
|
|
5045
|
+
}
|
|
5046
|
+
}));
|
|
5047
|
+
return colors;
|
|
5048
|
+
}
|
|
5049
|
+
static rgb(color) {
|
|
5050
|
+
if (!Array.isArray(color)) return color & 16777215;
|
|
5051
|
+
const [red, green, blue] = color.map((channel) => Math.floor(Math.fround(Math.fround(channel) * 255)));
|
|
5052
|
+
return red << 16 | green << 8 | blue;
|
|
5053
|
+
}
|
|
5054
|
+
};
|
|
5055
|
+
}
|
|
5056
|
+
});
|
|
5057
|
+
|
|
4928
5058
|
// src/model/scene/ModelObject.ts
|
|
4929
|
-
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";
|
|
4930
5060
|
function isModelObject(obj) {
|
|
4931
5061
|
return obj.isModelObject;
|
|
4932
5062
|
}
|
|
@@ -4947,6 +5077,7 @@ var init_ModelObject = __esm({
|
|
|
4947
5077
|
init_SpecialItems();
|
|
4948
5078
|
init_EntityObject();
|
|
4949
5079
|
init_GuiLight();
|
|
5080
|
+
init_ItemTints();
|
|
4950
5081
|
p7 = prefix("ModelObject");
|
|
4951
5082
|
ModelObject = class _ModelObject extends SceneObject {
|
|
4952
5083
|
constructor(originalModel, options) {
|
|
@@ -4965,6 +5096,7 @@ var init_ModelObject = __esm({
|
|
|
4965
5096
|
this.DEFAULT_OPTIONS = (0, import_ts_deepmerge5.default)({}, SceneObject.DEFAULT_OPTIONS, {});
|
|
4966
5097
|
}
|
|
4967
5098
|
async init() {
|
|
5099
|
+
this.options.tints = await ItemTints.get(this.originalModel, this.options.tints);
|
|
4968
5100
|
const special = this.originalModel.special;
|
|
4969
5101
|
if (special) {
|
|
4970
5102
|
const parts = await SpecialItems.getParts(special, this.originalModel.key?.root);
|
|
@@ -5031,7 +5163,7 @@ var init_ModelObject = __esm({
|
|
|
5031
5163
|
elGeo.clearGroups();
|
|
5032
5164
|
}
|
|
5033
5165
|
if (this.options.uvLockRotation) {
|
|
5034
|
-
UVMapper.lockUvs(elGeo, el.faces, this.atlas, new
|
|
5166
|
+
UVMapper.lockUvs(elGeo, el.faces, this.atlas, new Euler7(...this.options.uvLockRotation));
|
|
5035
5167
|
}
|
|
5036
5168
|
if (this.options.tints) {
|
|
5037
5169
|
const colors = new Float32Array(elGeo.getAttribute("position").count * 3).fill(1);
|
|
@@ -5652,7 +5784,7 @@ import {
|
|
|
5652
5784
|
Color as Color4,
|
|
5653
5785
|
Matrix3,
|
|
5654
5786
|
Vector2 as Vector22,
|
|
5655
|
-
Vector3 as
|
|
5787
|
+
Vector3 as Vector37
|
|
5656
5788
|
} from "three";
|
|
5657
5789
|
var OBJExporter = class {
|
|
5658
5790
|
parse(object) {
|
|
@@ -5660,9 +5792,9 @@ var OBJExporter = class {
|
|
|
5660
5792
|
let indexVertex = 0;
|
|
5661
5793
|
let indexVertexUvs = 0;
|
|
5662
5794
|
let indexNormals = 0;
|
|
5663
|
-
const vertex = new
|
|
5795
|
+
const vertex = new Vector37();
|
|
5664
5796
|
const color = new Color4();
|
|
5665
|
-
const normal = new
|
|
5797
|
+
const normal = new Vector37();
|
|
5666
5798
|
const uv = new Vector22();
|
|
5667
5799
|
const face = [];
|
|
5668
5800
|
function parseMesh(mesh) {
|
|
@@ -5791,7 +5923,7 @@ var OBJExporter = class {
|
|
|
5791
5923
|
// ../../node_modules/three/examples/jsm/exporters/PLYExporter.js
|
|
5792
5924
|
import {
|
|
5793
5925
|
Matrix3 as Matrix32,
|
|
5794
|
-
Vector3 as
|
|
5926
|
+
Vector3 as Vector38,
|
|
5795
5927
|
Color as Color5
|
|
5796
5928
|
} from "three";
|
|
5797
5929
|
var PLYExporter = class {
|
|
@@ -5884,7 +6016,7 @@ property list uchar int vertex_index
|
|
|
5884
6016
|
`;
|
|
5885
6017
|
}
|
|
5886
6018
|
header += "end_header\n";
|
|
5887
|
-
const vertex = new
|
|
6019
|
+
const vertex = new Vector38();
|
|
5888
6020
|
const normalMatrixWorld = new Matrix32();
|
|
5889
6021
|
let result = null;
|
|
5890
6022
|
if (options.binary === true) {
|
|
@@ -6083,7 +6215,7 @@ import {
|
|
|
6083
6215
|
Source,
|
|
6084
6216
|
SRGBColorSpace as SRGBColorSpace4,
|
|
6085
6217
|
CompressedTexture,
|
|
6086
|
-
Vector3 as
|
|
6218
|
+
Vector3 as Vector39,
|
|
6087
6219
|
Quaternion as Quaternion4
|
|
6088
6220
|
} from "three";
|
|
6089
6221
|
|
|
@@ -6544,7 +6676,7 @@ var GLTFWriter = class {
|
|
|
6544
6676
|
isNormalizedNormalAttribute(normal) {
|
|
6545
6677
|
const cache = this.cache;
|
|
6546
6678
|
if (cache.attributesNormalized.has(normal)) return false;
|
|
6547
|
-
const v = new
|
|
6679
|
+
const v = new Vector39();
|
|
6548
6680
|
for (let i = 0, il = normal.count; i < il; i++) {
|
|
6549
6681
|
if (Math.abs(v.fromBufferAttribute(normal, i).length() - 1) > 5e-4) return false;
|
|
6550
6682
|
}
|
|
@@ -6561,7 +6693,7 @@ var GLTFWriter = class {
|
|
|
6561
6693
|
const cache = this.cache;
|
|
6562
6694
|
if (cache.attributesNormalized.has(normal)) return cache.attributesNormalized.get(normal);
|
|
6563
6695
|
const attribute = normal.clone();
|
|
6564
|
-
const v = new
|
|
6696
|
+
const v = new Vector39();
|
|
6565
6697
|
for (let i = 0, il = attribute.count; i < il; i++) {
|
|
6566
6698
|
v.fromBufferAttribute(attribute, i);
|
|
6567
6699
|
if (v.x === 0 && v.y === 0 && v.z === 0) {
|
|
@@ -7828,9 +7960,9 @@ var GLTFMeshGpuInstancing = class {
|
|
|
7828
7960
|
const rotationAttr = new Float32Array(mesh.count * 4);
|
|
7829
7961
|
const scaleAttr = new Float32Array(mesh.count * 3);
|
|
7830
7962
|
const matrix = new Matrix46();
|
|
7831
|
-
const position = new
|
|
7963
|
+
const position = new Vector39();
|
|
7832
7964
|
const quaternion = new Quaternion4();
|
|
7833
|
-
const scale = new
|
|
7965
|
+
const scale = new Vector39();
|
|
7834
7966
|
for (let i = 0; i < mesh.count; i++) {
|
|
7835
7967
|
mesh.getMatrixAt(i, matrix);
|
|
7836
7968
|
matrix.decompose(position, quaternion, scale);
|
|
@@ -8812,6 +8944,7 @@ function isInstanceable(obj) {
|
|
|
8812
8944
|
init_DisplayPosition();
|
|
8813
8945
|
init_DisplayTransforms();
|
|
8814
8946
|
init_GuiLight();
|
|
8947
|
+
init_ItemTints();
|
|
8815
8948
|
init_Model();
|
|
8816
8949
|
init_ModelCulling();
|
|
8817
8950
|
init_ModelGenerator();
|
|
@@ -8822,7 +8955,7 @@ init_SpecialItems();
|
|
|
8822
8955
|
init_BlockStates();
|
|
8823
8956
|
init_MineRenderError();
|
|
8824
8957
|
init_util();
|
|
8825
|
-
import { Euler as
|
|
8958
|
+
import { Euler as Euler8 } from "three";
|
|
8826
8959
|
function matchesCondition(condition, state) {
|
|
8827
8960
|
return Object.entries(condition).every(([key, value]) => {
|
|
8828
8961
|
if (Array.isArray(value)) {
|
|
@@ -8897,7 +9030,7 @@ var BlockStateResolver = class {
|
|
|
8897
9030
|
return variants[variants.length - 1];
|
|
8898
9031
|
}
|
|
8899
9032
|
static rotation(variant) {
|
|
8900
|
-
const rotation = new
|
|
9033
|
+
const rotation = new Euler8();
|
|
8901
9034
|
if (typeof variant.x !== "undefined") {
|
|
8902
9035
|
rotation.x = toRadians(clampRotationDegrees(variant.x));
|
|
8903
9036
|
}
|
|
@@ -8909,10 +9042,7 @@ var BlockStateResolver = class {
|
|
|
8909
9042
|
};
|
|
8910
9043
|
|
|
8911
9044
|
// src/model/block/BlockTints.ts
|
|
8912
|
-
|
|
8913
|
-
init_ModelTextures();
|
|
8914
|
-
init_Caching();
|
|
8915
|
-
init_MineRenderError();
|
|
9045
|
+
init_Colormaps();
|
|
8916
9046
|
|
|
8917
9047
|
// src/model/block/blockTints.json
|
|
8918
9048
|
var blockTints_default = {
|
|
@@ -8967,7 +9097,7 @@ var BlockTints = class {
|
|
|
8967
9097
|
color = rule.color;
|
|
8968
9098
|
break;
|
|
8969
9099
|
case "grass":
|
|
8970
|
-
color = await
|
|
9100
|
+
color = await Colormaps.grassColor(key);
|
|
8971
9101
|
break;
|
|
8972
9102
|
case "redstone": {
|
|
8973
9103
|
const power = Number(state.power ?? 0) / 15;
|
|
@@ -8985,18 +9115,6 @@ var BlockTints = class {
|
|
|
8985
9115
|
}
|
|
8986
9116
|
return { ...Object.fromEntries([...indices].map((index) => [index, color])), ...tints };
|
|
8987
9117
|
}
|
|
8988
|
-
static async grassColor(origin) {
|
|
8989
|
-
const key = AssetKey.parse("textures", "minecraft:colormap/grass", origin);
|
|
8990
|
-
return await Caching.blockTintCache.get(key.serialize(), async () => {
|
|
8991
|
-
const image = await ModelTextures.get(key);
|
|
8992
|
-
if (!image) throw new MineRenderError(`Missing grass colormap: ${key.toNamespacedString()}`);
|
|
8993
|
-
if (image.width !== 256 || image.height !== 256) {
|
|
8994
|
-
throw new MineRenderError("Grass colormaps must be 256 \xD7 256 pixels");
|
|
8995
|
-
}
|
|
8996
|
-
const [red, green, blue] = image.data.getImageData(127, 127, 1, 1).data;
|
|
8997
|
-
return red << 16 | green << 8 | blue;
|
|
8998
|
-
});
|
|
8999
|
-
}
|
|
9000
9118
|
};
|
|
9001
9119
|
|
|
9002
9120
|
// src/model/block/scene/BlockObject.ts
|
|
@@ -9007,7 +9125,7 @@ var import_ts_deepmerge6 = __toESM(require_dist());
|
|
|
9007
9125
|
init_MineRenderError();
|
|
9008
9126
|
init_InstanceReference();
|
|
9009
9127
|
init_AssetKey();
|
|
9010
|
-
import { Euler as
|
|
9128
|
+
import { Euler as Euler9, Matrix4 as Matrix411, Quaternion as Quaternion5, Vector3 as Vector312 } from "three";
|
|
9011
9129
|
init_ModelCulling();
|
|
9012
9130
|
init_FluidGeometry();
|
|
9013
9131
|
init_Entities();
|
|
@@ -9130,12 +9248,12 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
9130
9248
|
getModelCullMask(model, worldMask) {
|
|
9131
9249
|
const object = isInstanceReference(model) ? model.instanceable : model;
|
|
9132
9250
|
if (object.options.displayPosition) return 0;
|
|
9133
|
-
const position = new
|
|
9251
|
+
const position = new Vector312();
|
|
9134
9252
|
const rotation = new Quaternion5();
|
|
9135
|
-
const scale = new
|
|
9253
|
+
const scale = new Vector312();
|
|
9136
9254
|
this.getModelMatrix(model).decompose(position, rotation, scale);
|
|
9137
|
-
if (position.distanceToSquared(this.position) > 1e-10 || scale.distanceToSquared(new
|
|
9138
|
-
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));
|
|
9139
9257
|
}
|
|
9140
9258
|
async setCullMask(worldMask) {
|
|
9141
9259
|
worldMask &= 63;
|
|
@@ -12252,6 +12370,7 @@ var SkinObject = class extends SceneObject {
|
|
|
12252
12370
|
|
|
12253
12371
|
// src/renderer/MineRenderScene.ts
|
|
12254
12372
|
init_EntityObject();
|
|
12373
|
+
init_ItemTints();
|
|
12255
12374
|
var MineRenderScene = class _MineRenderScene extends Scene5 {
|
|
12256
12375
|
constructor(options) {
|
|
12257
12376
|
super();
|
|
@@ -12347,6 +12466,7 @@ var MineRenderScene = class _MineRenderScene extends Scene5 {
|
|
|
12347
12466
|
}
|
|
12348
12467
|
}
|
|
12349
12468
|
async addModel(model, options, parent = this) {
|
|
12469
|
+
options = { ...options, tints: await ItemTints.get(model, options?.tints) };
|
|
12350
12470
|
return this.addSceneObject(model, () => new ModelObject(model, options), options, parent);
|
|
12351
12471
|
}
|
|
12352
12472
|
async addBlock(blockState, options, parent = this) {
|
|
@@ -12380,7 +12500,7 @@ function isMineRenderScene(obj) {
|
|
|
12380
12500
|
}
|
|
12381
12501
|
|
|
12382
12502
|
// src/renderer/Renderer.ts
|
|
12383
|
-
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";
|
|
12384
12504
|
var import_ts_deepmerge9 = __toESM(require_dist());
|
|
12385
12505
|
init_util();
|
|
12386
12506
|
init_Model();
|
|
@@ -12396,7 +12516,7 @@ import {
|
|
|
12396
12516
|
Spherical,
|
|
12397
12517
|
TOUCH,
|
|
12398
12518
|
Vector2 as Vector25,
|
|
12399
|
-
Vector3 as
|
|
12519
|
+
Vector3 as Vector313
|
|
12400
12520
|
} from "three";
|
|
12401
12521
|
var _changeEvent = { type: "change" };
|
|
12402
12522
|
var _startEvent = { type: "start" };
|
|
@@ -12410,7 +12530,7 @@ var OrbitControls = class extends EventDispatcher {
|
|
|
12410
12530
|
this.domElement = domElement;
|
|
12411
12531
|
this.domElement.style.touchAction = "none";
|
|
12412
12532
|
this.enabled = true;
|
|
12413
|
-
this.target = new
|
|
12533
|
+
this.target = new Vector313();
|
|
12414
12534
|
this.minDistance = 0;
|
|
12415
12535
|
this.maxDistance = Infinity;
|
|
12416
12536
|
this.minZoom = 0;
|
|
@@ -12462,10 +12582,10 @@ var OrbitControls = class extends EventDispatcher {
|
|
|
12462
12582
|
state = STATE.NONE;
|
|
12463
12583
|
};
|
|
12464
12584
|
this.update = function() {
|
|
12465
|
-
const offset = new
|
|
12466
|
-
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));
|
|
12467
12587
|
const quatInverse = quat.clone().invert();
|
|
12468
|
-
const lastPosition = new
|
|
12588
|
+
const lastPosition = new Vector313();
|
|
12469
12589
|
const lastQuaternion = new Quaternion6();
|
|
12470
12590
|
const twoPI = 2 * Math.PI;
|
|
12471
12591
|
return function update() {
|
|
@@ -12555,7 +12675,7 @@ var OrbitControls = class extends EventDispatcher {
|
|
|
12555
12675
|
const spherical = new Spherical();
|
|
12556
12676
|
const sphericalDelta = new Spherical();
|
|
12557
12677
|
let scale = 1;
|
|
12558
|
-
const panOffset = new
|
|
12678
|
+
const panOffset = new Vector313();
|
|
12559
12679
|
let zoomChanged = false;
|
|
12560
12680
|
const rotateStart = new Vector25();
|
|
12561
12681
|
const rotateEnd = new Vector25();
|
|
@@ -12581,7 +12701,7 @@ var OrbitControls = class extends EventDispatcher {
|
|
|
12581
12701
|
sphericalDelta.phi -= angle;
|
|
12582
12702
|
}
|
|
12583
12703
|
const panLeft = function() {
|
|
12584
|
-
const v = new
|
|
12704
|
+
const v = new Vector313();
|
|
12585
12705
|
return function panLeft2(distance, objectMatrix) {
|
|
12586
12706
|
v.setFromMatrixColumn(objectMatrix, 0);
|
|
12587
12707
|
v.multiplyScalar(-distance);
|
|
@@ -12589,7 +12709,7 @@ var OrbitControls = class extends EventDispatcher {
|
|
|
12589
12709
|
};
|
|
12590
12710
|
}();
|
|
12591
12711
|
const panUp = function() {
|
|
12592
|
-
const v = new
|
|
12712
|
+
const v = new Vector313();
|
|
12593
12713
|
return function panUp2(distance, objectMatrix) {
|
|
12594
12714
|
if (scope.screenSpacePanning === true) {
|
|
12595
12715
|
v.setFromMatrixColumn(objectMatrix, 1);
|
|
@@ -12602,7 +12722,7 @@ var OrbitControls = class extends EventDispatcher {
|
|
|
12602
12722
|
};
|
|
12603
12723
|
}();
|
|
12604
12724
|
const pan = function() {
|
|
12605
|
-
const offset = new
|
|
12725
|
+
const offset = new Vector313();
|
|
12606
12726
|
return function pan2(deltaX, deltaY) {
|
|
12607
12727
|
const element = scope.domElement;
|
|
12608
12728
|
if (scope.object.isPerspectiveCamera) {
|
|
@@ -13093,8 +13213,8 @@ var Renderer = class _Renderer {
|
|
|
13093
13213
|
top: void 0,
|
|
13094
13214
|
bottom: void 0
|
|
13095
13215
|
},
|
|
13096
|
-
position: new
|
|
13097
|
-
lookingAt: new
|
|
13216
|
+
position: new Vector314(50, 50, 50),
|
|
13217
|
+
lookingAt: new Vector314(0, 0, 0)
|
|
13098
13218
|
},
|
|
13099
13219
|
render: {
|
|
13100
13220
|
fpsLimit: 60,
|
|
@@ -13617,6 +13737,7 @@ var Skins = class {
|
|
|
13617
13737
|
};
|
|
13618
13738
|
|
|
13619
13739
|
// src/texture/index.ts
|
|
13740
|
+
init_Colormaps();
|
|
13620
13741
|
init_TextureAtlas();
|
|
13621
13742
|
init_TextureLoader();
|
|
13622
13743
|
init_Textures();
|
|
@@ -13885,13 +14006,13 @@ var AnvilParser = class {
|
|
|
13885
14006
|
};
|
|
13886
14007
|
|
|
13887
14008
|
// src/world/Chunk.ts
|
|
13888
|
-
import { Vector3 as
|
|
14009
|
+
import { Vector3 as Vector317 } from "three";
|
|
13889
14010
|
init_BlockStates();
|
|
13890
14011
|
init_AssetKey();
|
|
13891
14012
|
|
|
13892
14013
|
// src/world/MineRenderWorld.ts
|
|
13893
14014
|
init_Model();
|
|
13894
|
-
import { Vector3 as
|
|
14015
|
+
import { Vector3 as Vector316 } from "three";
|
|
13895
14016
|
init_BatchedExecutor();
|
|
13896
14017
|
init_AssetKey();
|
|
13897
14018
|
init_BlockStates();
|
|
@@ -13901,7 +14022,7 @@ init_CubeFace();
|
|
|
13901
14022
|
init_AssetKey();
|
|
13902
14023
|
init_Models();
|
|
13903
14024
|
init_CubeFace();
|
|
13904
|
-
import { Matrix4 as Matrix412, Vector3 as
|
|
14025
|
+
import { Matrix4 as Matrix412, Vector3 as Vector315 } from "three";
|
|
13905
14026
|
init_ModelCulling();
|
|
13906
14027
|
init_ModelObject();
|
|
13907
14028
|
init_UVMapper();
|
|
@@ -13969,7 +14090,7 @@ var SectionModels = class {
|
|
|
13969
14090
|
const cullFaces = CUBE_FACES.map((face) => {
|
|
13970
14091
|
const local = CUBE_FACES.findIndex((name) => name === atlas.model.elements[0].faces[face]?.cullface);
|
|
13971
14092
|
if (local < 0) return 0;
|
|
13972
|
-
const normal = new
|
|
14093
|
+
const normal = new Vector315(...CUBE_FACE_OFFSETS[local]).applyEuler(rotation);
|
|
13973
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);
|
|
13974
14095
|
return 1 << world;
|
|
13975
14096
|
});
|
|
@@ -13999,20 +14120,20 @@ var MineRenderWorld = class {
|
|
|
13999
14120
|
}
|
|
14000
14121
|
getBlockAt(posOrX, y, z) {
|
|
14001
14122
|
if (typeof posOrX == "number") {
|
|
14002
|
-
return this.getBlockAt(new
|
|
14123
|
+
return this.getBlockAt(new Vector316(posOrX, y, z));
|
|
14003
14124
|
}
|
|
14004
14125
|
if (isTripleArray(posOrX)) {
|
|
14005
|
-
return this.getBlockAt(new
|
|
14126
|
+
return this.getBlockAt(new Vector316(posOrX[0], posOrX[1], posOrX[2]));
|
|
14006
14127
|
}
|
|
14007
14128
|
this.validatePosBounds(posOrX);
|
|
14008
14129
|
return this.getChunkAt(posOrX)?.getBlockAt(posOrX);
|
|
14009
14130
|
}
|
|
14010
14131
|
async setBlockAt(posOrX, yOrBlock, z, block) {
|
|
14011
14132
|
if (typeof posOrX == "number") {
|
|
14012
|
-
return this.setBlockAt(new
|
|
14133
|
+
return this.setBlockAt(new Vector316(posOrX, yOrBlock, z), block);
|
|
14013
14134
|
}
|
|
14014
14135
|
if (isTripleArray(posOrX)) {
|
|
14015
|
-
return this.setBlockAt(new
|
|
14136
|
+
return this.setBlockAt(new Vector316(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
|
|
14016
14137
|
}
|
|
14017
14138
|
return this.placeBlock(posOrX, yOrBlock);
|
|
14018
14139
|
}
|
|
@@ -14033,7 +14154,7 @@ var MineRenderWorld = class {
|
|
|
14033
14154
|
const collect = async (positions2) => {
|
|
14034
14155
|
for (const pos of positions2) changes.set(pos.toArray().join(","), pos);
|
|
14035
14156
|
};
|
|
14036
|
-
const place = (block) => this.placeBlock(new
|
|
14157
|
+
const place = (block) => this.placeBlock(new Vector316(...block.position), block, collect);
|
|
14037
14158
|
const keys = /* @__PURE__ */ new Map();
|
|
14038
14159
|
for (const block of multiblock.blocks) {
|
|
14039
14160
|
if (Chunk.isAir(block)) continue;
|
|
@@ -14111,13 +14232,13 @@ var MineRenderWorld = class {
|
|
|
14111
14232
|
for (const pos of positions) {
|
|
14112
14233
|
this.pendingCulling.set(pos.toArray().join(","), pos.clone());
|
|
14113
14234
|
for (const offset of CUBE_FACE_OFFSETS) {
|
|
14114
|
-
const neighbor = pos.clone().add(new
|
|
14235
|
+
const neighbor = pos.clone().add(new Vector316(...offset));
|
|
14115
14236
|
this.pendingCulling.set(neighbor.toArray().join(","), neighbor);
|
|
14116
14237
|
}
|
|
14117
14238
|
for (let y = -1; y <= 1; y++) {
|
|
14118
14239
|
for (let z = -1; z <= 1; z++) {
|
|
14119
14240
|
for (let x = -1; x <= 1; x++) {
|
|
14120
|
-
const neighbor = pos.clone().add(new
|
|
14241
|
+
const neighbor = pos.clone().add(new Vector316(x, y, z));
|
|
14121
14242
|
if (this.getBlockAt(neighbor)?.object?.fluidKind) {
|
|
14122
14243
|
this.pendingCulling.set(neighbor.toArray().join(","), neighbor);
|
|
14123
14244
|
}
|
|
@@ -14139,7 +14260,7 @@ var MineRenderWorld = class {
|
|
|
14139
14260
|
if (!block) continue;
|
|
14140
14261
|
if (block.object?.fluidKind) {
|
|
14141
14262
|
await block.object.updateFluid((x, y, z) => {
|
|
14142
|
-
const neighbor = pos.clone().add(new
|
|
14263
|
+
const neighbor = pos.clone().add(new Vector316(x, y, z));
|
|
14143
14264
|
const section = this.getChunkAt(neighbor);
|
|
14144
14265
|
const object = section?.getBlockAt(neighbor)?.object;
|
|
14145
14266
|
return {
|
|
@@ -14151,7 +14272,7 @@ var MineRenderWorld = class {
|
|
|
14151
14272
|
}
|
|
14152
14273
|
let mask = 0;
|
|
14153
14274
|
for (const [face, offset] of CUBE_FACE_OFFSETS.entries()) {
|
|
14154
|
-
const neighbor = pos.clone().add(new
|
|
14275
|
+
const neighbor = pos.clone().add(new Vector316(...offset));
|
|
14155
14276
|
if (this.getChunkAt(neighbor)?.isOccludingAt(neighbor)) {
|
|
14156
14277
|
mask |= 1 << face;
|
|
14157
14278
|
}
|
|
@@ -14185,14 +14306,14 @@ var MineRenderWorld = class {
|
|
|
14185
14306
|
return this._chunks.get(this.worldPosToChunkKey(pos));
|
|
14186
14307
|
}
|
|
14187
14308
|
static worldToScenePosition(pos) {
|
|
14188
|
-
return new
|
|
14309
|
+
return new Vector316(
|
|
14189
14310
|
pos.x * 16,
|
|
14190
14311
|
pos.y * 16,
|
|
14191
14312
|
pos.z * 16
|
|
14192
14313
|
);
|
|
14193
14314
|
}
|
|
14194
14315
|
static sceneToWorldPosition(pos) {
|
|
14195
|
-
return new
|
|
14316
|
+
return new Vector316(
|
|
14196
14317
|
pos.x / 16,
|
|
14197
14318
|
pos.y / 16,
|
|
14198
14319
|
pos.z / 16
|
|
@@ -14336,10 +14457,10 @@ var Chunk = class _Chunk {
|
|
|
14336
14457
|
}
|
|
14337
14458
|
getBlockAt(posOrX, y, z) {
|
|
14338
14459
|
if (typeof posOrX == "number") {
|
|
14339
|
-
return this.getBlockAt(new
|
|
14460
|
+
return this.getBlockAt(new Vector317(posOrX, y, z));
|
|
14340
14461
|
}
|
|
14341
14462
|
if (isTripleArray(posOrX)) {
|
|
14342
|
-
return this.getBlockAt(new
|
|
14463
|
+
return this.getBlockAt(new Vector317(posOrX[0], posOrX[1], posOrX[2]));
|
|
14343
14464
|
}
|
|
14344
14465
|
const pos = this.worldPosToChunkPos(posOrX);
|
|
14345
14466
|
const index = _Chunk.chunkPosToBlockIndex(pos);
|
|
@@ -14347,10 +14468,10 @@ var Chunk = class _Chunk {
|
|
|
14347
14468
|
}
|
|
14348
14469
|
async setBlockAt(posOrX, yOrBlock, z, block) {
|
|
14349
14470
|
if (typeof posOrX == "number") {
|
|
14350
|
-
return this.setBlockAt(new
|
|
14471
|
+
return this.setBlockAt(new Vector317(posOrX, yOrBlock, z), block);
|
|
14351
14472
|
}
|
|
14352
14473
|
if (isTripleArray(posOrX)) {
|
|
14353
|
-
return this.setBlockAt(new
|
|
14474
|
+
return this.setBlockAt(new Vector317(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
|
|
14354
14475
|
}
|
|
14355
14476
|
const worldPos = posOrX;
|
|
14356
14477
|
const pos = this.worldPosToChunkPos(worldPos);
|
|
@@ -14436,7 +14557,7 @@ var Chunk = class _Chunk {
|
|
|
14436
14557
|
}
|
|
14437
14558
|
async clear(onBlocksChanged = this.onBlocksChanged) {
|
|
14438
14559
|
const positions = [...this.renderedBlocks.keys()].map((index) => this.chunkPosToWorldPos(
|
|
14439
|
-
new
|
|
14560
|
+
new Vector317(index % 16, Math.floor(index / 256), Math.floor(index / 16) % 16)
|
|
14440
14561
|
));
|
|
14441
14562
|
for (const info of this.renderedBlocks.values()) info.object?.removeFromScene();
|
|
14442
14563
|
this.sectionBlocks.clear();
|
|
@@ -14460,14 +14581,14 @@ var Chunk = class _Chunk {
|
|
|
14460
14581
|
return pos.y * 16 * 16 + pos.z * 16 + pos.x;
|
|
14461
14582
|
}
|
|
14462
14583
|
worldPosToChunkPos(pos) {
|
|
14463
|
-
return new
|
|
14584
|
+
return new Vector317(
|
|
14464
14585
|
pos.x - this.x * 16,
|
|
14465
14586
|
pos.y - this.y * 16,
|
|
14466
14587
|
pos.z - this.z * 16
|
|
14467
14588
|
);
|
|
14468
14589
|
}
|
|
14469
14590
|
chunkPosToWorldPos(pos) {
|
|
14470
|
-
return new
|
|
14591
|
+
return new Vector317(
|
|
14471
14592
|
this.x * 16 + pos.x,
|
|
14472
14593
|
this.y * 16 + pos.y,
|
|
14473
14594
|
this.z * 16 + pos.z
|
|
@@ -14501,6 +14622,7 @@ export {
|
|
|
14501
14622
|
CanvasImage,
|
|
14502
14623
|
Chunk,
|
|
14503
14624
|
ChunkData,
|
|
14625
|
+
Colormaps,
|
|
14504
14626
|
CubeFace,
|
|
14505
14627
|
CubeFaceIndex,
|
|
14506
14628
|
DEFAULT_ELEMENTS,
|
|
@@ -14526,6 +14648,7 @@ export {
|
|
|
14526
14648
|
ImageLoader,
|
|
14527
14649
|
InstanceManager,
|
|
14528
14650
|
InstanceReference,
|
|
14651
|
+
ItemTints,
|
|
14529
14652
|
MapControls,
|
|
14530
14653
|
Materials,
|
|
14531
14654
|
Meshes,
|