minerender 2.1.0-alpha.61 → 2.1.0-alpha.63

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.
@@ -3238,11 +3238,11 @@ var init_Entities = __esm({
3238
3238
  return { ...layers[names[0]], id: model.id, layers, ...model.transform && { transform: model.transform } };
3239
3239
  }
3240
3240
  /**
3241
- * Vanilla's keyframe animations of a model by name, or undefined when the model or the selected version has none.
3241
+ * Native and sampled vanilla clips by name, or undefined when the model or selected version has none.
3242
3242
  */
3243
3243
  static async getAnimations(modelKey) {
3244
3244
  const path = isAssetKey(modelKey) ? modelKey.getFullPath() : modelKey.path;
3245
- const key = new AssetKey(modelKey.namespace, path, void 0, void 0, "entity-models/animations", ".json");
3245
+ const key = new AssetKey(modelKey.namespace, path, void 0, void 0, "entity-models/animations", ".json", isAssetKey(modelKey) ? modelKey.root : void 0);
3246
3246
  const file = await Caching.entityAnimationCache.get(key.serialize(), () => AssetLoader.get(key, "json" /* JSON */));
3247
3247
  return file?.animations;
3248
3248
  }
@@ -3292,7 +3292,7 @@ function sampleEntityKeyframes(keyframes, time) {
3292
3292
  let low = 0, high = keyframes.length;
3293
3293
  while (low < high) {
3294
3294
  const middle = low + high >>> 1;
3295
- if (time <= keyframes[middle].time) high = middle;
3295
+ if (time < keyframes[middle].time) high = middle;
3296
3296
  else low = middle + 1;
3297
3297
  }
3298
3298
  const a = Math.max(0, low - 1);
@@ -3331,9 +3331,10 @@ var init_EntityAnimation = __esm({
3331
3331
  });
3332
3332
 
3333
3333
  // src/entity/scene/EntityAnimationPlayer.ts
3334
- var ZERO, EntityAnimationPlayer;
3334
+ var import_three11, ZERO, EntityAnimationPlayer;
3335
3335
  var init_EntityAnimationPlayer = __esm({
3336
3336
  "src/entity/scene/EntityAnimationPlayer.ts"() {
3337
+ import_three11 = require("three");
3337
3338
  init_EntityAnimation();
3338
3339
  ZERO = [0, 0, 0];
3339
3340
  EntityAnimationPlayer = class {
@@ -3350,25 +3351,45 @@ var init_EntityAnimationPlayer = __esm({
3350
3351
  return this._time;
3351
3352
  }
3352
3353
  /**
3353
- * Starts an animation on the named parts below each layer root. The current pose of a part becomes its default;
3354
- * bones without a matching part are skipped.
3354
+ * Starts an animation on matching named parts. Supplied baked poses are the baseline for offsets;
3355
+ * without them, the current pose is used. Stopping restores the pose from before playback.
3355
3356
  */
3356
- play(layers, animation, options = {}) {
3357
+ play(layers, animation, options = {}, poses) {
3357
3358
  this.stop();
3358
3359
  this._animation = animation;
3359
3360
  this._time = options.time ?? 0;
3360
3361
  this.loop = options.loop ?? animation.loop;
3361
3362
  this.speed = options.speed ?? 1;
3362
3363
  for (const layer of layers) {
3363
- for (const bone of Object.keys(animation.bones)) {
3364
- const object = layer.getObjectByName(`group:${bone}`);
3365
- if (!object) continue;
3366
- this.parts.push({ bone, object, position: object.position.clone(), rotation: object.rotation.clone(), scale: object.scale.clone() });
3364
+ const objects = [];
3365
+ if (poses) {
3366
+ layer.traverse((object) => {
3367
+ if (poses.has(object)) objects.push(object);
3368
+ });
3369
+ } else {
3370
+ for (const bone of Object.keys(animation.bones)) {
3371
+ const object = layer.getObjectByName(`group:${bone}`);
3372
+ if (object) objects.push(object);
3373
+ }
3374
+ }
3375
+ for (const object of objects) {
3376
+ const bone = object.name.slice("group:".length);
3377
+ const pose = poses?.get(object);
3378
+ this.parts.push({
3379
+ bone,
3380
+ object,
3381
+ position: object.position.clone(),
3382
+ rotation: object.rotation.clone(),
3383
+ scale: object.scale.clone(),
3384
+ basePosition: pose ? new import_three11.Vector3(...pose.offset) : object.position.clone(),
3385
+ baseRotation: pose ? new import_three11.Euler(...pose.rotation, "ZYX") : object.rotation.clone(),
3386
+ baseScale: pose ? new import_three11.Vector3(...pose.scale ?? [1, 1, 1]) : object.scale.clone()
3387
+ });
3367
3388
  }
3368
3389
  }
3369
3390
  this.apply();
3370
3391
  }
3371
- /** Restores the default poses. Returns whether an animation was active. */
3392
+ /** Restores the poses from before playback. Returns whether an animation was active. */
3372
3393
  stop() {
3373
3394
  if (!this._animation) return false;
3374
3395
  for (const part of this.parts) {
@@ -3397,10 +3418,10 @@ var init_EntityAnimationPlayer = __esm({
3397
3418
  apply() {
3398
3419
  const pose = sampleEntityAnimation(this._animation, this._time, this.loop);
3399
3420
  for (const part of this.parts) {
3400
- const { position = ZERO, rotation = ZERO, scale = ZERO } = pose[part.bone];
3401
- part.object.position.set(part.position.x + position[0], part.position.y + position[1], part.position.z + position[2]);
3402
- part.object.rotation.set(part.rotation.x + rotation[0], part.rotation.y + rotation[1], part.rotation.z + rotation[2], part.rotation.order);
3403
- part.object.scale.set(part.scale.x + scale[0], part.scale.y + scale[1], part.scale.z + scale[2]);
3421
+ const { position = ZERO, rotation = ZERO, scale = ZERO } = pose[part.bone] ?? {};
3422
+ part.object.position.set(part.basePosition.x + position[0], part.basePosition.y + position[1], part.basePosition.z + position[2]);
3423
+ part.object.rotation.set(part.baseRotation.x + rotation[0], part.baseRotation.y + rotation[1], part.baseRotation.z + rotation[2], part.baseRotation.order);
3424
+ part.object.scale.set(part.baseScale.x + scale[0], part.baseScale.y + scale[1], part.baseScale.z + scale[2]);
3404
3425
  }
3405
3426
  }
3406
3427
  };
@@ -3440,6 +3461,9 @@ var init_InstanceReference = __esm({
3440
3461
  setMatrix(matrix) {
3441
3462
  this.activeInstanceable.setMatrixAt(this.index, matrix);
3442
3463
  }
3464
+ setVisible(visible) {
3465
+ this.activeInstanceable.setInstanceVisibleAt(this.index, visible);
3466
+ }
3443
3467
  setPositionRotationScale(position, rotation, scale) {
3444
3468
  this.activeInstanceable.setPositionRotationScaleAt(this.index, position, rotation, scale);
3445
3469
  }
@@ -3470,10 +3494,10 @@ var init_InstanceReference = __esm({
3470
3494
  function isSceneObject(obj) {
3471
3495
  return obj.isSceneObject;
3472
3496
  }
3473
- var import_three11, import_ts_deepmerge3, p6, _SceneObject, SceneObject;
3497
+ var import_three12, import_ts_deepmerge3, p6, _SceneObject, SceneObject;
3474
3498
  var init_SceneObject = __esm({
3475
3499
  "src/renderer/SceneObject.ts"() {
3476
- import_three11 = require("three");
3500
+ import_three12 = require("three");
3477
3501
  init_Geometries();
3478
3502
  init_UVMapper();
3479
3503
  init_Axis();
@@ -3485,7 +3509,7 @@ var init_SceneObject = __esm({
3485
3509
  import_ts_deepmerge3 = __toESM(require_dist());
3486
3510
  init_log();
3487
3511
  p6 = prefix("SceneObject");
3488
- _SceneObject = class _SceneObject extends import_three11.Object3D {
3512
+ _SceneObject = class _SceneObject extends import_three12.Object3D {
3489
3513
  constructor(options) {
3490
3514
  super();
3491
3515
  this.isSceneObject = true;
@@ -3494,6 +3518,7 @@ var init_SceneObject = __esm({
3494
3518
  this._instanceCounter = 0;
3495
3519
  this.instanceReferences = /* @__PURE__ */ new Map();
3496
3520
  this.freeInstanceIndices = [];
3521
+ this.hiddenInstanceMatrices = /* @__PURE__ */ new Map();
3497
3522
  this.options = (0, import_ts_deepmerge3.default)({}, _SceneObject.DEFAULT_OPTIONS, options ?? {});
3498
3523
  console.log("SceneObject options", this.options);
3499
3524
  }
@@ -3529,7 +3554,7 @@ var init_SceneObject = __esm({
3529
3554
  return group;
3530
3555
  }
3531
3556
  createGroup(name, x = 0, y = 0, z = 0, offsetAxis, offset = 0) {
3532
- const obj = new import_three11.Object3D();
3557
+ const obj = new import_three12.Object3D();
3533
3558
  if (name) {
3534
3559
  obj.name = `group:${name}`;
3535
3560
  }
@@ -3579,7 +3604,7 @@ var init_SceneObject = __esm({
3579
3604
  return mesh;
3580
3605
  }
3581
3606
  createMesh(name, geometry, material, offsetAxis, offset = 0) {
3582
- const mesh = new import_three11.Mesh(geometry, material);
3607
+ const mesh = new import_three12.Mesh(geometry, material);
3583
3608
  if (name) {
3584
3609
  mesh.name = `mesh:${name}`;
3585
3610
  }
@@ -3591,7 +3616,7 @@ var init_SceneObject = __esm({
3591
3616
  return mesh;
3592
3617
  }
3593
3618
  createInstancedMesh(name, geometry, material, count) {
3594
- const mesh = new import_three11.InstancedMesh(geometry, material, count);
3619
+ const mesh = new import_three12.InstancedMesh(geometry, material, count);
3595
3620
  mesh.count = 0;
3596
3621
  this.instanceMesh = mesh;
3597
3622
  this._isInstanced = true;
@@ -3671,11 +3696,11 @@ var init_SceneObject = __esm({
3671
3696
  this._instanceCounter = this.instanceReferences.size;
3672
3697
  mesh.count = Math.max(mesh.count, index + 1);
3673
3698
  if (mesh.instanceColor) {
3674
- mesh.setColorAt(index, new import_three11.Color(16777215));
3699
+ mesh.setColorAt(index, new import_three12.Color(16777215));
3675
3700
  mesh.instanceColor.needsUpdate = true;
3676
3701
  }
3677
3702
  if (this._scene) this._scene.stats.instanceCount++;
3678
- this.setMatrixAt(index, new import_three11.Matrix4());
3703
+ this.setMatrixAt(index, new import_three12.Matrix4());
3679
3704
  return reference;
3680
3705
  }
3681
3706
  /** Returns the live reference for a raycast hit on this object's instance mesh. */
@@ -3688,7 +3713,8 @@ var init_SceneObject = __esm({
3688
3713
  removeInstanceAt(index) {
3689
3714
  if (!this.instanceReferences.has(index)) return;
3690
3715
  const mesh = this.instanceMesh;
3691
- this.setMatrixAt(index, new import_three11.Matrix4().makeScale(0, 0, 0));
3716
+ this.hiddenInstanceMatrices.delete(index);
3717
+ this.setMatrixAt(index, new import_three12.Matrix4().makeScale(0, 0, 0));
3692
3718
  this.instanceReferences.delete(index);
3693
3719
  this.freeInstanceIndices.push(index);
3694
3720
  this._instanceCounter = this.instanceReferences.size;
@@ -3701,7 +3727,7 @@ var init_SceneObject = __esm({
3701
3727
  const grow = (attribute, fill) => {
3702
3728
  const array = new Float32Array(capacity * attribute.itemSize).fill(fill);
3703
3729
  array.set(attribute.array);
3704
- return new import_three11.InstancedBufferAttribute(array, attribute.itemSize, attribute.normalized, attribute.meshPerAttribute).setUsage(attribute.usage);
3730
+ return new import_three12.InstancedBufferAttribute(array, attribute.itemSize, attribute.normalized, attribute.meshPerAttribute).setUsage(attribute.usage);
3705
3731
  };
3706
3732
  const matrix = grow(mesh.instanceMatrix, 0);
3707
3733
  const color = mesh.instanceColor ? grow(mesh.instanceColor, 1) : null;
@@ -3718,32 +3744,60 @@ var init_SceneObject = __esm({
3718
3744
  }
3719
3745
  //</editor-fold>
3720
3746
  //<editor-fold desc="TRANSFORMATION">
3721
- getMatrixAt(index, matrix = new import_three11.Matrix4()) {
3747
+ getMatrixAt(index, matrix = new import_three12.Matrix4()) {
3722
3748
  if (!this.instanceReferences.has(index)) throw new MineRenderError("Instance is not active");
3749
+ const hidden = this.hiddenInstanceMatrices.get(index);
3750
+ if (hidden) {
3751
+ return matrix.copy(hidden);
3752
+ }
3723
3753
  this.instanceMesh.getMatrixAt(index, matrix);
3724
3754
  return matrix;
3725
3755
  }
3726
3756
  setMatrixAt(index, matrix) {
3727
3757
  if (!this.instanceReferences.has(index)) throw new MineRenderError("Instance is not active");
3728
3758
  const mesh = this.instanceMesh;
3729
- mesh.setMatrixAt(index, matrix);
3759
+ const hidden = this.hiddenInstanceMatrices.get(index);
3760
+ if (hidden) {
3761
+ hidden.copy(matrix);
3762
+ }
3763
+ mesh.setMatrixAt(index, hidden ? new import_three12.Matrix4().makeScale(0, 0, 0) : matrix);
3730
3764
  mesh.instanceMatrix.needsUpdate = true;
3731
3765
  mesh.boundingBox = null;
3732
3766
  mesh.boundingSphere = null;
3733
3767
  this.notifyDirty();
3734
3768
  }
3769
+ setInstanceVisibleAt(index, visible) {
3770
+ if (!this.instanceReferences.has(index)) {
3771
+ throw new MineRenderError("Instance is not active");
3772
+ }
3773
+ const hidden = this.hiddenInstanceMatrices.get(index);
3774
+ if (visible) {
3775
+ if (!hidden) {
3776
+ return;
3777
+ }
3778
+ this.hiddenInstanceMatrices.delete(index);
3779
+ this.setMatrixAt(index, hidden);
3780
+ } else {
3781
+ if (hidden) {
3782
+ return;
3783
+ }
3784
+ const matrix = this.getMatrixAt(index);
3785
+ this.hiddenInstanceMatrices.set(index, matrix);
3786
+ this.setMatrixAt(index, matrix);
3787
+ }
3788
+ }
3735
3789
  setPositionRotationScaleAt(index, position, rotation, scale) {
3736
3790
  if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
3737
- const oldPosition = new import_three11.Vector3();
3738
- const oldRotation = new import_three11.Quaternion();
3739
- const oldScale = new import_three11.Vector3();
3740
- const matrix = new import_three11.Matrix4();
3791
+ const oldPosition = new import_three12.Vector3();
3792
+ const oldRotation = new import_three12.Quaternion();
3793
+ const oldScale = new import_three12.Vector3();
3794
+ const matrix = new import_three12.Matrix4();
3741
3795
  if (!scale || !rotation || !position) {
3742
3796
  this.getMatrixAt(index, matrix).decompose(oldPosition, oldRotation, oldScale);
3743
3797
  }
3744
3798
  matrix.compose(
3745
3799
  position ? position : oldPosition,
3746
- rotation ? new import_three11.Quaternion().setFromEuler(rotation) : oldRotation,
3800
+ rotation ? new import_three12.Quaternion().setFromEuler(rotation) : oldRotation,
3747
3801
  scale ? scale : oldScale
3748
3802
  );
3749
3803
  this.setMatrixAt(index, matrix);
@@ -3752,7 +3806,7 @@ var init_SceneObject = __esm({
3752
3806
  if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
3753
3807
  this.setPositionRotationScaleAt(index, position);
3754
3808
  }
3755
- getPositionAt(index, vector = new import_three11.Vector3()) {
3809
+ getPositionAt(index, vector = new import_three12.Vector3()) {
3756
3810
  if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
3757
3811
  const matrix = this.getMatrixAt(index);
3758
3812
  vector.setFromMatrixPosition(matrix);
@@ -3762,17 +3816,17 @@ var init_SceneObject = __esm({
3762
3816
  if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
3763
3817
  this.setPositionRotationScaleAt(index, void 0, rotation, void 0);
3764
3818
  }
3765
- getRotationAt(index, euler = new import_three11.Euler()) {
3819
+ getRotationAt(index, euler = new import_three12.Euler()) {
3766
3820
  if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
3767
- const rotation = new import_three11.Quaternion();
3768
- this.getMatrixAt(index).decompose(new import_three11.Vector3(), rotation, new import_three11.Vector3());
3821
+ const rotation = new import_three12.Quaternion();
3822
+ this.getMatrixAt(index).decompose(new import_three12.Vector3(), rotation, new import_three12.Vector3());
3769
3823
  return euler.setFromQuaternion(rotation);
3770
3824
  }
3771
3825
  setScaleAt(index, scale) {
3772
3826
  if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
3773
3827
  this.setPositionRotationScaleAt(index, void 0, void 0, scale);
3774
3828
  }
3775
- getScaleAt(index, vector = new import_three11.Vector3()) {
3829
+ getScaleAt(index, vector = new import_three12.Vector3()) {
3776
3830
  if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
3777
3831
  const matrix = this.getMatrixAt(index);
3778
3832
  vector.setFromMatrixScale(matrix);
@@ -3871,6 +3925,7 @@ var init_SceneObject = __esm({
3871
3925
  if (this._scene) this._scene.stats.instanceCount -= this.instanceReferences.size;
3872
3926
  this.instanceReferences.clear();
3873
3927
  this.freeInstanceIndices.length = 0;
3928
+ this.hiddenInstanceMatrices.clear();
3874
3929
  this._instanceCounter = 0;
3875
3930
  this.instanceMesh.count = 0;
3876
3931
  this.instanceMesh.dispose();
@@ -3907,13 +3962,13 @@ var init_SceneObject = __esm({
3907
3962
  function isEntityObject(obj) {
3908
3963
  return obj.isEntityObject;
3909
3964
  }
3910
- var import_ts_deepmerge4, import_three13, _EntityObject, EntityObject;
3965
+ var import_ts_deepmerge4, import_three14, _EntityObject, EntityObject;
3911
3966
  var init_EntityObject = __esm({
3912
3967
  "src/entity/scene/EntityObject.ts"() {
3913
3968
  init_SceneObject();
3914
3969
  init_Caching();
3915
3970
  import_ts_deepmerge4 = __toESM(require_dist());
3916
- import_three13 = require("three");
3971
+ import_three14 = require("three");
3917
3972
  init_Ticker();
3918
3973
  init_model();
3919
3974
  init_ModelTextures();
@@ -3934,7 +3989,8 @@ var init_EntityObject = __esm({
3934
3989
  this.scrollMaterials = [];
3935
3990
  /** Entity age in ticks, as vanilla's `ageInTicks`; drives the scrolling render modes. */
3936
3991
  this.age = 0;
3937
- this.animationPlayer = new EntityAnimationPlayer();
3992
+ this.animationPlayers = [];
3993
+ this.partPoses = /* @__PURE__ */ new Map();
3938
3994
  this.options = (0, import_ts_deepmerge4.default)({}, _EntityObject.DEFAULT_OPTIONS, options ?? {});
3939
3995
  this.addEventListener("added", () => this.updateScrollSubscription());
3940
3996
  this.addEventListener("removed", () => this.updateScrollSubscription());
@@ -3951,7 +4007,8 @@ var init_EntityObject = __esm({
3951
4007
  for (const geometry of this.geometries) geometry.dispose();
3952
4008
  this.geometries.clear();
3953
4009
  for (const dispose of this.disposeWireframes.splice(0)) dispose();
3954
- this.animationPlayer.clear();
4010
+ for (const player of this.animationPlayers.splice(0)) player.clear();
4011
+ this.partPoses.clear();
3955
4012
  super.disposeAndRemoveAllChildren();
3956
4013
  }
3957
4014
  clearScrollMaterials() {
@@ -3983,36 +4040,61 @@ var init_EntityObject = __esm({
3983
4040
  this.notifyDirty();
3984
4041
  }
3985
4042
  //<editor-fold desc="ANIMATION">
3986
- /** The animation started by {@link playAnimation}, until {@link stopAnimation} or disposal. */
4043
+ /** The first active clip, until playback is stopped or the object is disposed. */
3987
4044
  get animation() {
3988
- return this.animationPlayer.animation;
4045
+ return this.animationPlayers[0]?.animation;
4046
+ }
4047
+ /** Clips playing together, each targeting a separate geometry layer. */
4048
+ get activeAnimations() {
4049
+ return this.animationPlayers.map((player) => player.animation);
3989
4050
  }
3990
4051
  /** Seconds since the animation started, before looping. */
3991
4052
  get animationTime() {
3992
- return this.animationPlayer.time;
4053
+ return this.animationPlayers[0]?.time ?? 0;
3993
4054
  }
3994
4055
  /**
3995
- * Poses the object from a keyframe animation of {@link Entities.getAnimations}, replacing the current one.
3996
- * Parts of every layer are matched by name and their current pose is the default the offsets add to.
4056
+ * Plays a clip from {@link Entities.getAnimations}, replacing all active clips.
4057
+ * Offsets apply to the baked pose in the clip's layer (`main` by default), including repeated draws of that layer.
3997
4058
  * The object owns no clock: call {@link advanceAnimation} per frame, or {@link setAnimationTime}.
3998
4059
  */
3999
4060
  playAnimation(animation, options) {
4061
+ this.playAnimations([animation], options);
4062
+ }
4063
+ /** Plays one clip per selected geometry layer, with a shared clock and no blending between clips. */
4064
+ playAnimations(animations, options) {
4065
+ const targets = /* @__PURE__ */ new Set();
4066
+ const selections = animations.map((animation) => {
4067
+ const layer = animation.layer ?? "main";
4068
+ if (targets.has(layer)) throw new Error(`Multiple animations target layer "${layer}"`);
4069
+ targets.add(layer);
4070
+ const names = Object.keys(this.entityLayers).filter((name) => name.split("#")[0] === layer);
4071
+ if (!names.length) throw new Error(`Entity ${this.entity.id} has no selected animation layer "${layer}"`);
4072
+ return { animation, names };
4073
+ });
4000
4074
  this.createMeshes();
4001
- const layers = Object.keys(this.entityLayers).map((name) => this.getLayerGroup(name)).filter((layer) => !!layer);
4002
- this.animationPlayer.play(layers, animation, options);
4075
+ this.stopAnimation();
4076
+ for (const { animation, names } of selections) {
4077
+ const player = new EntityAnimationPlayer();
4078
+ player.play(names.map((name) => this.getLayerGroup(name)), animation, options, this.partPoses);
4079
+ this.animationPlayers.push(player);
4080
+ }
4003
4081
  this.notifyDirty();
4004
4082
  }
4005
- /** Stops the animation and restores the default pose. */
4083
+ /** Stops all clips and restores the poses from before playback. */
4006
4084
  stopAnimation() {
4007
- if (this.animationPlayer.stop()) this.notifyDirty();
4085
+ const players = this.animationPlayers.splice(0);
4086
+ for (const player of players) player.stop();
4087
+ if (players.length) this.notifyDirty();
4008
4088
  }
4009
4089
  /** Poses the object at an explicit time in seconds. Has no effect without an animation. */
4010
4090
  setAnimationTime(seconds) {
4011
- if (this.animationPlayer.setTime(seconds)) this.notifyDirty();
4091
+ for (const player of this.animationPlayers) player.setTime(seconds);
4092
+ if (this.animationPlayers.length) this.notifyDirty();
4012
4093
  }
4013
4094
  /** Advances the animation by a frame delta in seconds, scaled by its speed. Has no effect without an animation. */
4014
4095
  advanceAnimation(deltaSeconds) {
4015
- if (this.animationPlayer.advance(deltaSeconds)) this.notifyDirty();
4096
+ for (const player of this.animationPlayers) player.advance(deltaSeconds);
4097
+ if (this.animationPlayers.length) this.notifyDirty();
4016
4098
  }
4017
4099
  //</editor-fold>
4018
4100
  getLayerGroup(name) {
@@ -4044,14 +4126,14 @@ var init_EntityObject = __esm({
4044
4126
  }
4045
4127
  createMeshes(force = false) {
4046
4128
  if (this.meshesCreated && !force) return;
4047
- const modelRoot = new import_three13.Object3D();
4129
+ const modelRoot = new import_three14.Object3D();
4048
4130
  const transform = this.options.flip === void 0 ? this.entity.transform : void 0;
4049
4131
  if (transform) {
4050
4132
  for (const op of transform) {
4051
- const matrix = new import_three13.Matrix4();
4133
+ const matrix = new import_three14.Matrix4();
4052
4134
  if ("scale" in op) matrix.makeScale(...op.scale);
4053
4135
  else if ("translate" in op) matrix.makeTranslation(...op.translate);
4054
- else matrix.makeRotationFromEuler(new import_three13.Euler(...op.rotate, "ZYX"));
4136
+ else matrix.makeRotationFromEuler(new import_three14.Euler(...op.rotate, "ZYX"));
4055
4137
  modelRoot.matrix.multiply(matrix);
4056
4138
  }
4057
4139
  modelRoot.matrixAutoUpdate = false;
@@ -4072,6 +4154,7 @@ var init_EntityObject = __esm({
4072
4154
  anchor.position.fromArray(part.pose.offset);
4073
4155
  anchor.rotation.set(...part.pose.rotation, "ZYX");
4074
4156
  anchor.scale.fromArray(part.pose.scale ?? [1, 1, 1]);
4157
+ this.partPoses.set(anchor, part.pose);
4075
4158
  parent.add(anchor);
4076
4159
  const size = part.texture ?? textureSize;
4077
4160
  for (const cube of part.cubes) {
@@ -4107,7 +4190,7 @@ var init_EntityObject = __esm({
4107
4190
  const tint = layer.tint === void 0 ? void 0 : this.options.tints?.[layer.tint];
4108
4191
  const scroll = Materials.entityModeScroll(mode);
4109
4192
  const assetKeyStr = this.getTextureKey(layer).serialize();
4110
- const keyStr = `entity:${mode}:${tint === void 0 ? "" : new import_three13.Color(tint).getHexString()}:${assetKeyStr}`;
4193
+ const keyStr = `entity:${mode}:${tint === void 0 ? "" : new import_three14.Color(tint).getHexString()}:${assetKeyStr}`;
4111
4194
  let mat = scroll ? void 0 : Caching.materialCache.getIfPresent(keyStr);
4112
4195
  if (!mat) {
4113
4196
  const cachedAsset = Caching.textureAssetCache.getIfPresent(assetKeyStr);
@@ -4150,7 +4233,7 @@ function mergeBufferGeometries(geometries, useGroups = false) {
4150
4233
  const attributes = {};
4151
4234
  const morphAttributes = {};
4152
4235
  const morphTargetsRelative = geometries[0].morphTargetsRelative;
4153
- const mergedGeometry = new import_three20.BufferGeometry();
4236
+ const mergedGeometry = new import_three21.BufferGeometry();
4154
4237
  let offset = 0;
4155
4238
  for (let i = 0; i < geometries.length; ++i) {
4156
4239
  const geometry = geometries[i];
@@ -4274,7 +4357,7 @@ function mergeBufferAttributes(attributes) {
4274
4357
  array.set(attributes[i].array, offset);
4275
4358
  offset += attributes[i].array.length;
4276
4359
  }
4277
- return new import_three20.BufferAttribute(array, itemSize, normalized);
4360
+ return new import_three21.BufferAttribute(array, itemSize, normalized);
4278
4361
  }
4279
4362
  function interleaveAttributes(attributes) {
4280
4363
  let TypedArray;
@@ -4290,7 +4373,7 @@ function interleaveAttributes(attributes) {
4290
4373
  arrayLength += attribute.array.length;
4291
4374
  stride += attribute.itemSize;
4292
4375
  }
4293
- const interleavedBuffer = new import_three20.InterleavedBuffer(new TypedArray(arrayLength), stride);
4376
+ const interleavedBuffer = new import_three21.InterleavedBuffer(new TypedArray(arrayLength), stride);
4294
4377
  let offset = 0;
4295
4378
  const res = [];
4296
4379
  const getters = ["getX", "getY", "getZ", "getW"];
@@ -4299,7 +4382,7 @@ function interleaveAttributes(attributes) {
4299
4382
  const attribute = attributes[j];
4300
4383
  const itemSize = attribute.itemSize;
4301
4384
  const count = attribute.count;
4302
- const iba = new import_three20.InterleavedBufferAttribute(interleavedBuffer, itemSize, offset, attribute.normalized);
4385
+ const iba = new import_three21.InterleavedBufferAttribute(interleavedBuffer, itemSize, offset, attribute.normalized);
4303
4386
  res.push(iba);
4304
4387
  offset += itemSize;
4305
4388
  for (let c = 0; c < count; c++) {
@@ -4383,13 +4466,13 @@ function mergeVertices(geometry, tolerance = 1e-4) {
4383
4466
  const name = attributeNames[i];
4384
4467
  const oldAttribute = geometry.getAttribute(name);
4385
4468
  const buffer = new oldAttribute.array.constructor(attrArrays[name]);
4386
- const attribute = new import_three20.BufferAttribute(buffer, oldAttribute.itemSize, oldAttribute.normalized);
4469
+ const attribute = new import_three21.BufferAttribute(buffer, oldAttribute.itemSize, oldAttribute.normalized);
4387
4470
  result.setAttribute(name, attribute);
4388
4471
  if (name in morphAttrsArrays) {
4389
4472
  for (let j = 0; j < morphAttrsArrays[name].length; j++) {
4390
4473
  const oldMorphAttribute = geometry.morphAttributes[name][j];
4391
4474
  const buffer2 = new oldMorphAttribute.array.constructor(morphAttrsArrays[name][j]);
4392
- const morphAttribute = new import_three20.BufferAttribute(buffer2, oldMorphAttribute.itemSize, oldMorphAttribute.normalized);
4475
+ const morphAttribute = new import_three21.BufferAttribute(buffer2, oldMorphAttribute.itemSize, oldMorphAttribute.normalized);
4393
4476
  result.morphAttributes[name][j] = morphAttribute;
4394
4477
  }
4395
4478
  }
@@ -4398,11 +4481,11 @@ function mergeVertices(geometry, tolerance = 1e-4) {
4398
4481
  return result;
4399
4482
  }
4400
4483
  function toTrianglesDrawMode(geometry, drawMode) {
4401
- if (drawMode === import_three20.TrianglesDrawMode) {
4484
+ if (drawMode === import_three21.TrianglesDrawMode) {
4402
4485
  console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles.");
4403
4486
  return geometry;
4404
4487
  }
4405
- if (drawMode === import_three20.TriangleFanDrawMode || drawMode === import_three20.TriangleStripDrawMode) {
4488
+ if (drawMode === import_three21.TriangleFanDrawMode || drawMode === import_three21.TriangleStripDrawMode) {
4406
4489
  let index = geometry.getIndex();
4407
4490
  if (index === null) {
4408
4491
  const indices = [];
@@ -4420,7 +4503,7 @@ function toTrianglesDrawMode(geometry, drawMode) {
4420
4503
  }
4421
4504
  const numberOfTriangles = index.count - 2;
4422
4505
  const newIndices = [];
4423
- if (drawMode === import_three20.TriangleFanDrawMode) {
4506
+ if (drawMode === import_three21.TriangleFanDrawMode) {
4424
4507
  for (let i = 1; i <= numberOfTriangles; i++) {
4425
4508
  newIndices.push(index.getX(0));
4426
4509
  newIndices.push(index.getX(i));
@@ -4456,15 +4539,15 @@ function computeMorphedAttributes(object) {
4456
4539
  console.error("THREE.BufferGeometryUtils: Geometry is not of type BufferGeometry.");
4457
4540
  return null;
4458
4541
  }
4459
- const _vA = new import_three20.Vector3();
4460
- const _vB = new import_three20.Vector3();
4461
- const _vC = new import_three20.Vector3();
4462
- const _tempA = new import_three20.Vector3();
4463
- const _tempB = new import_three20.Vector3();
4464
- const _tempC = new import_three20.Vector3();
4465
- const _morphA = new import_three20.Vector3();
4466
- const _morphB = new import_three20.Vector3();
4467
- const _morphC = new import_three20.Vector3();
4542
+ const _vA = new import_three21.Vector3();
4543
+ const _vB = new import_three21.Vector3();
4544
+ const _vC = new import_three21.Vector3();
4545
+ const _tempA = new import_three21.Vector3();
4546
+ const _tempB = new import_three21.Vector3();
4547
+ const _tempC = new import_three21.Vector3();
4548
+ const _morphA = new import_three21.Vector3();
4549
+ const _morphB = new import_three21.Vector3();
4550
+ const _morphC = new import_three21.Vector3();
4468
4551
  function _calculateMorphedAttributeData(object2, material2, attribute, morphAttribute, morphTargetsRelative2, a2, b2, c2, modifiedAttributeArray) {
4469
4552
  _vA.fromBufferAttribute(attribute, a2);
4470
4553
  _vB.fromBufferAttribute(attribute, b2);
@@ -4659,8 +4742,8 @@ function computeMorphedAttributes(object) {
4659
4742
  }
4660
4743
  }
4661
4744
  }
4662
- const morphedPositionAttribute = new import_three20.Float32BufferAttribute(modifiedPosition, 3);
4663
- const morphedNormalAttribute = new import_three20.Float32BufferAttribute(modifiedNormal, 3);
4745
+ const morphedPositionAttribute = new import_three21.Float32BufferAttribute(modifiedPosition, 3);
4746
+ const morphedNormalAttribute = new import_three21.Float32BufferAttribute(modifiedNormal, 3);
4664
4747
  return {
4665
4748
  positionAttribute,
4666
4749
  normalAttribute,
@@ -4668,24 +4751,24 @@ function computeMorphedAttributes(object) {
4668
4751
  morphedNormalAttribute
4669
4752
  };
4670
4753
  }
4671
- var import_three20;
4754
+ var import_three21;
4672
4755
  var init_BufferGeometryUtils = __esm({
4673
4756
  "src/three/BufferGeometryUtils.js"() {
4674
- import_three20 = require("three");
4757
+ import_three21 = require("three");
4675
4758
  }
4676
4759
  });
4677
4760
 
4678
4761
  // src/model/ModelCulling.ts
4679
- var import_three21, ModelCulling;
4762
+ var import_three22, ModelCulling;
4680
4763
  var init_ModelCulling = __esm({
4681
4764
  "src/model/ModelCulling.ts"() {
4682
- import_three21 = require("three");
4765
+ import_three22 = require("three");
4683
4766
  init_CubeFace();
4684
4767
  ModelCulling = class {
4685
4768
  static toLocalMask(worldMask, rotation) {
4686
4769
  let localMask = 0;
4687
4770
  for (const [localFace, offset] of CUBE_FACE_OFFSETS.entries()) {
4688
- const normal = new import_three21.Vector3(...offset).applyEuler(rotation);
4771
+ const normal = new import_three22.Vector3(...offset).applyEuler(rotation);
4689
4772
  const worldFace = CUBE_FACE_OFFSETS.findIndex(([x, y, z]) => Math.abs(normal.x - x) < 1e-6 && Math.abs(normal.y - y) < 1e-6 && Math.abs(normal.z - z) < 1e-6);
4690
4773
  if (worldFace < 0) return 0;
4691
4774
  if (worldMask & 1 << worldFace) localMask |= 1 << localFace;
@@ -4718,10 +4801,10 @@ var init_ModelCulling = __esm({
4718
4801
  });
4719
4802
 
4720
4803
  // src/model/SpecialItems.ts
4721
- var import_three22, SpecialItems;
4804
+ var import_three23, SpecialItems;
4722
4805
  var init_SpecialItems = __esm({
4723
4806
  "src/model/SpecialItems.ts"() {
4724
- import_three22 = require("three");
4807
+ import_three23 = require("three");
4725
4808
  init_AssetKey();
4726
4809
  init_Entities();
4727
4810
  SpecialItems = class {
@@ -4749,7 +4832,7 @@ var init_SpecialItems = __esm({
4749
4832
  case "minecraft:chest":
4750
4833
  case "chest": {
4751
4834
  const angle = -(special.openness ?? 0) * Math.PI / 2;
4752
- const chest = await load("chest", texture(special.texture, "chest"), new import_three22.Matrix4(), {
4835
+ const chest = await load("chest", texture(special.texture, "chest"), new import_three23.Matrix4(), {
4753
4836
  lid: [angle, 0, 0],
4754
4837
  lock: [angle, 0, 0]
4755
4838
  });
@@ -4758,11 +4841,11 @@ var init_SpecialItems = __esm({
4758
4841
  }
4759
4842
  case "minecraft:bed":
4760
4843
  case "bed": {
4761
- const transform = new import_three22.Matrix4().makeTranslation(0, 9, 0).multiply(new import_three22.Matrix4().makeRotationX(Math.PI / 2)).multiply(new import_three22.Matrix4().makeTranslation(8, 8, 8)).multiply(new import_three22.Matrix4().makeRotationZ(Math.PI)).multiply(new import_three22.Matrix4().makeTranslation(-8, -8, -8));
4844
+ const transform = new import_three23.Matrix4().makeTranslation(0, 9, 0).multiply(new import_three23.Matrix4().makeRotationX(Math.PI / 2)).multiply(new import_three23.Matrix4().makeTranslation(8, 8, 8)).multiply(new import_three23.Matrix4().makeRotationZ(Math.PI)).multiply(new import_three23.Matrix4().makeTranslation(-8, -8, -8));
4762
4845
  const key = texture(special.texture, "bed");
4763
4846
  return Promise.all([
4764
4847
  load("bed_head", key, transform),
4765
- load("bed_foot", key, new import_three22.Matrix4().makeTranslation(0, 0, -16).multiply(transform))
4848
+ load("bed_foot", key, new import_three23.Matrix4().makeTranslation(0, 0, -16).multiply(transform))
4766
4849
  ]);
4767
4850
  }
4768
4851
  case "minecraft:head":
@@ -4787,7 +4870,7 @@ var init_SpecialItems = __esm({
4787
4870
  return [await load(
4788
4871
  id,
4789
4872
  special.texture ? texture(special.texture, "") : void 0,
4790
- new import_three22.Matrix4().makeTranslation(8, 0, 8).multiply(new import_three22.Matrix4().makeScale(-1, -1, 1)),
4873
+ new import_three23.Matrix4().makeTranslation(8, 0, 8).multiply(new import_three23.Matrix4().makeScale(-1, -1, 1)),
4791
4874
  rotations
4792
4875
  )];
4793
4876
  }
@@ -4915,13 +4998,13 @@ var init_ItemTints = __esm({
4915
4998
  function isModelObject(obj) {
4916
4999
  return obj.isModelObject;
4917
5000
  }
4918
- var import_three23, import_ts_deepmerge5, p7, _ModelObject, ModelObject;
5001
+ var import_three24, import_ts_deepmerge5, p7, _ModelObject, ModelObject;
4919
5002
  var init_ModelObject = __esm({
4920
5003
  "src/model/scene/ModelObject.ts"() {
4921
5004
  init_SceneObject();
4922
5005
  init_Materials();
4923
5006
  init_UVMapper();
4924
- import_three23 = require("three");
5007
+ import_three24 = require("three");
4925
5008
  init_BufferGeometryUtils();
4926
5009
  init_model();
4927
5010
  import_ts_deepmerge5 = __toESM(require_dist());
@@ -4953,8 +5036,8 @@ var init_ModelObject = __esm({
4953
5036
  const special = this.originalModel.special;
4954
5037
  if (special) {
4955
5038
  const parts = await SpecialItems.getParts(special, this.originalModel.key?.root);
4956
- const transform = this.options.displayPosition ? DisplayTransforms.getMatrix(this.originalModel.display, this.options.displayPosition) : new import_three23.Matrix4();
4957
- transform.multiply(new import_three23.Matrix4().makeTranslation(-8, -8, -8));
5039
+ const transform = this.options.displayPosition ? DisplayTransforms.getMatrix(this.originalModel.display, this.options.displayPosition) : new import_three24.Matrix4();
5040
+ transform.multiply(new import_three24.Matrix4().makeTranslation(-8, -8, -8));
4958
5041
  try {
4959
5042
  for (const part of parts) {
4960
5043
  const object = new EntityObject(part.model, { flip: false, wireframe: this.options.wireframe });
@@ -5016,7 +5099,7 @@ var init_ModelObject = __esm({
5016
5099
  elGeo.clearGroups();
5017
5100
  }
5018
5101
  if (this.options.uvLockRotation) {
5019
- UVMapper.lockUvs(elGeo, el.faces, this.atlas, new import_three23.Euler(...this.options.uvLockRotation));
5102
+ UVMapper.lockUvs(elGeo, el.faces, this.atlas, new import_three24.Euler(...this.options.uvLockRotation));
5020
5103
  }
5021
5104
  if (this.options.tints) {
5022
5105
  const colors = new Float32Array(elGeo.getAttribute("position").count * 3).fill(1);
@@ -5025,19 +5108,19 @@ var init_ModelObject = __esm({
5025
5108
  if (tintIndex === void 0 || tintIndex < 0) continue;
5026
5109
  const tint = this.options.tints[tintIndex];
5027
5110
  if (tint === void 0) continue;
5028
- const color = new import_three23.Color(tint);
5111
+ const color = new import_three24.Color(tint);
5029
5112
  for (let vertex = 0; vertex < 4; vertex++) {
5030
5113
  color.toArray(colors, (faceIndex * 4 + vertex) * 3);
5031
5114
  }
5032
5115
  }
5033
- elGeo.setAttribute("color", new import_three23.BufferAttribute(colors, 3));
5116
+ elGeo.setAttribute("color", new import_three24.BufferAttribute(colors, 3));
5034
5117
  }
5035
- elGeo.applyMatrix4(new import_three23.Matrix4().makeTranslation((el.to[0] - el.from[0]) / 2, (el.to[1] - el.from[1]) / 2, (el.to[2] - el.from[2]) / 2));
5036
- elGeo.applyMatrix4(new import_three23.Matrix4().makeTranslation(el.from[0], el.from[1], el.from[2]));
5118
+ elGeo.applyMatrix4(new import_three24.Matrix4().makeTranslation((el.to[0] - el.from[0]) / 2, (el.to[1] - el.from[1]) / 2, (el.to[2] - el.from[2]) / 2));
5119
+ elGeo.applyMatrix4(new import_three24.Matrix4().makeTranslation(el.from[0], el.from[1], el.from[2]));
5037
5120
  if (el.rotation) {
5038
5121
  applyElementRotation(el.rotation, elGeo);
5039
5122
  }
5040
- elGeo.applyMatrix4(new import_three23.Matrix4().makeTranslation(-8, -8, -8));
5123
+ elGeo.applyMatrix4(new import_three24.Matrix4().makeTranslation(-8, -8, -8));
5041
5124
  if (displayTransform) DisplayTransforms.apply(elGeo, displayTransform);
5042
5125
  if (this.options.mergeMeshes) {
5043
5126
  allGeos.push(elGeo);
@@ -5059,7 +5142,7 @@ var init_ModelObject = __esm({
5059
5142
  if (allGeos.length > 0) {
5060
5143
  combinedGeo = mergeBufferGeometries(allGeos);
5061
5144
  } else {
5062
- combinedGeo = new import_three23.BoxGeometry(16, 16, 16);
5145
+ combinedGeo = new import_three24.BoxGeometry(16, 16, 16);
5063
5146
  if (displayTransform) DisplayTransforms.apply(combinedGeo, displayTransform);
5064
5147
  }
5065
5148
  combinedGeo.computeBoundingBox();
@@ -5171,7 +5254,7 @@ function ownHeight(sample) {
5171
5254
  return (level === 0 || level >= 8 ? 8 : 8 - level) / 9;
5172
5255
  }
5173
5256
  function createFluidGeometry(kind, sample) {
5174
- const geometry = new import_three28.BufferGeometry();
5257
+ const geometry = new import_three29.BufferGeometry();
5175
5258
  const positions = [], normals = [], uvs = [], indices = [];
5176
5259
  const self = sample(0, 0, 0);
5177
5260
  const height = (x, z) => {
@@ -5270,16 +5353,16 @@ function createFluidGeometry(kind, sample) {
5270
5353
  1
5271
5354
  );
5272
5355
  }
5273
- geometry.setAttribute("position", new import_three28.Float32BufferAttribute(positions, 3));
5274
- geometry.setAttribute("normal", new import_three28.Float32BufferAttribute(normals, 3));
5275
- geometry.setAttribute("uv", new import_three28.Float32BufferAttribute(uvs, 2));
5356
+ geometry.setAttribute("position", new import_three29.Float32BufferAttribute(positions, 3));
5357
+ geometry.setAttribute("normal", new import_three29.Float32BufferAttribute(normals, 3));
5358
+ geometry.setAttribute("uv", new import_three29.Float32BufferAttribute(uvs, 2));
5276
5359
  geometry.setIndex(indices);
5277
5360
  return geometry;
5278
5361
  }
5279
- var import_three28, fluidRules, HORIZONTAL, EPSILON;
5362
+ var import_three29, fluidRules, HORIZONTAL, EPSILON;
5280
5363
  var init_FluidGeometry = __esm({
5281
5364
  "src/model/fluid/FluidGeometry.ts"() {
5282
- import_three28 = require("three");
5365
+ import_three29 = require("three");
5283
5366
  init_fluidBlocks();
5284
5367
  fluidRules = fluidBlocks_default;
5285
5368
  HORIZONTAL = [[0, -1], [0, 1], [-1, 0], [1, 0]];
@@ -5308,10 +5391,10 @@ function sampleFluid(kind, sample) {
5308
5391
  }
5309
5392
  return { key: key.join(""), sample: (x, y, z) => cells[(y + 1) * 9 + (z + 1) * 3 + x + 1] };
5310
5393
  }
5311
- var import_three29, FluidModelObject;
5394
+ var import_three30, FluidModelObject;
5312
5395
  var init_FluidModelObject = __esm({
5313
5396
  "src/model/fluid/FluidModelObject.ts"() {
5314
- import_three29 = require("three");
5397
+ import_three30 = require("three");
5315
5398
  init_AssetKey();
5316
5399
  init_Materials();
5317
5400
  init_ModelObject();
@@ -5344,10 +5427,10 @@ var init_FluidModelObject = __esm({
5344
5427
  }
5345
5428
  }
5346
5429
  geometry.clearGroups();
5347
- const color = new import_three29.Color(this.options.tints?.[0] ?? (this.kind === "water" ? 4159204 : 16777215));
5430
+ const color = new import_three30.Color(this.options.tints?.[0] ?? (this.kind === "water" ? 4159204 : 16777215));
5348
5431
  const colors = new Float32Array(geometry.getAttribute("position").count * 3);
5349
5432
  for (let i = 0; i < colors.length; i += 3) color.toArray(colors, i);
5350
- geometry.setAttribute("color", new import_three29.BufferAttribute(colors, 3));
5433
+ geometry.setAttribute("color", new import_three30.BufferAttribute(colors, 3));
5351
5434
  geometry.computeBoundingBox();
5352
5435
  geometry.computeBoundingSphere();
5353
5436
  if (this.options.instanceMeshes) {
@@ -5361,7 +5444,7 @@ var init_FluidModelObject = __esm({
5361
5444
  super.applyTextures();
5362
5445
  this.iterateAllMeshes((mesh) => {
5363
5446
  const material = mesh.material;
5364
- material.side = import_three29.DoubleSide;
5447
+ material.side = import_three30.DoubleSide;
5365
5448
  material.forceSinglePass = true;
5366
5449
  material.depthWrite = !material.transparent;
5367
5450
  });
@@ -5848,27 +5931,27 @@ init_EntityObject();
5848
5931
  init_MineRenderError();
5849
5932
 
5850
5933
  // src/export/SceneExporter.ts
5851
- var import_three19 = require("three");
5934
+ var import_three20 = require("three");
5852
5935
 
5853
5936
  // ../../node_modules/three/examples/jsm/exporters/OBJExporter.js
5854
- var import_three15 = require("three");
5937
+ var import_three16 = require("three");
5855
5938
  var OBJExporter = class {
5856
5939
  parse(object) {
5857
5940
  let output = "";
5858
5941
  let indexVertex = 0;
5859
5942
  let indexVertexUvs = 0;
5860
5943
  let indexNormals = 0;
5861
- const vertex = new import_three15.Vector3();
5862
- const color = new import_three15.Color();
5863
- const normal = new import_three15.Vector3();
5864
- const uv = new import_three15.Vector2();
5944
+ const vertex = new import_three16.Vector3();
5945
+ const color = new import_three16.Color();
5946
+ const normal = new import_three16.Vector3();
5947
+ const uv = new import_three16.Vector2();
5865
5948
  const face = [];
5866
5949
  function parseMesh(mesh) {
5867
5950
  let nbVertex = 0;
5868
5951
  let nbNormals = 0;
5869
5952
  let nbVertexUvs = 0;
5870
5953
  const geometry = mesh.geometry;
5871
- const normalMatrixWorld = new import_three15.Matrix3();
5954
+ const normalMatrixWorld = new import_three16.Matrix3();
5872
5955
  const vertices = geometry.getAttribute("position");
5873
5956
  const normals = geometry.getAttribute("normal");
5874
5957
  const uvs = geometry.getAttribute("uv");
@@ -5987,7 +6070,7 @@ var OBJExporter = class {
5987
6070
  };
5988
6071
 
5989
6072
  // ../../node_modules/three/examples/jsm/exporters/PLYExporter.js
5990
- var import_three16 = require("three");
6073
+ var import_three17 = require("three");
5991
6074
  var PLYExporter = class {
5992
6075
  parse(object, onDone, options = {}) {
5993
6076
  function traverseMeshes(cb) {
@@ -6044,7 +6127,7 @@ var PLYExporter = class {
6044
6127
  includeIndices = false;
6045
6128
  }
6046
6129
  });
6047
- const tempColor = new import_three16.Color();
6130
+ const tempColor = new import_three17.Color();
6048
6131
  includeIndices = includeIndices && excludeAttributes.indexOf("index") === -1;
6049
6132
  includeNormals = includeNormals && excludeAttributes.indexOf("normal") === -1;
6050
6133
  includeColors = includeColors && excludeAttributes.indexOf("color") === -1;
@@ -6078,8 +6161,8 @@ property list uchar int vertex_index
6078
6161
  `;
6079
6162
  }
6080
6163
  header += "end_header\n";
6081
- const vertex = new import_three16.Vector3();
6082
- const normalMatrixWorld = new import_three16.Matrix3();
6164
+ const vertex = new import_three17.Vector3();
6165
+ const normalMatrixWorld = new import_three17.Matrix3();
6083
6166
  let result = null;
6084
6167
  if (options.binary === true) {
6085
6168
  const headerBin = new TextEncoder().encode(header);
@@ -6253,18 +6336,18 @@ property list uchar int vertex_index
6253
6336
  };
6254
6337
 
6255
6338
  // ../../node_modules/three/examples/jsm/exporters/GLTFExporter.js
6256
- var import_three18 = require("three");
6339
+ var import_three19 = require("three");
6257
6340
 
6258
6341
  // ../../node_modules/three/examples/jsm/utils/TextureUtils.js
6259
- var import_three17 = require("three");
6342
+ var import_three18 = require("three");
6260
6343
  var _renderer;
6261
6344
  var fullscreenQuadGeometry;
6262
6345
  var fullscreenQuadMaterial;
6263
6346
  var fullscreenQuad;
6264
6347
  function decompress(texture, maxTextureSize = Infinity, renderer = null) {
6265
- if (!fullscreenQuadGeometry) fullscreenQuadGeometry = new import_three17.PlaneGeometry(2, 2, 1, 1);
6266
- if (!fullscreenQuadMaterial) fullscreenQuadMaterial = new import_three17.ShaderMaterial({
6267
- uniforms: { blitTexture: new import_three17.Uniform(texture) },
6348
+ if (!fullscreenQuadGeometry) fullscreenQuadGeometry = new import_three18.PlaneGeometry(2, 2, 1, 1);
6349
+ if (!fullscreenQuadMaterial) fullscreenQuadMaterial = new import_three18.ShaderMaterial({
6350
+ uniforms: { blitTexture: new import_three18.Uniform(texture) },
6268
6351
  vertexShader: `
6269
6352
  varying vec2 vUv;
6270
6353
  void main(){
@@ -6286,22 +6369,22 @@ function decompress(texture, maxTextureSize = Infinity, renderer = null) {
6286
6369
  }`
6287
6370
  });
6288
6371
  fullscreenQuadMaterial.uniforms.blitTexture.value = texture;
6289
- fullscreenQuadMaterial.defines.IS_SRGB = texture.colorSpace == import_three17.SRGBColorSpace;
6372
+ fullscreenQuadMaterial.defines.IS_SRGB = texture.colorSpace == import_three18.SRGBColorSpace;
6290
6373
  fullscreenQuadMaterial.needsUpdate = true;
6291
6374
  if (!fullscreenQuad) {
6292
- fullscreenQuad = new import_three17.Mesh(fullscreenQuadGeometry, fullscreenQuadMaterial);
6375
+ fullscreenQuad = new import_three18.Mesh(fullscreenQuadGeometry, fullscreenQuadMaterial);
6293
6376
  fullscreenQuad.frustrumCulled = false;
6294
6377
  }
6295
- const _camera = new import_three17.PerspectiveCamera();
6296
- const _scene = new import_three17.Scene();
6378
+ const _camera = new import_three18.PerspectiveCamera();
6379
+ const _scene = new import_three18.Scene();
6297
6380
  _scene.add(fullscreenQuad);
6298
6381
  if (!renderer) {
6299
- renderer = _renderer = new import_three17.WebGLRenderer({ antialias: false });
6382
+ renderer = _renderer = new import_three18.WebGLRenderer({ antialias: false });
6300
6383
  }
6301
6384
  renderer.setSize(Math.min(texture.image.width, maxTextureSize), Math.min(texture.image.height, maxTextureSize));
6302
6385
  renderer.clear();
6303
6386
  renderer.render(_scene, _camera);
6304
- const readableTexture = new import_three17.Texture(renderer.domElement);
6387
+ const readableTexture = new import_three18.Texture(renderer.domElement);
6305
6388
  readableTexture.minFilter = texture.minFilter;
6306
6389
  readableTexture.magFilter = texture.magFilter;
6307
6390
  readableTexture.wrapS = texture.wrapS;
@@ -6447,22 +6530,22 @@ var WEBGL_CONSTANTS = {
6447
6530
  };
6448
6531
  var KHR_MESH_QUANTIZATION = "KHR_mesh_quantization";
6449
6532
  var THREE_TO_WEBGL = {};
6450
- THREE_TO_WEBGL[import_three18.NearestFilter] = WEBGL_CONSTANTS.NEAREST;
6451
- THREE_TO_WEBGL[import_three18.NearestMipmapNearestFilter] = WEBGL_CONSTANTS.NEAREST_MIPMAP_NEAREST;
6452
- THREE_TO_WEBGL[import_three18.NearestMipmapLinearFilter] = WEBGL_CONSTANTS.NEAREST_MIPMAP_LINEAR;
6453
- THREE_TO_WEBGL[import_three18.LinearFilter] = WEBGL_CONSTANTS.LINEAR;
6454
- THREE_TO_WEBGL[import_three18.LinearMipmapNearestFilter] = WEBGL_CONSTANTS.LINEAR_MIPMAP_NEAREST;
6455
- THREE_TO_WEBGL[import_three18.LinearMipmapLinearFilter] = WEBGL_CONSTANTS.LINEAR_MIPMAP_LINEAR;
6456
- THREE_TO_WEBGL[import_three18.ClampToEdgeWrapping] = WEBGL_CONSTANTS.CLAMP_TO_EDGE;
6457
- THREE_TO_WEBGL[import_three18.RepeatWrapping] = WEBGL_CONSTANTS.REPEAT;
6458
- THREE_TO_WEBGL[import_three18.MirroredRepeatWrapping] = WEBGL_CONSTANTS.MIRRORED_REPEAT;
6533
+ THREE_TO_WEBGL[import_three19.NearestFilter] = WEBGL_CONSTANTS.NEAREST;
6534
+ THREE_TO_WEBGL[import_three19.NearestMipmapNearestFilter] = WEBGL_CONSTANTS.NEAREST_MIPMAP_NEAREST;
6535
+ THREE_TO_WEBGL[import_three19.NearestMipmapLinearFilter] = WEBGL_CONSTANTS.NEAREST_MIPMAP_LINEAR;
6536
+ THREE_TO_WEBGL[import_three19.LinearFilter] = WEBGL_CONSTANTS.LINEAR;
6537
+ THREE_TO_WEBGL[import_three19.LinearMipmapNearestFilter] = WEBGL_CONSTANTS.LINEAR_MIPMAP_NEAREST;
6538
+ THREE_TO_WEBGL[import_three19.LinearMipmapLinearFilter] = WEBGL_CONSTANTS.LINEAR_MIPMAP_LINEAR;
6539
+ THREE_TO_WEBGL[import_three19.ClampToEdgeWrapping] = WEBGL_CONSTANTS.CLAMP_TO_EDGE;
6540
+ THREE_TO_WEBGL[import_three19.RepeatWrapping] = WEBGL_CONSTANTS.REPEAT;
6541
+ THREE_TO_WEBGL[import_three19.MirroredRepeatWrapping] = WEBGL_CONSTANTS.MIRRORED_REPEAT;
6459
6542
  var PATH_PROPERTIES = {
6460
6543
  scale: "scale",
6461
6544
  position: "translation",
6462
6545
  quaternion: "rotation",
6463
6546
  morphTargetInfluences: "weights"
6464
6547
  };
6465
- var DEFAULT_SPECULAR_COLOR = new import_three18.Color();
6548
+ var DEFAULT_SPECULAR_COLOR = new import_three19.Color();
6466
6549
  var GLB_HEADER_BYTES = 12;
6467
6550
  var GLB_HEADER_MAGIC = 1179937895;
6468
6551
  var GLB_VERSION = 2;
@@ -6496,7 +6579,7 @@ function getMinMax(attribute, start, count) {
6496
6579
  else if (a === 2) value = attribute.getZ(i);
6497
6580
  else if (a === 3) value = attribute.getW(i);
6498
6581
  if (attribute.normalized === true) {
6499
- value = import_three18.MathUtils.normalize(value, attribute.array);
6582
+ value = import_three19.MathUtils.normalize(value, attribute.array);
6500
6583
  }
6501
6584
  }
6502
6585
  output.min[a] = Math.min(output.min[a], value);
@@ -6702,7 +6785,7 @@ var GLTFWriter = class {
6702
6785
  isNormalizedNormalAttribute(normal) {
6703
6786
  const cache = this.cache;
6704
6787
  if (cache.attributesNormalized.has(normal)) return false;
6705
- const v = new import_three18.Vector3();
6788
+ const v = new import_three19.Vector3();
6706
6789
  for (let i = 0, il = normal.count; i < il; i++) {
6707
6790
  if (Math.abs(v.fromBufferAttribute(normal, i).length() - 1) > 5e-4) return false;
6708
6791
  }
@@ -6719,7 +6802,7 @@ var GLTFWriter = class {
6719
6802
  const cache = this.cache;
6720
6803
  if (cache.attributesNormalized.has(normal)) return cache.attributesNormalized.get(normal);
6721
6804
  const attribute = normal.clone();
6722
- const v = new import_three18.Vector3();
6805
+ const v = new import_three19.Vector3();
6723
6806
  for (let i = 0, il = attribute.count; i < il; i++) {
6724
6807
  v.fromBufferAttribute(attribute, i);
6725
6808
  if (v.x === 0 && v.y === 0 && v.z === 0) {
@@ -6763,7 +6846,7 @@ var GLTFWriter = class {
6763
6846
  buildMetalRoughTexture(metalnessMap, roughnessMap) {
6764
6847
  if (metalnessMap === roughnessMap) return metalnessMap;
6765
6848
  function getEncodingConversion(map) {
6766
- if (map.colorSpace === import_three18.SRGBColorSpace) {
6849
+ if (map.colorSpace === import_three19.SRGBColorSpace) {
6767
6850
  return function SRGBToLinear(c) {
6768
6851
  return c < 0.04045 ? c * 0.0773993808 : Math.pow(c * 0.9478672986 + 0.0521327014, 2.4);
6769
6852
  };
@@ -6773,10 +6856,10 @@ var GLTFWriter = class {
6773
6856
  };
6774
6857
  }
6775
6858
  console.warn("THREE.GLTFExporter: Merged metalnessMap and roughnessMap textures.");
6776
- if (metalnessMap instanceof import_three18.CompressedTexture) {
6859
+ if (metalnessMap instanceof import_three19.CompressedTexture) {
6777
6860
  metalnessMap = decompress(metalnessMap);
6778
6861
  }
6779
- if (roughnessMap instanceof import_three18.CompressedTexture) {
6862
+ if (roughnessMap instanceof import_three19.CompressedTexture) {
6780
6863
  roughnessMap = decompress(roughnessMap);
6781
6864
  }
6782
6865
  const metalness = metalnessMap ? metalnessMap.image : null;
@@ -6809,8 +6892,8 @@ var GLTFWriter = class {
6809
6892
  context.putImageData(composite, 0, 0);
6810
6893
  const reference = metalnessMap || roughnessMap;
6811
6894
  const texture = reference.clone();
6812
- texture.source = new import_three18.Source(canvas);
6813
- texture.colorSpace = import_three18.NoColorSpace;
6895
+ texture.source = new import_three19.Source(canvas);
6896
+ texture.colorSpace = import_three19.NoColorSpace;
6814
6897
  texture.channel = (metalnessMap || roughnessMap).channel;
6815
6898
  if (metalnessMap && roughnessMap && metalnessMap.channel !== roughnessMap.channel) {
6816
6899
  console.warn("THREE.GLTFExporter: UV channels for metalnessMap and roughnessMap textures must match.");
@@ -6868,7 +6951,7 @@ var GLTFWriter = class {
6868
6951
  else if (a === 2) value = attribute.getZ(i);
6869
6952
  else if (a === 3) value = attribute.getW(i);
6870
6953
  if (attribute.normalized === true) {
6871
- value = import_three18.MathUtils.normalize(value, attribute.array);
6954
+ value = import_three19.MathUtils.normalize(value, attribute.array);
6872
6955
  }
6873
6956
  }
6874
6957
  if (componentType === WEBGL_CONSTANTS.FLOAT) {
@@ -7018,7 +7101,7 @@ var GLTFWriter = class {
7018
7101
  ctx.scale(1, -1);
7019
7102
  }
7020
7103
  if (image.data !== void 0) {
7021
- if (format !== import_three18.RGBAFormat) {
7104
+ if (format !== import_three19.RGBAFormat) {
7022
7105
  console.error("GLTFExporter: Only RGBAFormat is supported.", format);
7023
7106
  }
7024
7107
  if (image.width > options.maxTextureSize || image.height > options.maxTextureSize) {
@@ -7087,7 +7170,7 @@ var GLTFWriter = class {
7087
7170
  const json = this.json;
7088
7171
  if (cache.textures.has(map)) return cache.textures.get(map);
7089
7172
  if (!json.textures) json.textures = [];
7090
- if (map instanceof import_three18.CompressedTexture) {
7173
+ if (map instanceof import_three19.CompressedTexture) {
7091
7174
  map = decompress(map, options.maxTextureSize);
7092
7175
  }
7093
7176
  let mimeType = map.userData.mimeType;
@@ -7195,7 +7278,7 @@ var GLTFWriter = class {
7195
7278
  materialDef.alphaCutoff = material.alphaTest;
7196
7279
  }
7197
7280
  }
7198
- if (material.side === import_three18.DoubleSide) materialDef.doubleSided = true;
7281
+ if (material.side === import_three19.DoubleSide) materialDef.doubleSided = true;
7199
7282
  if (material.name !== "") materialDef.name = material.name;
7200
7283
  this.serializeUserData(material, materialDef);
7201
7284
  this._invokeAll(function(ext) {
@@ -7269,7 +7352,7 @@ var GLTFWriter = class {
7269
7352
  const array = attribute.array;
7270
7353
  if (attributeName === "JOINTS_0" && !(array instanceof Uint16Array) && !(array instanceof Uint8Array)) {
7271
7354
  console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.');
7272
- modifiedAttribute = new import_three18.BufferAttribute(new Uint16Array(array), attribute.itemSize, attribute.normalized);
7355
+ modifiedAttribute = new import_three19.BufferAttribute(new Uint16Array(array), attribute.itemSize, attribute.normalized);
7273
7356
  }
7274
7357
  const accessor = this.processAccessor(modifiedAttribute || attribute, geometry);
7275
7358
  if (accessor !== null) {
@@ -7429,7 +7512,7 @@ var GLTFWriter = class {
7429
7512
  } else {
7430
7513
  cameraDef.perspective = {
7431
7514
  aspectRatio: camera.aspect,
7432
- yfov: import_three18.MathUtils.degToRad(camera.fov),
7515
+ yfov: import_three19.MathUtils.degToRad(camera.fov),
7433
7516
  zfar: camera.far <= 0 ? 1e-3 : camera.far,
7434
7517
  znear: camera.near < 0 ? 0 : camera.near
7435
7518
  };
@@ -7457,8 +7540,8 @@ var GLTFWriter = class {
7457
7540
  const samplers = [];
7458
7541
  for (let i = 0; i < tracks.length; ++i) {
7459
7542
  const track = tracks[i];
7460
- const trackBinding = import_three18.PropertyBinding.parseTrackName(track.name);
7461
- let trackNode = import_three18.PropertyBinding.findNode(root, trackBinding.nodeName);
7543
+ const trackBinding = import_three19.PropertyBinding.parseTrackName(track.name);
7544
+ let trackNode = import_three19.PropertyBinding.findNode(root, trackBinding.nodeName);
7462
7545
  const trackProperty = PATH_PROPERTIES[trackBinding.propertyName];
7463
7546
  if (trackBinding.objectName === "bones") {
7464
7547
  if (trackNode.isSkinnedMesh === true) {
@@ -7480,14 +7563,14 @@ var GLTFWriter = class {
7480
7563
  if (track.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline === true) {
7481
7564
  interpolation = "CUBICSPLINE";
7482
7565
  outputItemSize /= 3;
7483
- } else if (track.getInterpolation() === import_three18.InterpolateDiscrete) {
7566
+ } else if (track.getInterpolation() === import_three19.InterpolateDiscrete) {
7484
7567
  interpolation = "STEP";
7485
7568
  } else {
7486
7569
  interpolation = "LINEAR";
7487
7570
  }
7488
7571
  samplers.push({
7489
- input: this.processAccessor(new import_three18.BufferAttribute(track.times, inputItemSize)),
7490
- output: this.processAccessor(new import_three18.BufferAttribute(track.values, outputItemSize)),
7572
+ input: this.processAccessor(new import_three19.BufferAttribute(track.times, inputItemSize)),
7573
+ output: this.processAccessor(new import_three19.BufferAttribute(track.values, outputItemSize)),
7491
7574
  interpolation
7492
7575
  });
7493
7576
  channels.push({
@@ -7519,7 +7602,7 @@ var GLTFWriter = class {
7519
7602
  if (rootJoint === void 0) return null;
7520
7603
  const joints = [];
7521
7604
  const inverseBindMatrices = new Float32Array(skeleton.bones.length * 16);
7522
- const temporaryBoneInverse = new import_three18.Matrix4();
7605
+ const temporaryBoneInverse = new import_three19.Matrix4();
7523
7606
  for (let i = 0; i < skeleton.bones.length; ++i) {
7524
7607
  joints.push(nodeMap.get(skeleton.bones[i]));
7525
7608
  temporaryBoneInverse.copy(skeleton.boneInverses[i]);
@@ -7527,7 +7610,7 @@ var GLTFWriter = class {
7527
7610
  }
7528
7611
  if (json.skins === void 0) json.skins = [];
7529
7612
  json.skins.push({
7530
- inverseBindMatrices: this.processAccessor(new import_three18.BufferAttribute(inverseBindMatrices, 16)),
7613
+ inverseBindMatrices: this.processAccessor(new import_three19.BufferAttribute(inverseBindMatrices, 16)),
7531
7614
  joints,
7532
7615
  skeleton: nodeMap.get(rootJoint)
7533
7616
  });
@@ -7623,7 +7706,7 @@ var GLTFWriter = class {
7623
7706
  * @param {Array} objects List of objects to process
7624
7707
  */
7625
7708
  processObjects(objects) {
7626
- const scene = new import_three18.Scene();
7709
+ const scene = new import_three19.Scene();
7627
7710
  scene.name = "AuxScene";
7628
7711
  for (let i = 0; i < objects.length; i++) {
7629
7712
  scene.children.push(objects[i]);
@@ -7641,7 +7724,7 @@ var GLTFWriter = class {
7641
7724
  });
7642
7725
  const objectsWithoutScene = [];
7643
7726
  for (let i = 0; i < input.length; i++) {
7644
- if (input[i] instanceof import_three18.Scene) {
7727
+ if (input[i] instanceof import_three19.Scene) {
7645
7728
  this.processScene(input[i]);
7646
7729
  } else {
7647
7730
  objectsWithoutScene.push(input[i]);
@@ -7985,10 +8068,10 @@ var GLTFMeshGpuInstancing = class {
7985
8068
  const translationAttr = new Float32Array(mesh.count * 3);
7986
8069
  const rotationAttr = new Float32Array(mesh.count * 4);
7987
8070
  const scaleAttr = new Float32Array(mesh.count * 3);
7988
- const matrix = new import_three18.Matrix4();
7989
- const position = new import_three18.Vector3();
7990
- const quaternion = new import_three18.Quaternion();
7991
- const scale = new import_three18.Vector3();
8071
+ const matrix = new import_three19.Matrix4();
8072
+ const position = new import_three19.Vector3();
8073
+ const quaternion = new import_three19.Quaternion();
8074
+ const scale = new import_three19.Vector3();
7992
8075
  for (let i = 0; i < mesh.count; i++) {
7993
8076
  mesh.getMatrixAt(i, matrix);
7994
8077
  matrix.decompose(position, quaternion, scale);
@@ -7997,9 +8080,9 @@ var GLTFMeshGpuInstancing = class {
7997
8080
  scale.toArray(scaleAttr, i * 3);
7998
8081
  }
7999
8082
  const attributes = {
8000
- TRANSLATION: writer.processAccessor(new import_three18.BufferAttribute(translationAttr, 3)),
8001
- ROTATION: writer.processAccessor(new import_three18.BufferAttribute(rotationAttr, 4)),
8002
- SCALE: writer.processAccessor(new import_three18.BufferAttribute(scaleAttr, 3))
8083
+ TRANSLATION: writer.processAccessor(new import_three19.BufferAttribute(translationAttr, 3)),
8084
+ ROTATION: writer.processAccessor(new import_three19.BufferAttribute(rotationAttr, 4)),
8085
+ SCALE: writer.processAccessor(new import_three19.BufferAttribute(scaleAttr, 3))
8003
8086
  };
8004
8087
  if (mesh.instanceColor)
8005
8088
  attributes._COLOR_0 = writer.processAccessor(mesh.instanceColor);
@@ -8064,8 +8147,8 @@ GLTFExporter.Utils = {
8064
8147
  const sourceTracks = clip.tracks;
8065
8148
  for (let i = 0; i < sourceTracks.length; ++i) {
8066
8149
  let sourceTrack = sourceTracks[i];
8067
- const sourceTrackBinding = import_three18.PropertyBinding.parseTrackName(sourceTrack.name);
8068
- const sourceTrackNode = import_three18.PropertyBinding.findNode(root, sourceTrackBinding.nodeName);
8150
+ const sourceTrackBinding = import_three19.PropertyBinding.parseTrackName(sourceTrack.name);
8151
+ const sourceTrackNode = import_three19.PropertyBinding.findNode(root, sourceTrackBinding.nodeName);
8069
8152
  if (sourceTrackBinding.propertyName !== "morphTargetInfluences" || sourceTrackBinding.propertyIndex === void 0) {
8070
8153
  tracks.push(sourceTrack);
8071
8154
  continue;
@@ -8076,7 +8159,7 @@ GLTFExporter.Utils = {
8076
8159
  }
8077
8160
  console.warn("THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead.");
8078
8161
  sourceTrack = sourceTrack.clone();
8079
- sourceTrack.setInterpolation(import_three18.InterpolateLinear);
8162
+ sourceTrack.setInterpolation(import_three19.InterpolateLinear);
8080
8163
  }
8081
8164
  const targetCount = sourceTrackNode.morphTargetInfluences.length;
8082
8165
  const targetIndex = sourceTrackNode.morphTargetDictionary[sourceTrackBinding.propertyIndex];
@@ -8159,10 +8242,10 @@ var SceneExporter = class {
8159
8242
  }
8160
8243
  };
8161
8244
  function localMatrix(object) {
8162
- return object.matrixAutoUpdate ? new import_three19.Matrix4().compose(object.position, object.quaternion, object.scale) : object.matrix.clone();
8245
+ return object.matrixAutoUpdate ? new import_three20.Matrix4().compose(object.position, object.quaternion, object.scale) : object.matrix.clone();
8163
8246
  }
8164
8247
  function createSnapshot(root, gltf, bakeColors = false) {
8165
- const scene = new import_three19.Scene();
8248
+ const scene = new import_three20.Scene();
8166
8249
  const geometries = [];
8167
8250
  const materials = [];
8168
8251
  const textures = [];
@@ -8180,7 +8263,7 @@ function createSnapshot(root, gltf, bakeColors = false) {
8180
8263
  if (!uniforms.map?.value?.isTexture || !uniforms.SHADE || !uniforms.BRIGHTNESS || !uniforms.EMISSIVE) {
8181
8264
  throw new MineRenderError("glTF export does not support this custom ShaderMaterial");
8182
8265
  }
8183
- material = new import_three19.MeshBasicMaterial({
8266
+ material = new import_three20.MeshBasicMaterial({
8184
8267
  map: uniforms.map.value,
8185
8268
  vertexColors: source.vertexColors,
8186
8269
  transparent: source.transparent,
@@ -8190,7 +8273,7 @@ function createSnapshot(root, gltf, bakeColors = false) {
8190
8273
  });
8191
8274
  material.name = source.name;
8192
8275
  } else if (shader.isShaderMaterial) {
8193
- material = new import_three19.MeshBasicMaterial({ vertexColors: source.vertexColors });
8276
+ material = new import_three20.MeshBasicMaterial({ vertexColors: source.vertexColors });
8194
8277
  material.name = source.name;
8195
8278
  } else {
8196
8279
  const copySource = Object.create(source);
@@ -8244,11 +8327,11 @@ function createSnapshot(root, gltf, bakeColors = false) {
8244
8327
  const material = copyMaterial(sourceMaterial, geometry);
8245
8328
  if (!sourceMaterial.vertexColors) geometry.deleteAttribute("color");
8246
8329
  if (bakeColors || instanceColor) {
8247
- const tint = (material.color ?? new import_three19.Color()).clone();
8330
+ const tint = (material.color ?? new import_three20.Color()).clone();
8248
8331
  if (instanceColor) tint.multiply(instanceColor);
8249
8332
  if (bakeColors) {
8250
8333
  const original = geometry.getAttribute("color");
8251
- const colors = new import_three19.Float32BufferAttribute(new Float32Array(geometry.getAttribute("position").count * 3), 3);
8334
+ const colors = new import_three20.Float32BufferAttribute(new Float32Array(geometry.getAttribute("position").count * 3), 3);
8252
8335
  for (let i = 0; i < colors.count; i++) {
8253
8336
  colors.setXYZ(i, (original?.getX(i) ?? 1) * tint.r, (original?.getY(i) ?? 1) * tint.g, (original?.getZ(i) ?? 1) * tint.b);
8254
8337
  }
@@ -8257,7 +8340,7 @@ function createSnapshot(root, gltf, bakeColors = false) {
8257
8340
  material.color.copy(tint);
8258
8341
  }
8259
8342
  }
8260
- const copy = new import_three19.Mesh(geometry, material);
8343
+ const copy = new import_three20.Mesh(geometry, material);
8261
8344
  copy.name = mesh.name;
8262
8345
  copy.renderOrder = mesh.renderOrder;
8263
8346
  scene.add(copy);
@@ -8271,9 +8354,9 @@ function createSnapshot(root, gltf, bakeColors = false) {
8271
8354
  const instanced = mesh;
8272
8355
  if (instanced.isInstancedMesh) {
8273
8356
  for (let i = 0; i < instanced.count; i++) {
8274
- const matrix = new import_three19.Matrix4();
8357
+ const matrix = new import_three20.Matrix4();
8275
8358
  instanced.getMatrixAt(i, matrix);
8276
- const color = instanced.instanceColor ? new import_three19.Color().fromBufferAttribute(instanced.instanceColor, i) : void 0;
8359
+ const color = instanced.instanceColor ? new import_three20.Color().fromBufferAttribute(instanced.instanceColor, i) : void 0;
8277
8360
  addMesh(mesh, world.clone().multiply(matrix), color);
8278
8361
  }
8279
8362
  } else {
@@ -8285,7 +8368,7 @@ function createSnapshot(root, gltf, bakeColors = false) {
8285
8368
  try {
8286
8369
  const ancestors = [];
8287
8370
  for (let parent = root.parent; parent; parent = parent.parent) ancestors.unshift(parent);
8288
- const world = new import_three19.Matrix4();
8371
+ const world = new import_three20.Matrix4();
8289
8372
  for (const ancestor of ancestors) {
8290
8373
  if (!ancestor.visible) return { scene, dispose };
8291
8374
  world.multiply(localMatrix(ancestor));
@@ -8299,7 +8382,7 @@ function createSnapshot(root, gltf, bakeColors = false) {
8299
8382
  }
8300
8383
  function selectAlphaMode(material, geometry) {
8301
8384
  const texture = material.map;
8302
- if (material.type !== "MeshBasicMaterial" || !material.transparent || !material.depthWrite || material.opacity !== 1 || material.alphaMap || !texture?.isDataTexture || texture.format !== import_three19.RGBAFormat || texture.type !== import_three19.UnsignedByteType || texture.wrapS !== import_three19.ClampToEdgeWrapping || texture.wrapT !== import_three19.ClampToEdgeWrapping || texture.magFilter !== import_three19.NearestFilter || texture.minFilter !== import_three19.NearestFilter || texture.anisotropy > 1 || texture.offset.x !== 0 || texture.offset.y !== 0 || texture.repeat.x !== 1 || texture.repeat.y !== 1 || texture.rotation !== 0 || !texture.matrixAutoUpdate && !texture.matrix.elements.every((value, i) => value === (i % 4 === 0 ? 1 : 0))) return;
8385
+ if (material.type !== "MeshBasicMaterial" || !material.transparent || !material.depthWrite || material.opacity !== 1 || material.alphaMap || !texture?.isDataTexture || texture.format !== import_three20.RGBAFormat || texture.type !== import_three20.UnsignedByteType || texture.wrapS !== import_three20.ClampToEdgeWrapping || texture.wrapT !== import_three20.ClampToEdgeWrapping || texture.magFilter !== import_three20.NearestFilter || texture.minFilter !== import_three20.NearestFilter || texture.anisotropy > 1 || texture.offset.x !== 0 || texture.offset.y !== 0 || texture.repeat.x !== 1 || texture.repeat.y !== 1 || texture.rotation !== 0 || !texture.matrixAutoUpdate && !texture.matrix.elements.every((value, i) => value === (i % 4 === 0 ? 1 : 0))) return;
8303
8386
  const uv = geometry.getAttribute(texture.channel === 0 ? "uv" : `uv${texture.channel}`);
8304
8387
  const colors = geometry.getAttribute("color");
8305
8388
  if (!uv || material.vertexColors && colors?.itemSize === 4) return;
@@ -8336,7 +8419,7 @@ function selectAlphaMode(material, geometry) {
8336
8419
  }
8337
8420
  function copyDataTexture(source) {
8338
8421
  const image = source.image;
8339
- if (source.format !== import_three19.RGBAFormat || source.type !== import_three19.UnsignedByteType) {
8422
+ if (source.format !== import_three20.RGBAFormat || source.type !== import_three20.UnsignedByteType) {
8340
8423
  throw new MineRenderError("glTF export requires RGBA unsigned-byte data textures");
8341
8424
  }
8342
8425
  const canvas = createCanvas(image.width, image.height);
@@ -8347,8 +8430,8 @@ function copyDataTexture(source) {
8347
8430
  context.putImageData(pixels, 0, 0);
8348
8431
  const copySource = Object.create(source);
8349
8432
  copySource.userData = {};
8350
- copySource.source = new import_three19.Source(canvas);
8351
- return new import_three19.Texture().copy(copySource);
8433
+ copySource.source = new import_three20.Source(canvas);
8434
+ return new import_three20.Texture().copy(copySource);
8352
8435
  }
8353
8436
 
8354
8437
  // src/gui/GuiHelper.ts
@@ -8418,7 +8501,7 @@ var GuiHelper = class {
8418
8501
  };
8419
8502
 
8420
8503
  // src/gui/scene/GuiObject.ts
8421
- var import_three24 = require("three");
8504
+ var import_three25 = require("three");
8422
8505
  init_AssetKey();
8423
8506
  init_ModelTextures();
8424
8507
  init_Models();
@@ -8434,7 +8517,7 @@ var GuiObject = class extends SceneObject {
8434
8517
  this.textureLayers = textureLayers;
8435
8518
  this.isGuiObject = true;
8436
8519
  /** Local bounds in GUI pixels, with y growing down from the origin. */
8437
- this.bounds = new import_three24.Box2();
8520
+ this.bounds = new import_three25.Box2();
8438
8521
  this.geometries = /* @__PURE__ */ new Set();
8439
8522
  this.ownedMaterials = /* @__PURE__ */ new Set();
8440
8523
  this.initialized = false;
@@ -8452,17 +8535,17 @@ var GuiObject = class extends SceneObject {
8452
8535
  item.scale.set(width2 / 16, height2 / 16, width2 / 16);
8453
8536
  item.updateWorldMatrix(true, true);
8454
8537
  const inverse = this.matrixWorld.clone().invert();
8455
- const bounds = new import_three24.Box3();
8538
+ const bounds = new import_three25.Box3();
8456
8539
  item.iterateAllMeshes((mesh2) => {
8457
8540
  mesh2.geometry.computeBoundingBox();
8458
- bounds.union(mesh2.geometry.boundingBox.clone().applyMatrix4(new import_three24.Matrix4().multiplyMatrices(inverse, mesh2.matrixWorld)));
8541
+ bounds.union(mesh2.geometry.boundingBox.clone().applyMatrix4(new import_three25.Matrix4().multiplyMatrices(inverse, mesh2.matrixWorld)));
8459
8542
  });
8460
8543
  item.position.z = depth - bounds.min.z;
8461
8544
  depth += bounds.max.z - bounds.min.z + 0.01;
8462
- this.bounds.expandByPoint(new import_three24.Vector2(x, y));
8463
- this.bounds.expandByPoint(new import_three24.Vector2(x + width2, y + height2));
8464
- this.bounds.expandByPoint(new import_three24.Vector2(bounds.min.x, -bounds.max.y));
8465
- this.bounds.expandByPoint(new import_three24.Vector2(bounds.max.x, -bounds.min.y));
8545
+ this.bounds.expandByPoint(new import_three25.Vector2(x, y));
8546
+ this.bounds.expandByPoint(new import_three25.Vector2(x + width2, y + height2));
8547
+ this.bounds.expandByPoint(new import_three25.Vector2(bounds.min.x, -bounds.max.y));
8548
+ this.bounds.expandByPoint(new import_three25.Vector2(bounds.max.x, -bounds.min.y));
8466
8549
  continue;
8467
8550
  }
8468
8551
  const key = typeof layer.texture === "string" ? AssetKey.parse("textures", layer.texture) : layer.texture;
@@ -8470,7 +8553,7 @@ var GuiObject = class extends SceneObject {
8470
8553
  const image = material.map.image;
8471
8554
  const [cropX, cropY, cropWidth, cropHeight] = layer.crop ?? [0, 0, image.width, image.height];
8472
8555
  const [width, height] = layer.size ?? [cropWidth, cropHeight];
8473
- const geometry = new import_three24.PlaneGeometry(width, height);
8556
+ const geometry = new import_three25.PlaneGeometry(width, height);
8474
8557
  this.geometries.add(geometry);
8475
8558
  const uv = geometry.getAttribute("uv");
8476
8559
  for (let i = 0; i < uv.count; i++) {
@@ -8480,13 +8563,13 @@ var GuiObject = class extends SceneObject {
8480
8563
  1 - (cropY + (1 - uv.getY(i)) * cropHeight) / image.height
8481
8564
  );
8482
8565
  }
8483
- const mesh = new import_three24.Mesh(geometry, material);
8566
+ const mesh = new import_three25.Mesh(geometry, material);
8484
8567
  mesh.name = `mesh:${layer.name ?? index}`;
8485
8568
  mesh.position.set(x + width / 2, -y - height / 2, depth);
8486
8569
  mesh.renderOrder = index;
8487
8570
  this.add(mesh);
8488
- this.bounds.expandByPoint(new import_three24.Vector2(x, y));
8489
- this.bounds.expandByPoint(new import_three24.Vector2(x + width, y + height));
8571
+ this.bounds.expandByPoint(new import_three25.Vector2(x, y));
8572
+ this.bounds.expandByPoint(new import_three25.Vector2(x + width, y + height));
8490
8573
  depth += 0.01;
8491
8574
  }
8492
8575
  for (const child of this.children) child.position.z -= depth - 0.01;
@@ -8561,7 +8644,7 @@ function isGuiObject(obj) {
8561
8644
  init_image();
8562
8645
 
8563
8646
  // src/inspector/SceneInspector.ts
8564
- var import_three25 = require("three");
8647
+ var import_three26 = require("three");
8565
8648
  init_SceneObject();
8566
8649
  init_util();
8567
8650
  init_log();
@@ -8571,11 +8654,11 @@ var help = "<span>Ctrl/Cmd+Click to Select<br/></span><br/>";
8571
8654
  var SceneInspector = class {
8572
8655
  constructor(renderer) {
8573
8656
  this.renderer = renderer;
8574
- this.mouse = new import_three25.Vector2();
8657
+ this.mouse = new import_three26.Vector2();
8575
8658
  this.listeners = new AbortController();
8576
8659
  this.objectInfoContainer = document.createElement("div");
8577
8660
  this.objectControlsContainer = document.createElement("div");
8578
- this.raycaster = new import_three25.Raycaster();
8661
+ this.raycaster = new import_three26.Raycaster();
8579
8662
  this.init();
8580
8663
  }
8581
8664
  init() {
@@ -8978,7 +9061,7 @@ init_ModelMerger();
8978
9061
  init_SpecialItems();
8979
9062
 
8980
9063
  // src/model/block/BlockStateResolver.ts
8981
- var import_three27 = require("three");
9064
+ var import_three28 = require("three");
8982
9065
  init_BlockStates();
8983
9066
  init_MineRenderError();
8984
9067
  init_util();
@@ -9056,7 +9139,7 @@ var BlockStateResolver = class {
9056
9139
  return variants[variants.length - 1];
9057
9140
  }
9058
9141
  static rotation(variant) {
9059
- const rotation = new import_three27.Euler();
9142
+ const rotation = new import_three28.Euler();
9060
9143
  if (typeof variant.x !== "undefined") {
9061
9144
  rotation.x = toRadians(clampRotationDegrees(variant.x));
9062
9145
  }
@@ -9148,7 +9231,7 @@ init_SceneObject();
9148
9231
  init_ModelObject();
9149
9232
  init_Models();
9150
9233
  var import_ts_deepmerge6 = __toESM(require_dist());
9151
- var import_three30 = require("three");
9234
+ var import_three31 = require("three");
9152
9235
  init_MineRenderError();
9153
9236
  init_InstanceReference();
9154
9237
  init_AssetKey();
@@ -9170,7 +9253,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
9170
9253
  this._models = [];
9171
9254
  this._cullMask = 0;
9172
9255
  this._entities = [];
9173
- this._entityPlacement = new import_three30.Matrix4();
9256
+ this._entityPlacement = new import_three31.Matrix4();
9174
9257
  this._entityGeneration = 0;
9175
9258
  this.options = (0, import_ts_deepmerge6.default)({}, _BlockObject.DEFAULT_OPTIONS, options ?? {});
9176
9259
  }
@@ -9214,6 +9297,21 @@ var _BlockObject = class _BlockObject extends SceneObject {
9214
9297
  get blockEntities() {
9215
9298
  return this._entities;
9216
9299
  }
9300
+ /** Sets visibility for this block's model instances and block entities. */
9301
+ setVisible(visible) {
9302
+ this.visible = visible;
9303
+ for (const model of this._models) {
9304
+ if (isInstanceReference(model)) {
9305
+ model.setVisible(visible);
9306
+ } else {
9307
+ model.visible = visible;
9308
+ }
9309
+ }
9310
+ for (const entity of this._entities) {
9311
+ entity.visible = visible;
9312
+ }
9313
+ this.notifyDirty();
9314
+ }
9217
9315
  /**
9218
9316
  * Draws the block through the dataset's block-entity index. Returns false, leaving nothing behind,
9219
9317
  * when the block is not listed or one of its models cannot be loaded.
@@ -9247,15 +9345,19 @@ var _BlockObject = class _BlockObject extends SceneObject {
9247
9345
  BlockEntities.matrix(resolved, this._entityPlacement);
9248
9346
  this._entities = created;
9249
9347
  this.placeEntities();
9348
+ this.setVisible(this.visible);
9250
9349
  return true;
9251
9350
  }
9252
9351
  placeEntities() {
9253
- const matrix = new import_three30.Matrix4().makeTranslation(this.position.x - 8, this.position.y - 8, this.position.z - 8).multiply(this._entityPlacement);
9352
+ const matrix = new import_three31.Matrix4().makeTranslation(this.position.x - 8, this.position.y - 8, this.position.z - 8).multiply(this._entityPlacement);
9254
9353
  for (const entity of this._entities) {
9255
9354
  matrix.decompose(entity.position, entity.quaternion, entity.scale);
9256
9355
  }
9257
9356
  }
9258
9357
  get isOccluding() {
9358
+ if (!this.visible) {
9359
+ return false;
9360
+ }
9259
9361
  return this._models.some((model) => {
9260
9362
  const object = isInstanceReference(model) ? model.instanceable : model;
9261
9363
  return object.isOpaqueFullCube && this.getModelCullMask(model, 63) === 63;
@@ -9269,12 +9371,12 @@ var _BlockObject = class _BlockObject extends SceneObject {
9269
9371
  getModelCullMask(model, worldMask) {
9270
9372
  const object = isInstanceReference(model) ? model.instanceable : model;
9271
9373
  if (object.options.displayPosition) return 0;
9272
- const position = new import_three30.Vector3();
9273
- const rotation = new import_three30.Quaternion();
9274
- const scale = new import_three30.Vector3();
9374
+ const position = new import_three31.Vector3();
9375
+ const rotation = new import_three31.Quaternion();
9376
+ const scale = new import_three31.Vector3();
9275
9377
  this.getModelMatrix(model).decompose(position, rotation, scale);
9276
- if (position.distanceToSquared(this.position) > 1e-10 || scale.distanceToSquared(new import_three30.Vector3(1, 1, 1)) > 1e-10) return 0;
9277
- return ModelCulling.toLocalMask(worldMask, new import_three30.Euler().setFromQuaternion(rotation));
9378
+ if (position.distanceToSquared(this.position) > 1e-10 || scale.distanceToSquared(new import_three31.Vector3(1, 1, 1)) > 1e-10) return 0;
9379
+ return ModelCulling.toLocalMask(worldMask, new import_three31.Euler().setFromQuaternion(rotation));
9278
9380
  }
9279
9381
  async setCullMask(worldMask) {
9280
9382
  worldMask &= 63;
@@ -9311,6 +9413,9 @@ var _BlockObject = class _BlockObject extends SceneObject {
9311
9413
  this._models = replacements;
9312
9414
  this._cullMask = worldMask;
9313
9415
  this.removeModels(previous.filter((model) => !replacements.includes(model)));
9416
+ if (!this.visible) {
9417
+ this.setVisible(false);
9418
+ }
9314
9419
  this.notifyDirty();
9315
9420
  }
9316
9421
  get state() {
@@ -9336,7 +9441,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
9336
9441
  () => new FluidModelObject2(kind, surface.sample, this.blockState.key, this.options)
9337
9442
  );
9338
9443
  const previous = this._fluidModel;
9339
- const matrix = previous ? this.getModelMatrix(previous) : new import_three30.Matrix4().makeTranslation(...this.position.toArray());
9444
+ const matrix = previous ? this.getModelMatrix(previous) : new import_three31.Matrix4().makeTranslation(...this.position.toArray());
9340
9445
  if (isInstanceReference(replacement)) replacement.setMatrix(matrix);
9341
9446
  else matrix.decompose(replacement.position, replacement.quaternion, replacement.scale);
9342
9447
  this._models = this._models.filter((model) => model !== previous);
@@ -9346,6 +9451,9 @@ var _BlockObject = class _BlockObject extends SceneObject {
9346
9451
  this._isInstanced || (this._isInstanced = isInstanceReference(replacement));
9347
9452
  this._instanceCounter = this._isInstanced ? 1 : 0;
9348
9453
  if (previous) this.removeModels([previous]);
9454
+ if (!this.visible) {
9455
+ this.setVisible(false);
9456
+ }
9349
9457
  this.notifyDirty();
9350
9458
  }
9351
9459
  nextInstance() {
@@ -9374,6 +9482,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
9374
9482
  this._models.push(await this.createVariant(blockStateVariant));
9375
9483
  }
9376
9484
  await this.updateFluid(this._fluidSampler);
9485
+ this.setVisible(this.visible);
9377
9486
  }
9378
9487
  async hasGeometry(variant) {
9379
9488
  const modelKey = AssetKey.parse("models", variant.model);
@@ -9474,7 +9583,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
9474
9583
  setPositionRotationScaleAt(index, position, rotation, scale) {
9475
9584
  super.setPositionRotationScaleAt(index, position, rotation, scale);
9476
9585
  }
9477
- getMatrixAt(index, matrix = new import_three30.Matrix4()) {
9586
+ getMatrixAt(index, matrix = new import_three31.Matrix4()) {
9478
9587
  if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
9479
9588
  const child = this._models[0];
9480
9589
  if (child && isModelObject(child)) {
@@ -11345,7 +11454,7 @@ init_ModelObject();
11345
11454
  init_nbt();
11346
11455
 
11347
11456
  // src/renderer/MineRenderScene.ts
11348
- var import_three32 = require("three");
11457
+ var import_three33 = require("three");
11349
11458
  init_SceneObject();
11350
11459
  var import_ts_deepmerge8 = __toESM(require_dist());
11351
11460
  init_ModelObject();
@@ -12078,7 +12187,7 @@ var import_ts_deepmerge7 = __toESM(require_dist());
12078
12187
  init_util();
12079
12188
 
12080
12189
  // src/skin/SkinTextures.ts
12081
- var import_three31 = require("three");
12190
+ var import_three32 = require("three");
12082
12191
  init_Caching();
12083
12192
  init_CacheKey();
12084
12193
  init_MineRenderError();
@@ -12162,11 +12271,11 @@ var SkinTextures = class {
12162
12271
  });
12163
12272
  }
12164
12273
  static createMaterial(pixels, width, height, transparent = true) {
12165
- const texture = Textures.initTextureProps(new import_three31.DataTexture(pixels, width, height));
12166
- texture.colorSpace = import_three31.SRGBColorSpace;
12274
+ const texture = Textures.initTextureProps(new import_three32.DataTexture(pixels, width, height));
12275
+ texture.colorSpace = import_three32.SRGBColorSpace;
12167
12276
  texture.flipY = true;
12168
12277
  texture.needsUpdate = true;
12169
- return new import_three31.MeshBasicMaterial({ map: texture, transparent, side: transparent ? import_three31.DoubleSide : import_three31.FrontSide, alphaTest: transparent ? 0.1 : 0 });
12278
+ return new import_three32.MeshBasicMaterial({ map: texture, transparent, side: transparent ? import_three32.DoubleSide : import_three32.FrontSide, alphaTest: transparent ? 0.1 : 0 });
12170
12279
  }
12171
12280
  static isSlim(image, scale) {
12172
12281
  for (const [x, y] of [[46, 52], [54, 20]]) {
@@ -12396,7 +12505,7 @@ var SkinObject = class extends SceneObject {
12396
12505
  // src/renderer/MineRenderScene.ts
12397
12506
  init_EntityObject();
12398
12507
  init_ItemTints();
12399
- var _MineRenderScene = class _MineRenderScene extends import_three32.Scene {
12508
+ var _MineRenderScene = class _MineRenderScene extends import_three33.Scene {
12400
12509
  constructor(options) {
12401
12510
  super();
12402
12511
  this.isMineRenderScene = true;
@@ -12524,7 +12633,7 @@ function isMineRenderScene(obj) {
12524
12633
  }
12525
12634
 
12526
12635
  // src/renderer/Renderer.ts
12527
- var import_three34 = require("three");
12636
+ var import_three35 = require("three");
12528
12637
  var import_ts_deepmerge9 = __toESM(require_dist());
12529
12638
  var import_stats = __toESM(require("stats.js"));
12530
12639
  var import_postprocessing = require("postprocessing");
@@ -12533,11 +12642,11 @@ init_Model();
12533
12642
  init_three();
12534
12643
 
12535
12644
  // src/three/OrbitControls.js
12536
- var import_three33 = require("three");
12645
+ var import_three34 = require("three");
12537
12646
  var _changeEvent = { type: "change" };
12538
12647
  var _startEvent = { type: "start" };
12539
12648
  var _endEvent = { type: "end" };
12540
- var OrbitControls = class extends import_three33.EventDispatcher {
12649
+ var OrbitControls = class extends import_three34.EventDispatcher {
12541
12650
  constructor(object, domElement) {
12542
12651
  super();
12543
12652
  if (domElement === void 0) console.warn('THREE.OrbitControls: The second parameter "domElement" is now mandatory.');
@@ -12546,7 +12655,7 @@ var OrbitControls = class extends import_three33.EventDispatcher {
12546
12655
  this.domElement = domElement;
12547
12656
  this.domElement.style.touchAction = "none";
12548
12657
  this.enabled = true;
12549
- this.target = new import_three33.Vector3();
12658
+ this.target = new import_three34.Vector3();
12550
12659
  this.minDistance = 0;
12551
12660
  this.maxDistance = Infinity;
12552
12661
  this.minZoom = 0;
@@ -12568,8 +12677,8 @@ var OrbitControls = class extends import_three33.EventDispatcher {
12568
12677
  this.autoRotate = false;
12569
12678
  this.autoRotateSpeed = 2;
12570
12679
  this.keys = { LEFT: "ArrowLeft", UP: "ArrowUp", RIGHT: "ArrowRight", BOTTOM: "ArrowDown" };
12571
- this.mouseButtons = { LEFT: import_three33.MOUSE.ROTATE, MIDDLE: import_three33.MOUSE.DOLLY, RIGHT: import_three33.MOUSE.PAN };
12572
- this.touches = { ONE: import_three33.TOUCH.ROTATE, TWO: import_three33.TOUCH.DOLLY_PAN };
12680
+ this.mouseButtons = { LEFT: import_three34.MOUSE.ROTATE, MIDDLE: import_three34.MOUSE.DOLLY, RIGHT: import_three34.MOUSE.PAN };
12681
+ this.touches = { ONE: import_three34.TOUCH.ROTATE, TWO: import_three34.TOUCH.DOLLY_PAN };
12573
12682
  this.target0 = this.target.clone();
12574
12683
  this.position0 = this.object.position.clone();
12575
12684
  this.zoom0 = this.object.zoom;
@@ -12598,11 +12707,11 @@ var OrbitControls = class extends import_three33.EventDispatcher {
12598
12707
  state = STATE.NONE;
12599
12708
  };
12600
12709
  this.update = function() {
12601
- const offset = new import_three33.Vector3();
12602
- const quat = new import_three33.Quaternion().setFromUnitVectors(object.up, new import_three33.Vector3(0, 1, 0));
12710
+ const offset = new import_three34.Vector3();
12711
+ const quat = new import_three34.Quaternion().setFromUnitVectors(object.up, new import_three34.Vector3(0, 1, 0));
12603
12712
  const quatInverse = quat.clone().invert();
12604
- const lastPosition = new import_three33.Vector3();
12605
- const lastQuaternion = new import_three33.Quaternion();
12713
+ const lastPosition = new import_three34.Vector3();
12714
+ const lastQuaternion = new import_three34.Quaternion();
12606
12715
  const twoPI = 2 * Math.PI;
12607
12716
  return function update() {
12608
12717
  const position = scope.object.position;
@@ -12688,20 +12797,20 @@ var OrbitControls = class extends import_three33.EventDispatcher {
12688
12797
  };
12689
12798
  let state = STATE.NONE;
12690
12799
  const EPS = 1e-6;
12691
- const spherical = new import_three33.Spherical();
12692
- const sphericalDelta = new import_three33.Spherical();
12800
+ const spherical = new import_three34.Spherical();
12801
+ const sphericalDelta = new import_three34.Spherical();
12693
12802
  let scale = 1;
12694
- const panOffset = new import_three33.Vector3();
12803
+ const panOffset = new import_three34.Vector3();
12695
12804
  let zoomChanged = false;
12696
- const rotateStart = new import_three33.Vector2();
12697
- const rotateEnd = new import_three33.Vector2();
12698
- const rotateDelta = new import_three33.Vector2();
12699
- const panStart = new import_three33.Vector2();
12700
- const panEnd = new import_three33.Vector2();
12701
- const panDelta = new import_three33.Vector2();
12702
- const dollyStart = new import_three33.Vector2();
12703
- const dollyEnd = new import_three33.Vector2();
12704
- const dollyDelta = new import_three33.Vector2();
12805
+ const rotateStart = new import_three34.Vector2();
12806
+ const rotateEnd = new import_three34.Vector2();
12807
+ const rotateDelta = new import_three34.Vector2();
12808
+ const panStart = new import_three34.Vector2();
12809
+ const panEnd = new import_three34.Vector2();
12810
+ const panDelta = new import_three34.Vector2();
12811
+ const dollyStart = new import_three34.Vector2();
12812
+ const dollyEnd = new import_three34.Vector2();
12813
+ const dollyDelta = new import_three34.Vector2();
12705
12814
  const pointers = [];
12706
12815
  const pointerPositions = {};
12707
12816
  function getAutoRotationAngle() {
@@ -12717,7 +12826,7 @@ var OrbitControls = class extends import_three33.EventDispatcher {
12717
12826
  sphericalDelta.phi -= angle;
12718
12827
  }
12719
12828
  const panLeft = function() {
12720
- const v = new import_three33.Vector3();
12829
+ const v = new import_three34.Vector3();
12721
12830
  return function panLeft2(distance, objectMatrix) {
12722
12831
  v.setFromMatrixColumn(objectMatrix, 0);
12723
12832
  v.multiplyScalar(-distance);
@@ -12725,7 +12834,7 @@ var OrbitControls = class extends import_three33.EventDispatcher {
12725
12834
  };
12726
12835
  }();
12727
12836
  const panUp = function() {
12728
- const v = new import_three33.Vector3();
12837
+ const v = new import_three34.Vector3();
12729
12838
  return function panUp2(distance, objectMatrix) {
12730
12839
  if (scope.screenSpacePanning === true) {
12731
12840
  v.setFromMatrixColumn(objectMatrix, 1);
@@ -12738,7 +12847,7 @@ var OrbitControls = class extends import_three33.EventDispatcher {
12738
12847
  };
12739
12848
  }();
12740
12849
  const pan = function() {
12741
- const offset = new import_three33.Vector3();
12850
+ const offset = new import_three34.Vector3();
12742
12851
  return function pan2(deltaX, deltaY) {
12743
12852
  const element = scope.domElement;
12744
12853
  if (scope.object.isPerspectiveCamera) {
@@ -12987,12 +13096,12 @@ var OrbitControls = class extends import_three33.EventDispatcher {
12987
13096
  mouseAction = -1;
12988
13097
  }
12989
13098
  switch (mouseAction) {
12990
- case import_three33.MOUSE.DOLLY:
13099
+ case import_three34.MOUSE.DOLLY:
12991
13100
  if (scope.enableZoom === false) return;
12992
13101
  handleMouseDownDolly(event);
12993
13102
  state = STATE.DOLLY;
12994
13103
  break;
12995
- case import_three33.MOUSE.ROTATE:
13104
+ case import_three34.MOUSE.ROTATE:
12996
13105
  if (event.ctrlKey || event.metaKey || event.shiftKey) {
12997
13106
  if (scope.enablePan === false) return;
12998
13107
  handleMouseDownPan(event);
@@ -13003,7 +13112,7 @@ var OrbitControls = class extends import_three33.EventDispatcher {
13003
13112
  state = STATE.ROTATE;
13004
13113
  }
13005
13114
  break;
13006
- case import_three33.MOUSE.PAN:
13115
+ case import_three34.MOUSE.PAN:
13007
13116
  if (event.ctrlKey || event.metaKey || event.shiftKey) {
13008
13117
  if (scope.enableRotate === false) return;
13009
13118
  handleMouseDownRotate(event);
@@ -13059,12 +13168,12 @@ var OrbitControls = class extends import_three33.EventDispatcher {
13059
13168
  switch (pointers.length) {
13060
13169
  case 1:
13061
13170
  switch (scope.touches.ONE) {
13062
- case import_three33.TOUCH.ROTATE:
13171
+ case import_three34.TOUCH.ROTATE:
13063
13172
  if (scope.enableRotate === false) return;
13064
13173
  handleTouchStartRotate();
13065
13174
  state = STATE.TOUCH_ROTATE;
13066
13175
  break;
13067
- case import_three33.TOUCH.PAN:
13176
+ case import_three34.TOUCH.PAN:
13068
13177
  if (scope.enablePan === false) return;
13069
13178
  handleTouchStartPan();
13070
13179
  state = STATE.TOUCH_PAN;
@@ -13075,12 +13184,12 @@ var OrbitControls = class extends import_three33.EventDispatcher {
13075
13184
  break;
13076
13185
  case 2:
13077
13186
  switch (scope.touches.TWO) {
13078
- case import_three33.TOUCH.DOLLY_PAN:
13187
+ case import_three34.TOUCH.DOLLY_PAN:
13079
13188
  if (scope.enableZoom === false && scope.enablePan === false) return;
13080
13189
  handleTouchStartDollyPan();
13081
13190
  state = STATE.TOUCH_DOLLY_PAN;
13082
13191
  break;
13083
- case import_three33.TOUCH.DOLLY_ROTATE:
13192
+ case import_three34.TOUCH.DOLLY_ROTATE:
13084
13193
  if (scope.enableZoom === false && scope.enableRotate === false) return;
13085
13194
  handleTouchStartDollyRotate();
13086
13195
  state = STATE.TOUCH_DOLLY_ROTATE;
@@ -13147,7 +13256,7 @@ var OrbitControls = class extends import_three33.EventDispatcher {
13147
13256
  function trackPointer(event) {
13148
13257
  let position = pointerPositions[event.pointerId];
13149
13258
  if (position === void 0) {
13150
- position = new import_three33.Vector2();
13259
+ position = new import_three34.Vector2();
13151
13260
  pointerPositions[event.pointerId] = position;
13152
13261
  }
13153
13262
  position.set(event.pageX, event.pageY);
@@ -13167,10 +13276,10 @@ var MapControls = class extends OrbitControls {
13167
13276
  constructor(object, domElement) {
13168
13277
  super(object, domElement);
13169
13278
  this.screenSpacePanning = false;
13170
- this.mouseButtons.LEFT = import_three33.MOUSE.PAN;
13171
- this.mouseButtons.RIGHT = import_three33.MOUSE.ROTATE;
13172
- this.touches.ONE = import_three33.TOUCH.PAN;
13173
- this.touches.TWO = import_three33.TOUCH.DOLLY_ROTATE;
13279
+ this.mouseButtons.LEFT = import_three34.MOUSE.PAN;
13280
+ this.mouseButtons.RIGHT = import_three34.MOUSE.ROTATE;
13281
+ this.touches.ONE = import_three34.TOUCH.PAN;
13282
+ this.touches.TWO = import_three34.TOUCH.DOLLY_ROTATE;
13174
13283
  }
13175
13284
  };
13176
13285
 
@@ -13221,14 +13330,14 @@ var _Renderer = class _Renderer {
13221
13330
  switch (this.options.camera.type) {
13222
13331
  case "perspective":
13223
13332
  default:
13224
- return new import_three34.PerspectiveCamera(
13333
+ return new import_three35.PerspectiveCamera(
13225
13334
  this.options.camera.perspective.fov,
13226
13335
  this.options.camera.perspective.aspect ?? this.viewWidth / this.viewHeight,
13227
13336
  this.options.camera.near,
13228
13337
  this.options.camera.far
13229
13338
  );
13230
13339
  case "orthographic":
13231
- return new import_three34.OrthographicCamera(
13340
+ return new import_three35.OrthographicCamera(
13232
13341
  this.options.camera.orthographic.left ?? this.viewWidth / -2,
13233
13342
  this.options.camera.orthographic.right ?? this.viewWidth / 2,
13234
13343
  this.options.camera.orthographic.top ?? this.viewHeight / 2,
@@ -13239,7 +13348,7 @@ var _Renderer = class _Renderer {
13239
13348
  }
13240
13349
  }
13241
13350
  createRenderer() {
13242
- const renderer = new import_three34.WebGLRenderer({
13351
+ const renderer = new import_three35.WebGLRenderer({
13243
13352
  antialias: this.options.render.antialias,
13244
13353
  alpha: true,
13245
13354
  powerPreference: "high-performance",
@@ -13247,8 +13356,8 @@ var _Renderer = class _Renderer {
13247
13356
  });
13248
13357
  renderer.setClearColor(0, 0);
13249
13358
  renderer.shadowMap.enabled = true;
13250
- renderer.shadowMap.type = import_three34.PCFSoftShadowMap;
13251
- renderer.outputColorSpace = import_three34.SRGBColorSpace;
13359
+ renderer.shadowMap.type = import_three35.PCFSoftShadowMap;
13360
+ renderer.outputColorSpace = import_three35.SRGBColorSpace;
13252
13361
  renderer.setPixelRatio(this.options.render.pixelRatio ?? 1);
13253
13362
  renderer.setSize(this.viewWidth, this.viewHeight);
13254
13363
  return renderer;
@@ -13283,20 +13392,20 @@ var _Renderer = class _Renderer {
13283
13392
  window["__THREE_DEVTOOLS__"].dispatchEvent(new CustomEvent("observe", { detail: this.scene }));
13284
13393
  }
13285
13394
  if (this.options.debug.grid) {
13286
- const gridHelper = new import_three34.GridHelper(128, 16);
13395
+ const gridHelper = new import_three35.GridHelper(128, 16);
13287
13396
  this._debugHelpers.push(gridHelper);
13288
13397
  this.scene.add(gridHelper);
13289
- const gridHelper2 = new import_three34.GridHelper(128, 16);
13398
+ const gridHelper2 = new import_three35.GridHelper(128, 16);
13290
13399
  this._debugHelpers.push(gridHelper2);
13291
13400
  gridHelper2.rotation.x = 90 * (Math.PI / 180);
13292
13401
  this.scene.add(gridHelper2);
13293
- const gridHelper3 = new import_three34.GridHelper(128, 16);
13402
+ const gridHelper3 = new import_three35.GridHelper(128, 16);
13294
13403
  this._debugHelpers.push(gridHelper3);
13295
13404
  gridHelper3.rotation.z = 90 * (Math.PI / 180);
13296
13405
  this.scene.add(gridHelper3);
13297
13406
  }
13298
13407
  if (this.options.debug.axes) {
13299
- const axesHelper = new import_three34.AxesHelper(64);
13408
+ const axesHelper = new import_three35.AxesHelper(64);
13300
13409
  this._debugHelpers.push(axesHelper);
13301
13410
  this.scene.add(axesHelper);
13302
13411
  }
@@ -13555,8 +13664,8 @@ _Renderer.DEFAULT_OPTIONS = (0, import_ts_deepmerge9.default)({}, {
13555
13664
  top: void 0,
13556
13665
  bottom: void 0
13557
13666
  },
13558
- position: new import_three34.Vector3(50, 50, 50),
13559
- lookingAt: new import_three34.Vector3(0, 0, 0)
13667
+ position: new import_three35.Vector3(50, 50, 50),
13668
+ lookingAt: new import_three35.Vector3(0, 0, 0)
13560
13669
  },
13561
13670
  render: {
13562
13671
  fpsLimit: 60,
@@ -14021,12 +14130,12 @@ var AnvilParser = class {
14021
14130
  };
14022
14131
 
14023
14132
  // src/world/Chunk.ts
14024
- var import_three39 = require("three");
14133
+ var import_three40 = require("three");
14025
14134
  init_BlockStates();
14026
14135
  init_AssetKey();
14027
14136
 
14028
14137
  // src/world/MineRenderWorld.ts
14029
- var import_three37 = require("three");
14138
+ var import_three38 = require("three");
14030
14139
  init_Model();
14031
14140
  init_BatchedExecutor();
14032
14141
  init_AssetKey();
@@ -14034,7 +14143,7 @@ init_BlockStates();
14034
14143
  init_CubeFace();
14035
14144
 
14036
14145
  // src/world/SectionModels.ts
14037
- var import_three36 = require("three");
14146
+ var import_three37 = require("three");
14038
14147
  init_AssetKey();
14039
14148
  init_Models();
14040
14149
  init_CubeFace();
@@ -14100,12 +14209,12 @@ var SectionModels = class {
14100
14209
  });
14101
14210
  await object.init();
14102
14211
  const geometry = object.children[0].geometry;
14103
- geometry.applyMatrix4(new import_three36.Matrix4().makeRotationFromEuler(rotation));
14212
+ geometry.applyMatrix4(new import_three37.Matrix4().makeRotationFromEuler(rotation));
14104
14213
  object.clear();
14105
14214
  const cullFaces = CUBE_FACES.map((face) => {
14106
14215
  const local = CUBE_FACES.findIndex((name) => name === atlas.model.elements[0].faces[face]?.cullface);
14107
14216
  if (local < 0) return 0;
14108
- const normal = new import_three36.Vector3(...CUBE_FACE_OFFSETS[local]).applyEuler(rotation);
14217
+ const normal = new import_three37.Vector3(...CUBE_FACE_OFFSETS[local]).applyEuler(rotation);
14109
14218
  const world = CUBE_FACE_OFFSETS.findIndex(([x, y, z]) => Math.abs(normal.x - x) < 1e-6 && Math.abs(normal.y - y) < 1e-6 && Math.abs(normal.z - z) < 1e-6);
14110
14219
  return 1 << world;
14111
14220
  });
@@ -14135,20 +14244,20 @@ var MineRenderWorld = class {
14135
14244
  }
14136
14245
  getBlockAt(posOrX, y, z) {
14137
14246
  if (typeof posOrX == "number") {
14138
- return this.getBlockAt(new import_three37.Vector3(posOrX, y, z));
14247
+ return this.getBlockAt(new import_three38.Vector3(posOrX, y, z));
14139
14248
  }
14140
14249
  if (isTripleArray(posOrX)) {
14141
- return this.getBlockAt(new import_three37.Vector3(posOrX[0], posOrX[1], posOrX[2]));
14250
+ return this.getBlockAt(new import_three38.Vector3(posOrX[0], posOrX[1], posOrX[2]));
14142
14251
  }
14143
14252
  this.validatePosBounds(posOrX);
14144
14253
  return this.getChunkAt(posOrX)?.getBlockAt(posOrX);
14145
14254
  }
14146
14255
  async setBlockAt(posOrX, yOrBlock, z, block) {
14147
14256
  if (typeof posOrX == "number") {
14148
- return this.setBlockAt(new import_three37.Vector3(posOrX, yOrBlock, z), block);
14257
+ return this.setBlockAt(new import_three38.Vector3(posOrX, yOrBlock, z), block);
14149
14258
  }
14150
14259
  if (isTripleArray(posOrX)) {
14151
- return this.setBlockAt(new import_three37.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
14260
+ return this.setBlockAt(new import_three38.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
14152
14261
  }
14153
14262
  return this.placeBlock(posOrX, yOrBlock);
14154
14263
  }
@@ -14157,6 +14266,16 @@ var MineRenderWorld = class {
14157
14266
  const chunk = Chunk.isAir(value) ? this.getChunkAt(pos) : this.getOrCreateChunkAt(pos);
14158
14267
  return chunk?.setBlockInChunkAt(chunk.worldPosToChunkPos(pos), value, pos, onBlocksChanged);
14159
14268
  }
14269
+ async setBlockVisibleAt(posOrX, yOrVisible, z, visible) {
14270
+ if (typeof posOrX === "number") {
14271
+ return this.setBlockVisibleAt(new import_three38.Vector3(posOrX, yOrVisible, z), visible);
14272
+ }
14273
+ if (isTripleArray(posOrX)) {
14274
+ return this.setBlockVisibleAt(new import_three38.Vector3(...posOrX), yOrVisible);
14275
+ }
14276
+ this.validatePosBounds(posOrX);
14277
+ await this.getChunkAt(posOrX)?.setBlockVisibleAt(posOrX, yOrVisible);
14278
+ }
14160
14279
  async placeMultiBlock(multiblock, useBatches = true, executor) {
14161
14280
  const changes = /* @__PURE__ */ new Map();
14162
14281
  try {
@@ -14169,7 +14288,7 @@ var MineRenderWorld = class {
14169
14288
  const collect = async (positions2) => {
14170
14289
  for (const pos of positions2) changes.set(pos.toArray().join(","), pos);
14171
14290
  };
14172
- const place = (block) => this.placeBlock(new import_three37.Vector3(...block.position), block, collect);
14291
+ const place = (block) => this.placeBlock(new import_three38.Vector3(...block.position), block, collect);
14173
14292
  const keys = /* @__PURE__ */ new Map();
14174
14293
  for (const block of multiblock.blocks) {
14175
14294
  if (Chunk.isAir(block)) continue;
@@ -14247,13 +14366,13 @@ var MineRenderWorld = class {
14247
14366
  for (const pos of positions) {
14248
14367
  this.pendingCulling.set(pos.toArray().join(","), pos.clone());
14249
14368
  for (const offset of CUBE_FACE_OFFSETS) {
14250
- const neighbor = pos.clone().add(new import_three37.Vector3(...offset));
14369
+ const neighbor = pos.clone().add(new import_three38.Vector3(...offset));
14251
14370
  this.pendingCulling.set(neighbor.toArray().join(","), neighbor);
14252
14371
  }
14253
14372
  for (let y = -1; y <= 1; y++) {
14254
14373
  for (let z = -1; z <= 1; z++) {
14255
14374
  for (let x = -1; x <= 1; x++) {
14256
- const neighbor = pos.clone().add(new import_three37.Vector3(x, y, z));
14375
+ const neighbor = pos.clone().add(new import_three38.Vector3(x, y, z));
14257
14376
  if (this.getBlockAt(neighbor)?.object?.fluidKind) {
14258
14377
  this.pendingCulling.set(neighbor.toArray().join(","), neighbor);
14259
14378
  }
@@ -14272,12 +14391,14 @@ var MineRenderWorld = class {
14272
14391
  if (!chunk) continue;
14273
14392
  changed.add(chunk);
14274
14393
  const block = chunk.getBlockAt(pos);
14275
- if (!block) continue;
14394
+ if (!block || !chunk.isBlockVisibleAt(pos)) {
14395
+ continue;
14396
+ }
14276
14397
  if (block.object?.fluidKind) {
14277
14398
  await block.object.updateFluid((x, y, z) => {
14278
- const neighbor = pos.clone().add(new import_three37.Vector3(x, y, z));
14399
+ const neighbor = pos.clone().add(new import_three38.Vector3(x, y, z));
14279
14400
  const section = this.getChunkAt(neighbor);
14280
- const object = section?.getBlockAt(neighbor)?.object;
14401
+ const object = section?.isBlockVisibleAt(neighbor) ? section.getBlockAt(neighbor)?.object : void 0;
14281
14402
  return {
14282
14403
  fluid: object?.fluidKind,
14283
14404
  level: object?.fluidLevel,
@@ -14287,7 +14408,7 @@ var MineRenderWorld = class {
14287
14408
  }
14288
14409
  let mask = 0;
14289
14410
  for (const [face, offset] of CUBE_FACE_OFFSETS.entries()) {
14290
- const neighbor = pos.clone().add(new import_three37.Vector3(...offset));
14411
+ const neighbor = pos.clone().add(new import_three38.Vector3(...offset));
14291
14412
  if (this.getChunkAt(neighbor)?.isOccludingAt(neighbor)) {
14292
14413
  mask |= 1 << face;
14293
14414
  }
@@ -14321,14 +14442,14 @@ var MineRenderWorld = class {
14321
14442
  return this._chunks.get(this.worldPosToChunkKey(pos));
14322
14443
  }
14323
14444
  static worldToScenePosition(pos) {
14324
- return new import_three37.Vector3(
14445
+ return new import_three38.Vector3(
14325
14446
  pos.x * 16,
14326
14447
  pos.y * 16,
14327
14448
  pos.z * 16
14328
14449
  );
14329
14450
  }
14330
14451
  static sceneToWorldPosition(pos) {
14331
- return new import_three37.Vector3(
14452
+ return new import_three38.Vector3(
14332
14453
  pos.x / 16,
14333
14454
  pos.y / 16,
14334
14455
  pos.z / 16
@@ -14351,10 +14472,10 @@ var MineRenderWorld = class {
14351
14472
  init_Model();
14352
14473
 
14353
14474
  // src/world/SectionMesh.ts
14354
- var import_three38 = require("three");
14475
+ var import_three39 = require("three");
14355
14476
  init_CanvasCompat();
14356
14477
  init_Materials();
14357
- var SectionMesh = class _SectionMesh extends import_three38.Group {
14478
+ var SectionMesh = class _SectionMesh extends import_three39.Group {
14358
14479
  constructor() {
14359
14480
  super(...arguments);
14360
14481
  this.ownedMeshes = [];
@@ -14427,18 +14548,18 @@ var SectionMesh = class _SectionMesh extends import_three38.Group {
14427
14548
  for (let corner = 0; corner < 6; corner++) indices.push(start + sourceIndices.getX(face * 6 + corner) - face * 4);
14428
14549
  }
14429
14550
  }
14430
- const geometry = new import_three38.BufferGeometry();
14431
- geometry.setAttribute("position", new import_three38.Float32BufferAttribute(positions, 3));
14432
- geometry.setAttribute("normal", new import_three38.Float32BufferAttribute(normals, 3));
14433
- geometry.setAttribute("uv", new import_three38.Float32BufferAttribute(uvs, 2));
14434
- geometry.setAttribute("color", new import_three38.Float32BufferAttribute(colors, 3));
14551
+ const geometry = new import_three39.BufferGeometry();
14552
+ geometry.setAttribute("position", new import_three39.Float32BufferAttribute(positions, 3));
14553
+ geometry.setAttribute("normal", new import_three39.Float32BufferAttribute(normals, 3));
14554
+ geometry.setAttribute("uv", new import_three39.Float32BufferAttribute(uvs, 2));
14555
+ geometry.setAttribute("color", new import_three39.Float32BufferAttribute(colors, 3));
14435
14556
  geometry.setIndex(indices);
14436
14557
  geometry.computeBoundingBox();
14437
14558
  geometry.computeBoundingSphere();
14438
14559
  const material = Materials.createShadedCanvasMaterial(canvas, false);
14439
14560
  material.vertexColors = true;
14440
14561
  const texture = material.uniforms?.map?.value ?? material.map;
14441
- const mesh = new import_three38.Mesh(geometry, material);
14562
+ const mesh = new import_three39.Mesh(geometry, material);
14442
14563
  section.add(mesh);
14443
14564
  section.ownedMeshes.push({ mesh, texture });
14444
14565
  }
@@ -14464,6 +14585,7 @@ var Chunk = class _Chunk {
14464
14585
  this.data = new ChunkData();
14465
14586
  this.renderedBlocks = /* @__PURE__ */ new Map();
14466
14587
  this.sectionBlocks = /* @__PURE__ */ new Map();
14588
+ this.hiddenBlocks = /* @__PURE__ */ new Set();
14467
14589
  this.meshDirty = false;
14468
14590
  this.scene = scene;
14469
14591
  this.x = x;
@@ -14472,10 +14594,10 @@ var Chunk = class _Chunk {
14472
14594
  }
14473
14595
  getBlockAt(posOrX, y, z) {
14474
14596
  if (typeof posOrX == "number") {
14475
- return this.getBlockAt(new import_three39.Vector3(posOrX, y, z));
14597
+ return this.getBlockAt(new import_three40.Vector3(posOrX, y, z));
14476
14598
  }
14477
14599
  if (isTripleArray(posOrX)) {
14478
- return this.getBlockAt(new import_three39.Vector3(posOrX[0], posOrX[1], posOrX[2]));
14600
+ return this.getBlockAt(new import_three40.Vector3(posOrX[0], posOrX[1], posOrX[2]));
14479
14601
  }
14480
14602
  const pos = this.worldPosToChunkPos(posOrX);
14481
14603
  const index = _Chunk.chunkPosToBlockIndex(pos);
@@ -14483,10 +14605,10 @@ var Chunk = class _Chunk {
14483
14605
  }
14484
14606
  async setBlockAt(posOrX, yOrBlock, z, block) {
14485
14607
  if (typeof posOrX == "number") {
14486
- return this.setBlockAt(new import_three39.Vector3(posOrX, yOrBlock, z), block);
14608
+ return this.setBlockAt(new import_three40.Vector3(posOrX, yOrBlock, z), block);
14487
14609
  }
14488
14610
  if (isTripleArray(posOrX)) {
14489
- return this.setBlockAt(new import_three39.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
14611
+ return this.setBlockAt(new import_three40.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
14490
14612
  }
14491
14613
  const worldPos = posOrX;
14492
14614
  const pos = this.worldPosToChunkPos(worldPos);
@@ -14501,6 +14623,7 @@ var Chunk = class _Chunk {
14501
14623
  worldPos = this.chunkPosToWorldPos(pos);
14502
14624
  }
14503
14625
  const index = _Chunk.chunkPosToBlockIndex(pos);
14626
+ this.hiddenBlocks.delete(index);
14504
14627
  this.data.set(index, block);
14505
14628
  const readBlock = this.data.snapshot(index);
14506
14629
  this.renderedBlocks.get(index)?.object?.removeFromScene();
@@ -14542,9 +14665,31 @@ var Chunk = class _Chunk {
14542
14665
  await onBlocksChanged?.([worldPos]);
14543
14666
  }
14544
14667
  }
14668
+ async setBlockVisibleAt(pos, visible) {
14669
+ const index = _Chunk.chunkPosToBlockIndex(this.worldPosToChunkPos(pos));
14670
+ const block = this.renderedBlocks.get(index);
14671
+ if (!block || visible === !this.hiddenBlocks.has(index)) {
14672
+ return;
14673
+ }
14674
+ if (visible) {
14675
+ this.hiddenBlocks.delete(index);
14676
+ } else {
14677
+ this.hiddenBlocks.add(index);
14678
+ }
14679
+ block.object?.setVisible(visible);
14680
+ if (this.sectionBlocks.has(index)) {
14681
+ this.meshDirty = true;
14682
+ }
14683
+ this.scene.dirty = true;
14684
+ await this.onBlocksChanged?.([pos]);
14685
+ }
14686
+ isBlockVisibleAt(pos) {
14687
+ const index = _Chunk.chunkPosToBlockIndex(this.worldPosToChunkPos(pos));
14688
+ return this.renderedBlocks.has(index) && !this.hiddenBlocks.has(index);
14689
+ }
14545
14690
  isOccludingAt(pos) {
14546
14691
  const index = _Chunk.chunkPosToBlockIndex(this.worldPosToChunkPos(pos));
14547
- return this.sectionBlocks.has(index) || (this.renderedBlocks.get(index)?.object?.isOccluding ?? false);
14692
+ return !this.hiddenBlocks.has(index) && (this.sectionBlocks.has(index) || (this.renderedBlocks.get(index)?.object?.isOccluding ?? false));
14548
14693
  }
14549
14694
  async setCullMaskAt(pos, mask) {
14550
14695
  const index = _Chunk.chunkPosToBlockIndex(this.worldPosToChunkPos(pos));
@@ -14560,7 +14705,10 @@ var Chunk = class _Chunk {
14560
14705
  }
14561
14706
  rebuildSectionMesh() {
14562
14707
  if (!this.meshDirty) return;
14563
- const next = this.sectionBlocks.size ? SectionMesh.build([...this.sectionBlocks.values()], this.sectionModels.maxAtlasSize) : void 0;
14708
+ const next = this.sectionBlocks.size ? SectionMesh.build(
14709
+ [...this.sectionBlocks.values()].filter((entry) => !this.hiddenBlocks.has(entry.index)),
14710
+ this.sectionModels.maxAtlasSize
14711
+ ) : void 0;
14564
14712
  this.sectionMesh?.dispose();
14565
14713
  this.sectionMesh = next;
14566
14714
  if (next) {
@@ -14572,7 +14720,7 @@ var Chunk = class _Chunk {
14572
14720
  }
14573
14721
  async clear(onBlocksChanged = this.onBlocksChanged) {
14574
14722
  const positions = [...this.renderedBlocks.keys()].map((index) => this.chunkPosToWorldPos(
14575
- new import_three39.Vector3(index % 16, Math.floor(index / 256), Math.floor(index / 16) % 16)
14723
+ new import_three40.Vector3(index % 16, Math.floor(index / 256), Math.floor(index / 16) % 16)
14576
14724
  ));
14577
14725
  for (const info of this.renderedBlocks.values()) info.object?.removeFromScene();
14578
14726
  this.sectionBlocks.clear();
@@ -14580,6 +14728,7 @@ var Chunk = class _Chunk {
14580
14728
  this.sectionMesh = void 0;
14581
14729
  this.meshDirty = false;
14582
14730
  this.renderedBlocks.clear();
14731
+ this.hiddenBlocks.clear();
14583
14732
  this.data.clear();
14584
14733
  await onBlocksChanged?.(positions);
14585
14734
  }
@@ -14596,14 +14745,14 @@ var Chunk = class _Chunk {
14596
14745
  return pos.y * 16 * 16 + pos.z * 16 + pos.x;
14597
14746
  }
14598
14747
  worldPosToChunkPos(pos) {
14599
- return new import_three39.Vector3(
14748
+ return new import_three40.Vector3(
14600
14749
  pos.x - this.x * 16,
14601
14750
  pos.y - this.y * 16,
14602
14751
  pos.z - this.z * 16
14603
14752
  );
14604
14753
  }
14605
14754
  chunkPosToWorldPos(pos) {
14606
- return new import_three39.Vector3(
14755
+ return new import_three40.Vector3(
14607
14756
  this.x * 16 + pos.x,
14608
14757
  this.y * 16 + pos.y,
14609
14758
  this.z * 16 + pos.z