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.
@@ -3324,11 +3324,11 @@ var init_Entities = __esm({
3324
3324
  return { ...layers[names[0]], id: model.id, layers, ...model.transform && { transform: model.transform } };
3325
3325
  }
3326
3326
  /**
3327
- * Vanilla's keyframe animations of a model by name, or undefined when the model or the selected version has none.
3327
+ * Native and sampled vanilla clips by name, or undefined when the model or selected version has none.
3328
3328
  */
3329
3329
  static async getAnimations(modelKey) {
3330
3330
  const path = isAssetKey(modelKey) ? modelKey.getFullPath() : modelKey.path;
3331
- const key = new AssetKey(modelKey.namespace, path, void 0, void 0, "entity-models/animations", ".json");
3331
+ const key = new AssetKey(modelKey.namespace, path, void 0, void 0, "entity-models/animations", ".json", isAssetKey(modelKey) ? modelKey.root : void 0);
3332
3332
  const file = await Caching.entityAnimationCache.get(key.serialize(), () => AssetLoader.get(key, "json" /* JSON */));
3333
3333
  return file?.animations;
3334
3334
  }
@@ -3378,7 +3378,7 @@ function sampleEntityKeyframes(keyframes, time) {
3378
3378
  let low = 0, high = keyframes.length;
3379
3379
  while (low < high) {
3380
3380
  const middle = low + high >>> 1;
3381
- if (time <= keyframes[middle].time) high = middle;
3381
+ if (time < keyframes[middle].time) high = middle;
3382
3382
  else low = middle + 1;
3383
3383
  }
3384
3384
  const a = Math.max(0, low - 1);
@@ -3417,9 +3417,10 @@ var init_EntityAnimation = __esm({
3417
3417
  });
3418
3418
 
3419
3419
  // src/entity/scene/EntityAnimationPlayer.ts
3420
- var ZERO, EntityAnimationPlayer;
3420
+ var import_three11, ZERO, EntityAnimationPlayer;
3421
3421
  var init_EntityAnimationPlayer = __esm({
3422
3422
  "src/entity/scene/EntityAnimationPlayer.ts"() {
3423
+ import_three11 = require("three");
3423
3424
  init_EntityAnimation();
3424
3425
  ZERO = [0, 0, 0];
3425
3426
  EntityAnimationPlayer = class {
@@ -3436,25 +3437,45 @@ var init_EntityAnimationPlayer = __esm({
3436
3437
  return this._time;
3437
3438
  }
3438
3439
  /**
3439
- * Starts an animation on the named parts below each layer root. The current pose of a part becomes its default;
3440
- * bones without a matching part are skipped.
3440
+ * Starts an animation on matching named parts. Supplied baked poses are the baseline for offsets;
3441
+ * without them, the current pose is used. Stopping restores the pose from before playback.
3441
3442
  */
3442
- play(layers, animation, options = {}) {
3443
+ play(layers, animation, options = {}, poses) {
3443
3444
  this.stop();
3444
3445
  this._animation = animation;
3445
3446
  this._time = options.time ?? 0;
3446
3447
  this.loop = options.loop ?? animation.loop;
3447
3448
  this.speed = options.speed ?? 1;
3448
3449
  for (const layer of layers) {
3449
- for (const bone of Object.keys(animation.bones)) {
3450
- const object = layer.getObjectByName(`group:${bone}`);
3451
- if (!object) continue;
3452
- this.parts.push({ bone, object, position: object.position.clone(), rotation: object.rotation.clone(), scale: object.scale.clone() });
3450
+ const objects = [];
3451
+ if (poses) {
3452
+ layer.traverse((object) => {
3453
+ if (poses.has(object)) objects.push(object);
3454
+ });
3455
+ } else {
3456
+ for (const bone of Object.keys(animation.bones)) {
3457
+ const object = layer.getObjectByName(`group:${bone}`);
3458
+ if (object) objects.push(object);
3459
+ }
3460
+ }
3461
+ for (const object of objects) {
3462
+ const bone = object.name.slice("group:".length);
3463
+ const pose = poses?.get(object);
3464
+ this.parts.push({
3465
+ bone,
3466
+ object,
3467
+ position: object.position.clone(),
3468
+ rotation: object.rotation.clone(),
3469
+ scale: object.scale.clone(),
3470
+ basePosition: pose ? new import_three11.Vector3(...pose.offset) : object.position.clone(),
3471
+ baseRotation: pose ? new import_three11.Euler(...pose.rotation, "ZYX") : object.rotation.clone(),
3472
+ baseScale: pose ? new import_three11.Vector3(...pose.scale ?? [1, 1, 1]) : object.scale.clone()
3473
+ });
3453
3474
  }
3454
3475
  }
3455
3476
  this.apply();
3456
3477
  }
3457
- /** Restores the default poses. Returns whether an animation was active. */
3478
+ /** Restores the poses from before playback. Returns whether an animation was active. */
3458
3479
  stop() {
3459
3480
  if (!this._animation) return false;
3460
3481
  for (const part of this.parts) {
@@ -3483,10 +3504,10 @@ var init_EntityAnimationPlayer = __esm({
3483
3504
  apply() {
3484
3505
  const pose = sampleEntityAnimation(this._animation, this._time, this.loop);
3485
3506
  for (const part of this.parts) {
3486
- const { position = ZERO, rotation = ZERO, scale = ZERO } = pose[part.bone];
3487
- part.object.position.set(part.position.x + position[0], part.position.y + position[1], part.position.z + position[2]);
3488
- part.object.rotation.set(part.rotation.x + rotation[0], part.rotation.y + rotation[1], part.rotation.z + rotation[2], part.rotation.order);
3489
- part.object.scale.set(part.scale.x + scale[0], part.scale.y + scale[1], part.scale.z + scale[2]);
3507
+ const { position = ZERO, rotation = ZERO, scale = ZERO } = pose[part.bone] ?? {};
3508
+ part.object.position.set(part.basePosition.x + position[0], part.basePosition.y + position[1], part.basePosition.z + position[2]);
3509
+ part.object.rotation.set(part.baseRotation.x + rotation[0], part.baseRotation.y + rotation[1], part.baseRotation.z + rotation[2], part.baseRotation.order);
3510
+ part.object.scale.set(part.baseScale.x + scale[0], part.baseScale.y + scale[1], part.baseScale.z + scale[2]);
3490
3511
  }
3491
3512
  }
3492
3513
  };
@@ -3526,6 +3547,9 @@ var init_InstanceReference = __esm({
3526
3547
  setMatrix(matrix) {
3527
3548
  this.activeInstanceable.setMatrixAt(this.index, matrix);
3528
3549
  }
3550
+ setVisible(visible) {
3551
+ this.activeInstanceable.setInstanceVisibleAt(this.index, visible);
3552
+ }
3529
3553
  setPositionRotationScale(position, rotation, scale) {
3530
3554
  this.activeInstanceable.setPositionRotationScaleAt(this.index, position, rotation, scale);
3531
3555
  }
@@ -3556,10 +3580,10 @@ var init_InstanceReference = __esm({
3556
3580
  function isSceneObject(obj) {
3557
3581
  return obj.isSceneObject;
3558
3582
  }
3559
- var import_three11, import_ts_deepmerge3, p6, SceneObject;
3583
+ var import_three12, import_ts_deepmerge3, p6, SceneObject;
3560
3584
  var init_SceneObject = __esm({
3561
3585
  "src/renderer/SceneObject.ts"() {
3562
- import_three11 = require("three");
3586
+ import_three12 = require("three");
3563
3587
  init_Geometries();
3564
3588
  init_UVMapper();
3565
3589
  init_Axis();
@@ -3571,7 +3595,7 @@ var init_SceneObject = __esm({
3571
3595
  import_ts_deepmerge3 = __toESM(require_dist());
3572
3596
  init_log();
3573
3597
  p6 = prefix("SceneObject");
3574
- SceneObject = class _SceneObject extends import_three11.Object3D {
3598
+ SceneObject = class _SceneObject extends import_three12.Object3D {
3575
3599
  constructor(options) {
3576
3600
  super();
3577
3601
  this.isSceneObject = true;
@@ -3580,6 +3604,7 @@ var init_SceneObject = __esm({
3580
3604
  this._instanceCounter = 0;
3581
3605
  this.instanceReferences = /* @__PURE__ */ new Map();
3582
3606
  this.freeInstanceIndices = [];
3607
+ this.hiddenInstanceMatrices = /* @__PURE__ */ new Map();
3583
3608
  this.options = (0, import_ts_deepmerge3.default)({}, _SceneObject.DEFAULT_OPTIONS, options ?? {});
3584
3609
  console.log("SceneObject options", this.options);
3585
3610
  }
@@ -3623,7 +3648,7 @@ var init_SceneObject = __esm({
3623
3648
  return group;
3624
3649
  }
3625
3650
  createGroup(name, x = 0, y = 0, z = 0, offsetAxis, offset = 0) {
3626
- const obj = new import_three11.Object3D();
3651
+ const obj = new import_three12.Object3D();
3627
3652
  if (name) {
3628
3653
  obj.name = `group:${name}`;
3629
3654
  }
@@ -3673,7 +3698,7 @@ var init_SceneObject = __esm({
3673
3698
  return mesh;
3674
3699
  }
3675
3700
  createMesh(name, geometry, material, offsetAxis, offset = 0) {
3676
- const mesh = new import_three11.Mesh(geometry, material);
3701
+ const mesh = new import_three12.Mesh(geometry, material);
3677
3702
  if (name) {
3678
3703
  mesh.name = `mesh:${name}`;
3679
3704
  }
@@ -3685,7 +3710,7 @@ var init_SceneObject = __esm({
3685
3710
  return mesh;
3686
3711
  }
3687
3712
  createInstancedMesh(name, geometry, material, count) {
3688
- const mesh = new import_three11.InstancedMesh(geometry, material, count);
3713
+ const mesh = new import_three12.InstancedMesh(geometry, material, count);
3689
3714
  mesh.count = 0;
3690
3715
  this.instanceMesh = mesh;
3691
3716
  this._isInstanced = true;
@@ -3765,11 +3790,11 @@ var init_SceneObject = __esm({
3765
3790
  this._instanceCounter = this.instanceReferences.size;
3766
3791
  mesh.count = Math.max(mesh.count, index + 1);
3767
3792
  if (mesh.instanceColor) {
3768
- mesh.setColorAt(index, new import_three11.Color(16777215));
3793
+ mesh.setColorAt(index, new import_three12.Color(16777215));
3769
3794
  mesh.instanceColor.needsUpdate = true;
3770
3795
  }
3771
3796
  if (this._scene) this._scene.stats.instanceCount++;
3772
- this.setMatrixAt(index, new import_three11.Matrix4());
3797
+ this.setMatrixAt(index, new import_three12.Matrix4());
3773
3798
  return reference;
3774
3799
  }
3775
3800
  /** Returns the live reference for a raycast hit on this object's instance mesh. */
@@ -3782,7 +3807,8 @@ var init_SceneObject = __esm({
3782
3807
  removeInstanceAt(index) {
3783
3808
  if (!this.instanceReferences.has(index)) return;
3784
3809
  const mesh = this.instanceMesh;
3785
- this.setMatrixAt(index, new import_three11.Matrix4().makeScale(0, 0, 0));
3810
+ this.hiddenInstanceMatrices.delete(index);
3811
+ this.setMatrixAt(index, new import_three12.Matrix4().makeScale(0, 0, 0));
3786
3812
  this.instanceReferences.delete(index);
3787
3813
  this.freeInstanceIndices.push(index);
3788
3814
  this._instanceCounter = this.instanceReferences.size;
@@ -3795,7 +3821,7 @@ var init_SceneObject = __esm({
3795
3821
  const grow = (attribute, fill) => {
3796
3822
  const array = new Float32Array(capacity * attribute.itemSize).fill(fill);
3797
3823
  array.set(attribute.array);
3798
- return new import_three11.InstancedBufferAttribute(array, attribute.itemSize, attribute.normalized, attribute.meshPerAttribute).setUsage(attribute.usage);
3824
+ return new import_three12.InstancedBufferAttribute(array, attribute.itemSize, attribute.normalized, attribute.meshPerAttribute).setUsage(attribute.usage);
3799
3825
  };
3800
3826
  const matrix = grow(mesh.instanceMatrix, 0);
3801
3827
  const color = mesh.instanceColor ? grow(mesh.instanceColor, 1) : null;
@@ -3812,32 +3838,60 @@ var init_SceneObject = __esm({
3812
3838
  }
3813
3839
  //</editor-fold>
3814
3840
  //<editor-fold desc="TRANSFORMATION">
3815
- getMatrixAt(index, matrix = new import_three11.Matrix4()) {
3841
+ getMatrixAt(index, matrix = new import_three12.Matrix4()) {
3816
3842
  if (!this.instanceReferences.has(index)) throw new MineRenderError("Instance is not active");
3843
+ const hidden = this.hiddenInstanceMatrices.get(index);
3844
+ if (hidden) {
3845
+ return matrix.copy(hidden);
3846
+ }
3817
3847
  this.instanceMesh.getMatrixAt(index, matrix);
3818
3848
  return matrix;
3819
3849
  }
3820
3850
  setMatrixAt(index, matrix) {
3821
3851
  if (!this.instanceReferences.has(index)) throw new MineRenderError("Instance is not active");
3822
3852
  const mesh = this.instanceMesh;
3823
- mesh.setMatrixAt(index, matrix);
3853
+ const hidden = this.hiddenInstanceMatrices.get(index);
3854
+ if (hidden) {
3855
+ hidden.copy(matrix);
3856
+ }
3857
+ mesh.setMatrixAt(index, hidden ? new import_three12.Matrix4().makeScale(0, 0, 0) : matrix);
3824
3858
  mesh.instanceMatrix.needsUpdate = true;
3825
3859
  mesh.boundingBox = null;
3826
3860
  mesh.boundingSphere = null;
3827
3861
  this.notifyDirty();
3828
3862
  }
3863
+ setInstanceVisibleAt(index, visible) {
3864
+ if (!this.instanceReferences.has(index)) {
3865
+ throw new MineRenderError("Instance is not active");
3866
+ }
3867
+ const hidden = this.hiddenInstanceMatrices.get(index);
3868
+ if (visible) {
3869
+ if (!hidden) {
3870
+ return;
3871
+ }
3872
+ this.hiddenInstanceMatrices.delete(index);
3873
+ this.setMatrixAt(index, hidden);
3874
+ } else {
3875
+ if (hidden) {
3876
+ return;
3877
+ }
3878
+ const matrix = this.getMatrixAt(index);
3879
+ this.hiddenInstanceMatrices.set(index, matrix);
3880
+ this.setMatrixAt(index, matrix);
3881
+ }
3882
+ }
3829
3883
  setPositionRotationScaleAt(index, position, rotation, scale) {
3830
3884
  if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
3831
- const oldPosition = new import_three11.Vector3();
3832
- const oldRotation = new import_three11.Quaternion();
3833
- const oldScale = new import_three11.Vector3();
3834
- const matrix = new import_three11.Matrix4();
3885
+ const oldPosition = new import_three12.Vector3();
3886
+ const oldRotation = new import_three12.Quaternion();
3887
+ const oldScale = new import_three12.Vector3();
3888
+ const matrix = new import_three12.Matrix4();
3835
3889
  if (!scale || !rotation || !position) {
3836
3890
  this.getMatrixAt(index, matrix).decompose(oldPosition, oldRotation, oldScale);
3837
3891
  }
3838
3892
  matrix.compose(
3839
3893
  position ? position : oldPosition,
3840
- rotation ? new import_three11.Quaternion().setFromEuler(rotation) : oldRotation,
3894
+ rotation ? new import_three12.Quaternion().setFromEuler(rotation) : oldRotation,
3841
3895
  scale ? scale : oldScale
3842
3896
  );
3843
3897
  this.setMatrixAt(index, matrix);
@@ -3846,7 +3900,7 @@ var init_SceneObject = __esm({
3846
3900
  if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
3847
3901
  this.setPositionRotationScaleAt(index, position);
3848
3902
  }
3849
- getPositionAt(index, vector = new import_three11.Vector3()) {
3903
+ getPositionAt(index, vector = new import_three12.Vector3()) {
3850
3904
  if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
3851
3905
  const matrix = this.getMatrixAt(index);
3852
3906
  vector.setFromMatrixPosition(matrix);
@@ -3856,17 +3910,17 @@ var init_SceneObject = __esm({
3856
3910
  if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
3857
3911
  this.setPositionRotationScaleAt(index, void 0, rotation, void 0);
3858
3912
  }
3859
- getRotationAt(index, euler = new import_three11.Euler()) {
3913
+ getRotationAt(index, euler = new import_three12.Euler()) {
3860
3914
  if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
3861
- const rotation = new import_three11.Quaternion();
3862
- this.getMatrixAt(index).decompose(new import_three11.Vector3(), rotation, new import_three11.Vector3());
3915
+ const rotation = new import_three12.Quaternion();
3916
+ this.getMatrixAt(index).decompose(new import_three12.Vector3(), rotation, new import_three12.Vector3());
3863
3917
  return euler.setFromQuaternion(rotation);
3864
3918
  }
3865
3919
  setScaleAt(index, scale) {
3866
3920
  if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
3867
3921
  this.setPositionRotationScaleAt(index, void 0, void 0, scale);
3868
3922
  }
3869
- getScaleAt(index, vector = new import_three11.Vector3()) {
3923
+ getScaleAt(index, vector = new import_three12.Vector3()) {
3870
3924
  if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
3871
3925
  const matrix = this.getMatrixAt(index);
3872
3926
  vector.setFromMatrixScale(matrix);
@@ -3965,6 +4019,7 @@ var init_SceneObject = __esm({
3965
4019
  if (this._scene) this._scene.stats.instanceCount -= this.instanceReferences.size;
3966
4020
  this.instanceReferences.clear();
3967
4021
  this.freeInstanceIndices.length = 0;
4022
+ this.hiddenInstanceMatrices.clear();
3968
4023
  this._instanceCounter = 0;
3969
4024
  this.instanceMesh.count = 0;
3970
4025
  this.instanceMesh.dispose();
@@ -3994,13 +4049,13 @@ var init_SceneObject = __esm({
3994
4049
  function isEntityObject(obj) {
3995
4050
  return obj.isEntityObject;
3996
4051
  }
3997
- var import_ts_deepmerge4, import_three13, EntityObject;
4052
+ var import_ts_deepmerge4, import_three14, EntityObject;
3998
4053
  var init_EntityObject = __esm({
3999
4054
  "src/entity/scene/EntityObject.ts"() {
4000
4055
  init_SceneObject();
4001
4056
  init_Caching();
4002
4057
  import_ts_deepmerge4 = __toESM(require_dist());
4003
- import_three13 = require("three");
4058
+ import_three14 = require("three");
4004
4059
  init_Ticker();
4005
4060
  init_model();
4006
4061
  init_ModelTextures();
@@ -4021,7 +4076,8 @@ var init_EntityObject = __esm({
4021
4076
  this.scrollMaterials = [];
4022
4077
  /** Entity age in ticks, as vanilla's `ageInTicks`; drives the scrolling render modes. */
4023
4078
  this.age = 0;
4024
- this.animationPlayer = new EntityAnimationPlayer();
4079
+ this.animationPlayers = [];
4080
+ this.partPoses = /* @__PURE__ */ new Map();
4025
4081
  this.options = (0, import_ts_deepmerge4.default)({}, _EntityObject.DEFAULT_OPTIONS, options ?? {});
4026
4082
  this.addEventListener("added", () => this.updateScrollSubscription());
4027
4083
  this.addEventListener("removed", () => this.updateScrollSubscription());
@@ -4041,7 +4097,8 @@ var init_EntityObject = __esm({
4041
4097
  for (const geometry of this.geometries) geometry.dispose();
4042
4098
  this.geometries.clear();
4043
4099
  for (const dispose of this.disposeWireframes.splice(0)) dispose();
4044
- this.animationPlayer.clear();
4100
+ for (const player of this.animationPlayers.splice(0)) player.clear();
4101
+ this.partPoses.clear();
4045
4102
  super.disposeAndRemoveAllChildren();
4046
4103
  }
4047
4104
  clearScrollMaterials() {
@@ -4073,36 +4130,61 @@ var init_EntityObject = __esm({
4073
4130
  this.notifyDirty();
4074
4131
  }
4075
4132
  //<editor-fold desc="ANIMATION">
4076
- /** The animation started by {@link playAnimation}, until {@link stopAnimation} or disposal. */
4133
+ /** The first active clip, until playback is stopped or the object is disposed. */
4077
4134
  get animation() {
4078
- return this.animationPlayer.animation;
4135
+ return this.animationPlayers[0]?.animation;
4136
+ }
4137
+ /** Clips playing together, each targeting a separate geometry layer. */
4138
+ get activeAnimations() {
4139
+ return this.animationPlayers.map((player) => player.animation);
4079
4140
  }
4080
4141
  /** Seconds since the animation started, before looping. */
4081
4142
  get animationTime() {
4082
- return this.animationPlayer.time;
4143
+ return this.animationPlayers[0]?.time ?? 0;
4083
4144
  }
4084
4145
  /**
4085
- * Poses the object from a keyframe animation of {@link Entities.getAnimations}, replacing the current one.
4086
- * Parts of every layer are matched by name and their current pose is the default the offsets add to.
4146
+ * Plays a clip from {@link Entities.getAnimations}, replacing all active clips.
4147
+ * Offsets apply to the baked pose in the clip's layer (`main` by default), including repeated draws of that layer.
4087
4148
  * The object owns no clock: call {@link advanceAnimation} per frame, or {@link setAnimationTime}.
4088
4149
  */
4089
4150
  playAnimation(animation, options) {
4151
+ this.playAnimations([animation], options);
4152
+ }
4153
+ /** Plays one clip per selected geometry layer, with a shared clock and no blending between clips. */
4154
+ playAnimations(animations, options) {
4155
+ const targets = /* @__PURE__ */ new Set();
4156
+ const selections = animations.map((animation) => {
4157
+ const layer = animation.layer ?? "main";
4158
+ if (targets.has(layer)) throw new Error(`Multiple animations target layer "${layer}"`);
4159
+ targets.add(layer);
4160
+ const names = Object.keys(this.entityLayers).filter((name) => name.split("#")[0] === layer);
4161
+ if (!names.length) throw new Error(`Entity ${this.entity.id} has no selected animation layer "${layer}"`);
4162
+ return { animation, names };
4163
+ });
4090
4164
  this.createMeshes();
4091
- const layers = Object.keys(this.entityLayers).map((name) => this.getLayerGroup(name)).filter((layer) => !!layer);
4092
- this.animationPlayer.play(layers, animation, options);
4165
+ this.stopAnimation();
4166
+ for (const { animation, names } of selections) {
4167
+ const player = new EntityAnimationPlayer();
4168
+ player.play(names.map((name) => this.getLayerGroup(name)), animation, options, this.partPoses);
4169
+ this.animationPlayers.push(player);
4170
+ }
4093
4171
  this.notifyDirty();
4094
4172
  }
4095
- /** Stops the animation and restores the default pose. */
4173
+ /** Stops all clips and restores the poses from before playback. */
4096
4174
  stopAnimation() {
4097
- if (this.animationPlayer.stop()) this.notifyDirty();
4175
+ const players = this.animationPlayers.splice(0);
4176
+ for (const player of players) player.stop();
4177
+ if (players.length) this.notifyDirty();
4098
4178
  }
4099
4179
  /** Poses the object at an explicit time in seconds. Has no effect without an animation. */
4100
4180
  setAnimationTime(seconds) {
4101
- if (this.animationPlayer.setTime(seconds)) this.notifyDirty();
4181
+ for (const player of this.animationPlayers) player.setTime(seconds);
4182
+ if (this.animationPlayers.length) this.notifyDirty();
4102
4183
  }
4103
4184
  /** Advances the animation by a frame delta in seconds, scaled by its speed. Has no effect without an animation. */
4104
4185
  advanceAnimation(deltaSeconds) {
4105
- if (this.animationPlayer.advance(deltaSeconds)) this.notifyDirty();
4186
+ for (const player of this.animationPlayers) player.advance(deltaSeconds);
4187
+ if (this.animationPlayers.length) this.notifyDirty();
4106
4188
  }
4107
4189
  //</editor-fold>
4108
4190
  getLayerGroup(name) {
@@ -4134,14 +4216,14 @@ var init_EntityObject = __esm({
4134
4216
  }
4135
4217
  createMeshes(force = false) {
4136
4218
  if (this.meshesCreated && !force) return;
4137
- const modelRoot = new import_three13.Object3D();
4219
+ const modelRoot = new import_three14.Object3D();
4138
4220
  const transform = this.options.flip === void 0 ? this.entity.transform : void 0;
4139
4221
  if (transform) {
4140
4222
  for (const op of transform) {
4141
- const matrix = new import_three13.Matrix4();
4223
+ const matrix = new import_three14.Matrix4();
4142
4224
  if ("scale" in op) matrix.makeScale(...op.scale);
4143
4225
  else if ("translate" in op) matrix.makeTranslation(...op.translate);
4144
- else matrix.makeRotationFromEuler(new import_three13.Euler(...op.rotate, "ZYX"));
4226
+ else matrix.makeRotationFromEuler(new import_three14.Euler(...op.rotate, "ZYX"));
4145
4227
  modelRoot.matrix.multiply(matrix);
4146
4228
  }
4147
4229
  modelRoot.matrixAutoUpdate = false;
@@ -4162,6 +4244,7 @@ var init_EntityObject = __esm({
4162
4244
  anchor.position.fromArray(part.pose.offset);
4163
4245
  anchor.rotation.set(...part.pose.rotation, "ZYX");
4164
4246
  anchor.scale.fromArray(part.pose.scale ?? [1, 1, 1]);
4247
+ this.partPoses.set(anchor, part.pose);
4165
4248
  parent.add(anchor);
4166
4249
  const size = part.texture ?? textureSize;
4167
4250
  for (const cube of part.cubes) {
@@ -4197,7 +4280,7 @@ var init_EntityObject = __esm({
4197
4280
  const tint = layer.tint === void 0 ? void 0 : this.options.tints?.[layer.tint];
4198
4281
  const scroll = Materials.entityModeScroll(mode);
4199
4282
  const assetKeyStr = this.getTextureKey(layer).serialize();
4200
- const keyStr = `entity:${mode}:${tint === void 0 ? "" : new import_three13.Color(tint).getHexString()}:${assetKeyStr}`;
4283
+ const keyStr = `entity:${mode}:${tint === void 0 ? "" : new import_three14.Color(tint).getHexString()}:${assetKeyStr}`;
4201
4284
  let mat = scroll ? void 0 : Caching.materialCache.getIfPresent(keyStr);
4202
4285
  if (!mat) {
4203
4286
  const cachedAsset = Caching.textureAssetCache.getIfPresent(assetKeyStr);
@@ -4238,7 +4321,7 @@ function mergeBufferGeometries(geometries, useGroups = false) {
4238
4321
  const attributes = {};
4239
4322
  const morphAttributes = {};
4240
4323
  const morphTargetsRelative = geometries[0].morphTargetsRelative;
4241
- const mergedGeometry = new import_three20.BufferGeometry();
4324
+ const mergedGeometry = new import_three21.BufferGeometry();
4242
4325
  let offset = 0;
4243
4326
  for (let i = 0; i < geometries.length; ++i) {
4244
4327
  const geometry = geometries[i];
@@ -4362,7 +4445,7 @@ function mergeBufferAttributes(attributes) {
4362
4445
  array.set(attributes[i].array, offset);
4363
4446
  offset += attributes[i].array.length;
4364
4447
  }
4365
- return new import_three20.BufferAttribute(array, itemSize, normalized);
4448
+ return new import_three21.BufferAttribute(array, itemSize, normalized);
4366
4449
  }
4367
4450
  function interleaveAttributes(attributes) {
4368
4451
  let TypedArray;
@@ -4378,7 +4461,7 @@ function interleaveAttributes(attributes) {
4378
4461
  arrayLength += attribute.array.length;
4379
4462
  stride += attribute.itemSize;
4380
4463
  }
4381
- const interleavedBuffer = new import_three20.InterleavedBuffer(new TypedArray(arrayLength), stride);
4464
+ const interleavedBuffer = new import_three21.InterleavedBuffer(new TypedArray(arrayLength), stride);
4382
4465
  let offset = 0;
4383
4466
  const res = [];
4384
4467
  const getters = ["getX", "getY", "getZ", "getW"];
@@ -4387,7 +4470,7 @@ function interleaveAttributes(attributes) {
4387
4470
  const attribute = attributes[j];
4388
4471
  const itemSize = attribute.itemSize;
4389
4472
  const count = attribute.count;
4390
- const iba = new import_three20.InterleavedBufferAttribute(interleavedBuffer, itemSize, offset, attribute.normalized);
4473
+ const iba = new import_three21.InterleavedBufferAttribute(interleavedBuffer, itemSize, offset, attribute.normalized);
4391
4474
  res.push(iba);
4392
4475
  offset += itemSize;
4393
4476
  for (let c = 0; c < count; c++) {
@@ -4471,13 +4554,13 @@ function mergeVertices(geometry, tolerance = 1e-4) {
4471
4554
  const name = attributeNames[i];
4472
4555
  const oldAttribute = geometry.getAttribute(name);
4473
4556
  const buffer = new oldAttribute.array.constructor(attrArrays[name]);
4474
- const attribute = new import_three20.BufferAttribute(buffer, oldAttribute.itemSize, oldAttribute.normalized);
4557
+ const attribute = new import_three21.BufferAttribute(buffer, oldAttribute.itemSize, oldAttribute.normalized);
4475
4558
  result.setAttribute(name, attribute);
4476
4559
  if (name in morphAttrsArrays) {
4477
4560
  for (let j = 0; j < morphAttrsArrays[name].length; j++) {
4478
4561
  const oldMorphAttribute = geometry.morphAttributes[name][j];
4479
4562
  const buffer2 = new oldMorphAttribute.array.constructor(morphAttrsArrays[name][j]);
4480
- const morphAttribute = new import_three20.BufferAttribute(buffer2, oldMorphAttribute.itemSize, oldMorphAttribute.normalized);
4563
+ const morphAttribute = new import_three21.BufferAttribute(buffer2, oldMorphAttribute.itemSize, oldMorphAttribute.normalized);
4481
4564
  result.morphAttributes[name][j] = morphAttribute;
4482
4565
  }
4483
4566
  }
@@ -4486,11 +4569,11 @@ function mergeVertices(geometry, tolerance = 1e-4) {
4486
4569
  return result;
4487
4570
  }
4488
4571
  function toTrianglesDrawMode(geometry, drawMode) {
4489
- if (drawMode === import_three20.TrianglesDrawMode) {
4572
+ if (drawMode === import_three21.TrianglesDrawMode) {
4490
4573
  console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles.");
4491
4574
  return geometry;
4492
4575
  }
4493
- if (drawMode === import_three20.TriangleFanDrawMode || drawMode === import_three20.TriangleStripDrawMode) {
4576
+ if (drawMode === import_three21.TriangleFanDrawMode || drawMode === import_three21.TriangleStripDrawMode) {
4494
4577
  let index = geometry.getIndex();
4495
4578
  if (index === null) {
4496
4579
  const indices = [];
@@ -4508,7 +4591,7 @@ function toTrianglesDrawMode(geometry, drawMode) {
4508
4591
  }
4509
4592
  const numberOfTriangles = index.count - 2;
4510
4593
  const newIndices = [];
4511
- if (drawMode === import_three20.TriangleFanDrawMode) {
4594
+ if (drawMode === import_three21.TriangleFanDrawMode) {
4512
4595
  for (let i = 1; i <= numberOfTriangles; i++) {
4513
4596
  newIndices.push(index.getX(0));
4514
4597
  newIndices.push(index.getX(i));
@@ -4544,15 +4627,15 @@ function computeMorphedAttributes(object) {
4544
4627
  console.error("THREE.BufferGeometryUtils: Geometry is not of type BufferGeometry.");
4545
4628
  return null;
4546
4629
  }
4547
- const _vA = new import_three20.Vector3();
4548
- const _vB = new import_three20.Vector3();
4549
- const _vC = new import_three20.Vector3();
4550
- const _tempA = new import_three20.Vector3();
4551
- const _tempB = new import_three20.Vector3();
4552
- const _tempC = new import_three20.Vector3();
4553
- const _morphA = new import_three20.Vector3();
4554
- const _morphB = new import_three20.Vector3();
4555
- const _morphC = new import_three20.Vector3();
4630
+ const _vA = new import_three21.Vector3();
4631
+ const _vB = new import_three21.Vector3();
4632
+ const _vC = new import_three21.Vector3();
4633
+ const _tempA = new import_three21.Vector3();
4634
+ const _tempB = new import_three21.Vector3();
4635
+ const _tempC = new import_three21.Vector3();
4636
+ const _morphA = new import_three21.Vector3();
4637
+ const _morphB = new import_three21.Vector3();
4638
+ const _morphC = new import_three21.Vector3();
4556
4639
  function _calculateMorphedAttributeData(object2, material2, attribute, morphAttribute, morphTargetsRelative2, a2, b2, c2, modifiedAttributeArray) {
4557
4640
  _vA.fromBufferAttribute(attribute, a2);
4558
4641
  _vB.fromBufferAttribute(attribute, b2);
@@ -4747,8 +4830,8 @@ function computeMorphedAttributes(object) {
4747
4830
  }
4748
4831
  }
4749
4832
  }
4750
- const morphedPositionAttribute = new import_three20.Float32BufferAttribute(modifiedPosition, 3);
4751
- const morphedNormalAttribute = new import_three20.Float32BufferAttribute(modifiedNormal, 3);
4833
+ const morphedPositionAttribute = new import_three21.Float32BufferAttribute(modifiedPosition, 3);
4834
+ const morphedNormalAttribute = new import_three21.Float32BufferAttribute(modifiedNormal, 3);
4752
4835
  return {
4753
4836
  positionAttribute,
4754
4837
  normalAttribute,
@@ -4756,24 +4839,24 @@ function computeMorphedAttributes(object) {
4756
4839
  morphedNormalAttribute
4757
4840
  };
4758
4841
  }
4759
- var import_three20;
4842
+ var import_three21;
4760
4843
  var init_BufferGeometryUtils = __esm({
4761
4844
  "src/three/BufferGeometryUtils.js"() {
4762
- import_three20 = require("three");
4845
+ import_three21 = require("three");
4763
4846
  }
4764
4847
  });
4765
4848
 
4766
4849
  // src/model/ModelCulling.ts
4767
- var import_three21, ModelCulling;
4850
+ var import_three22, ModelCulling;
4768
4851
  var init_ModelCulling = __esm({
4769
4852
  "src/model/ModelCulling.ts"() {
4770
- import_three21 = require("three");
4853
+ import_three22 = require("three");
4771
4854
  init_CubeFace();
4772
4855
  ModelCulling = class {
4773
4856
  static toLocalMask(worldMask, rotation) {
4774
4857
  let localMask = 0;
4775
4858
  for (const [localFace, offset] of CUBE_FACE_OFFSETS.entries()) {
4776
- const normal = new import_three21.Vector3(...offset).applyEuler(rotation);
4859
+ const normal = new import_three22.Vector3(...offset).applyEuler(rotation);
4777
4860
  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);
4778
4861
  if (worldFace < 0) return 0;
4779
4862
  if (worldMask & 1 << worldFace) localMask |= 1 << localFace;
@@ -4806,10 +4889,10 @@ var init_ModelCulling = __esm({
4806
4889
  });
4807
4890
 
4808
4891
  // src/model/SpecialItems.ts
4809
- var import_three22, SpecialItems;
4892
+ var import_three23, SpecialItems;
4810
4893
  var init_SpecialItems = __esm({
4811
4894
  "src/model/SpecialItems.ts"() {
4812
- import_three22 = require("three");
4895
+ import_three23 = require("three");
4813
4896
  init_AssetKey();
4814
4897
  init_Entities();
4815
4898
  SpecialItems = class {
@@ -4837,7 +4920,7 @@ var init_SpecialItems = __esm({
4837
4920
  case "minecraft:chest":
4838
4921
  case "chest": {
4839
4922
  const angle = -(special.openness ?? 0) * Math.PI / 2;
4840
- const chest = await load("chest", texture(special.texture, "chest"), new import_three22.Matrix4(), {
4923
+ const chest = await load("chest", texture(special.texture, "chest"), new import_three23.Matrix4(), {
4841
4924
  lid: [angle, 0, 0],
4842
4925
  lock: [angle, 0, 0]
4843
4926
  });
@@ -4846,11 +4929,11 @@ var init_SpecialItems = __esm({
4846
4929
  }
4847
4930
  case "minecraft:bed":
4848
4931
  case "bed": {
4849
- 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));
4932
+ 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));
4850
4933
  const key = texture(special.texture, "bed");
4851
4934
  return Promise.all([
4852
4935
  load("bed_head", key, transform),
4853
- load("bed_foot", key, new import_three22.Matrix4().makeTranslation(0, 0, -16).multiply(transform))
4936
+ load("bed_foot", key, new import_three23.Matrix4().makeTranslation(0, 0, -16).multiply(transform))
4854
4937
  ]);
4855
4938
  }
4856
4939
  case "minecraft:head":
@@ -4875,7 +4958,7 @@ var init_SpecialItems = __esm({
4875
4958
  return [await load(
4876
4959
  id,
4877
4960
  special.texture ? texture(special.texture, "") : void 0,
4878
- new import_three22.Matrix4().makeTranslation(8, 0, 8).multiply(new import_three22.Matrix4().makeScale(-1, -1, 1)),
4961
+ new import_three23.Matrix4().makeTranslation(8, 0, 8).multiply(new import_three23.Matrix4().makeScale(-1, -1, 1)),
4879
4962
  rotations
4880
4963
  )];
4881
4964
  }
@@ -5003,13 +5086,13 @@ var init_ItemTints = __esm({
5003
5086
  function isModelObject(obj) {
5004
5087
  return obj.isModelObject;
5005
5088
  }
5006
- var import_three23, import_ts_deepmerge5, p7, ModelObject;
5089
+ var import_three24, import_ts_deepmerge5, p7, ModelObject;
5007
5090
  var init_ModelObject = __esm({
5008
5091
  "src/model/scene/ModelObject.ts"() {
5009
5092
  init_SceneObject();
5010
5093
  init_Materials();
5011
5094
  init_UVMapper();
5012
- import_three23 = require("three");
5095
+ import_three24 = require("three");
5013
5096
  init_BufferGeometryUtils();
5014
5097
  init_model();
5015
5098
  import_ts_deepmerge5 = __toESM(require_dist());
@@ -5044,8 +5127,8 @@ var init_ModelObject = __esm({
5044
5127
  const special = this.originalModel.special;
5045
5128
  if (special) {
5046
5129
  const parts = await SpecialItems.getParts(special, this.originalModel.key?.root);
5047
- const transform = this.options.displayPosition ? DisplayTransforms.getMatrix(this.originalModel.display, this.options.displayPosition) : new import_three23.Matrix4();
5048
- transform.multiply(new import_three23.Matrix4().makeTranslation(-8, -8, -8));
5130
+ const transform = this.options.displayPosition ? DisplayTransforms.getMatrix(this.originalModel.display, this.options.displayPosition) : new import_three24.Matrix4();
5131
+ transform.multiply(new import_three24.Matrix4().makeTranslation(-8, -8, -8));
5049
5132
  try {
5050
5133
  for (const part of parts) {
5051
5134
  const object = new EntityObject(part.model, { flip: false, wireframe: this.options.wireframe });
@@ -5107,7 +5190,7 @@ var init_ModelObject = __esm({
5107
5190
  elGeo.clearGroups();
5108
5191
  }
5109
5192
  if (this.options.uvLockRotation) {
5110
- UVMapper.lockUvs(elGeo, el.faces, this.atlas, new import_three23.Euler(...this.options.uvLockRotation));
5193
+ UVMapper.lockUvs(elGeo, el.faces, this.atlas, new import_three24.Euler(...this.options.uvLockRotation));
5111
5194
  }
5112
5195
  if (this.options.tints) {
5113
5196
  const colors = new Float32Array(elGeo.getAttribute("position").count * 3).fill(1);
@@ -5116,19 +5199,19 @@ var init_ModelObject = __esm({
5116
5199
  if (tintIndex === void 0 || tintIndex < 0) continue;
5117
5200
  const tint = this.options.tints[tintIndex];
5118
5201
  if (tint === void 0) continue;
5119
- const color = new import_three23.Color(tint);
5202
+ const color = new import_three24.Color(tint);
5120
5203
  for (let vertex = 0; vertex < 4; vertex++) {
5121
5204
  color.toArray(colors, (faceIndex * 4 + vertex) * 3);
5122
5205
  }
5123
5206
  }
5124
- elGeo.setAttribute("color", new import_three23.BufferAttribute(colors, 3));
5207
+ elGeo.setAttribute("color", new import_three24.BufferAttribute(colors, 3));
5125
5208
  }
5126
- 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));
5127
- elGeo.applyMatrix4(new import_three23.Matrix4().makeTranslation(el.from[0], el.from[1], el.from[2]));
5209
+ 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));
5210
+ elGeo.applyMatrix4(new import_three24.Matrix4().makeTranslation(el.from[0], el.from[1], el.from[2]));
5128
5211
  if (el.rotation) {
5129
5212
  applyElementRotation(el.rotation, elGeo);
5130
5213
  }
5131
- elGeo.applyMatrix4(new import_three23.Matrix4().makeTranslation(-8, -8, -8));
5214
+ elGeo.applyMatrix4(new import_three24.Matrix4().makeTranslation(-8, -8, -8));
5132
5215
  if (displayTransform) DisplayTransforms.apply(elGeo, displayTransform);
5133
5216
  if (this.options.mergeMeshes) {
5134
5217
  allGeos.push(elGeo);
@@ -5150,7 +5233,7 @@ var init_ModelObject = __esm({
5150
5233
  if (allGeos.length > 0) {
5151
5234
  combinedGeo = mergeBufferGeometries(allGeos);
5152
5235
  } else {
5153
- combinedGeo = new import_three23.BoxGeometry(16, 16, 16);
5236
+ combinedGeo = new import_three24.BoxGeometry(16, 16, 16);
5154
5237
  if (displayTransform) DisplayTransforms.apply(combinedGeo, displayTransform);
5155
5238
  }
5156
5239
  combinedGeo.computeBoundingBox();
@@ -5260,7 +5343,7 @@ function ownHeight(sample) {
5260
5343
  return (level === 0 || level >= 8 ? 8 : 8 - level) / 9;
5261
5344
  }
5262
5345
  function createFluidGeometry(kind, sample) {
5263
- const geometry = new import_three28.BufferGeometry();
5346
+ const geometry = new import_three29.BufferGeometry();
5264
5347
  const positions = [], normals = [], uvs = [], indices = [];
5265
5348
  const self = sample(0, 0, 0);
5266
5349
  const height = (x, z) => {
@@ -5359,16 +5442,16 @@ function createFluidGeometry(kind, sample) {
5359
5442
  1
5360
5443
  );
5361
5444
  }
5362
- geometry.setAttribute("position", new import_three28.Float32BufferAttribute(positions, 3));
5363
- geometry.setAttribute("normal", new import_three28.Float32BufferAttribute(normals, 3));
5364
- geometry.setAttribute("uv", new import_three28.Float32BufferAttribute(uvs, 2));
5445
+ geometry.setAttribute("position", new import_three29.Float32BufferAttribute(positions, 3));
5446
+ geometry.setAttribute("normal", new import_three29.Float32BufferAttribute(normals, 3));
5447
+ geometry.setAttribute("uv", new import_three29.Float32BufferAttribute(uvs, 2));
5365
5448
  geometry.setIndex(indices);
5366
5449
  return geometry;
5367
5450
  }
5368
- var import_three28, fluidRules, HORIZONTAL, EPSILON;
5451
+ var import_three29, fluidRules, HORIZONTAL, EPSILON;
5369
5452
  var init_FluidGeometry = __esm({
5370
5453
  "src/model/fluid/FluidGeometry.ts"() {
5371
- import_three28 = require("three");
5454
+ import_three29 = require("three");
5372
5455
  init_fluidBlocks();
5373
5456
  fluidRules = fluidBlocks_default;
5374
5457
  HORIZONTAL = [[0, -1], [0, 1], [-1, 0], [1, 0]];
@@ -5397,10 +5480,10 @@ function sampleFluid(kind, sample) {
5397
5480
  }
5398
5481
  return { key: key.join(""), sample: (x, y, z) => cells[(y + 1) * 9 + (z + 1) * 3 + x + 1] };
5399
5482
  }
5400
- var import_three29, FluidModelObject;
5483
+ var import_three30, FluidModelObject;
5401
5484
  var init_FluidModelObject = __esm({
5402
5485
  "src/model/fluid/FluidModelObject.ts"() {
5403
- import_three29 = require("three");
5486
+ import_three30 = require("three");
5404
5487
  init_AssetKey();
5405
5488
  init_Materials();
5406
5489
  init_ModelObject();
@@ -5433,10 +5516,10 @@ var init_FluidModelObject = __esm({
5433
5516
  }
5434
5517
  }
5435
5518
  geometry.clearGroups();
5436
- const color = new import_three29.Color(this.options.tints?.[0] ?? (this.kind === "water" ? 4159204 : 16777215));
5519
+ const color = new import_three30.Color(this.options.tints?.[0] ?? (this.kind === "water" ? 4159204 : 16777215));
5437
5520
  const colors = new Float32Array(geometry.getAttribute("position").count * 3);
5438
5521
  for (let i = 0; i < colors.length; i += 3) color.toArray(colors, i);
5439
- geometry.setAttribute("color", new import_three29.BufferAttribute(colors, 3));
5522
+ geometry.setAttribute("color", new import_three30.BufferAttribute(colors, 3));
5440
5523
  geometry.computeBoundingBox();
5441
5524
  geometry.computeBoundingSphere();
5442
5525
  if (this.options.instanceMeshes) {
@@ -5450,7 +5533,7 @@ var init_FluidModelObject = __esm({
5450
5533
  super.applyTextures();
5451
5534
  this.iterateAllMeshes((mesh) => {
5452
5535
  const material = mesh.material;
5453
- material.side = import_three29.DoubleSide;
5536
+ material.side = import_three30.DoubleSide;
5454
5537
  material.forceSinglePass = true;
5455
5538
  material.depthWrite = !material.transparent;
5456
5539
  });
@@ -5898,27 +5981,27 @@ init_EntityObject();
5898
5981
  init_MineRenderError();
5899
5982
 
5900
5983
  // src/export/SceneExporter.ts
5901
- var import_three19 = require("three");
5984
+ var import_three20 = require("three");
5902
5985
 
5903
5986
  // ../../node_modules/three/examples/jsm/exporters/OBJExporter.js
5904
- var import_three15 = require("three");
5987
+ var import_three16 = require("three");
5905
5988
  var OBJExporter = class {
5906
5989
  parse(object) {
5907
5990
  let output = "";
5908
5991
  let indexVertex = 0;
5909
5992
  let indexVertexUvs = 0;
5910
5993
  let indexNormals = 0;
5911
- const vertex = new import_three15.Vector3();
5912
- const color = new import_three15.Color();
5913
- const normal = new import_three15.Vector3();
5914
- const uv = new import_three15.Vector2();
5994
+ const vertex = new import_three16.Vector3();
5995
+ const color = new import_three16.Color();
5996
+ const normal = new import_three16.Vector3();
5997
+ const uv = new import_three16.Vector2();
5915
5998
  const face = [];
5916
5999
  function parseMesh(mesh) {
5917
6000
  let nbVertex = 0;
5918
6001
  let nbNormals = 0;
5919
6002
  let nbVertexUvs = 0;
5920
6003
  const geometry = mesh.geometry;
5921
- const normalMatrixWorld = new import_three15.Matrix3();
6004
+ const normalMatrixWorld = new import_three16.Matrix3();
5922
6005
  const vertices = geometry.getAttribute("position");
5923
6006
  const normals = geometry.getAttribute("normal");
5924
6007
  const uvs = geometry.getAttribute("uv");
@@ -6037,7 +6120,7 @@ var OBJExporter = class {
6037
6120
  };
6038
6121
 
6039
6122
  // ../../node_modules/three/examples/jsm/exporters/PLYExporter.js
6040
- var import_three16 = require("three");
6123
+ var import_three17 = require("three");
6041
6124
  var PLYExporter = class {
6042
6125
  parse(object, onDone, options = {}) {
6043
6126
  function traverseMeshes(cb) {
@@ -6094,7 +6177,7 @@ var PLYExporter = class {
6094
6177
  includeIndices = false;
6095
6178
  }
6096
6179
  });
6097
- const tempColor = new import_three16.Color();
6180
+ const tempColor = new import_three17.Color();
6098
6181
  includeIndices = includeIndices && excludeAttributes.indexOf("index") === -1;
6099
6182
  includeNormals = includeNormals && excludeAttributes.indexOf("normal") === -1;
6100
6183
  includeColors = includeColors && excludeAttributes.indexOf("color") === -1;
@@ -6128,8 +6211,8 @@ property list uchar int vertex_index
6128
6211
  `;
6129
6212
  }
6130
6213
  header += "end_header\n";
6131
- const vertex = new import_three16.Vector3();
6132
- const normalMatrixWorld = new import_three16.Matrix3();
6214
+ const vertex = new import_three17.Vector3();
6215
+ const normalMatrixWorld = new import_three17.Matrix3();
6133
6216
  let result = null;
6134
6217
  if (options.binary === true) {
6135
6218
  const headerBin = new TextEncoder().encode(header);
@@ -6303,18 +6386,18 @@ property list uchar int vertex_index
6303
6386
  };
6304
6387
 
6305
6388
  // ../../node_modules/three/examples/jsm/exporters/GLTFExporter.js
6306
- var import_three18 = require("three");
6389
+ var import_three19 = require("three");
6307
6390
 
6308
6391
  // ../../node_modules/three/examples/jsm/utils/TextureUtils.js
6309
- var import_three17 = require("three");
6392
+ var import_three18 = require("three");
6310
6393
  var _renderer;
6311
6394
  var fullscreenQuadGeometry;
6312
6395
  var fullscreenQuadMaterial;
6313
6396
  var fullscreenQuad;
6314
6397
  function decompress(texture, maxTextureSize = Infinity, renderer = null) {
6315
- if (!fullscreenQuadGeometry) fullscreenQuadGeometry = new import_three17.PlaneGeometry(2, 2, 1, 1);
6316
- if (!fullscreenQuadMaterial) fullscreenQuadMaterial = new import_three17.ShaderMaterial({
6317
- uniforms: { blitTexture: new import_three17.Uniform(texture) },
6398
+ if (!fullscreenQuadGeometry) fullscreenQuadGeometry = new import_three18.PlaneGeometry(2, 2, 1, 1);
6399
+ if (!fullscreenQuadMaterial) fullscreenQuadMaterial = new import_three18.ShaderMaterial({
6400
+ uniforms: { blitTexture: new import_three18.Uniform(texture) },
6318
6401
  vertexShader: `
6319
6402
  varying vec2 vUv;
6320
6403
  void main(){
@@ -6336,22 +6419,22 @@ function decompress(texture, maxTextureSize = Infinity, renderer = null) {
6336
6419
  }`
6337
6420
  });
6338
6421
  fullscreenQuadMaterial.uniforms.blitTexture.value = texture;
6339
- fullscreenQuadMaterial.defines.IS_SRGB = texture.colorSpace == import_three17.SRGBColorSpace;
6422
+ fullscreenQuadMaterial.defines.IS_SRGB = texture.colorSpace == import_three18.SRGBColorSpace;
6340
6423
  fullscreenQuadMaterial.needsUpdate = true;
6341
6424
  if (!fullscreenQuad) {
6342
- fullscreenQuad = new import_three17.Mesh(fullscreenQuadGeometry, fullscreenQuadMaterial);
6425
+ fullscreenQuad = new import_three18.Mesh(fullscreenQuadGeometry, fullscreenQuadMaterial);
6343
6426
  fullscreenQuad.frustrumCulled = false;
6344
6427
  }
6345
- const _camera = new import_three17.PerspectiveCamera();
6346
- const _scene = new import_three17.Scene();
6428
+ const _camera = new import_three18.PerspectiveCamera();
6429
+ const _scene = new import_three18.Scene();
6347
6430
  _scene.add(fullscreenQuad);
6348
6431
  if (!renderer) {
6349
- renderer = _renderer = new import_three17.WebGLRenderer({ antialias: false });
6432
+ renderer = _renderer = new import_three18.WebGLRenderer({ antialias: false });
6350
6433
  }
6351
6434
  renderer.setSize(Math.min(texture.image.width, maxTextureSize), Math.min(texture.image.height, maxTextureSize));
6352
6435
  renderer.clear();
6353
6436
  renderer.render(_scene, _camera);
6354
- const readableTexture = new import_three17.Texture(renderer.domElement);
6437
+ const readableTexture = new import_three18.Texture(renderer.domElement);
6355
6438
  readableTexture.minFilter = texture.minFilter;
6356
6439
  readableTexture.magFilter = texture.magFilter;
6357
6440
  readableTexture.wrapS = texture.wrapS;
@@ -6497,22 +6580,22 @@ var WEBGL_CONSTANTS = {
6497
6580
  };
6498
6581
  var KHR_MESH_QUANTIZATION = "KHR_mesh_quantization";
6499
6582
  var THREE_TO_WEBGL = {};
6500
- THREE_TO_WEBGL[import_three18.NearestFilter] = WEBGL_CONSTANTS.NEAREST;
6501
- THREE_TO_WEBGL[import_three18.NearestMipmapNearestFilter] = WEBGL_CONSTANTS.NEAREST_MIPMAP_NEAREST;
6502
- THREE_TO_WEBGL[import_three18.NearestMipmapLinearFilter] = WEBGL_CONSTANTS.NEAREST_MIPMAP_LINEAR;
6503
- THREE_TO_WEBGL[import_three18.LinearFilter] = WEBGL_CONSTANTS.LINEAR;
6504
- THREE_TO_WEBGL[import_three18.LinearMipmapNearestFilter] = WEBGL_CONSTANTS.LINEAR_MIPMAP_NEAREST;
6505
- THREE_TO_WEBGL[import_three18.LinearMipmapLinearFilter] = WEBGL_CONSTANTS.LINEAR_MIPMAP_LINEAR;
6506
- THREE_TO_WEBGL[import_three18.ClampToEdgeWrapping] = WEBGL_CONSTANTS.CLAMP_TO_EDGE;
6507
- THREE_TO_WEBGL[import_three18.RepeatWrapping] = WEBGL_CONSTANTS.REPEAT;
6508
- THREE_TO_WEBGL[import_three18.MirroredRepeatWrapping] = WEBGL_CONSTANTS.MIRRORED_REPEAT;
6583
+ THREE_TO_WEBGL[import_three19.NearestFilter] = WEBGL_CONSTANTS.NEAREST;
6584
+ THREE_TO_WEBGL[import_three19.NearestMipmapNearestFilter] = WEBGL_CONSTANTS.NEAREST_MIPMAP_NEAREST;
6585
+ THREE_TO_WEBGL[import_three19.NearestMipmapLinearFilter] = WEBGL_CONSTANTS.NEAREST_MIPMAP_LINEAR;
6586
+ THREE_TO_WEBGL[import_three19.LinearFilter] = WEBGL_CONSTANTS.LINEAR;
6587
+ THREE_TO_WEBGL[import_three19.LinearMipmapNearestFilter] = WEBGL_CONSTANTS.LINEAR_MIPMAP_NEAREST;
6588
+ THREE_TO_WEBGL[import_three19.LinearMipmapLinearFilter] = WEBGL_CONSTANTS.LINEAR_MIPMAP_LINEAR;
6589
+ THREE_TO_WEBGL[import_three19.ClampToEdgeWrapping] = WEBGL_CONSTANTS.CLAMP_TO_EDGE;
6590
+ THREE_TO_WEBGL[import_three19.RepeatWrapping] = WEBGL_CONSTANTS.REPEAT;
6591
+ THREE_TO_WEBGL[import_three19.MirroredRepeatWrapping] = WEBGL_CONSTANTS.MIRRORED_REPEAT;
6509
6592
  var PATH_PROPERTIES = {
6510
6593
  scale: "scale",
6511
6594
  position: "translation",
6512
6595
  quaternion: "rotation",
6513
6596
  morphTargetInfluences: "weights"
6514
6597
  };
6515
- var DEFAULT_SPECULAR_COLOR = new import_three18.Color();
6598
+ var DEFAULT_SPECULAR_COLOR = new import_three19.Color();
6516
6599
  var GLB_HEADER_BYTES = 12;
6517
6600
  var GLB_HEADER_MAGIC = 1179937895;
6518
6601
  var GLB_VERSION = 2;
@@ -6546,7 +6629,7 @@ function getMinMax(attribute, start, count) {
6546
6629
  else if (a === 2) value = attribute.getZ(i);
6547
6630
  else if (a === 3) value = attribute.getW(i);
6548
6631
  if (attribute.normalized === true) {
6549
- value = import_three18.MathUtils.normalize(value, attribute.array);
6632
+ value = import_three19.MathUtils.normalize(value, attribute.array);
6550
6633
  }
6551
6634
  }
6552
6635
  output.min[a] = Math.min(output.min[a], value);
@@ -6752,7 +6835,7 @@ var GLTFWriter = class {
6752
6835
  isNormalizedNormalAttribute(normal) {
6753
6836
  const cache = this.cache;
6754
6837
  if (cache.attributesNormalized.has(normal)) return false;
6755
- const v = new import_three18.Vector3();
6838
+ const v = new import_three19.Vector3();
6756
6839
  for (let i = 0, il = normal.count; i < il; i++) {
6757
6840
  if (Math.abs(v.fromBufferAttribute(normal, i).length() - 1) > 5e-4) return false;
6758
6841
  }
@@ -6769,7 +6852,7 @@ var GLTFWriter = class {
6769
6852
  const cache = this.cache;
6770
6853
  if (cache.attributesNormalized.has(normal)) return cache.attributesNormalized.get(normal);
6771
6854
  const attribute = normal.clone();
6772
- const v = new import_three18.Vector3();
6855
+ const v = new import_three19.Vector3();
6773
6856
  for (let i = 0, il = attribute.count; i < il; i++) {
6774
6857
  v.fromBufferAttribute(attribute, i);
6775
6858
  if (v.x === 0 && v.y === 0 && v.z === 0) {
@@ -6813,7 +6896,7 @@ var GLTFWriter = class {
6813
6896
  buildMetalRoughTexture(metalnessMap, roughnessMap) {
6814
6897
  if (metalnessMap === roughnessMap) return metalnessMap;
6815
6898
  function getEncodingConversion(map) {
6816
- if (map.colorSpace === import_three18.SRGBColorSpace) {
6899
+ if (map.colorSpace === import_three19.SRGBColorSpace) {
6817
6900
  return function SRGBToLinear(c) {
6818
6901
  return c < 0.04045 ? c * 0.0773993808 : Math.pow(c * 0.9478672986 + 0.0521327014, 2.4);
6819
6902
  };
@@ -6823,10 +6906,10 @@ var GLTFWriter = class {
6823
6906
  };
6824
6907
  }
6825
6908
  console.warn("THREE.GLTFExporter: Merged metalnessMap and roughnessMap textures.");
6826
- if (metalnessMap instanceof import_three18.CompressedTexture) {
6909
+ if (metalnessMap instanceof import_three19.CompressedTexture) {
6827
6910
  metalnessMap = decompress(metalnessMap);
6828
6911
  }
6829
- if (roughnessMap instanceof import_three18.CompressedTexture) {
6912
+ if (roughnessMap instanceof import_three19.CompressedTexture) {
6830
6913
  roughnessMap = decompress(roughnessMap);
6831
6914
  }
6832
6915
  const metalness = metalnessMap ? metalnessMap.image : null;
@@ -6859,8 +6942,8 @@ var GLTFWriter = class {
6859
6942
  context.putImageData(composite, 0, 0);
6860
6943
  const reference = metalnessMap || roughnessMap;
6861
6944
  const texture = reference.clone();
6862
- texture.source = new import_three18.Source(canvas);
6863
- texture.colorSpace = import_three18.NoColorSpace;
6945
+ texture.source = new import_three19.Source(canvas);
6946
+ texture.colorSpace = import_three19.NoColorSpace;
6864
6947
  texture.channel = (metalnessMap || roughnessMap).channel;
6865
6948
  if (metalnessMap && roughnessMap && metalnessMap.channel !== roughnessMap.channel) {
6866
6949
  console.warn("THREE.GLTFExporter: UV channels for metalnessMap and roughnessMap textures must match.");
@@ -6918,7 +7001,7 @@ var GLTFWriter = class {
6918
7001
  else if (a === 2) value = attribute.getZ(i);
6919
7002
  else if (a === 3) value = attribute.getW(i);
6920
7003
  if (attribute.normalized === true) {
6921
- value = import_three18.MathUtils.normalize(value, attribute.array);
7004
+ value = import_three19.MathUtils.normalize(value, attribute.array);
6922
7005
  }
6923
7006
  }
6924
7007
  if (componentType === WEBGL_CONSTANTS.FLOAT) {
@@ -7068,7 +7151,7 @@ var GLTFWriter = class {
7068
7151
  ctx.scale(1, -1);
7069
7152
  }
7070
7153
  if (image.data !== void 0) {
7071
- if (format !== import_three18.RGBAFormat) {
7154
+ if (format !== import_three19.RGBAFormat) {
7072
7155
  console.error("GLTFExporter: Only RGBAFormat is supported.", format);
7073
7156
  }
7074
7157
  if (image.width > options.maxTextureSize || image.height > options.maxTextureSize) {
@@ -7137,7 +7220,7 @@ var GLTFWriter = class {
7137
7220
  const json = this.json;
7138
7221
  if (cache.textures.has(map)) return cache.textures.get(map);
7139
7222
  if (!json.textures) json.textures = [];
7140
- if (map instanceof import_three18.CompressedTexture) {
7223
+ if (map instanceof import_three19.CompressedTexture) {
7141
7224
  map = decompress(map, options.maxTextureSize);
7142
7225
  }
7143
7226
  let mimeType = map.userData.mimeType;
@@ -7245,7 +7328,7 @@ var GLTFWriter = class {
7245
7328
  materialDef.alphaCutoff = material.alphaTest;
7246
7329
  }
7247
7330
  }
7248
- if (material.side === import_three18.DoubleSide) materialDef.doubleSided = true;
7331
+ if (material.side === import_three19.DoubleSide) materialDef.doubleSided = true;
7249
7332
  if (material.name !== "") materialDef.name = material.name;
7250
7333
  this.serializeUserData(material, materialDef);
7251
7334
  this._invokeAll(function(ext) {
@@ -7319,7 +7402,7 @@ var GLTFWriter = class {
7319
7402
  const array = attribute.array;
7320
7403
  if (attributeName === "JOINTS_0" && !(array instanceof Uint16Array) && !(array instanceof Uint8Array)) {
7321
7404
  console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.');
7322
- modifiedAttribute = new import_three18.BufferAttribute(new Uint16Array(array), attribute.itemSize, attribute.normalized);
7405
+ modifiedAttribute = new import_three19.BufferAttribute(new Uint16Array(array), attribute.itemSize, attribute.normalized);
7323
7406
  }
7324
7407
  const accessor = this.processAccessor(modifiedAttribute || attribute, geometry);
7325
7408
  if (accessor !== null) {
@@ -7479,7 +7562,7 @@ var GLTFWriter = class {
7479
7562
  } else {
7480
7563
  cameraDef.perspective = {
7481
7564
  aspectRatio: camera.aspect,
7482
- yfov: import_three18.MathUtils.degToRad(camera.fov),
7565
+ yfov: import_three19.MathUtils.degToRad(camera.fov),
7483
7566
  zfar: camera.far <= 0 ? 1e-3 : camera.far,
7484
7567
  znear: camera.near < 0 ? 0 : camera.near
7485
7568
  };
@@ -7507,8 +7590,8 @@ var GLTFWriter = class {
7507
7590
  const samplers = [];
7508
7591
  for (let i = 0; i < tracks.length; ++i) {
7509
7592
  const track = tracks[i];
7510
- const trackBinding = import_three18.PropertyBinding.parseTrackName(track.name);
7511
- let trackNode = import_three18.PropertyBinding.findNode(root, trackBinding.nodeName);
7593
+ const trackBinding = import_three19.PropertyBinding.parseTrackName(track.name);
7594
+ let trackNode = import_three19.PropertyBinding.findNode(root, trackBinding.nodeName);
7512
7595
  const trackProperty = PATH_PROPERTIES[trackBinding.propertyName];
7513
7596
  if (trackBinding.objectName === "bones") {
7514
7597
  if (trackNode.isSkinnedMesh === true) {
@@ -7530,14 +7613,14 @@ var GLTFWriter = class {
7530
7613
  if (track.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline === true) {
7531
7614
  interpolation = "CUBICSPLINE";
7532
7615
  outputItemSize /= 3;
7533
- } else if (track.getInterpolation() === import_three18.InterpolateDiscrete) {
7616
+ } else if (track.getInterpolation() === import_three19.InterpolateDiscrete) {
7534
7617
  interpolation = "STEP";
7535
7618
  } else {
7536
7619
  interpolation = "LINEAR";
7537
7620
  }
7538
7621
  samplers.push({
7539
- input: this.processAccessor(new import_three18.BufferAttribute(track.times, inputItemSize)),
7540
- output: this.processAccessor(new import_three18.BufferAttribute(track.values, outputItemSize)),
7622
+ input: this.processAccessor(new import_three19.BufferAttribute(track.times, inputItemSize)),
7623
+ output: this.processAccessor(new import_three19.BufferAttribute(track.values, outputItemSize)),
7541
7624
  interpolation
7542
7625
  });
7543
7626
  channels.push({
@@ -7569,7 +7652,7 @@ var GLTFWriter = class {
7569
7652
  if (rootJoint === void 0) return null;
7570
7653
  const joints = [];
7571
7654
  const inverseBindMatrices = new Float32Array(skeleton.bones.length * 16);
7572
- const temporaryBoneInverse = new import_three18.Matrix4();
7655
+ const temporaryBoneInverse = new import_three19.Matrix4();
7573
7656
  for (let i = 0; i < skeleton.bones.length; ++i) {
7574
7657
  joints.push(nodeMap.get(skeleton.bones[i]));
7575
7658
  temporaryBoneInverse.copy(skeleton.boneInverses[i]);
@@ -7577,7 +7660,7 @@ var GLTFWriter = class {
7577
7660
  }
7578
7661
  if (json.skins === void 0) json.skins = [];
7579
7662
  json.skins.push({
7580
- inverseBindMatrices: this.processAccessor(new import_three18.BufferAttribute(inverseBindMatrices, 16)),
7663
+ inverseBindMatrices: this.processAccessor(new import_three19.BufferAttribute(inverseBindMatrices, 16)),
7581
7664
  joints,
7582
7665
  skeleton: nodeMap.get(rootJoint)
7583
7666
  });
@@ -7673,7 +7756,7 @@ var GLTFWriter = class {
7673
7756
  * @param {Array} objects List of objects to process
7674
7757
  */
7675
7758
  processObjects(objects) {
7676
- const scene = new import_three18.Scene();
7759
+ const scene = new import_three19.Scene();
7677
7760
  scene.name = "AuxScene";
7678
7761
  for (let i = 0; i < objects.length; i++) {
7679
7762
  scene.children.push(objects[i]);
@@ -7691,7 +7774,7 @@ var GLTFWriter = class {
7691
7774
  });
7692
7775
  const objectsWithoutScene = [];
7693
7776
  for (let i = 0; i < input.length; i++) {
7694
- if (input[i] instanceof import_three18.Scene) {
7777
+ if (input[i] instanceof import_three19.Scene) {
7695
7778
  this.processScene(input[i]);
7696
7779
  } else {
7697
7780
  objectsWithoutScene.push(input[i]);
@@ -8035,10 +8118,10 @@ var GLTFMeshGpuInstancing = class {
8035
8118
  const translationAttr = new Float32Array(mesh.count * 3);
8036
8119
  const rotationAttr = new Float32Array(mesh.count * 4);
8037
8120
  const scaleAttr = new Float32Array(mesh.count * 3);
8038
- const matrix = new import_three18.Matrix4();
8039
- const position = new import_three18.Vector3();
8040
- const quaternion = new import_three18.Quaternion();
8041
- const scale = new import_three18.Vector3();
8121
+ const matrix = new import_three19.Matrix4();
8122
+ const position = new import_three19.Vector3();
8123
+ const quaternion = new import_three19.Quaternion();
8124
+ const scale = new import_three19.Vector3();
8042
8125
  for (let i = 0; i < mesh.count; i++) {
8043
8126
  mesh.getMatrixAt(i, matrix);
8044
8127
  matrix.decompose(position, quaternion, scale);
@@ -8047,9 +8130,9 @@ var GLTFMeshGpuInstancing = class {
8047
8130
  scale.toArray(scaleAttr, i * 3);
8048
8131
  }
8049
8132
  const attributes = {
8050
- TRANSLATION: writer.processAccessor(new import_three18.BufferAttribute(translationAttr, 3)),
8051
- ROTATION: writer.processAccessor(new import_three18.BufferAttribute(rotationAttr, 4)),
8052
- SCALE: writer.processAccessor(new import_three18.BufferAttribute(scaleAttr, 3))
8133
+ TRANSLATION: writer.processAccessor(new import_three19.BufferAttribute(translationAttr, 3)),
8134
+ ROTATION: writer.processAccessor(new import_three19.BufferAttribute(rotationAttr, 4)),
8135
+ SCALE: writer.processAccessor(new import_three19.BufferAttribute(scaleAttr, 3))
8053
8136
  };
8054
8137
  if (mesh.instanceColor)
8055
8138
  attributes._COLOR_0 = writer.processAccessor(mesh.instanceColor);
@@ -8114,8 +8197,8 @@ GLTFExporter.Utils = {
8114
8197
  const sourceTracks = clip.tracks;
8115
8198
  for (let i = 0; i < sourceTracks.length; ++i) {
8116
8199
  let sourceTrack = sourceTracks[i];
8117
- const sourceTrackBinding = import_three18.PropertyBinding.parseTrackName(sourceTrack.name);
8118
- const sourceTrackNode = import_three18.PropertyBinding.findNode(root, sourceTrackBinding.nodeName);
8200
+ const sourceTrackBinding = import_three19.PropertyBinding.parseTrackName(sourceTrack.name);
8201
+ const sourceTrackNode = import_three19.PropertyBinding.findNode(root, sourceTrackBinding.nodeName);
8119
8202
  if (sourceTrackBinding.propertyName !== "morphTargetInfluences" || sourceTrackBinding.propertyIndex === void 0) {
8120
8203
  tracks.push(sourceTrack);
8121
8204
  continue;
@@ -8126,7 +8209,7 @@ GLTFExporter.Utils = {
8126
8209
  }
8127
8210
  console.warn("THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead.");
8128
8211
  sourceTrack = sourceTrack.clone();
8129
- sourceTrack.setInterpolation(import_three18.InterpolateLinear);
8212
+ sourceTrack.setInterpolation(import_three19.InterpolateLinear);
8130
8213
  }
8131
8214
  const targetCount = sourceTrackNode.morphTargetInfluences.length;
8132
8215
  const targetIndex = sourceTrackNode.morphTargetDictionary[sourceTrackBinding.propertyIndex];
@@ -8209,10 +8292,10 @@ var SceneExporter = class {
8209
8292
  }
8210
8293
  };
8211
8294
  function localMatrix(object) {
8212
- return object.matrixAutoUpdate ? new import_three19.Matrix4().compose(object.position, object.quaternion, object.scale) : object.matrix.clone();
8295
+ return object.matrixAutoUpdate ? new import_three20.Matrix4().compose(object.position, object.quaternion, object.scale) : object.matrix.clone();
8213
8296
  }
8214
8297
  function createSnapshot(root, gltf, bakeColors = false) {
8215
- const scene = new import_three19.Scene();
8298
+ const scene = new import_three20.Scene();
8216
8299
  const geometries = [];
8217
8300
  const materials = [];
8218
8301
  const textures = [];
@@ -8230,7 +8313,7 @@ function createSnapshot(root, gltf, bakeColors = false) {
8230
8313
  if (!uniforms.map?.value?.isTexture || !uniforms.SHADE || !uniforms.BRIGHTNESS || !uniforms.EMISSIVE) {
8231
8314
  throw new MineRenderError("glTF export does not support this custom ShaderMaterial");
8232
8315
  }
8233
- material = new import_three19.MeshBasicMaterial({
8316
+ material = new import_three20.MeshBasicMaterial({
8234
8317
  map: uniforms.map.value,
8235
8318
  vertexColors: source.vertexColors,
8236
8319
  transparent: source.transparent,
@@ -8240,7 +8323,7 @@ function createSnapshot(root, gltf, bakeColors = false) {
8240
8323
  });
8241
8324
  material.name = source.name;
8242
8325
  } else if (shader.isShaderMaterial) {
8243
- material = new import_three19.MeshBasicMaterial({ vertexColors: source.vertexColors });
8326
+ material = new import_three20.MeshBasicMaterial({ vertexColors: source.vertexColors });
8244
8327
  material.name = source.name;
8245
8328
  } else {
8246
8329
  const copySource = Object.create(source);
@@ -8294,11 +8377,11 @@ function createSnapshot(root, gltf, bakeColors = false) {
8294
8377
  const material = copyMaterial(sourceMaterial, geometry);
8295
8378
  if (!sourceMaterial.vertexColors) geometry.deleteAttribute("color");
8296
8379
  if (bakeColors || instanceColor) {
8297
- const tint = (material.color ?? new import_three19.Color()).clone();
8380
+ const tint = (material.color ?? new import_three20.Color()).clone();
8298
8381
  if (instanceColor) tint.multiply(instanceColor);
8299
8382
  if (bakeColors) {
8300
8383
  const original = geometry.getAttribute("color");
8301
- const colors = new import_three19.Float32BufferAttribute(new Float32Array(geometry.getAttribute("position").count * 3), 3);
8384
+ const colors = new import_three20.Float32BufferAttribute(new Float32Array(geometry.getAttribute("position").count * 3), 3);
8302
8385
  for (let i = 0; i < colors.count; i++) {
8303
8386
  colors.setXYZ(i, (original?.getX(i) ?? 1) * tint.r, (original?.getY(i) ?? 1) * tint.g, (original?.getZ(i) ?? 1) * tint.b);
8304
8387
  }
@@ -8307,7 +8390,7 @@ function createSnapshot(root, gltf, bakeColors = false) {
8307
8390
  material.color.copy(tint);
8308
8391
  }
8309
8392
  }
8310
- const copy = new import_three19.Mesh(geometry, material);
8393
+ const copy = new import_three20.Mesh(geometry, material);
8311
8394
  copy.name = mesh.name;
8312
8395
  copy.renderOrder = mesh.renderOrder;
8313
8396
  scene.add(copy);
@@ -8321,9 +8404,9 @@ function createSnapshot(root, gltf, bakeColors = false) {
8321
8404
  const instanced = mesh;
8322
8405
  if (instanced.isInstancedMesh) {
8323
8406
  for (let i = 0; i < instanced.count; i++) {
8324
- const matrix = new import_three19.Matrix4();
8407
+ const matrix = new import_three20.Matrix4();
8325
8408
  instanced.getMatrixAt(i, matrix);
8326
- const color = instanced.instanceColor ? new import_three19.Color().fromBufferAttribute(instanced.instanceColor, i) : void 0;
8409
+ const color = instanced.instanceColor ? new import_three20.Color().fromBufferAttribute(instanced.instanceColor, i) : void 0;
8327
8410
  addMesh(mesh, world.clone().multiply(matrix), color);
8328
8411
  }
8329
8412
  } else {
@@ -8335,7 +8418,7 @@ function createSnapshot(root, gltf, bakeColors = false) {
8335
8418
  try {
8336
8419
  const ancestors = [];
8337
8420
  for (let parent = root.parent; parent; parent = parent.parent) ancestors.unshift(parent);
8338
- const world = new import_three19.Matrix4();
8421
+ const world = new import_three20.Matrix4();
8339
8422
  for (const ancestor of ancestors) {
8340
8423
  if (!ancestor.visible) return { scene, dispose };
8341
8424
  world.multiply(localMatrix(ancestor));
@@ -8349,7 +8432,7 @@ function createSnapshot(root, gltf, bakeColors = false) {
8349
8432
  }
8350
8433
  function selectAlphaMode(material, geometry) {
8351
8434
  const texture = material.map;
8352
- 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;
8435
+ 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;
8353
8436
  const uv = geometry.getAttribute(texture.channel === 0 ? "uv" : `uv${texture.channel}`);
8354
8437
  const colors = geometry.getAttribute("color");
8355
8438
  if (!uv || material.vertexColors && colors?.itemSize === 4) return;
@@ -8386,7 +8469,7 @@ function selectAlphaMode(material, geometry) {
8386
8469
  }
8387
8470
  function copyDataTexture(source) {
8388
8471
  const image = source.image;
8389
- if (source.format !== import_three19.RGBAFormat || source.type !== import_three19.UnsignedByteType) {
8472
+ if (source.format !== import_three20.RGBAFormat || source.type !== import_three20.UnsignedByteType) {
8390
8473
  throw new MineRenderError("glTF export requires RGBA unsigned-byte data textures");
8391
8474
  }
8392
8475
  const canvas = createCanvas2(image.width, image.height);
@@ -8397,8 +8480,8 @@ function copyDataTexture(source) {
8397
8480
  context.putImageData(pixels, 0, 0);
8398
8481
  const copySource = Object.create(source);
8399
8482
  copySource.userData = {};
8400
- copySource.source = new import_three19.Source(canvas);
8401
- return new import_three19.Texture().copy(copySource);
8483
+ copySource.source = new import_three20.Source(canvas);
8484
+ return new import_three20.Texture().copy(copySource);
8402
8485
  }
8403
8486
 
8404
8487
  // src/gui/GuiHelper.ts
@@ -8468,7 +8551,7 @@ var GuiHelper = class {
8468
8551
  };
8469
8552
 
8470
8553
  // src/gui/scene/GuiObject.ts
8471
- var import_three24 = require("three");
8554
+ var import_three25 = require("three");
8472
8555
  init_AssetKey();
8473
8556
  init_ModelTextures();
8474
8557
  init_Models();
@@ -8484,7 +8567,7 @@ var GuiObject = class extends SceneObject {
8484
8567
  this.textureLayers = textureLayers;
8485
8568
  this.isGuiObject = true;
8486
8569
  /** Local bounds in GUI pixels, with y growing down from the origin. */
8487
- this.bounds = new import_three24.Box2();
8570
+ this.bounds = new import_three25.Box2();
8488
8571
  this.geometries = /* @__PURE__ */ new Set();
8489
8572
  this.ownedMaterials = /* @__PURE__ */ new Set();
8490
8573
  this.initialized = false;
@@ -8502,17 +8585,17 @@ var GuiObject = class extends SceneObject {
8502
8585
  item.scale.set(width2 / 16, height2 / 16, width2 / 16);
8503
8586
  item.updateWorldMatrix(true, true);
8504
8587
  const inverse = this.matrixWorld.clone().invert();
8505
- const bounds = new import_three24.Box3();
8588
+ const bounds = new import_three25.Box3();
8506
8589
  item.iterateAllMeshes((mesh2) => {
8507
8590
  mesh2.geometry.computeBoundingBox();
8508
- bounds.union(mesh2.geometry.boundingBox.clone().applyMatrix4(new import_three24.Matrix4().multiplyMatrices(inverse, mesh2.matrixWorld)));
8591
+ bounds.union(mesh2.geometry.boundingBox.clone().applyMatrix4(new import_three25.Matrix4().multiplyMatrices(inverse, mesh2.matrixWorld)));
8509
8592
  });
8510
8593
  item.position.z = depth - bounds.min.z;
8511
8594
  depth += bounds.max.z - bounds.min.z + 0.01;
8512
- this.bounds.expandByPoint(new import_three24.Vector2(x, y));
8513
- this.bounds.expandByPoint(new import_three24.Vector2(x + width2, y + height2));
8514
- this.bounds.expandByPoint(new import_three24.Vector2(bounds.min.x, -bounds.max.y));
8515
- this.bounds.expandByPoint(new import_three24.Vector2(bounds.max.x, -bounds.min.y));
8595
+ this.bounds.expandByPoint(new import_three25.Vector2(x, y));
8596
+ this.bounds.expandByPoint(new import_three25.Vector2(x + width2, y + height2));
8597
+ this.bounds.expandByPoint(new import_three25.Vector2(bounds.min.x, -bounds.max.y));
8598
+ this.bounds.expandByPoint(new import_three25.Vector2(bounds.max.x, -bounds.min.y));
8516
8599
  continue;
8517
8600
  }
8518
8601
  const key = typeof layer.texture === "string" ? AssetKey.parse("textures", layer.texture) : layer.texture;
@@ -8520,7 +8603,7 @@ var GuiObject = class extends SceneObject {
8520
8603
  const image = material.map.image;
8521
8604
  const [cropX, cropY, cropWidth, cropHeight] = layer.crop ?? [0, 0, image.width, image.height];
8522
8605
  const [width, height] = layer.size ?? [cropWidth, cropHeight];
8523
- const geometry = new import_three24.PlaneGeometry(width, height);
8606
+ const geometry = new import_three25.PlaneGeometry(width, height);
8524
8607
  this.geometries.add(geometry);
8525
8608
  const uv = geometry.getAttribute("uv");
8526
8609
  for (let i = 0; i < uv.count; i++) {
@@ -8530,13 +8613,13 @@ var GuiObject = class extends SceneObject {
8530
8613
  1 - (cropY + (1 - uv.getY(i)) * cropHeight) / image.height
8531
8614
  );
8532
8615
  }
8533
- const mesh = new import_three24.Mesh(geometry, material);
8616
+ const mesh = new import_three25.Mesh(geometry, material);
8534
8617
  mesh.name = `mesh:${layer.name ?? index}`;
8535
8618
  mesh.position.set(x + width / 2, -y - height / 2, depth);
8536
8619
  mesh.renderOrder = index;
8537
8620
  this.add(mesh);
8538
- this.bounds.expandByPoint(new import_three24.Vector2(x, y));
8539
- this.bounds.expandByPoint(new import_three24.Vector2(x + width, y + height));
8621
+ this.bounds.expandByPoint(new import_three25.Vector2(x, y));
8622
+ this.bounds.expandByPoint(new import_three25.Vector2(x + width, y + height));
8540
8623
  depth += 0.01;
8541
8624
  }
8542
8625
  for (const child of this.children) child.position.z -= depth - 0.01;
@@ -8611,7 +8694,7 @@ function isGuiObject(obj) {
8611
8694
  init_image();
8612
8695
 
8613
8696
  // src/inspector/SceneInspector.ts
8614
- var import_three25 = require("three");
8697
+ var import_three26 = require("three");
8615
8698
  init_SceneObject();
8616
8699
  init_util();
8617
8700
  init_log();
@@ -8621,11 +8704,11 @@ var help = "<span>Ctrl/Cmd+Click to Select<br/></span><br/>";
8621
8704
  var SceneInspector = class {
8622
8705
  constructor(renderer) {
8623
8706
  this.renderer = renderer;
8624
- this.mouse = new import_three25.Vector2();
8707
+ this.mouse = new import_three26.Vector2();
8625
8708
  this.listeners = new AbortController();
8626
8709
  this.objectInfoContainer = document.createElement("div");
8627
8710
  this.objectControlsContainer = document.createElement("div");
8628
- this.raycaster = new import_three25.Raycaster();
8711
+ this.raycaster = new import_three26.Raycaster();
8629
8712
  this.init();
8630
8713
  }
8631
8714
  init() {
@@ -9028,7 +9111,7 @@ init_ModelMerger();
9028
9111
  init_SpecialItems();
9029
9112
 
9030
9113
  // src/model/block/BlockStateResolver.ts
9031
- var import_three27 = require("three");
9114
+ var import_three28 = require("three");
9032
9115
  init_BlockStates();
9033
9116
  init_MineRenderError();
9034
9117
  init_util();
@@ -9106,7 +9189,7 @@ var BlockStateResolver = class {
9106
9189
  return variants[variants.length - 1];
9107
9190
  }
9108
9191
  static rotation(variant) {
9109
- const rotation = new import_three27.Euler();
9192
+ const rotation = new import_three28.Euler();
9110
9193
  if (typeof variant.x !== "undefined") {
9111
9194
  rotation.x = toRadians(clampRotationDegrees(variant.x));
9112
9195
  }
@@ -9198,7 +9281,7 @@ init_SceneObject();
9198
9281
  init_ModelObject();
9199
9282
  init_Models();
9200
9283
  var import_ts_deepmerge6 = __toESM(require_dist());
9201
- var import_three30 = require("three");
9284
+ var import_three31 = require("three");
9202
9285
  init_MineRenderError();
9203
9286
  init_InstanceReference();
9204
9287
  init_AssetKey();
@@ -9220,7 +9303,7 @@ var BlockObject = class _BlockObject extends SceneObject {
9220
9303
  this._models = [];
9221
9304
  this._cullMask = 0;
9222
9305
  this._entities = [];
9223
- this._entityPlacement = new import_three30.Matrix4();
9306
+ this._entityPlacement = new import_three31.Matrix4();
9224
9307
  this._entityGeneration = 0;
9225
9308
  this.options = (0, import_ts_deepmerge6.default)({}, _BlockObject.DEFAULT_OPTIONS, options ?? {});
9226
9309
  }
@@ -9269,6 +9352,21 @@ var BlockObject = class _BlockObject extends SceneObject {
9269
9352
  get blockEntities() {
9270
9353
  return this._entities;
9271
9354
  }
9355
+ /** Sets visibility for this block's model instances and block entities. */
9356
+ setVisible(visible) {
9357
+ this.visible = visible;
9358
+ for (const model of this._models) {
9359
+ if (isInstanceReference(model)) {
9360
+ model.setVisible(visible);
9361
+ } else {
9362
+ model.visible = visible;
9363
+ }
9364
+ }
9365
+ for (const entity of this._entities) {
9366
+ entity.visible = visible;
9367
+ }
9368
+ this.notifyDirty();
9369
+ }
9272
9370
  /**
9273
9371
  * Draws the block through the dataset's block-entity index. Returns false, leaving nothing behind,
9274
9372
  * when the block is not listed or one of its models cannot be loaded.
@@ -9302,15 +9400,19 @@ var BlockObject = class _BlockObject extends SceneObject {
9302
9400
  BlockEntities.matrix(resolved, this._entityPlacement);
9303
9401
  this._entities = created;
9304
9402
  this.placeEntities();
9403
+ this.setVisible(this.visible);
9305
9404
  return true;
9306
9405
  }
9307
9406
  placeEntities() {
9308
- const matrix = new import_three30.Matrix4().makeTranslation(this.position.x - 8, this.position.y - 8, this.position.z - 8).multiply(this._entityPlacement);
9407
+ const matrix = new import_three31.Matrix4().makeTranslation(this.position.x - 8, this.position.y - 8, this.position.z - 8).multiply(this._entityPlacement);
9309
9408
  for (const entity of this._entities) {
9310
9409
  matrix.decompose(entity.position, entity.quaternion, entity.scale);
9311
9410
  }
9312
9411
  }
9313
9412
  get isOccluding() {
9413
+ if (!this.visible) {
9414
+ return false;
9415
+ }
9314
9416
  return this._models.some((model) => {
9315
9417
  const object = isInstanceReference(model) ? model.instanceable : model;
9316
9418
  return object.isOpaqueFullCube && this.getModelCullMask(model, 63) === 63;
@@ -9324,12 +9426,12 @@ var BlockObject = class _BlockObject extends SceneObject {
9324
9426
  getModelCullMask(model, worldMask) {
9325
9427
  const object = isInstanceReference(model) ? model.instanceable : model;
9326
9428
  if (object.options.displayPosition) return 0;
9327
- const position = new import_three30.Vector3();
9328
- const rotation = new import_three30.Quaternion();
9329
- const scale = new import_three30.Vector3();
9429
+ const position = new import_three31.Vector3();
9430
+ const rotation = new import_three31.Quaternion();
9431
+ const scale = new import_three31.Vector3();
9330
9432
  this.getModelMatrix(model).decompose(position, rotation, scale);
9331
- if (position.distanceToSquared(this.position) > 1e-10 || scale.distanceToSquared(new import_three30.Vector3(1, 1, 1)) > 1e-10) return 0;
9332
- return ModelCulling.toLocalMask(worldMask, new import_three30.Euler().setFromQuaternion(rotation));
9433
+ if (position.distanceToSquared(this.position) > 1e-10 || scale.distanceToSquared(new import_three31.Vector3(1, 1, 1)) > 1e-10) return 0;
9434
+ return ModelCulling.toLocalMask(worldMask, new import_three31.Euler().setFromQuaternion(rotation));
9333
9435
  }
9334
9436
  async setCullMask(worldMask) {
9335
9437
  worldMask &= 63;
@@ -9366,6 +9468,9 @@ var BlockObject = class _BlockObject extends SceneObject {
9366
9468
  this._models = replacements;
9367
9469
  this._cullMask = worldMask;
9368
9470
  this.removeModels(previous.filter((model) => !replacements.includes(model)));
9471
+ if (!this.visible) {
9472
+ this.setVisible(false);
9473
+ }
9369
9474
  this.notifyDirty();
9370
9475
  }
9371
9476
  get state() {
@@ -9391,7 +9496,7 @@ var BlockObject = class _BlockObject extends SceneObject {
9391
9496
  () => new FluidModelObject2(kind, surface.sample, this.blockState.key, this.options)
9392
9497
  );
9393
9498
  const previous = this._fluidModel;
9394
- const matrix = previous ? this.getModelMatrix(previous) : new import_three30.Matrix4().makeTranslation(...this.position.toArray());
9499
+ const matrix = previous ? this.getModelMatrix(previous) : new import_three31.Matrix4().makeTranslation(...this.position.toArray());
9395
9500
  if (isInstanceReference(replacement)) replacement.setMatrix(matrix);
9396
9501
  else matrix.decompose(replacement.position, replacement.quaternion, replacement.scale);
9397
9502
  this._models = this._models.filter((model) => model !== previous);
@@ -9401,6 +9506,9 @@ var BlockObject = class _BlockObject extends SceneObject {
9401
9506
  this._isInstanced ||= isInstanceReference(replacement);
9402
9507
  this._instanceCounter = this._isInstanced ? 1 : 0;
9403
9508
  if (previous) this.removeModels([previous]);
9509
+ if (!this.visible) {
9510
+ this.setVisible(false);
9511
+ }
9404
9512
  this.notifyDirty();
9405
9513
  }
9406
9514
  nextInstance() {
@@ -9429,6 +9537,7 @@ var BlockObject = class _BlockObject extends SceneObject {
9429
9537
  this._models.push(await this.createVariant(blockStateVariant));
9430
9538
  }
9431
9539
  await this.updateFluid(this._fluidSampler);
9540
+ this.setVisible(this.visible);
9432
9541
  }
9433
9542
  async hasGeometry(variant) {
9434
9543
  const modelKey = AssetKey.parse("models", variant.model);
@@ -9529,7 +9638,7 @@ var BlockObject = class _BlockObject extends SceneObject {
9529
9638
  setPositionRotationScaleAt(index, position, rotation, scale) {
9530
9639
  super.setPositionRotationScaleAt(index, position, rotation, scale);
9531
9640
  }
9532
- getMatrixAt(index, matrix = new import_three30.Matrix4()) {
9641
+ getMatrixAt(index, matrix = new import_three31.Matrix4()) {
9533
9642
  if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
9534
9643
  const child = this._models[0];
9535
9644
  if (child && isModelObject(child)) {
@@ -11396,7 +11505,7 @@ init_ModelObject();
11396
11505
  init_nbt();
11397
11506
 
11398
11507
  // src/renderer/MineRenderScene.ts
11399
- var import_three32 = require("three");
11508
+ var import_three33 = require("three");
11400
11509
  init_SceneObject();
11401
11510
  var import_ts_deepmerge8 = __toESM(require_dist());
11402
11511
  init_ModelObject();
@@ -12129,7 +12238,7 @@ var import_ts_deepmerge7 = __toESM(require_dist());
12129
12238
  init_util();
12130
12239
 
12131
12240
  // src/skin/SkinTextures.ts
12132
- var import_three31 = require("three");
12241
+ var import_three32 = require("three");
12133
12242
  init_Caching();
12134
12243
  init_CacheKey();
12135
12244
  init_MineRenderError();
@@ -12213,11 +12322,11 @@ var SkinTextures = class {
12213
12322
  });
12214
12323
  }
12215
12324
  static createMaterial(pixels, width, height, transparent = true) {
12216
- const texture = Textures.initTextureProps(new import_three31.DataTexture(pixels, width, height));
12217
- texture.colorSpace = import_three31.SRGBColorSpace;
12325
+ const texture = Textures.initTextureProps(new import_three32.DataTexture(pixels, width, height));
12326
+ texture.colorSpace = import_three32.SRGBColorSpace;
12218
12327
  texture.flipY = true;
12219
12328
  texture.needsUpdate = true;
12220
- return new import_three31.MeshBasicMaterial({ map: texture, transparent, side: transparent ? import_three31.DoubleSide : import_three31.FrontSide, alphaTest: transparent ? 0.1 : 0 });
12329
+ return new import_three32.MeshBasicMaterial({ map: texture, transparent, side: transparent ? import_three32.DoubleSide : import_three32.FrontSide, alphaTest: transparent ? 0.1 : 0 });
12221
12330
  }
12222
12331
  static isSlim(image, scale) {
12223
12332
  for (const [x, y] of [[46, 52], [54, 20]]) {
@@ -12447,7 +12556,7 @@ var SkinObject = class extends SceneObject {
12447
12556
  // src/renderer/MineRenderScene.ts
12448
12557
  init_EntityObject();
12449
12558
  init_ItemTints();
12450
- var MineRenderScene = class _MineRenderScene extends import_three32.Scene {
12559
+ var MineRenderScene = class _MineRenderScene extends import_three33.Scene {
12451
12560
  constructor(options) {
12452
12561
  super();
12453
12562
  this.isMineRenderScene = true;
@@ -12576,7 +12685,7 @@ function isMineRenderScene(obj) {
12576
12685
  }
12577
12686
 
12578
12687
  // src/renderer/Renderer.ts
12579
- var import_three34 = require("three");
12688
+ var import_three35 = require("three");
12580
12689
  var import_ts_deepmerge9 = __toESM(require_dist());
12581
12690
  var import_stats = __toESM(require("stats.js"));
12582
12691
  var import_postprocessing = require("postprocessing");
@@ -12585,11 +12694,11 @@ init_Model();
12585
12694
  init_three();
12586
12695
 
12587
12696
  // src/three/OrbitControls.js
12588
- var import_three33 = require("three");
12697
+ var import_three34 = require("three");
12589
12698
  var _changeEvent = { type: "change" };
12590
12699
  var _startEvent = { type: "start" };
12591
12700
  var _endEvent = { type: "end" };
12592
- var OrbitControls = class extends import_three33.EventDispatcher {
12701
+ var OrbitControls = class extends import_three34.EventDispatcher {
12593
12702
  constructor(object, domElement) {
12594
12703
  super();
12595
12704
  if (domElement === void 0) console.warn('THREE.OrbitControls: The second parameter "domElement" is now mandatory.');
@@ -12598,7 +12707,7 @@ var OrbitControls = class extends import_three33.EventDispatcher {
12598
12707
  this.domElement = domElement;
12599
12708
  this.domElement.style.touchAction = "none";
12600
12709
  this.enabled = true;
12601
- this.target = new import_three33.Vector3();
12710
+ this.target = new import_three34.Vector3();
12602
12711
  this.minDistance = 0;
12603
12712
  this.maxDistance = Infinity;
12604
12713
  this.minZoom = 0;
@@ -12620,8 +12729,8 @@ var OrbitControls = class extends import_three33.EventDispatcher {
12620
12729
  this.autoRotate = false;
12621
12730
  this.autoRotateSpeed = 2;
12622
12731
  this.keys = { LEFT: "ArrowLeft", UP: "ArrowUp", RIGHT: "ArrowRight", BOTTOM: "ArrowDown" };
12623
- this.mouseButtons = { LEFT: import_three33.MOUSE.ROTATE, MIDDLE: import_three33.MOUSE.DOLLY, RIGHT: import_three33.MOUSE.PAN };
12624
- this.touches = { ONE: import_three33.TOUCH.ROTATE, TWO: import_three33.TOUCH.DOLLY_PAN };
12732
+ this.mouseButtons = { LEFT: import_three34.MOUSE.ROTATE, MIDDLE: import_three34.MOUSE.DOLLY, RIGHT: import_three34.MOUSE.PAN };
12733
+ this.touches = { ONE: import_three34.TOUCH.ROTATE, TWO: import_three34.TOUCH.DOLLY_PAN };
12625
12734
  this.target0 = this.target.clone();
12626
12735
  this.position0 = this.object.position.clone();
12627
12736
  this.zoom0 = this.object.zoom;
@@ -12650,11 +12759,11 @@ var OrbitControls = class extends import_three33.EventDispatcher {
12650
12759
  state = STATE.NONE;
12651
12760
  };
12652
12761
  this.update = function() {
12653
- const offset = new import_three33.Vector3();
12654
- const quat = new import_three33.Quaternion().setFromUnitVectors(object.up, new import_three33.Vector3(0, 1, 0));
12762
+ const offset = new import_three34.Vector3();
12763
+ const quat = new import_three34.Quaternion().setFromUnitVectors(object.up, new import_three34.Vector3(0, 1, 0));
12655
12764
  const quatInverse = quat.clone().invert();
12656
- const lastPosition = new import_three33.Vector3();
12657
- const lastQuaternion = new import_three33.Quaternion();
12765
+ const lastPosition = new import_three34.Vector3();
12766
+ const lastQuaternion = new import_three34.Quaternion();
12658
12767
  const twoPI = 2 * Math.PI;
12659
12768
  return function update() {
12660
12769
  const position = scope.object.position;
@@ -12740,20 +12849,20 @@ var OrbitControls = class extends import_three33.EventDispatcher {
12740
12849
  };
12741
12850
  let state = STATE.NONE;
12742
12851
  const EPS = 1e-6;
12743
- const spherical = new import_three33.Spherical();
12744
- const sphericalDelta = new import_three33.Spherical();
12852
+ const spherical = new import_three34.Spherical();
12853
+ const sphericalDelta = new import_three34.Spherical();
12745
12854
  let scale = 1;
12746
- const panOffset = new import_three33.Vector3();
12855
+ const panOffset = new import_three34.Vector3();
12747
12856
  let zoomChanged = false;
12748
- const rotateStart = new import_three33.Vector2();
12749
- const rotateEnd = new import_three33.Vector2();
12750
- const rotateDelta = new import_three33.Vector2();
12751
- const panStart = new import_three33.Vector2();
12752
- const panEnd = new import_three33.Vector2();
12753
- const panDelta = new import_three33.Vector2();
12754
- const dollyStart = new import_three33.Vector2();
12755
- const dollyEnd = new import_three33.Vector2();
12756
- const dollyDelta = new import_three33.Vector2();
12857
+ const rotateStart = new import_three34.Vector2();
12858
+ const rotateEnd = new import_three34.Vector2();
12859
+ const rotateDelta = new import_three34.Vector2();
12860
+ const panStart = new import_three34.Vector2();
12861
+ const panEnd = new import_three34.Vector2();
12862
+ const panDelta = new import_three34.Vector2();
12863
+ const dollyStart = new import_three34.Vector2();
12864
+ const dollyEnd = new import_three34.Vector2();
12865
+ const dollyDelta = new import_three34.Vector2();
12757
12866
  const pointers = [];
12758
12867
  const pointerPositions = {};
12759
12868
  function getAutoRotationAngle() {
@@ -12769,7 +12878,7 @@ var OrbitControls = class extends import_three33.EventDispatcher {
12769
12878
  sphericalDelta.phi -= angle;
12770
12879
  }
12771
12880
  const panLeft = function() {
12772
- const v = new import_three33.Vector3();
12881
+ const v = new import_three34.Vector3();
12773
12882
  return function panLeft2(distance, objectMatrix) {
12774
12883
  v.setFromMatrixColumn(objectMatrix, 0);
12775
12884
  v.multiplyScalar(-distance);
@@ -12777,7 +12886,7 @@ var OrbitControls = class extends import_three33.EventDispatcher {
12777
12886
  };
12778
12887
  }();
12779
12888
  const panUp = function() {
12780
- const v = new import_three33.Vector3();
12889
+ const v = new import_three34.Vector3();
12781
12890
  return function panUp2(distance, objectMatrix) {
12782
12891
  if (scope.screenSpacePanning === true) {
12783
12892
  v.setFromMatrixColumn(objectMatrix, 1);
@@ -12790,7 +12899,7 @@ var OrbitControls = class extends import_three33.EventDispatcher {
12790
12899
  };
12791
12900
  }();
12792
12901
  const pan = function() {
12793
- const offset = new import_three33.Vector3();
12902
+ const offset = new import_three34.Vector3();
12794
12903
  return function pan2(deltaX, deltaY) {
12795
12904
  const element = scope.domElement;
12796
12905
  if (scope.object.isPerspectiveCamera) {
@@ -13039,12 +13148,12 @@ var OrbitControls = class extends import_three33.EventDispatcher {
13039
13148
  mouseAction = -1;
13040
13149
  }
13041
13150
  switch (mouseAction) {
13042
- case import_three33.MOUSE.DOLLY:
13151
+ case import_three34.MOUSE.DOLLY:
13043
13152
  if (scope.enableZoom === false) return;
13044
13153
  handleMouseDownDolly(event);
13045
13154
  state = STATE.DOLLY;
13046
13155
  break;
13047
- case import_three33.MOUSE.ROTATE:
13156
+ case import_three34.MOUSE.ROTATE:
13048
13157
  if (event.ctrlKey || event.metaKey || event.shiftKey) {
13049
13158
  if (scope.enablePan === false) return;
13050
13159
  handleMouseDownPan(event);
@@ -13055,7 +13164,7 @@ var OrbitControls = class extends import_three33.EventDispatcher {
13055
13164
  state = STATE.ROTATE;
13056
13165
  }
13057
13166
  break;
13058
- case import_three33.MOUSE.PAN:
13167
+ case import_three34.MOUSE.PAN:
13059
13168
  if (event.ctrlKey || event.metaKey || event.shiftKey) {
13060
13169
  if (scope.enableRotate === false) return;
13061
13170
  handleMouseDownRotate(event);
@@ -13111,12 +13220,12 @@ var OrbitControls = class extends import_three33.EventDispatcher {
13111
13220
  switch (pointers.length) {
13112
13221
  case 1:
13113
13222
  switch (scope.touches.ONE) {
13114
- case import_three33.TOUCH.ROTATE:
13223
+ case import_three34.TOUCH.ROTATE:
13115
13224
  if (scope.enableRotate === false) return;
13116
13225
  handleTouchStartRotate();
13117
13226
  state = STATE.TOUCH_ROTATE;
13118
13227
  break;
13119
- case import_three33.TOUCH.PAN:
13228
+ case import_three34.TOUCH.PAN:
13120
13229
  if (scope.enablePan === false) return;
13121
13230
  handleTouchStartPan();
13122
13231
  state = STATE.TOUCH_PAN;
@@ -13127,12 +13236,12 @@ var OrbitControls = class extends import_three33.EventDispatcher {
13127
13236
  break;
13128
13237
  case 2:
13129
13238
  switch (scope.touches.TWO) {
13130
- case import_three33.TOUCH.DOLLY_PAN:
13239
+ case import_three34.TOUCH.DOLLY_PAN:
13131
13240
  if (scope.enableZoom === false && scope.enablePan === false) return;
13132
13241
  handleTouchStartDollyPan();
13133
13242
  state = STATE.TOUCH_DOLLY_PAN;
13134
13243
  break;
13135
- case import_three33.TOUCH.DOLLY_ROTATE:
13244
+ case import_three34.TOUCH.DOLLY_ROTATE:
13136
13245
  if (scope.enableZoom === false && scope.enableRotate === false) return;
13137
13246
  handleTouchStartDollyRotate();
13138
13247
  state = STATE.TOUCH_DOLLY_ROTATE;
@@ -13199,7 +13308,7 @@ var OrbitControls = class extends import_three33.EventDispatcher {
13199
13308
  function trackPointer(event) {
13200
13309
  let position = pointerPositions[event.pointerId];
13201
13310
  if (position === void 0) {
13202
- position = new import_three33.Vector2();
13311
+ position = new import_three34.Vector2();
13203
13312
  pointerPositions[event.pointerId] = position;
13204
13313
  }
13205
13314
  position.set(event.pageX, event.pageY);
@@ -13219,10 +13328,10 @@ var MapControls = class extends OrbitControls {
13219
13328
  constructor(object, domElement) {
13220
13329
  super(object, domElement);
13221
13330
  this.screenSpacePanning = false;
13222
- this.mouseButtons.LEFT = import_three33.MOUSE.PAN;
13223
- this.mouseButtons.RIGHT = import_three33.MOUSE.ROTATE;
13224
- this.touches.ONE = import_three33.TOUCH.PAN;
13225
- this.touches.TWO = import_three33.TOUCH.DOLLY_ROTATE;
13331
+ this.mouseButtons.LEFT = import_three34.MOUSE.PAN;
13332
+ this.mouseButtons.RIGHT = import_three34.MOUSE.ROTATE;
13333
+ this.touches.ONE = import_three34.TOUCH.PAN;
13334
+ this.touches.TWO = import_three34.TOUCH.DOLLY_ROTATE;
13226
13335
  }
13227
13336
  };
13228
13337
 
@@ -13281,8 +13390,8 @@ var Renderer = class _Renderer {
13281
13390
  top: void 0,
13282
13391
  bottom: void 0
13283
13392
  },
13284
- position: new import_three34.Vector3(50, 50, 50),
13285
- lookingAt: new import_three34.Vector3(0, 0, 0)
13393
+ position: new import_three35.Vector3(50, 50, 50),
13394
+ lookingAt: new import_three35.Vector3(0, 0, 0)
13286
13395
  },
13287
13396
  render: {
13288
13397
  fpsLimit: 60,
@@ -13313,14 +13422,14 @@ var Renderer = class _Renderer {
13313
13422
  switch (this.options.camera.type) {
13314
13423
  case "perspective":
13315
13424
  default:
13316
- return new import_three34.PerspectiveCamera(
13425
+ return new import_three35.PerspectiveCamera(
13317
13426
  this.options.camera.perspective.fov,
13318
13427
  this.options.camera.perspective.aspect ?? this.viewWidth / this.viewHeight,
13319
13428
  this.options.camera.near,
13320
13429
  this.options.camera.far
13321
13430
  );
13322
13431
  case "orthographic":
13323
- return new import_three34.OrthographicCamera(
13432
+ return new import_three35.OrthographicCamera(
13324
13433
  this.options.camera.orthographic.left ?? this.viewWidth / -2,
13325
13434
  this.options.camera.orthographic.right ?? this.viewWidth / 2,
13326
13435
  this.options.camera.orthographic.top ?? this.viewHeight / 2,
@@ -13331,7 +13440,7 @@ var Renderer = class _Renderer {
13331
13440
  }
13332
13441
  }
13333
13442
  createRenderer() {
13334
- const renderer = new import_three34.WebGLRenderer({
13443
+ const renderer = new import_three35.WebGLRenderer({
13335
13444
  antialias: this.options.render.antialias,
13336
13445
  alpha: true,
13337
13446
  powerPreference: "high-performance",
@@ -13339,8 +13448,8 @@ var Renderer = class _Renderer {
13339
13448
  });
13340
13449
  renderer.setClearColor(0, 0);
13341
13450
  renderer.shadowMap.enabled = true;
13342
- renderer.shadowMap.type = import_three34.PCFSoftShadowMap;
13343
- renderer.outputColorSpace = import_three34.SRGBColorSpace;
13451
+ renderer.shadowMap.type = import_three35.PCFSoftShadowMap;
13452
+ renderer.outputColorSpace = import_three35.SRGBColorSpace;
13344
13453
  renderer.setPixelRatio(this.options.render.pixelRatio ?? 1);
13345
13454
  renderer.setSize(this.viewWidth, this.viewHeight);
13346
13455
  return renderer;
@@ -13375,20 +13484,20 @@ var Renderer = class _Renderer {
13375
13484
  window["__THREE_DEVTOOLS__"].dispatchEvent(new CustomEvent("observe", { detail: this.scene }));
13376
13485
  }
13377
13486
  if (this.options.debug.grid) {
13378
- const gridHelper = new import_three34.GridHelper(128, 16);
13487
+ const gridHelper = new import_three35.GridHelper(128, 16);
13379
13488
  this._debugHelpers.push(gridHelper);
13380
13489
  this.scene.add(gridHelper);
13381
- const gridHelper2 = new import_three34.GridHelper(128, 16);
13490
+ const gridHelper2 = new import_three35.GridHelper(128, 16);
13382
13491
  this._debugHelpers.push(gridHelper2);
13383
13492
  gridHelper2.rotation.x = 90 * (Math.PI / 180);
13384
13493
  this.scene.add(gridHelper2);
13385
- const gridHelper3 = new import_three34.GridHelper(128, 16);
13494
+ const gridHelper3 = new import_three35.GridHelper(128, 16);
13386
13495
  this._debugHelpers.push(gridHelper3);
13387
13496
  gridHelper3.rotation.z = 90 * (Math.PI / 180);
13388
13497
  this.scene.add(gridHelper3);
13389
13498
  }
13390
13499
  if (this.options.debug.axes) {
13391
- const axesHelper = new import_three34.AxesHelper(64);
13500
+ const axesHelper = new import_three35.AxesHelper(64);
13392
13501
  this._debugHelpers.push(axesHelper);
13393
13502
  this.scene.add(axesHelper);
13394
13503
  }
@@ -14074,12 +14183,12 @@ var AnvilParser = class {
14074
14183
  };
14075
14184
 
14076
14185
  // src/world/Chunk.ts
14077
- var import_three39 = require("three");
14186
+ var import_three40 = require("three");
14078
14187
  init_BlockStates();
14079
14188
  init_AssetKey();
14080
14189
 
14081
14190
  // src/world/MineRenderWorld.ts
14082
- var import_three37 = require("three");
14191
+ var import_three38 = require("three");
14083
14192
  init_Model();
14084
14193
  init_BatchedExecutor();
14085
14194
  init_AssetKey();
@@ -14087,7 +14196,7 @@ init_BlockStates();
14087
14196
  init_CubeFace();
14088
14197
 
14089
14198
  // src/world/SectionModels.ts
14090
- var import_three36 = require("three");
14199
+ var import_three37 = require("three");
14091
14200
  init_AssetKey();
14092
14201
  init_Models();
14093
14202
  init_CubeFace();
@@ -14153,12 +14262,12 @@ var SectionModels = class {
14153
14262
  });
14154
14263
  await object.init();
14155
14264
  const geometry = object.children[0].geometry;
14156
- geometry.applyMatrix4(new import_three36.Matrix4().makeRotationFromEuler(rotation));
14265
+ geometry.applyMatrix4(new import_three37.Matrix4().makeRotationFromEuler(rotation));
14157
14266
  object.clear();
14158
14267
  const cullFaces = CUBE_FACES.map((face) => {
14159
14268
  const local = CUBE_FACES.findIndex((name) => name === atlas.model.elements[0].faces[face]?.cullface);
14160
14269
  if (local < 0) return 0;
14161
- const normal = new import_three36.Vector3(...CUBE_FACE_OFFSETS[local]).applyEuler(rotation);
14270
+ const normal = new import_three37.Vector3(...CUBE_FACE_OFFSETS[local]).applyEuler(rotation);
14162
14271
  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);
14163
14272
  return 1 << world;
14164
14273
  });
@@ -14188,20 +14297,20 @@ var MineRenderWorld = class {
14188
14297
  }
14189
14298
  getBlockAt(posOrX, y, z) {
14190
14299
  if (typeof posOrX == "number") {
14191
- return this.getBlockAt(new import_three37.Vector3(posOrX, y, z));
14300
+ return this.getBlockAt(new import_three38.Vector3(posOrX, y, z));
14192
14301
  }
14193
14302
  if (isTripleArray(posOrX)) {
14194
- return this.getBlockAt(new import_three37.Vector3(posOrX[0], posOrX[1], posOrX[2]));
14303
+ return this.getBlockAt(new import_three38.Vector3(posOrX[0], posOrX[1], posOrX[2]));
14195
14304
  }
14196
14305
  this.validatePosBounds(posOrX);
14197
14306
  return this.getChunkAt(posOrX)?.getBlockAt(posOrX);
14198
14307
  }
14199
14308
  async setBlockAt(posOrX, yOrBlock, z, block) {
14200
14309
  if (typeof posOrX == "number") {
14201
- return this.setBlockAt(new import_three37.Vector3(posOrX, yOrBlock, z), block);
14310
+ return this.setBlockAt(new import_three38.Vector3(posOrX, yOrBlock, z), block);
14202
14311
  }
14203
14312
  if (isTripleArray(posOrX)) {
14204
- return this.setBlockAt(new import_three37.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
14313
+ return this.setBlockAt(new import_three38.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
14205
14314
  }
14206
14315
  return this.placeBlock(posOrX, yOrBlock);
14207
14316
  }
@@ -14210,6 +14319,16 @@ var MineRenderWorld = class {
14210
14319
  const chunk = Chunk.isAir(value) ? this.getChunkAt(pos) : this.getOrCreateChunkAt(pos);
14211
14320
  return chunk?.setBlockInChunkAt(chunk.worldPosToChunkPos(pos), value, pos, onBlocksChanged);
14212
14321
  }
14322
+ async setBlockVisibleAt(posOrX, yOrVisible, z, visible) {
14323
+ if (typeof posOrX === "number") {
14324
+ return this.setBlockVisibleAt(new import_three38.Vector3(posOrX, yOrVisible, z), visible);
14325
+ }
14326
+ if (isTripleArray(posOrX)) {
14327
+ return this.setBlockVisibleAt(new import_three38.Vector3(...posOrX), yOrVisible);
14328
+ }
14329
+ this.validatePosBounds(posOrX);
14330
+ await this.getChunkAt(posOrX)?.setBlockVisibleAt(posOrX, yOrVisible);
14331
+ }
14213
14332
  async placeMultiBlock(multiblock, useBatches = true, executor) {
14214
14333
  const changes = /* @__PURE__ */ new Map();
14215
14334
  try {
@@ -14222,7 +14341,7 @@ var MineRenderWorld = class {
14222
14341
  const collect = async (positions2) => {
14223
14342
  for (const pos of positions2) changes.set(pos.toArray().join(","), pos);
14224
14343
  };
14225
- const place = (block) => this.placeBlock(new import_three37.Vector3(...block.position), block, collect);
14344
+ const place = (block) => this.placeBlock(new import_three38.Vector3(...block.position), block, collect);
14226
14345
  const keys = /* @__PURE__ */ new Map();
14227
14346
  for (const block of multiblock.blocks) {
14228
14347
  if (Chunk.isAir(block)) continue;
@@ -14300,13 +14419,13 @@ var MineRenderWorld = class {
14300
14419
  for (const pos of positions) {
14301
14420
  this.pendingCulling.set(pos.toArray().join(","), pos.clone());
14302
14421
  for (const offset of CUBE_FACE_OFFSETS) {
14303
- const neighbor = pos.clone().add(new import_three37.Vector3(...offset));
14422
+ const neighbor = pos.clone().add(new import_three38.Vector3(...offset));
14304
14423
  this.pendingCulling.set(neighbor.toArray().join(","), neighbor);
14305
14424
  }
14306
14425
  for (let y = -1; y <= 1; y++) {
14307
14426
  for (let z = -1; z <= 1; z++) {
14308
14427
  for (let x = -1; x <= 1; x++) {
14309
- const neighbor = pos.clone().add(new import_three37.Vector3(x, y, z));
14428
+ const neighbor = pos.clone().add(new import_three38.Vector3(x, y, z));
14310
14429
  if (this.getBlockAt(neighbor)?.object?.fluidKind) {
14311
14430
  this.pendingCulling.set(neighbor.toArray().join(","), neighbor);
14312
14431
  }
@@ -14325,12 +14444,14 @@ var MineRenderWorld = class {
14325
14444
  if (!chunk) continue;
14326
14445
  changed.add(chunk);
14327
14446
  const block = chunk.getBlockAt(pos);
14328
- if (!block) continue;
14447
+ if (!block || !chunk.isBlockVisibleAt(pos)) {
14448
+ continue;
14449
+ }
14329
14450
  if (block.object?.fluidKind) {
14330
14451
  await block.object.updateFluid((x, y, z) => {
14331
- const neighbor = pos.clone().add(new import_three37.Vector3(x, y, z));
14452
+ const neighbor = pos.clone().add(new import_three38.Vector3(x, y, z));
14332
14453
  const section = this.getChunkAt(neighbor);
14333
- const object = section?.getBlockAt(neighbor)?.object;
14454
+ const object = section?.isBlockVisibleAt(neighbor) ? section.getBlockAt(neighbor)?.object : void 0;
14334
14455
  return {
14335
14456
  fluid: object?.fluidKind,
14336
14457
  level: object?.fluidLevel,
@@ -14340,7 +14461,7 @@ var MineRenderWorld = class {
14340
14461
  }
14341
14462
  let mask = 0;
14342
14463
  for (const [face, offset] of CUBE_FACE_OFFSETS.entries()) {
14343
- const neighbor = pos.clone().add(new import_three37.Vector3(...offset));
14464
+ const neighbor = pos.clone().add(new import_three38.Vector3(...offset));
14344
14465
  if (this.getChunkAt(neighbor)?.isOccludingAt(neighbor)) {
14345
14466
  mask |= 1 << face;
14346
14467
  }
@@ -14374,14 +14495,14 @@ var MineRenderWorld = class {
14374
14495
  return this._chunks.get(this.worldPosToChunkKey(pos));
14375
14496
  }
14376
14497
  static worldToScenePosition(pos) {
14377
- return new import_three37.Vector3(
14498
+ return new import_three38.Vector3(
14378
14499
  pos.x * 16,
14379
14500
  pos.y * 16,
14380
14501
  pos.z * 16
14381
14502
  );
14382
14503
  }
14383
14504
  static sceneToWorldPosition(pos) {
14384
- return new import_three37.Vector3(
14505
+ return new import_three38.Vector3(
14385
14506
  pos.x / 16,
14386
14507
  pos.y / 16,
14387
14508
  pos.z / 16
@@ -14404,10 +14525,10 @@ var MineRenderWorld = class {
14404
14525
  init_Model();
14405
14526
 
14406
14527
  // src/world/SectionMesh.ts
14407
- var import_three38 = require("three");
14528
+ var import_three39 = require("three");
14408
14529
  init_CanvasCompat();
14409
14530
  init_Materials();
14410
- var SectionMesh = class _SectionMesh extends import_three38.Group {
14531
+ var SectionMesh = class _SectionMesh extends import_three39.Group {
14411
14532
  constructor() {
14412
14533
  super(...arguments);
14413
14534
  this.ownedMeshes = [];
@@ -14480,18 +14601,18 @@ var SectionMesh = class _SectionMesh extends import_three38.Group {
14480
14601
  for (let corner = 0; corner < 6; corner++) indices.push(start + sourceIndices.getX(face * 6 + corner) - face * 4);
14481
14602
  }
14482
14603
  }
14483
- const geometry = new import_three38.BufferGeometry();
14484
- geometry.setAttribute("position", new import_three38.Float32BufferAttribute(positions, 3));
14485
- geometry.setAttribute("normal", new import_three38.Float32BufferAttribute(normals, 3));
14486
- geometry.setAttribute("uv", new import_three38.Float32BufferAttribute(uvs, 2));
14487
- geometry.setAttribute("color", new import_three38.Float32BufferAttribute(colors, 3));
14604
+ const geometry = new import_three39.BufferGeometry();
14605
+ geometry.setAttribute("position", new import_three39.Float32BufferAttribute(positions, 3));
14606
+ geometry.setAttribute("normal", new import_three39.Float32BufferAttribute(normals, 3));
14607
+ geometry.setAttribute("uv", new import_three39.Float32BufferAttribute(uvs, 2));
14608
+ geometry.setAttribute("color", new import_three39.Float32BufferAttribute(colors, 3));
14488
14609
  geometry.setIndex(indices);
14489
14610
  geometry.computeBoundingBox();
14490
14611
  geometry.computeBoundingSphere();
14491
14612
  const material = Materials.createShadedCanvasMaterial(canvas, false);
14492
14613
  material.vertexColors = true;
14493
14614
  const texture = material.uniforms?.map?.value ?? material.map;
14494
- const mesh = new import_three38.Mesh(geometry, material);
14615
+ const mesh = new import_three39.Mesh(geometry, material);
14495
14616
  section.add(mesh);
14496
14617
  section.ownedMeshes.push({ mesh, texture });
14497
14618
  }
@@ -14517,6 +14638,7 @@ var Chunk = class _Chunk {
14517
14638
  this.data = new ChunkData();
14518
14639
  this.renderedBlocks = /* @__PURE__ */ new Map();
14519
14640
  this.sectionBlocks = /* @__PURE__ */ new Map();
14641
+ this.hiddenBlocks = /* @__PURE__ */ new Set();
14520
14642
  this.meshDirty = false;
14521
14643
  this.scene = scene;
14522
14644
  this.x = x;
@@ -14525,10 +14647,10 @@ var Chunk = class _Chunk {
14525
14647
  }
14526
14648
  getBlockAt(posOrX, y, z) {
14527
14649
  if (typeof posOrX == "number") {
14528
- return this.getBlockAt(new import_three39.Vector3(posOrX, y, z));
14650
+ return this.getBlockAt(new import_three40.Vector3(posOrX, y, z));
14529
14651
  }
14530
14652
  if (isTripleArray(posOrX)) {
14531
- return this.getBlockAt(new import_three39.Vector3(posOrX[0], posOrX[1], posOrX[2]));
14653
+ return this.getBlockAt(new import_three40.Vector3(posOrX[0], posOrX[1], posOrX[2]));
14532
14654
  }
14533
14655
  const pos = this.worldPosToChunkPos(posOrX);
14534
14656
  const index = _Chunk.chunkPosToBlockIndex(pos);
@@ -14536,10 +14658,10 @@ var Chunk = class _Chunk {
14536
14658
  }
14537
14659
  async setBlockAt(posOrX, yOrBlock, z, block) {
14538
14660
  if (typeof posOrX == "number") {
14539
- return this.setBlockAt(new import_three39.Vector3(posOrX, yOrBlock, z), block);
14661
+ return this.setBlockAt(new import_three40.Vector3(posOrX, yOrBlock, z), block);
14540
14662
  }
14541
14663
  if (isTripleArray(posOrX)) {
14542
- return this.setBlockAt(new import_three39.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
14664
+ return this.setBlockAt(new import_three40.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
14543
14665
  }
14544
14666
  const worldPos = posOrX;
14545
14667
  const pos = this.worldPosToChunkPos(worldPos);
@@ -14554,6 +14676,7 @@ var Chunk = class _Chunk {
14554
14676
  worldPos = this.chunkPosToWorldPos(pos);
14555
14677
  }
14556
14678
  const index = _Chunk.chunkPosToBlockIndex(pos);
14679
+ this.hiddenBlocks.delete(index);
14557
14680
  this.data.set(index, block);
14558
14681
  const readBlock = this.data.snapshot(index);
14559
14682
  this.renderedBlocks.get(index)?.object?.removeFromScene();
@@ -14595,9 +14718,31 @@ var Chunk = class _Chunk {
14595
14718
  await onBlocksChanged?.([worldPos]);
14596
14719
  }
14597
14720
  }
14721
+ async setBlockVisibleAt(pos, visible) {
14722
+ const index = _Chunk.chunkPosToBlockIndex(this.worldPosToChunkPos(pos));
14723
+ const block = this.renderedBlocks.get(index);
14724
+ if (!block || visible === !this.hiddenBlocks.has(index)) {
14725
+ return;
14726
+ }
14727
+ if (visible) {
14728
+ this.hiddenBlocks.delete(index);
14729
+ } else {
14730
+ this.hiddenBlocks.add(index);
14731
+ }
14732
+ block.object?.setVisible(visible);
14733
+ if (this.sectionBlocks.has(index)) {
14734
+ this.meshDirty = true;
14735
+ }
14736
+ this.scene.dirty = true;
14737
+ await this.onBlocksChanged?.([pos]);
14738
+ }
14739
+ isBlockVisibleAt(pos) {
14740
+ const index = _Chunk.chunkPosToBlockIndex(this.worldPosToChunkPos(pos));
14741
+ return this.renderedBlocks.has(index) && !this.hiddenBlocks.has(index);
14742
+ }
14598
14743
  isOccludingAt(pos) {
14599
14744
  const index = _Chunk.chunkPosToBlockIndex(this.worldPosToChunkPos(pos));
14600
- return this.sectionBlocks.has(index) || (this.renderedBlocks.get(index)?.object?.isOccluding ?? false);
14745
+ return !this.hiddenBlocks.has(index) && (this.sectionBlocks.has(index) || (this.renderedBlocks.get(index)?.object?.isOccluding ?? false));
14601
14746
  }
14602
14747
  async setCullMaskAt(pos, mask) {
14603
14748
  const index = _Chunk.chunkPosToBlockIndex(this.worldPosToChunkPos(pos));
@@ -14613,7 +14758,10 @@ var Chunk = class _Chunk {
14613
14758
  }
14614
14759
  rebuildSectionMesh() {
14615
14760
  if (!this.meshDirty) return;
14616
- const next = this.sectionBlocks.size ? SectionMesh.build([...this.sectionBlocks.values()], this.sectionModels.maxAtlasSize) : void 0;
14761
+ const next = this.sectionBlocks.size ? SectionMesh.build(
14762
+ [...this.sectionBlocks.values()].filter((entry) => !this.hiddenBlocks.has(entry.index)),
14763
+ this.sectionModels.maxAtlasSize
14764
+ ) : void 0;
14617
14765
  this.sectionMesh?.dispose();
14618
14766
  this.sectionMesh = next;
14619
14767
  if (next) {
@@ -14625,7 +14773,7 @@ var Chunk = class _Chunk {
14625
14773
  }
14626
14774
  async clear(onBlocksChanged = this.onBlocksChanged) {
14627
14775
  const positions = [...this.renderedBlocks.keys()].map((index) => this.chunkPosToWorldPos(
14628
- new import_three39.Vector3(index % 16, Math.floor(index / 256), Math.floor(index / 16) % 16)
14776
+ new import_three40.Vector3(index % 16, Math.floor(index / 256), Math.floor(index / 16) % 16)
14629
14777
  ));
14630
14778
  for (const info of this.renderedBlocks.values()) info.object?.removeFromScene();
14631
14779
  this.sectionBlocks.clear();
@@ -14633,6 +14781,7 @@ var Chunk = class _Chunk {
14633
14781
  this.sectionMesh = void 0;
14634
14782
  this.meshDirty = false;
14635
14783
  this.renderedBlocks.clear();
14784
+ this.hiddenBlocks.clear();
14636
14785
  this.data.clear();
14637
14786
  await onBlocksChanged?.(positions);
14638
14787
  }
@@ -14649,14 +14798,14 @@ var Chunk = class _Chunk {
14649
14798
  return pos.y * 16 * 16 + pos.z * 16 + pos.x;
14650
14799
  }
14651
14800
  worldPosToChunkPos(pos) {
14652
- return new import_three39.Vector3(
14801
+ return new import_three40.Vector3(
14653
14802
  pos.x - this.x * 16,
14654
14803
  pos.y - this.y * 16,
14655
14804
  pos.z - this.z * 16
14656
14805
  );
14657
14806
  }
14658
14807
  chunkPosToWorldPos(pos) {
14659
- return new import_three39.Vector3(
14808
+ return new import_three40.Vector3(
14660
14809
  this.x * 16 + pos.x,
14661
14810
  this.y * 16 + pos.y,
14662
14811
  this.z * 16 + pos.z