minerender 2.1.0-alpha.54 → 2.1.0-alpha.55

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.
@@ -257,7 +257,9 @@ var init_Caching = __esm({
257
257
  this.defaultBlockStatesCache,
258
258
  this.blockTintCache,
259
259
  this.entityModelCache,
260
- this.entityTextureCache
260
+ this.entityTextureCache,
261
+ this.entityAnimationCache,
262
+ this.blockEntityIndexCache
261
263
  ];
262
264
  }
263
265
  static clear() {
@@ -302,6 +304,8 @@ var init_Caching = __esm({
302
304
  _Caching.blockTintCache = _Caching.createAssetCache();
303
305
  _Caching.entityModelCache = _Caching.createAssetCache();
304
306
  _Caching.entityTextureCache = _Caching.createAssetCache();
307
+ _Caching.entityAnimationCache = _Caching.createAssetCache();
308
+ _Caching.blockEntityIndexCache = _Caching.createAssetCache();
305
309
  Caching = _Caching;
306
310
  }
307
311
  });
@@ -3084,10 +3088,10 @@ var init_InstanceReference = __esm({
3084
3088
  function isSceneObject(obj) {
3085
3089
  return obj.isSceneObject;
3086
3090
  }
3087
- var import_three10, import_ts_deepmerge3, p6, _SceneObject, SceneObject;
3091
+ var import_three11, import_ts_deepmerge3, p6, _SceneObject, SceneObject;
3088
3092
  var init_SceneObject = __esm({
3089
3093
  "src/renderer/SceneObject.ts"() {
3090
- import_three10 = require("three");
3094
+ import_three11 = require("three");
3091
3095
  init_Geometries();
3092
3096
  init_UVMapper();
3093
3097
  init_Axis();
@@ -3099,7 +3103,7 @@ var init_SceneObject = __esm({
3099
3103
  import_ts_deepmerge3 = __toESM(require_dist());
3100
3104
  init_log();
3101
3105
  p6 = prefix("SceneObject");
3102
- _SceneObject = class _SceneObject extends import_three10.Object3D {
3106
+ _SceneObject = class _SceneObject extends import_three11.Object3D {
3103
3107
  constructor(options) {
3104
3108
  super();
3105
3109
  this.isSceneObject = true;
@@ -3143,7 +3147,7 @@ var init_SceneObject = __esm({
3143
3147
  return group;
3144
3148
  }
3145
3149
  createGroup(name, x = 0, y = 0, z = 0, offsetAxis, offset = 0) {
3146
- const obj = new import_three10.Object3D();
3150
+ const obj = new import_three11.Object3D();
3147
3151
  if (name) {
3148
3152
  obj.name = `group:${name}`;
3149
3153
  }
@@ -3193,7 +3197,7 @@ var init_SceneObject = __esm({
3193
3197
  return mesh;
3194
3198
  }
3195
3199
  createMesh(name, geometry, material, offsetAxis, offset = 0) {
3196
- const mesh = new import_three10.Mesh(geometry, material);
3200
+ const mesh = new import_three11.Mesh(geometry, material);
3197
3201
  if (name) {
3198
3202
  mesh.name = `mesh:${name}`;
3199
3203
  }
@@ -3205,7 +3209,7 @@ var init_SceneObject = __esm({
3205
3209
  return mesh;
3206
3210
  }
3207
3211
  createInstancedMesh(name, geometry, material, count) {
3208
- const mesh = new import_three10.InstancedMesh(geometry, material, count);
3212
+ const mesh = new import_three11.InstancedMesh(geometry, material, count);
3209
3213
  mesh.count = 0;
3210
3214
  this.instanceMesh = mesh;
3211
3215
  this._isInstanced = true;
@@ -3285,11 +3289,11 @@ var init_SceneObject = __esm({
3285
3289
  this._instanceCounter = this.instanceReferences.size;
3286
3290
  mesh.count = Math.max(mesh.count, index + 1);
3287
3291
  if (mesh.instanceColor) {
3288
- mesh.setColorAt(index, new import_three10.Color(16777215));
3292
+ mesh.setColorAt(index, new import_three11.Color(16777215));
3289
3293
  mesh.instanceColor.needsUpdate = true;
3290
3294
  }
3291
3295
  if (this._scene) this._scene.stats.instanceCount++;
3292
- this.setMatrixAt(index, new import_three10.Matrix4());
3296
+ this.setMatrixAt(index, new import_three11.Matrix4());
3293
3297
  return reference;
3294
3298
  }
3295
3299
  /** Returns the live reference for a raycast hit on this object's instance mesh. */
@@ -3302,7 +3306,7 @@ var init_SceneObject = __esm({
3302
3306
  removeInstanceAt(index) {
3303
3307
  if (!this.instanceReferences.has(index)) return;
3304
3308
  const mesh = this.instanceMesh;
3305
- this.setMatrixAt(index, new import_three10.Matrix4().makeScale(0, 0, 0));
3309
+ this.setMatrixAt(index, new import_three11.Matrix4().makeScale(0, 0, 0));
3306
3310
  this.instanceReferences.delete(index);
3307
3311
  this.freeInstanceIndices.push(index);
3308
3312
  this._instanceCounter = this.instanceReferences.size;
@@ -3315,7 +3319,7 @@ var init_SceneObject = __esm({
3315
3319
  const grow = (attribute, fill) => {
3316
3320
  const array = new Float32Array(capacity * attribute.itemSize).fill(fill);
3317
3321
  array.set(attribute.array);
3318
- return new import_three10.InstancedBufferAttribute(array, attribute.itemSize, attribute.normalized, attribute.meshPerAttribute).setUsage(attribute.usage);
3322
+ return new import_three11.InstancedBufferAttribute(array, attribute.itemSize, attribute.normalized, attribute.meshPerAttribute).setUsage(attribute.usage);
3319
3323
  };
3320
3324
  const matrix = grow(mesh.instanceMatrix, 0);
3321
3325
  const color = mesh.instanceColor ? grow(mesh.instanceColor, 1) : null;
@@ -3332,7 +3336,7 @@ var init_SceneObject = __esm({
3332
3336
  }
3333
3337
  //</editor-fold>
3334
3338
  //<editor-fold desc="TRANSFORMATION">
3335
- getMatrixAt(index, matrix = new import_three10.Matrix4()) {
3339
+ getMatrixAt(index, matrix = new import_three11.Matrix4()) {
3336
3340
  if (!this.instanceReferences.has(index)) throw new MineRenderError("Instance is not active");
3337
3341
  this.instanceMesh.getMatrixAt(index, matrix);
3338
3342
  return matrix;
@@ -3348,16 +3352,16 @@ var init_SceneObject = __esm({
3348
3352
  }
3349
3353
  setPositionRotationScaleAt(index, position, rotation, scale) {
3350
3354
  if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
3351
- const oldPosition = new import_three10.Vector3();
3352
- const oldRotation = new import_three10.Quaternion();
3353
- const oldScale = new import_three10.Vector3();
3354
- const matrix = new import_three10.Matrix4();
3355
+ const oldPosition = new import_three11.Vector3();
3356
+ const oldRotation = new import_three11.Quaternion();
3357
+ const oldScale = new import_three11.Vector3();
3358
+ const matrix = new import_three11.Matrix4();
3355
3359
  if (!scale || !rotation || !position) {
3356
3360
  this.getMatrixAt(index, matrix).decompose(oldPosition, oldRotation, oldScale);
3357
3361
  }
3358
3362
  matrix.compose(
3359
3363
  position ? position : oldPosition,
3360
- rotation ? new import_three10.Quaternion().setFromEuler(rotation) : oldRotation,
3364
+ rotation ? new import_three11.Quaternion().setFromEuler(rotation) : oldRotation,
3361
3365
  scale ? scale : oldScale
3362
3366
  );
3363
3367
  this.setMatrixAt(index, matrix);
@@ -3366,7 +3370,7 @@ var init_SceneObject = __esm({
3366
3370
  if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
3367
3371
  this.setPositionRotationScaleAt(index, position);
3368
3372
  }
3369
- getPositionAt(index, vector = new import_three10.Vector3()) {
3373
+ getPositionAt(index, vector = new import_three11.Vector3()) {
3370
3374
  if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
3371
3375
  const matrix = this.getMatrixAt(index);
3372
3376
  vector.setFromMatrixPosition(matrix);
@@ -3376,17 +3380,17 @@ var init_SceneObject = __esm({
3376
3380
  if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
3377
3381
  this.setPositionRotationScaleAt(index, void 0, rotation, void 0);
3378
3382
  }
3379
- getRotationAt(index, euler = new import_three10.Euler()) {
3383
+ getRotationAt(index, euler = new import_three11.Euler()) {
3380
3384
  if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
3381
- const rotation = new import_three10.Quaternion();
3382
- this.getMatrixAt(index).decompose(new import_three10.Vector3(), rotation, new import_three10.Vector3());
3385
+ const rotation = new import_three11.Quaternion();
3386
+ this.getMatrixAt(index).decompose(new import_three11.Vector3(), rotation, new import_three11.Vector3());
3383
3387
  return euler.setFromQuaternion(rotation);
3384
3388
  }
3385
3389
  setScaleAt(index, scale) {
3386
3390
  if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
3387
3391
  this.setPositionRotationScaleAt(index, void 0, void 0, scale);
3388
3392
  }
3389
- getScaleAt(index, vector = new import_three10.Vector3()) {
3393
+ getScaleAt(index, vector = new import_three11.Vector3()) {
3390
3394
  if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
3391
3395
  const matrix = this.getMatrixAt(index);
3392
3396
  vector.setFromMatrixScale(matrix);
@@ -3529,7 +3533,7 @@ function mergeBufferGeometries(geometries, useGroups = false) {
3529
3533
  const attributes = {};
3530
3534
  const morphAttributes = {};
3531
3535
  const morphTargetsRelative = geometries[0].morphTargetsRelative;
3532
- const mergedGeometry = new import_three19.BufferGeometry();
3536
+ const mergedGeometry = new import_three20.BufferGeometry();
3533
3537
  let offset = 0;
3534
3538
  for (let i = 0; i < geometries.length; ++i) {
3535
3539
  const geometry = geometries[i];
@@ -3653,7 +3657,7 @@ function mergeBufferAttributes(attributes) {
3653
3657
  array.set(attributes[i].array, offset);
3654
3658
  offset += attributes[i].array.length;
3655
3659
  }
3656
- return new import_three19.BufferAttribute(array, itemSize, normalized);
3660
+ return new import_three20.BufferAttribute(array, itemSize, normalized);
3657
3661
  }
3658
3662
  function interleaveAttributes(attributes) {
3659
3663
  let TypedArray;
@@ -3669,7 +3673,7 @@ function interleaveAttributes(attributes) {
3669
3673
  arrayLength += attribute.array.length;
3670
3674
  stride += attribute.itemSize;
3671
3675
  }
3672
- const interleavedBuffer = new import_three19.InterleavedBuffer(new TypedArray(arrayLength), stride);
3676
+ const interleavedBuffer = new import_three20.InterleavedBuffer(new TypedArray(arrayLength), stride);
3673
3677
  let offset = 0;
3674
3678
  const res = [];
3675
3679
  const getters = ["getX", "getY", "getZ", "getW"];
@@ -3678,7 +3682,7 @@ function interleaveAttributes(attributes) {
3678
3682
  const attribute = attributes[j];
3679
3683
  const itemSize = attribute.itemSize;
3680
3684
  const count = attribute.count;
3681
- const iba = new import_three19.InterleavedBufferAttribute(interleavedBuffer, itemSize, offset, attribute.normalized);
3685
+ const iba = new import_three20.InterleavedBufferAttribute(interleavedBuffer, itemSize, offset, attribute.normalized);
3682
3686
  res.push(iba);
3683
3687
  offset += itemSize;
3684
3688
  for (let c = 0; c < count; c++) {
@@ -3762,13 +3766,13 @@ function mergeVertices(geometry, tolerance = 1e-4) {
3762
3766
  const name = attributeNames[i];
3763
3767
  const oldAttribute = geometry.getAttribute(name);
3764
3768
  const buffer = new oldAttribute.array.constructor(attrArrays[name]);
3765
- const attribute = new import_three19.BufferAttribute(buffer, oldAttribute.itemSize, oldAttribute.normalized);
3769
+ const attribute = new import_three20.BufferAttribute(buffer, oldAttribute.itemSize, oldAttribute.normalized);
3766
3770
  result.setAttribute(name, attribute);
3767
3771
  if (name in morphAttrsArrays) {
3768
3772
  for (let j = 0; j < morphAttrsArrays[name].length; j++) {
3769
3773
  const oldMorphAttribute = geometry.morphAttributes[name][j];
3770
3774
  const buffer2 = new oldMorphAttribute.array.constructor(morphAttrsArrays[name][j]);
3771
- const morphAttribute = new import_three19.BufferAttribute(buffer2, oldMorphAttribute.itemSize, oldMorphAttribute.normalized);
3775
+ const morphAttribute = new import_three20.BufferAttribute(buffer2, oldMorphAttribute.itemSize, oldMorphAttribute.normalized);
3772
3776
  result.morphAttributes[name][j] = morphAttribute;
3773
3777
  }
3774
3778
  }
@@ -3777,11 +3781,11 @@ function mergeVertices(geometry, tolerance = 1e-4) {
3777
3781
  return result;
3778
3782
  }
3779
3783
  function toTrianglesDrawMode(geometry, drawMode) {
3780
- if (drawMode === import_three19.TrianglesDrawMode) {
3784
+ if (drawMode === import_three20.TrianglesDrawMode) {
3781
3785
  console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles.");
3782
3786
  return geometry;
3783
3787
  }
3784
- if (drawMode === import_three19.TriangleFanDrawMode || drawMode === import_three19.TriangleStripDrawMode) {
3788
+ if (drawMode === import_three20.TriangleFanDrawMode || drawMode === import_three20.TriangleStripDrawMode) {
3785
3789
  let index = geometry.getIndex();
3786
3790
  if (index === null) {
3787
3791
  const indices = [];
@@ -3799,7 +3803,7 @@ function toTrianglesDrawMode(geometry, drawMode) {
3799
3803
  }
3800
3804
  const numberOfTriangles = index.count - 2;
3801
3805
  const newIndices = [];
3802
- if (drawMode === import_three19.TriangleFanDrawMode) {
3806
+ if (drawMode === import_three20.TriangleFanDrawMode) {
3803
3807
  for (let i = 1; i <= numberOfTriangles; i++) {
3804
3808
  newIndices.push(index.getX(0));
3805
3809
  newIndices.push(index.getX(i));
@@ -3835,15 +3839,15 @@ function computeMorphedAttributes(object) {
3835
3839
  console.error("THREE.BufferGeometryUtils: Geometry is not of type BufferGeometry.");
3836
3840
  return null;
3837
3841
  }
3838
- const _vA = new import_three19.Vector3();
3839
- const _vB = new import_three19.Vector3();
3840
- const _vC = new import_three19.Vector3();
3841
- const _tempA = new import_three19.Vector3();
3842
- const _tempB = new import_three19.Vector3();
3843
- const _tempC = new import_three19.Vector3();
3844
- const _morphA = new import_three19.Vector3();
3845
- const _morphB = new import_three19.Vector3();
3846
- const _morphC = new import_three19.Vector3();
3842
+ const _vA = new import_three20.Vector3();
3843
+ const _vB = new import_three20.Vector3();
3844
+ const _vC = new import_three20.Vector3();
3845
+ const _tempA = new import_three20.Vector3();
3846
+ const _tempB = new import_three20.Vector3();
3847
+ const _tempC = new import_three20.Vector3();
3848
+ const _morphA = new import_three20.Vector3();
3849
+ const _morphB = new import_three20.Vector3();
3850
+ const _morphC = new import_three20.Vector3();
3847
3851
  function _calculateMorphedAttributeData(object2, material2, attribute, morphAttribute, morphTargetsRelative2, a2, b2, c2, modifiedAttributeArray) {
3848
3852
  _vA.fromBufferAttribute(attribute, a2);
3849
3853
  _vB.fromBufferAttribute(attribute, b2);
@@ -4038,8 +4042,8 @@ function computeMorphedAttributes(object) {
4038
4042
  }
4039
4043
  }
4040
4044
  }
4041
- const morphedPositionAttribute = new import_three19.Float32BufferAttribute(modifiedPosition, 3);
4042
- const morphedNormalAttribute = new import_three19.Float32BufferAttribute(modifiedNormal, 3);
4045
+ const morphedPositionAttribute = new import_three20.Float32BufferAttribute(modifiedPosition, 3);
4046
+ const morphedNormalAttribute = new import_three20.Float32BufferAttribute(modifiedNormal, 3);
4043
4047
  return {
4044
4048
  positionAttribute,
4045
4049
  normalAttribute,
@@ -4047,24 +4051,24 @@ function computeMorphedAttributes(object) {
4047
4051
  morphedNormalAttribute
4048
4052
  };
4049
4053
  }
4050
- var import_three19;
4054
+ var import_three20;
4051
4055
  var init_BufferGeometryUtils = __esm({
4052
4056
  "src/three/BufferGeometryUtils.js"() {
4053
- import_three19 = require("three");
4057
+ import_three20 = require("three");
4054
4058
  }
4055
4059
  });
4056
4060
 
4057
4061
  // src/model/ModelCulling.ts
4058
- var import_three20, ModelCulling;
4062
+ var import_three21, ModelCulling;
4059
4063
  var init_ModelCulling = __esm({
4060
4064
  "src/model/ModelCulling.ts"() {
4061
- import_three20 = require("three");
4065
+ import_three21 = require("three");
4062
4066
  init_CubeFace();
4063
4067
  ModelCulling = class {
4064
4068
  static toLocalMask(worldMask, rotation) {
4065
4069
  let localMask = 0;
4066
4070
  for (const [localFace, offset] of CUBE_FACE_OFFSETS.entries()) {
4067
- const normal = new import_three20.Vector3(...offset).applyEuler(rotation);
4071
+ const normal = new import_three21.Vector3(...offset).applyEuler(rotation);
4068
4072
  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);
4069
4073
  if (worldFace < 0) return 0;
4070
4074
  if (worldMask & 1 << worldFace) localMask |= 1 << localFace;
@@ -4100,13 +4104,13 @@ var init_ModelCulling = __esm({
4100
4104
  function isModelObject(obj) {
4101
4105
  return obj.isModelObject;
4102
4106
  }
4103
- var import_three21, import_ts_deepmerge5, p7, _ModelObject, ModelObject;
4107
+ var import_three22, import_ts_deepmerge5, p7, _ModelObject, ModelObject;
4104
4108
  var init_ModelObject = __esm({
4105
4109
  "src/model/scene/ModelObject.ts"() {
4106
4110
  init_SceneObject();
4107
4111
  init_Materials();
4108
4112
  init_UVMapper();
4109
- import_three21 = require("three");
4113
+ import_three22 = require("three");
4110
4114
  init_BufferGeometryUtils();
4111
4115
  init_model();
4112
4116
  import_ts_deepmerge5 = __toESM(require_dist());
@@ -4160,7 +4164,7 @@ var init_ModelObject = __esm({
4160
4164
  elGeo.clearGroups();
4161
4165
  }
4162
4166
  if (this.options.uvLockRotation) {
4163
- UVMapper.lockUvs(elGeo, el.faces, this.atlas, new import_three21.Euler(...this.options.uvLockRotation));
4167
+ UVMapper.lockUvs(elGeo, el.faces, this.atlas, new import_three22.Euler(...this.options.uvLockRotation));
4164
4168
  }
4165
4169
  if (this.options.tints) {
4166
4170
  const colors = new Float32Array(elGeo.getAttribute("position").count * 3).fill(1);
@@ -4169,19 +4173,19 @@ var init_ModelObject = __esm({
4169
4173
  if (tintIndex === void 0 || tintIndex < 0) continue;
4170
4174
  const tint = this.options.tints[tintIndex];
4171
4175
  if (tint === void 0) continue;
4172
- const color = new import_three21.Color(tint);
4176
+ const color = new import_three22.Color(tint);
4173
4177
  for (let vertex = 0; vertex < 4; vertex++) {
4174
4178
  color.toArray(colors, (faceIndex * 4 + vertex) * 3);
4175
4179
  }
4176
4180
  }
4177
- elGeo.setAttribute("color", new import_three21.BufferAttribute(colors, 3));
4181
+ elGeo.setAttribute("color", new import_three22.BufferAttribute(colors, 3));
4178
4182
  }
4179
- elGeo.applyMatrix4(new import_three21.Matrix4().makeTranslation((el.to[0] - el.from[0]) / 2, (el.to[1] - el.from[1]) / 2, (el.to[2] - el.from[2]) / 2));
4180
- elGeo.applyMatrix4(new import_three21.Matrix4().makeTranslation(el.from[0], el.from[1], el.from[2]));
4183
+ elGeo.applyMatrix4(new import_three22.Matrix4().makeTranslation((el.to[0] - el.from[0]) / 2, (el.to[1] - el.from[1]) / 2, (el.to[2] - el.from[2]) / 2));
4184
+ elGeo.applyMatrix4(new import_three22.Matrix4().makeTranslation(el.from[0], el.from[1], el.from[2]));
4181
4185
  if (el.rotation) {
4182
4186
  applyElementRotation(el.rotation, elGeo);
4183
4187
  }
4184
- elGeo.applyMatrix4(new import_three21.Matrix4().makeTranslation(-8, -8, -8));
4188
+ elGeo.applyMatrix4(new import_three22.Matrix4().makeTranslation(-8, -8, -8));
4185
4189
  if (displayTransform) DisplayTransforms.apply(elGeo, displayTransform);
4186
4190
  if (this.options.mergeMeshes) {
4187
4191
  allGeos.push(elGeo);
@@ -4203,7 +4207,7 @@ var init_ModelObject = __esm({
4203
4207
  if (allGeos.length > 0) {
4204
4208
  combinedGeo = mergeBufferGeometries(allGeos);
4205
4209
  } else {
4206
- combinedGeo = new import_three21.BoxGeometry(16, 16, 16);
4210
+ combinedGeo = new import_three22.BoxGeometry(16, 16, 16);
4207
4211
  if (displayTransform) DisplayTransforms.apply(combinedGeo, displayTransform);
4208
4212
  }
4209
4213
  combinedGeo.computeBoundingBox();
@@ -4313,7 +4317,7 @@ function ownHeight(sample) {
4313
4317
  return (level === 0 || level >= 8 ? 8 : 8 - level) / 9;
4314
4318
  }
4315
4319
  function createFluidGeometry(kind, sample) {
4316
- const geometry = new import_three26.BufferGeometry();
4320
+ const geometry = new import_three27.BufferGeometry();
4317
4321
  const positions = [], normals = [], uvs = [], indices = [];
4318
4322
  const self = sample(0, 0, 0);
4319
4323
  const height = (x, z) => {
@@ -4412,16 +4416,16 @@ function createFluidGeometry(kind, sample) {
4412
4416
  1
4413
4417
  );
4414
4418
  }
4415
- geometry.setAttribute("position", new import_three26.Float32BufferAttribute(positions, 3));
4416
- geometry.setAttribute("normal", new import_three26.Float32BufferAttribute(normals, 3));
4417
- geometry.setAttribute("uv", new import_three26.Float32BufferAttribute(uvs, 2));
4419
+ geometry.setAttribute("position", new import_three27.Float32BufferAttribute(positions, 3));
4420
+ geometry.setAttribute("normal", new import_three27.Float32BufferAttribute(normals, 3));
4421
+ geometry.setAttribute("uv", new import_three27.Float32BufferAttribute(uvs, 2));
4418
4422
  geometry.setIndex(indices);
4419
4423
  return geometry;
4420
4424
  }
4421
- var import_three26, fluidRules, HORIZONTAL, EPSILON;
4425
+ var import_three27, fluidRules, HORIZONTAL, EPSILON;
4422
4426
  var init_FluidGeometry = __esm({
4423
4427
  "src/model/fluid/FluidGeometry.ts"() {
4424
- import_three26 = require("three");
4428
+ import_three27 = require("three");
4425
4429
  init_fluidBlocks();
4426
4430
  fluidRules = fluidBlocks_default;
4427
4431
  HORIZONTAL = [[0, -1], [0, 1], [-1, 0], [1, 0]];
@@ -4450,10 +4454,10 @@ function sampleFluid(kind, sample) {
4450
4454
  }
4451
4455
  return { key: key.join(""), sample: (x, y, z) => cells[(y + 1) * 9 + (z + 1) * 3 + x + 1] };
4452
4456
  }
4453
- var import_three27, FluidModelObject;
4457
+ var import_three28, FluidModelObject;
4454
4458
  var init_FluidModelObject = __esm({
4455
4459
  "src/model/fluid/FluidModelObject.ts"() {
4456
- import_three27 = require("three");
4460
+ import_three28 = require("three");
4457
4461
  init_AssetKey();
4458
4462
  init_Materials();
4459
4463
  init_ModelObject();
@@ -4486,10 +4490,10 @@ var init_FluidModelObject = __esm({
4486
4490
  }
4487
4491
  }
4488
4492
  geometry.clearGroups();
4489
- const color = new import_three27.Color(this.options.tints?.[0] ?? (this.kind === "water" ? 4159204 : 16777215));
4493
+ const color = new import_three28.Color(this.options.tints?.[0] ?? (this.kind === "water" ? 4159204 : 16777215));
4490
4494
  const colors = new Float32Array(geometry.getAttribute("position").count * 3);
4491
4495
  for (let i = 0; i < colors.length; i += 3) color.toArray(colors, i);
4492
- geometry.setAttribute("color", new import_three27.BufferAttribute(colors, 3));
4496
+ geometry.setAttribute("color", new import_three28.BufferAttribute(colors, 3));
4493
4497
  geometry.computeBoundingBox();
4494
4498
  geometry.computeBoundingSphere();
4495
4499
  if (this.options.instanceMeshes) {
@@ -4503,7 +4507,7 @@ var init_FluidModelObject = __esm({
4503
4507
  super.applyTextures();
4504
4508
  this.iterateAllMeshes((mesh) => {
4505
4509
  const material = mesh.material;
4506
- material.side = import_three27.DoubleSide;
4510
+ material.side = import_three28.DoubleSide;
4507
4511
  material.forceSinglePass = true;
4508
4512
  material.depthWrite = !material.transparent;
4509
4513
  });
@@ -4534,6 +4538,7 @@ __export(index_browser_exports, {
4534
4538
  BUILTIN_GENERATED: () => BUILTIN_GENERATED,
4535
4539
  BasicAssetKey: () => BasicAssetKey,
4536
4540
  BatchedExecutor: () => BatchedExecutor,
4541
+ BlockEntities: () => BlockEntities,
4537
4542
  BlockObject: () => BlockObject,
4538
4543
  BlockStateResolver: () => BlockStateResolver,
4539
4544
  BlockStates: () => BlockStates,
@@ -4557,7 +4562,9 @@ __export(index_browser_exports, {
4557
4562
  DefaultBlockStates: () => DefaultBlockStates,
4558
4563
  DisplayPosition: () => DisplayPosition,
4559
4564
  DisplayTransforms: () => DisplayTransforms,
4565
+ ENTITY_ANIMATION_CHANNELS: () => ENTITY_ANIMATION_CHANNELS,
4560
4566
  Entities: () => Entities,
4567
+ EntityAnimationPlayer: () => EntityAnimationPlayer,
4561
4568
  EntityObject: () => EntityObject,
4562
4569
  Env: () => Env,
4563
4570
  FluidModelObject: () => FluidModelObject,
@@ -4631,6 +4638,7 @@ __export(index_browser_exports, {
4631
4638
  createCanvas: () => createCanvas,
4632
4639
  createFluidGeometry: () => createFluidGeometry,
4633
4640
  createImage: () => createImage,
4641
+ entityAnimationTime: () => entityAnimationTime,
4634
4642
  estimateBytesUsed: () => estimateBytesUsed,
4635
4643
  getBlockFluidState: () => getBlockFluidState,
4636
4644
  getFluidKind: () => getFluidKind,
@@ -4664,6 +4672,8 @@ __export(index_browser_exports, {
4664
4672
  prefix: () => prefix,
4665
4673
  probeImageSize: () => probeImageSize,
4666
4674
  registerBrowserEnv: () => registerBrowserEnv,
4675
+ sampleEntityAnimation: () => sampleEntityAnimation,
4676
+ sampleEntityKeyframes: () => sampleEntityKeyframes,
4667
4677
  sampleFluid: () => sampleFluid,
4668
4678
  serializeBoxGeometryKey: () => serializeBoxGeometryKey,
4669
4679
  serializeImageKey: () => serializeImageKey,
@@ -4959,6 +4969,59 @@ function shutdown() {
4959
4969
  init_AssetKey();
4960
4970
  init_AssetLoader();
4961
4971
  init_Assets();
4972
+
4973
+ // src/assets/BlockEntities.ts
4974
+ var import_three10 = require("three");
4975
+ init_AssetKey();
4976
+ init_AssetLoader();
4977
+ init_source();
4978
+ init_Caching();
4979
+ var BlockEntities = class {
4980
+ /**
4981
+ * Loads the block index of a version. Versions and sources without one yield an empty index, and so does
4982
+ * a failed load: the index is optional, and blocks must not retry or fail with it one by one. The empty
4983
+ * result is cached like any other; `Caching.clear()` or `AssetLoader.setVersion()` forces a new attempt.
4984
+ */
4985
+ static async getIndex(root) {
4986
+ const key = new AssetKey("entity-models", "blocks", void 0, void 0, void 0, ".json", root);
4987
+ key.rootType = void 0;
4988
+ const index = await Caching.blockEntityIndexCache.get(key.serialize(), async () => {
4989
+ try {
4990
+ return await AssetLoader.get(key, "json" /* JSON */) ?? {};
4991
+ } catch (error) {
4992
+ console.warn("Could not load the block entity index; block entities are drawn as plain block models", error);
4993
+ return {};
4994
+ }
4995
+ });
4996
+ return index ?? {};
4997
+ }
4998
+ /** The index entry of a block ID such as `minecraft:chest`. */
4999
+ static entry(index, block) {
5000
+ const entry = Object.prototype.hasOwnProperty.call(index, block) ? index[block] : void 0;
5001
+ return Array.isArray(entry?.parts) ? entry : void 0;
5002
+ }
5003
+ /** Selects the parts and placement for a block ID such as `minecraft:chest`; undefined when nothing is drawn. */
5004
+ static resolve(index, block, state = {}) {
5005
+ const entry = this.entry(index, block);
5006
+ if (!entry) return void 0;
5007
+ const value = (property) => String(state[property]).toLowerCase();
5008
+ const parts = entry.parts.filter((part) => Object.entries(part.when ?? {}).every(([property, values]) => String(values).split("|").includes(value(property))));
5009
+ if (!parts.length) return void 0;
5010
+ let rotation = 0;
5011
+ if (entry.rotation) {
5012
+ const selected = value(entry.rotation.property);
5013
+ rotation = "degrees" in entry.rotation ? entry.rotation.degrees[selected] : Number(selected) * entry.rotation.step;
5014
+ if (!Number.isFinite(rotation)) rotation = 0;
5015
+ }
5016
+ return { parts, rotation, translation: entry.translation ?? [0, 0, 0] };
5017
+ }
5018
+ /** Placement in block space (0..16 per axis), applied on top of the model's own transform. */
5019
+ static matrix(resolved, matrix = new import_three10.Matrix4()) {
5020
+ return matrix.makeTranslation(8, 0, 8).multiply(new import_three10.Matrix4().makeRotationY(resolved.rotation * Math.PI / 180)).multiply(new import_three10.Matrix4().makeTranslation(resolved.translation[0] - 8, resolved.translation[1], resolved.translation[2] - 8));
5021
+ }
5022
+ };
5023
+
5024
+ // src/assets/index.ts
4962
5025
  init_BlockStates();
4963
5026
 
4964
5027
  // src/assets/Entities.ts
@@ -5029,6 +5092,15 @@ var Entities = class {
5029
5092
  })));
5030
5093
  return { ...layers[names[0]], id: model.id, layers, ...model.transform && { transform: model.transform } };
5031
5094
  }
5095
+ /**
5096
+ * Vanilla's keyframe animations of a model by name, or undefined when the model or the selected version has none.
5097
+ */
5098
+ static async getAnimations(modelKey) {
5099
+ const path = isAssetKey(modelKey) ? modelKey.getFullPath() : modelKey.path;
5100
+ const key = new AssetKey(modelKey.namespace, path, void 0, void 0, "entity-models/animations", ".json");
5101
+ const file = await Caching.entityAnimationCache.get(key.serialize(), () => AssetLoader.get(key, "json" /* JSON */));
5102
+ return file?.animations;
5103
+ }
5032
5104
  static async resolveTexture(modelKey) {
5033
5105
  const path = isAssetKey(modelKey) ? modelKey.getFullPath() : modelKey.path;
5034
5106
  const key = new AssetKey(modelKey.namespace, path, void 0, void 0, "entity-models", ".json");
@@ -5105,11 +5177,124 @@ function trimCanvas(source) {
5105
5177
  return canvas;
5106
5178
  }
5107
5179
 
5180
+ // src/entity/EntityAnimation.ts
5181
+ var ENTITY_ANIMATION_CHANNELS = ["position", "rotation", "scale"];
5182
+ function catmullRom(delta, p0, p1, p22, p32) {
5183
+ return 0.5 * (2 * p1 + (p22 - p0) * delta + (2 * p0 - 5 * p1 + 4 * p22 - p32) * delta * delta + (3 * p1 - p0 - 3 * p22 + p32) * delta * delta * delta);
5184
+ }
5185
+ function sampleEntityKeyframes(keyframes, time) {
5186
+ if (keyframes.length === 0) return [0, 0, 0];
5187
+ let low = 0, high = keyframes.length;
5188
+ while (low < high) {
5189
+ const middle = low + high >>> 1;
5190
+ if (time <= keyframes[middle].time) high = middle;
5191
+ else low = middle + 1;
5192
+ }
5193
+ const a = Math.max(0, low - 1);
5194
+ const b = Math.min(keyframes.length - 1, a + 1);
5195
+ const from = keyframes[a];
5196
+ const to = keyframes[b];
5197
+ const delta = a === b ? 0 : Math.min(1, Math.max(0, (time - from.time) / (to.time - from.time)));
5198
+ if (to.interpolation === "catmullrom") {
5199
+ const before = keyframes[Math.max(0, a - 1)].value;
5200
+ const after = keyframes[Math.min(keyframes.length - 1, b + 1)].value;
5201
+ return [0, 1, 2].map((i) => catmullRom(delta, before[i], from.value[i], to.value[i], after[i]));
5202
+ }
5203
+ const target = to.pre ?? to.value;
5204
+ return [0, 1, 2].map((i) => from.value[i] + (target[i] - from.value[i]) * delta);
5205
+ }
5206
+ function entityAnimationTime(animation, time, loop = animation.loop) {
5207
+ return loop && animation.length > 0 ? time % animation.length : time;
5208
+ }
5209
+ function sampleEntityAnimation(animation, time, loop = animation.loop) {
5210
+ const elapsed = entityAnimationTime(animation, time, loop);
5211
+ const pose = {};
5212
+ for (const [name, bone] of Object.entries(animation.bones)) {
5213
+ const sampled = pose[name] = {};
5214
+ for (const channel of ENTITY_ANIMATION_CHANNELS) {
5215
+ const keyframes = bone[channel];
5216
+ if (keyframes?.length) sampled[channel] = sampleEntityKeyframes(keyframes, elapsed);
5217
+ }
5218
+ }
5219
+ return pose;
5220
+ }
5221
+
5222
+ // src/entity/scene/EntityAnimationPlayer.ts
5223
+ var ZERO = [0, 0, 0];
5224
+ var EntityAnimationPlayer = class {
5225
+ constructor() {
5226
+ this.parts = [];
5227
+ this._time = 0;
5228
+ this.loop = false;
5229
+ this.speed = 1;
5230
+ }
5231
+ get animation() {
5232
+ return this._animation;
5233
+ }
5234
+ get time() {
5235
+ return this._time;
5236
+ }
5237
+ /**
5238
+ * Starts an animation on the named parts below each layer root. The current pose of a part becomes its default;
5239
+ * bones without a matching part are skipped.
5240
+ */
5241
+ play(layers, animation, options = {}) {
5242
+ this.stop();
5243
+ this._animation = animation;
5244
+ this._time = options.time ?? 0;
5245
+ this.loop = options.loop ?? animation.loop;
5246
+ this.speed = options.speed ?? 1;
5247
+ for (const layer of layers) {
5248
+ for (const bone of Object.keys(animation.bones)) {
5249
+ const object = layer.getObjectByName(`group:${bone}`);
5250
+ if (!object) continue;
5251
+ this.parts.push({ bone, object, position: object.position.clone(), rotation: object.rotation.clone(), scale: object.scale.clone() });
5252
+ }
5253
+ }
5254
+ this.apply();
5255
+ }
5256
+ /** Restores the default poses. Returns whether an animation was active. */
5257
+ stop() {
5258
+ if (!this._animation) return false;
5259
+ for (const part of this.parts) {
5260
+ part.object.position.copy(part.position);
5261
+ part.object.rotation.copy(part.rotation);
5262
+ part.object.scale.copy(part.scale);
5263
+ }
5264
+ this.clear();
5265
+ return true;
5266
+ }
5267
+ /** Forgets the animation without touching the parts, for parts that no longer exist. */
5268
+ clear() {
5269
+ this.parts = [];
5270
+ this._animation = void 0;
5271
+ this._time = 0;
5272
+ }
5273
+ setTime(seconds) {
5274
+ if (!this._animation) return false;
5275
+ this._time = seconds;
5276
+ this.apply();
5277
+ return true;
5278
+ }
5279
+ advance(deltaSeconds) {
5280
+ return this.setTime(this._time + deltaSeconds * this.speed);
5281
+ }
5282
+ apply() {
5283
+ const pose = sampleEntityAnimation(this._animation, this._time, this.loop);
5284
+ for (const part of this.parts) {
5285
+ const { position = ZERO, rotation = ZERO, scale = ZERO } = pose[part.bone];
5286
+ part.object.position.set(part.position.x + position[0], part.position.y + position[1], part.position.z + position[2]);
5287
+ part.object.rotation.set(part.rotation.x + rotation[0], part.rotation.y + rotation[1], part.rotation.z + rotation[2], part.rotation.order);
5288
+ part.object.scale.set(part.scale.x + scale[0], part.scale.y + scale[1], part.scale.z + scale[2]);
5289
+ }
5290
+ }
5291
+ };
5292
+
5108
5293
  // src/entity/scene/EntityObject.ts
5109
5294
  init_SceneObject();
5110
5295
  init_Caching();
5111
5296
  var import_ts_deepmerge4 = __toESM(require_dist());
5112
- var import_three12 = require("three");
5297
+ var import_three13 = require("three");
5113
5298
  init_Ticker();
5114
5299
  init_model();
5115
5300
  init_ModelTextures();
@@ -5126,6 +5311,7 @@ var _EntityObject = class _EntityObject extends SceneObject {
5126
5311
  this.scrollMaterials = [];
5127
5312
  /** Entity age in ticks, as vanilla's `ageInTicks`; drives the scrolling render modes. */
5128
5313
  this.age = 0;
5314
+ this.animationPlayer = new EntityAnimationPlayer();
5129
5315
  this.options = (0, import_ts_deepmerge4.default)({}, _EntityObject.DEFAULT_OPTIONS, options ?? {});
5130
5316
  }
5131
5317
  async init() {
@@ -5137,6 +5323,7 @@ var _EntityObject = class _EntityObject extends SceneObject {
5137
5323
  }
5138
5324
  disposeAndRemoveAllChildren() {
5139
5325
  this.clearScrollMaterials();
5326
+ this.animationPlayer.clear();
5140
5327
  super.disposeAndRemoveAllChildren();
5141
5328
  }
5142
5329
  clearScrollMaterials() {
@@ -5154,6 +5341,39 @@ var _EntityObject = class _EntityObject extends SceneObject {
5154
5341
  }
5155
5342
  this.notifyDirty();
5156
5343
  }
5344
+ //<editor-fold desc="ANIMATION">
5345
+ /** The animation started by {@link playAnimation}, until {@link stopAnimation} or disposal. */
5346
+ get animation() {
5347
+ return this.animationPlayer.animation;
5348
+ }
5349
+ /** Seconds since the animation started, before looping. */
5350
+ get animationTime() {
5351
+ return this.animationPlayer.time;
5352
+ }
5353
+ /**
5354
+ * Poses the object from a keyframe animation of {@link Entities.getAnimations}, replacing the current one.
5355
+ * Parts of every layer are matched by name and their current pose is the default the offsets add to.
5356
+ * The object owns no clock: call {@link advanceAnimation} per frame, or {@link setAnimationTime}.
5357
+ */
5358
+ playAnimation(animation, options) {
5359
+ this.createMeshes();
5360
+ const layers = Object.keys(this.entityLayers).map((name) => this.getLayerGroup(name)).filter((layer) => !!layer);
5361
+ this.animationPlayer.play(layers, animation, options);
5362
+ this.notifyDirty();
5363
+ }
5364
+ /** Stops the animation and restores the default pose. */
5365
+ stopAnimation() {
5366
+ if (this.animationPlayer.stop()) this.notifyDirty();
5367
+ }
5368
+ /** Poses the object at an explicit time in seconds. Has no effect without an animation. */
5369
+ setAnimationTime(seconds) {
5370
+ if (this.animationPlayer.setTime(seconds)) this.notifyDirty();
5371
+ }
5372
+ /** Advances the animation by a frame delta in seconds, scaled by its speed. Has no effect without an animation. */
5373
+ advanceAnimation(deltaSeconds) {
5374
+ if (this.animationPlayer.advance(deltaSeconds)) this.notifyDirty();
5375
+ }
5376
+ //</editor-fold>
5157
5377
  getLayerGroup(name) {
5158
5378
  return super.getGroupByName(`layer:${name}`);
5159
5379
  }
@@ -5183,14 +5403,14 @@ var _EntityObject = class _EntityObject extends SceneObject {
5183
5403
  }
5184
5404
  createMeshes(force = false) {
5185
5405
  if (this.meshesCreated && !force) return;
5186
- const modelRoot = new import_three12.Object3D();
5406
+ const modelRoot = new import_three13.Object3D();
5187
5407
  const transform = this.options.flip === void 0 ? this.entity.transform : void 0;
5188
5408
  if (transform) {
5189
5409
  for (const op of transform) {
5190
- const matrix = new import_three12.Matrix4();
5410
+ const matrix = new import_three13.Matrix4();
5191
5411
  if ("scale" in op) matrix.makeScale(...op.scale);
5192
5412
  else if ("translate" in op) matrix.makeTranslation(...op.translate);
5193
- else matrix.makeRotationFromEuler(new import_three12.Euler(...op.rotate, "ZYX"));
5413
+ else matrix.makeRotationFromEuler(new import_three13.Euler(...op.rotate, "ZYX"));
5194
5414
  modelRoot.matrix.multiply(matrix);
5195
5415
  }
5196
5416
  modelRoot.matrixAutoUpdate = false;
@@ -5245,7 +5465,7 @@ var _EntityObject = class _EntityObject extends SceneObject {
5245
5465
  const tint = layer.tint === void 0 ? void 0 : this.options.tints?.[layer.tint];
5246
5466
  const scroll = Materials.entityModeScroll(mode);
5247
5467
  const assetKeyStr = this.getTextureKey(layer).serialize();
5248
- const keyStr = `entity:${mode}:${tint === void 0 ? "" : new import_three12.Color(tint).getHexString()}:${assetKeyStr}`;
5468
+ const keyStr = `entity:${mode}:${tint === void 0 ? "" : new import_three13.Color(tint).getHexString()}:${assetKeyStr}`;
5249
5469
  let mat = scroll ? void 0 : Caching.materialCache.getIfPresent(keyStr);
5250
5470
  if (!mat) {
5251
5471
  const cachedAsset = Caching.textureAssetCache.getIfPresent(assetKeyStr);
@@ -5284,27 +5504,27 @@ function isEntityObject(obj) {
5284
5504
  init_MineRenderError();
5285
5505
 
5286
5506
  // src/export/SceneExporter.ts
5287
- var import_three18 = require("three");
5507
+ var import_three19 = require("three");
5288
5508
 
5289
5509
  // ../../node_modules/three/examples/jsm/exporters/OBJExporter.js
5290
- var import_three14 = require("three");
5510
+ var import_three15 = require("three");
5291
5511
  var OBJExporter = class {
5292
5512
  parse(object) {
5293
5513
  let output = "";
5294
5514
  let indexVertex = 0;
5295
5515
  let indexVertexUvs = 0;
5296
5516
  let indexNormals = 0;
5297
- const vertex = new import_three14.Vector3();
5298
- const color = new import_three14.Color();
5299
- const normal = new import_three14.Vector3();
5300
- const uv = new import_three14.Vector2();
5517
+ const vertex = new import_three15.Vector3();
5518
+ const color = new import_three15.Color();
5519
+ const normal = new import_three15.Vector3();
5520
+ const uv = new import_three15.Vector2();
5301
5521
  const face = [];
5302
5522
  function parseMesh(mesh) {
5303
5523
  let nbVertex = 0;
5304
5524
  let nbNormals = 0;
5305
5525
  let nbVertexUvs = 0;
5306
5526
  const geometry = mesh.geometry;
5307
- const normalMatrixWorld = new import_three14.Matrix3();
5527
+ const normalMatrixWorld = new import_three15.Matrix3();
5308
5528
  const vertices = geometry.getAttribute("position");
5309
5529
  const normals = geometry.getAttribute("normal");
5310
5530
  const uvs = geometry.getAttribute("uv");
@@ -5423,7 +5643,7 @@ var OBJExporter = class {
5423
5643
  };
5424
5644
 
5425
5645
  // ../../node_modules/three/examples/jsm/exporters/PLYExporter.js
5426
- var import_three15 = require("three");
5646
+ var import_three16 = require("three");
5427
5647
  var PLYExporter = class {
5428
5648
  parse(object, onDone, options = {}) {
5429
5649
  function traverseMeshes(cb) {
@@ -5480,7 +5700,7 @@ var PLYExporter = class {
5480
5700
  includeIndices = false;
5481
5701
  }
5482
5702
  });
5483
- const tempColor = new import_three15.Color();
5703
+ const tempColor = new import_three16.Color();
5484
5704
  includeIndices = includeIndices && excludeAttributes.indexOf("index") === -1;
5485
5705
  includeNormals = includeNormals && excludeAttributes.indexOf("normal") === -1;
5486
5706
  includeColors = includeColors && excludeAttributes.indexOf("color") === -1;
@@ -5514,8 +5734,8 @@ property list uchar int vertex_index
5514
5734
  `;
5515
5735
  }
5516
5736
  header += "end_header\n";
5517
- const vertex = new import_three15.Vector3();
5518
- const normalMatrixWorld = new import_three15.Matrix3();
5737
+ const vertex = new import_three16.Vector3();
5738
+ const normalMatrixWorld = new import_three16.Matrix3();
5519
5739
  let result = null;
5520
5740
  if (options.binary === true) {
5521
5741
  const headerBin = new TextEncoder().encode(header);
@@ -5689,18 +5909,18 @@ property list uchar int vertex_index
5689
5909
  };
5690
5910
 
5691
5911
  // ../../node_modules/three/examples/jsm/exporters/GLTFExporter.js
5692
- var import_three17 = require("three");
5912
+ var import_three18 = require("three");
5693
5913
 
5694
5914
  // ../../node_modules/three/examples/jsm/utils/TextureUtils.js
5695
- var import_three16 = require("three");
5915
+ var import_three17 = require("three");
5696
5916
  var _renderer;
5697
5917
  var fullscreenQuadGeometry;
5698
5918
  var fullscreenQuadMaterial;
5699
5919
  var fullscreenQuad;
5700
5920
  function decompress(texture, maxTextureSize = Infinity, renderer = null) {
5701
- if (!fullscreenQuadGeometry) fullscreenQuadGeometry = new import_three16.PlaneGeometry(2, 2, 1, 1);
5702
- if (!fullscreenQuadMaterial) fullscreenQuadMaterial = new import_three16.ShaderMaterial({
5703
- uniforms: { blitTexture: new import_three16.Uniform(texture) },
5921
+ if (!fullscreenQuadGeometry) fullscreenQuadGeometry = new import_three17.PlaneGeometry(2, 2, 1, 1);
5922
+ if (!fullscreenQuadMaterial) fullscreenQuadMaterial = new import_three17.ShaderMaterial({
5923
+ uniforms: { blitTexture: new import_three17.Uniform(texture) },
5704
5924
  vertexShader: `
5705
5925
  varying vec2 vUv;
5706
5926
  void main(){
@@ -5722,22 +5942,22 @@ function decompress(texture, maxTextureSize = Infinity, renderer = null) {
5722
5942
  }`
5723
5943
  });
5724
5944
  fullscreenQuadMaterial.uniforms.blitTexture.value = texture;
5725
- fullscreenQuadMaterial.defines.IS_SRGB = texture.colorSpace == import_three16.SRGBColorSpace;
5945
+ fullscreenQuadMaterial.defines.IS_SRGB = texture.colorSpace == import_three17.SRGBColorSpace;
5726
5946
  fullscreenQuadMaterial.needsUpdate = true;
5727
5947
  if (!fullscreenQuad) {
5728
- fullscreenQuad = new import_three16.Mesh(fullscreenQuadGeometry, fullscreenQuadMaterial);
5948
+ fullscreenQuad = new import_three17.Mesh(fullscreenQuadGeometry, fullscreenQuadMaterial);
5729
5949
  fullscreenQuad.frustrumCulled = false;
5730
5950
  }
5731
- const _camera = new import_three16.PerspectiveCamera();
5732
- const _scene = new import_three16.Scene();
5951
+ const _camera = new import_three17.PerspectiveCamera();
5952
+ const _scene = new import_three17.Scene();
5733
5953
  _scene.add(fullscreenQuad);
5734
5954
  if (!renderer) {
5735
- renderer = _renderer = new import_three16.WebGLRenderer({ antialias: false });
5955
+ renderer = _renderer = new import_three17.WebGLRenderer({ antialias: false });
5736
5956
  }
5737
5957
  renderer.setSize(Math.min(texture.image.width, maxTextureSize), Math.min(texture.image.height, maxTextureSize));
5738
5958
  renderer.clear();
5739
5959
  renderer.render(_scene, _camera);
5740
- const readableTexture = new import_three16.Texture(renderer.domElement);
5960
+ const readableTexture = new import_three17.Texture(renderer.domElement);
5741
5961
  readableTexture.minFilter = texture.minFilter;
5742
5962
  readableTexture.magFilter = texture.magFilter;
5743
5963
  readableTexture.wrapS = texture.wrapS;
@@ -5883,22 +6103,22 @@ var WEBGL_CONSTANTS = {
5883
6103
  };
5884
6104
  var KHR_MESH_QUANTIZATION = "KHR_mesh_quantization";
5885
6105
  var THREE_TO_WEBGL = {};
5886
- THREE_TO_WEBGL[import_three17.NearestFilter] = WEBGL_CONSTANTS.NEAREST;
5887
- THREE_TO_WEBGL[import_three17.NearestMipmapNearestFilter] = WEBGL_CONSTANTS.NEAREST_MIPMAP_NEAREST;
5888
- THREE_TO_WEBGL[import_three17.NearestMipmapLinearFilter] = WEBGL_CONSTANTS.NEAREST_MIPMAP_LINEAR;
5889
- THREE_TO_WEBGL[import_three17.LinearFilter] = WEBGL_CONSTANTS.LINEAR;
5890
- THREE_TO_WEBGL[import_three17.LinearMipmapNearestFilter] = WEBGL_CONSTANTS.LINEAR_MIPMAP_NEAREST;
5891
- THREE_TO_WEBGL[import_three17.LinearMipmapLinearFilter] = WEBGL_CONSTANTS.LINEAR_MIPMAP_LINEAR;
5892
- THREE_TO_WEBGL[import_three17.ClampToEdgeWrapping] = WEBGL_CONSTANTS.CLAMP_TO_EDGE;
5893
- THREE_TO_WEBGL[import_three17.RepeatWrapping] = WEBGL_CONSTANTS.REPEAT;
5894
- THREE_TO_WEBGL[import_three17.MirroredRepeatWrapping] = WEBGL_CONSTANTS.MIRRORED_REPEAT;
6106
+ THREE_TO_WEBGL[import_three18.NearestFilter] = WEBGL_CONSTANTS.NEAREST;
6107
+ THREE_TO_WEBGL[import_three18.NearestMipmapNearestFilter] = WEBGL_CONSTANTS.NEAREST_MIPMAP_NEAREST;
6108
+ THREE_TO_WEBGL[import_three18.NearestMipmapLinearFilter] = WEBGL_CONSTANTS.NEAREST_MIPMAP_LINEAR;
6109
+ THREE_TO_WEBGL[import_three18.LinearFilter] = WEBGL_CONSTANTS.LINEAR;
6110
+ THREE_TO_WEBGL[import_three18.LinearMipmapNearestFilter] = WEBGL_CONSTANTS.LINEAR_MIPMAP_NEAREST;
6111
+ THREE_TO_WEBGL[import_three18.LinearMipmapLinearFilter] = WEBGL_CONSTANTS.LINEAR_MIPMAP_LINEAR;
6112
+ THREE_TO_WEBGL[import_three18.ClampToEdgeWrapping] = WEBGL_CONSTANTS.CLAMP_TO_EDGE;
6113
+ THREE_TO_WEBGL[import_three18.RepeatWrapping] = WEBGL_CONSTANTS.REPEAT;
6114
+ THREE_TO_WEBGL[import_three18.MirroredRepeatWrapping] = WEBGL_CONSTANTS.MIRRORED_REPEAT;
5895
6115
  var PATH_PROPERTIES = {
5896
6116
  scale: "scale",
5897
6117
  position: "translation",
5898
6118
  quaternion: "rotation",
5899
6119
  morphTargetInfluences: "weights"
5900
6120
  };
5901
- var DEFAULT_SPECULAR_COLOR = new import_three17.Color();
6121
+ var DEFAULT_SPECULAR_COLOR = new import_three18.Color();
5902
6122
  var GLB_HEADER_BYTES = 12;
5903
6123
  var GLB_HEADER_MAGIC = 1179937895;
5904
6124
  var GLB_VERSION = 2;
@@ -5932,7 +6152,7 @@ function getMinMax(attribute, start, count) {
5932
6152
  else if (a === 2) value = attribute.getZ(i);
5933
6153
  else if (a === 3) value = attribute.getW(i);
5934
6154
  if (attribute.normalized === true) {
5935
- value = import_three17.MathUtils.normalize(value, attribute.array);
6155
+ value = import_three18.MathUtils.normalize(value, attribute.array);
5936
6156
  }
5937
6157
  }
5938
6158
  output.min[a] = Math.min(output.min[a], value);
@@ -6138,7 +6358,7 @@ var GLTFWriter = class {
6138
6358
  isNormalizedNormalAttribute(normal) {
6139
6359
  const cache = this.cache;
6140
6360
  if (cache.attributesNormalized.has(normal)) return false;
6141
- const v = new import_three17.Vector3();
6361
+ const v = new import_three18.Vector3();
6142
6362
  for (let i = 0, il = normal.count; i < il; i++) {
6143
6363
  if (Math.abs(v.fromBufferAttribute(normal, i).length() - 1) > 5e-4) return false;
6144
6364
  }
@@ -6155,7 +6375,7 @@ var GLTFWriter = class {
6155
6375
  const cache = this.cache;
6156
6376
  if (cache.attributesNormalized.has(normal)) return cache.attributesNormalized.get(normal);
6157
6377
  const attribute = normal.clone();
6158
- const v = new import_three17.Vector3();
6378
+ const v = new import_three18.Vector3();
6159
6379
  for (let i = 0, il = attribute.count; i < il; i++) {
6160
6380
  v.fromBufferAttribute(attribute, i);
6161
6381
  if (v.x === 0 && v.y === 0 && v.z === 0) {
@@ -6199,7 +6419,7 @@ var GLTFWriter = class {
6199
6419
  buildMetalRoughTexture(metalnessMap, roughnessMap) {
6200
6420
  if (metalnessMap === roughnessMap) return metalnessMap;
6201
6421
  function getEncodingConversion(map) {
6202
- if (map.colorSpace === import_three17.SRGBColorSpace) {
6422
+ if (map.colorSpace === import_three18.SRGBColorSpace) {
6203
6423
  return function SRGBToLinear(c) {
6204
6424
  return c < 0.04045 ? c * 0.0773993808 : Math.pow(c * 0.9478672986 + 0.0521327014, 2.4);
6205
6425
  };
@@ -6209,10 +6429,10 @@ var GLTFWriter = class {
6209
6429
  };
6210
6430
  }
6211
6431
  console.warn("THREE.GLTFExporter: Merged metalnessMap and roughnessMap textures.");
6212
- if (metalnessMap instanceof import_three17.CompressedTexture) {
6432
+ if (metalnessMap instanceof import_three18.CompressedTexture) {
6213
6433
  metalnessMap = decompress(metalnessMap);
6214
6434
  }
6215
- if (roughnessMap instanceof import_three17.CompressedTexture) {
6435
+ if (roughnessMap instanceof import_three18.CompressedTexture) {
6216
6436
  roughnessMap = decompress(roughnessMap);
6217
6437
  }
6218
6438
  const metalness = metalnessMap ? metalnessMap.image : null;
@@ -6245,8 +6465,8 @@ var GLTFWriter = class {
6245
6465
  context.putImageData(composite, 0, 0);
6246
6466
  const reference = metalnessMap || roughnessMap;
6247
6467
  const texture = reference.clone();
6248
- texture.source = new import_three17.Source(canvas);
6249
- texture.colorSpace = import_three17.NoColorSpace;
6468
+ texture.source = new import_three18.Source(canvas);
6469
+ texture.colorSpace = import_three18.NoColorSpace;
6250
6470
  texture.channel = (metalnessMap || roughnessMap).channel;
6251
6471
  if (metalnessMap && roughnessMap && metalnessMap.channel !== roughnessMap.channel) {
6252
6472
  console.warn("THREE.GLTFExporter: UV channels for metalnessMap and roughnessMap textures must match.");
@@ -6304,7 +6524,7 @@ var GLTFWriter = class {
6304
6524
  else if (a === 2) value = attribute.getZ(i);
6305
6525
  else if (a === 3) value = attribute.getW(i);
6306
6526
  if (attribute.normalized === true) {
6307
- value = import_three17.MathUtils.normalize(value, attribute.array);
6527
+ value = import_three18.MathUtils.normalize(value, attribute.array);
6308
6528
  }
6309
6529
  }
6310
6530
  if (componentType === WEBGL_CONSTANTS.FLOAT) {
@@ -6454,7 +6674,7 @@ var GLTFWriter = class {
6454
6674
  ctx.scale(1, -1);
6455
6675
  }
6456
6676
  if (image.data !== void 0) {
6457
- if (format !== import_three17.RGBAFormat) {
6677
+ if (format !== import_three18.RGBAFormat) {
6458
6678
  console.error("GLTFExporter: Only RGBAFormat is supported.", format);
6459
6679
  }
6460
6680
  if (image.width > options.maxTextureSize || image.height > options.maxTextureSize) {
@@ -6523,7 +6743,7 @@ var GLTFWriter = class {
6523
6743
  const json = this.json;
6524
6744
  if (cache.textures.has(map)) return cache.textures.get(map);
6525
6745
  if (!json.textures) json.textures = [];
6526
- if (map instanceof import_three17.CompressedTexture) {
6746
+ if (map instanceof import_three18.CompressedTexture) {
6527
6747
  map = decompress(map, options.maxTextureSize);
6528
6748
  }
6529
6749
  let mimeType = map.userData.mimeType;
@@ -6631,7 +6851,7 @@ var GLTFWriter = class {
6631
6851
  materialDef.alphaCutoff = material.alphaTest;
6632
6852
  }
6633
6853
  }
6634
- if (material.side === import_three17.DoubleSide) materialDef.doubleSided = true;
6854
+ if (material.side === import_three18.DoubleSide) materialDef.doubleSided = true;
6635
6855
  if (material.name !== "") materialDef.name = material.name;
6636
6856
  this.serializeUserData(material, materialDef);
6637
6857
  this._invokeAll(function(ext) {
@@ -6705,7 +6925,7 @@ var GLTFWriter = class {
6705
6925
  const array = attribute.array;
6706
6926
  if (attributeName === "JOINTS_0" && !(array instanceof Uint16Array) && !(array instanceof Uint8Array)) {
6707
6927
  console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.');
6708
- modifiedAttribute = new import_three17.BufferAttribute(new Uint16Array(array), attribute.itemSize, attribute.normalized);
6928
+ modifiedAttribute = new import_three18.BufferAttribute(new Uint16Array(array), attribute.itemSize, attribute.normalized);
6709
6929
  }
6710
6930
  const accessor = this.processAccessor(modifiedAttribute || attribute, geometry);
6711
6931
  if (accessor !== null) {
@@ -6865,7 +7085,7 @@ var GLTFWriter = class {
6865
7085
  } else {
6866
7086
  cameraDef.perspective = {
6867
7087
  aspectRatio: camera.aspect,
6868
- yfov: import_three17.MathUtils.degToRad(camera.fov),
7088
+ yfov: import_three18.MathUtils.degToRad(camera.fov),
6869
7089
  zfar: camera.far <= 0 ? 1e-3 : camera.far,
6870
7090
  znear: camera.near < 0 ? 0 : camera.near
6871
7091
  };
@@ -6893,8 +7113,8 @@ var GLTFWriter = class {
6893
7113
  const samplers = [];
6894
7114
  for (let i = 0; i < tracks.length; ++i) {
6895
7115
  const track = tracks[i];
6896
- const trackBinding = import_three17.PropertyBinding.parseTrackName(track.name);
6897
- let trackNode = import_three17.PropertyBinding.findNode(root, trackBinding.nodeName);
7116
+ const trackBinding = import_three18.PropertyBinding.parseTrackName(track.name);
7117
+ let trackNode = import_three18.PropertyBinding.findNode(root, trackBinding.nodeName);
6898
7118
  const trackProperty = PATH_PROPERTIES[trackBinding.propertyName];
6899
7119
  if (trackBinding.objectName === "bones") {
6900
7120
  if (trackNode.isSkinnedMesh === true) {
@@ -6916,14 +7136,14 @@ var GLTFWriter = class {
6916
7136
  if (track.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline === true) {
6917
7137
  interpolation = "CUBICSPLINE";
6918
7138
  outputItemSize /= 3;
6919
- } else if (track.getInterpolation() === import_three17.InterpolateDiscrete) {
7139
+ } else if (track.getInterpolation() === import_three18.InterpolateDiscrete) {
6920
7140
  interpolation = "STEP";
6921
7141
  } else {
6922
7142
  interpolation = "LINEAR";
6923
7143
  }
6924
7144
  samplers.push({
6925
- input: this.processAccessor(new import_three17.BufferAttribute(track.times, inputItemSize)),
6926
- output: this.processAccessor(new import_three17.BufferAttribute(track.values, outputItemSize)),
7145
+ input: this.processAccessor(new import_three18.BufferAttribute(track.times, inputItemSize)),
7146
+ output: this.processAccessor(new import_three18.BufferAttribute(track.values, outputItemSize)),
6927
7147
  interpolation
6928
7148
  });
6929
7149
  channels.push({
@@ -6955,7 +7175,7 @@ var GLTFWriter = class {
6955
7175
  if (rootJoint === void 0) return null;
6956
7176
  const joints = [];
6957
7177
  const inverseBindMatrices = new Float32Array(skeleton.bones.length * 16);
6958
- const temporaryBoneInverse = new import_three17.Matrix4();
7178
+ const temporaryBoneInverse = new import_three18.Matrix4();
6959
7179
  for (let i = 0; i < skeleton.bones.length; ++i) {
6960
7180
  joints.push(nodeMap.get(skeleton.bones[i]));
6961
7181
  temporaryBoneInverse.copy(skeleton.boneInverses[i]);
@@ -6963,7 +7183,7 @@ var GLTFWriter = class {
6963
7183
  }
6964
7184
  if (json.skins === void 0) json.skins = [];
6965
7185
  json.skins.push({
6966
- inverseBindMatrices: this.processAccessor(new import_three17.BufferAttribute(inverseBindMatrices, 16)),
7186
+ inverseBindMatrices: this.processAccessor(new import_three18.BufferAttribute(inverseBindMatrices, 16)),
6967
7187
  joints,
6968
7188
  skeleton: nodeMap.get(rootJoint)
6969
7189
  });
@@ -7059,7 +7279,7 @@ var GLTFWriter = class {
7059
7279
  * @param {Array} objects List of objects to process
7060
7280
  */
7061
7281
  processObjects(objects) {
7062
- const scene = new import_three17.Scene();
7282
+ const scene = new import_three18.Scene();
7063
7283
  scene.name = "AuxScene";
7064
7284
  for (let i = 0; i < objects.length; i++) {
7065
7285
  scene.children.push(objects[i]);
@@ -7077,7 +7297,7 @@ var GLTFWriter = class {
7077
7297
  });
7078
7298
  const objectsWithoutScene = [];
7079
7299
  for (let i = 0; i < input.length; i++) {
7080
- if (input[i] instanceof import_three17.Scene) {
7300
+ if (input[i] instanceof import_three18.Scene) {
7081
7301
  this.processScene(input[i]);
7082
7302
  } else {
7083
7303
  objectsWithoutScene.push(input[i]);
@@ -7421,10 +7641,10 @@ var GLTFMeshGpuInstancing = class {
7421
7641
  const translationAttr = new Float32Array(mesh.count * 3);
7422
7642
  const rotationAttr = new Float32Array(mesh.count * 4);
7423
7643
  const scaleAttr = new Float32Array(mesh.count * 3);
7424
- const matrix = new import_three17.Matrix4();
7425
- const position = new import_three17.Vector3();
7426
- const quaternion = new import_three17.Quaternion();
7427
- const scale = new import_three17.Vector3();
7644
+ const matrix = new import_three18.Matrix4();
7645
+ const position = new import_three18.Vector3();
7646
+ const quaternion = new import_three18.Quaternion();
7647
+ const scale = new import_three18.Vector3();
7428
7648
  for (let i = 0; i < mesh.count; i++) {
7429
7649
  mesh.getMatrixAt(i, matrix);
7430
7650
  matrix.decompose(position, quaternion, scale);
@@ -7433,9 +7653,9 @@ var GLTFMeshGpuInstancing = class {
7433
7653
  scale.toArray(scaleAttr, i * 3);
7434
7654
  }
7435
7655
  const attributes = {
7436
- TRANSLATION: writer.processAccessor(new import_three17.BufferAttribute(translationAttr, 3)),
7437
- ROTATION: writer.processAccessor(new import_three17.BufferAttribute(rotationAttr, 4)),
7438
- SCALE: writer.processAccessor(new import_three17.BufferAttribute(scaleAttr, 3))
7656
+ TRANSLATION: writer.processAccessor(new import_three18.BufferAttribute(translationAttr, 3)),
7657
+ ROTATION: writer.processAccessor(new import_three18.BufferAttribute(rotationAttr, 4)),
7658
+ SCALE: writer.processAccessor(new import_three18.BufferAttribute(scaleAttr, 3))
7439
7659
  };
7440
7660
  if (mesh.instanceColor)
7441
7661
  attributes._COLOR_0 = writer.processAccessor(mesh.instanceColor);
@@ -7500,8 +7720,8 @@ GLTFExporter.Utils = {
7500
7720
  const sourceTracks = clip.tracks;
7501
7721
  for (let i = 0; i < sourceTracks.length; ++i) {
7502
7722
  let sourceTrack = sourceTracks[i];
7503
- const sourceTrackBinding = import_three17.PropertyBinding.parseTrackName(sourceTrack.name);
7504
- const sourceTrackNode = import_three17.PropertyBinding.findNode(root, sourceTrackBinding.nodeName);
7723
+ const sourceTrackBinding = import_three18.PropertyBinding.parseTrackName(sourceTrack.name);
7724
+ const sourceTrackNode = import_three18.PropertyBinding.findNode(root, sourceTrackBinding.nodeName);
7505
7725
  if (sourceTrackBinding.propertyName !== "morphTargetInfluences" || sourceTrackBinding.propertyIndex === void 0) {
7506
7726
  tracks.push(sourceTrack);
7507
7727
  continue;
@@ -7512,7 +7732,7 @@ GLTFExporter.Utils = {
7512
7732
  }
7513
7733
  console.warn("THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead.");
7514
7734
  sourceTrack = sourceTrack.clone();
7515
- sourceTrack.setInterpolation(import_three17.InterpolateLinear);
7735
+ sourceTrack.setInterpolation(import_three18.InterpolateLinear);
7516
7736
  }
7517
7737
  const targetCount = sourceTrackNode.morphTargetInfluences.length;
7518
7738
  const targetIndex = sourceTrackNode.morphTargetDictionary[sourceTrackBinding.propertyIndex];
@@ -7595,10 +7815,10 @@ var SceneExporter = class {
7595
7815
  }
7596
7816
  };
7597
7817
  function localMatrix(object) {
7598
- return object.matrixAutoUpdate ? new import_three18.Matrix4().compose(object.position, object.quaternion, object.scale) : object.matrix.clone();
7818
+ return object.matrixAutoUpdate ? new import_three19.Matrix4().compose(object.position, object.quaternion, object.scale) : object.matrix.clone();
7599
7819
  }
7600
7820
  function createSnapshot(root, gltf, bakeColors = false) {
7601
- const scene = new import_three18.Scene();
7821
+ const scene = new import_three19.Scene();
7602
7822
  const geometries = [];
7603
7823
  const materials = [];
7604
7824
  const textures = [];
@@ -7616,7 +7836,7 @@ function createSnapshot(root, gltf, bakeColors = false) {
7616
7836
  if (!uniforms.map?.value?.isTexture || !uniforms.SHADE || !uniforms.BRIGHTNESS || !uniforms.EMISSIVE) {
7617
7837
  throw new MineRenderError("glTF export does not support this custom ShaderMaterial");
7618
7838
  }
7619
- material = new import_three18.MeshBasicMaterial({
7839
+ material = new import_three19.MeshBasicMaterial({
7620
7840
  map: uniforms.map.value,
7621
7841
  vertexColors: source.vertexColors,
7622
7842
  transparent: source.transparent,
@@ -7626,7 +7846,7 @@ function createSnapshot(root, gltf, bakeColors = false) {
7626
7846
  });
7627
7847
  material.name = source.name;
7628
7848
  } else if (shader.isShaderMaterial) {
7629
- material = new import_three18.MeshBasicMaterial({ vertexColors: source.vertexColors });
7849
+ material = new import_three19.MeshBasicMaterial({ vertexColors: source.vertexColors });
7630
7850
  material.name = source.name;
7631
7851
  } else {
7632
7852
  const copySource = Object.create(source);
@@ -7680,11 +7900,11 @@ function createSnapshot(root, gltf, bakeColors = false) {
7680
7900
  const material = copyMaterial(sourceMaterial, geometry);
7681
7901
  if (!sourceMaterial.vertexColors) geometry.deleteAttribute("color");
7682
7902
  if (bakeColors || instanceColor) {
7683
- const tint = (material.color ?? new import_three18.Color()).clone();
7903
+ const tint = (material.color ?? new import_three19.Color()).clone();
7684
7904
  if (instanceColor) tint.multiply(instanceColor);
7685
7905
  if (bakeColors) {
7686
7906
  const original = geometry.getAttribute("color");
7687
- const colors = new import_three18.Float32BufferAttribute(new Float32Array(geometry.getAttribute("position").count * 3), 3);
7907
+ const colors = new import_three19.Float32BufferAttribute(new Float32Array(geometry.getAttribute("position").count * 3), 3);
7688
7908
  for (let i = 0; i < colors.count; i++) {
7689
7909
  colors.setXYZ(i, (original?.getX(i) ?? 1) * tint.r, (original?.getY(i) ?? 1) * tint.g, (original?.getZ(i) ?? 1) * tint.b);
7690
7910
  }
@@ -7693,7 +7913,7 @@ function createSnapshot(root, gltf, bakeColors = false) {
7693
7913
  material.color.copy(tint);
7694
7914
  }
7695
7915
  }
7696
- const copy = new import_three18.Mesh(geometry, material);
7916
+ const copy = new import_three19.Mesh(geometry, material);
7697
7917
  copy.name = mesh.name;
7698
7918
  copy.renderOrder = mesh.renderOrder;
7699
7919
  scene.add(copy);
@@ -7707,9 +7927,9 @@ function createSnapshot(root, gltf, bakeColors = false) {
7707
7927
  const instanced = mesh;
7708
7928
  if (instanced.isInstancedMesh) {
7709
7929
  for (let i = 0; i < instanced.count; i++) {
7710
- const matrix = new import_three18.Matrix4();
7930
+ const matrix = new import_three19.Matrix4();
7711
7931
  instanced.getMatrixAt(i, matrix);
7712
- const color = instanced.instanceColor ? new import_three18.Color().fromBufferAttribute(instanced.instanceColor, i) : void 0;
7932
+ const color = instanced.instanceColor ? new import_three19.Color().fromBufferAttribute(instanced.instanceColor, i) : void 0;
7713
7933
  addMesh(mesh, world.clone().multiply(matrix), color);
7714
7934
  }
7715
7935
  } else {
@@ -7721,7 +7941,7 @@ function createSnapshot(root, gltf, bakeColors = false) {
7721
7941
  try {
7722
7942
  const ancestors = [];
7723
7943
  for (let parent = root.parent; parent; parent = parent.parent) ancestors.unshift(parent);
7724
- const world = new import_three18.Matrix4();
7944
+ const world = new import_three19.Matrix4();
7725
7945
  for (const ancestor of ancestors) {
7726
7946
  if (!ancestor.visible) return { scene, dispose };
7727
7947
  world.multiply(localMatrix(ancestor));
@@ -7735,7 +7955,7 @@ function createSnapshot(root, gltf, bakeColors = false) {
7735
7955
  }
7736
7956
  function selectAlphaMode(material, geometry) {
7737
7957
  const texture = material.map;
7738
- if (material.type !== "MeshBasicMaterial" || !material.transparent || !material.depthWrite || material.opacity !== 1 || material.alphaMap || !texture?.isDataTexture || texture.format !== import_three18.RGBAFormat || texture.type !== import_three18.UnsignedByteType || texture.wrapS !== import_three18.ClampToEdgeWrapping || texture.wrapT !== import_three18.ClampToEdgeWrapping || texture.magFilter !== import_three18.NearestFilter || texture.minFilter !== import_three18.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;
7958
+ 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;
7739
7959
  const uv = geometry.getAttribute(texture.channel === 0 ? "uv" : `uv${texture.channel}`);
7740
7960
  const colors = geometry.getAttribute("color");
7741
7961
  if (!uv || material.vertexColors && colors?.itemSize === 4) return;
@@ -7772,7 +7992,7 @@ function selectAlphaMode(material, geometry) {
7772
7992
  }
7773
7993
  function copyDataTexture(source) {
7774
7994
  const image = source.image;
7775
- if (source.format !== import_three18.RGBAFormat || source.type !== import_three18.UnsignedByteType) {
7995
+ if (source.format !== import_three19.RGBAFormat || source.type !== import_three19.UnsignedByteType) {
7776
7996
  throw new MineRenderError("glTF export requires RGBA unsigned-byte data textures");
7777
7997
  }
7778
7998
  const canvas = createCanvas(image.width, image.height);
@@ -7783,8 +8003,8 @@ function copyDataTexture(source) {
7783
8003
  context.putImageData(pixels, 0, 0);
7784
8004
  const copySource = Object.create(source);
7785
8005
  copySource.userData = {};
7786
- copySource.source = new import_three18.Source(canvas);
7787
- return new import_three18.Texture().copy(copySource);
8006
+ copySource.source = new import_three19.Source(canvas);
8007
+ return new import_three19.Texture().copy(copySource);
7788
8008
  }
7789
8009
 
7790
8010
  // src/gui/GuiHelper.ts
@@ -7854,7 +8074,7 @@ var GuiHelper = class {
7854
8074
  };
7855
8075
 
7856
8076
  // src/gui/scene/GuiObject.ts
7857
- var import_three22 = require("three");
8077
+ var import_three23 = require("three");
7858
8078
  init_AssetKey();
7859
8079
  init_ModelTextures();
7860
8080
  init_Models();
@@ -7878,7 +8098,7 @@ var GuiObject = class extends SceneObject {
7878
8098
  this.textureLayers = textureLayers;
7879
8099
  this.isGuiObject = true;
7880
8100
  /** Local bounds in GUI pixels, with y growing down from the origin. */
7881
- this.bounds = new import_three22.Box2();
8101
+ this.bounds = new import_three23.Box2();
7882
8102
  this.geometries = /* @__PURE__ */ new Set();
7883
8103
  this.ownedMaterials = /* @__PURE__ */ new Set();
7884
8104
  this.initialized = false;
@@ -7895,7 +8115,7 @@ var GuiObject = class extends SceneObject {
7895
8115
  item.position.set(x + width2 / 2, -y - height2 / 2, 0);
7896
8116
  item.scale.set(width2 / 16, height2 / 16, width2 / 16);
7897
8117
  item.updateMatrix();
7898
- const bounds = new import_three22.Box3();
8118
+ const bounds = new import_three23.Box3();
7899
8119
  item.iterateAllMeshes((mesh2) => {
7900
8120
  mesh2.geometry.computeBoundingBox();
7901
8121
  bounds.union(mesh2.geometry.boundingBox);
@@ -7903,10 +8123,10 @@ var GuiObject = class extends SceneObject {
7903
8123
  bounds.applyMatrix4(item.matrix);
7904
8124
  item.position.z = depth - bounds.min.z;
7905
8125
  depth += bounds.max.z - bounds.min.z + 0.01;
7906
- this.bounds.expandByPoint(new import_three22.Vector2(x, y));
7907
- this.bounds.expandByPoint(new import_three22.Vector2(x + width2, y + height2));
7908
- this.bounds.expandByPoint(new import_three22.Vector2(bounds.min.x, -bounds.max.y));
7909
- this.bounds.expandByPoint(new import_three22.Vector2(bounds.max.x, -bounds.min.y));
8126
+ this.bounds.expandByPoint(new import_three23.Vector2(x, y));
8127
+ this.bounds.expandByPoint(new import_three23.Vector2(x + width2, y + height2));
8128
+ this.bounds.expandByPoint(new import_three23.Vector2(bounds.min.x, -bounds.max.y));
8129
+ this.bounds.expandByPoint(new import_three23.Vector2(bounds.max.x, -bounds.min.y));
7910
8130
  continue;
7911
8131
  }
7912
8132
  const key = typeof layer.texture === "string" ? AssetKey.parse("textures", layer.texture) : layer.texture;
@@ -7914,7 +8134,7 @@ var GuiObject = class extends SceneObject {
7914
8134
  const image = material.map.image;
7915
8135
  const [cropX, cropY, cropWidth, cropHeight] = layer.crop ?? [0, 0, image.width, image.height];
7916
8136
  const [width, height] = layer.size ?? [cropWidth, cropHeight];
7917
- const geometry = new import_three22.PlaneGeometry(width, height);
8137
+ const geometry = new import_three23.PlaneGeometry(width, height);
7918
8138
  this.geometries.add(geometry);
7919
8139
  const uv = geometry.getAttribute("uv");
7920
8140
  for (let i = 0; i < uv.count; i++) {
@@ -7924,13 +8144,13 @@ var GuiObject = class extends SceneObject {
7924
8144
  1 - (cropY + (1 - uv.getY(i)) * cropHeight) / image.height
7925
8145
  );
7926
8146
  }
7927
- const mesh = new import_three22.Mesh(geometry, material);
8147
+ const mesh = new import_three23.Mesh(geometry, material);
7928
8148
  mesh.name = `mesh:${layer.name ?? index}`;
7929
8149
  mesh.position.set(x + width / 2, -y - height / 2, depth);
7930
8150
  mesh.renderOrder = index;
7931
8151
  this.add(mesh);
7932
- this.bounds.expandByPoint(new import_three22.Vector2(x, y));
7933
- this.bounds.expandByPoint(new import_three22.Vector2(x + width, y + height));
8152
+ this.bounds.expandByPoint(new import_three23.Vector2(x, y));
8153
+ this.bounds.expandByPoint(new import_three23.Vector2(x + width, y + height));
7934
8154
  depth += 0.01;
7935
8155
  }
7936
8156
  for (const child of this.children) child.position.z -= depth - 0.01;
@@ -8005,7 +8225,7 @@ function isGuiObject(obj) {
8005
8225
  init_image();
8006
8226
 
8007
8227
  // src/inspector/SceneInspector.ts
8008
- var import_three23 = require("three");
8228
+ var import_three24 = require("three");
8009
8229
  init_SceneObject();
8010
8230
  init_util();
8011
8231
  init_log();
@@ -8015,11 +8235,11 @@ var help = "<span>Ctrl/Cmd+Click to Select<br/></span><br/>";
8015
8235
  var SceneInspector = class {
8016
8236
  constructor(renderer) {
8017
8237
  this.renderer = renderer;
8018
- this.mouse = new import_three23.Vector2();
8238
+ this.mouse = new import_three24.Vector2();
8019
8239
  this.listeners = new AbortController();
8020
8240
  this.objectInfoContainer = document.createElement("div");
8021
8241
  this.objectControlsContainer = document.createElement("div");
8022
- this.raycaster = new import_three23.Raycaster();
8242
+ this.raycaster = new import_three24.Raycaster();
8023
8243
  this.init();
8024
8244
  }
8025
8245
  init() {
@@ -8435,7 +8655,7 @@ init_ModelGenerator();
8435
8655
  init_ModelMerger();
8436
8656
 
8437
8657
  // src/model/block/BlockStateResolver.ts
8438
- var import_three25 = require("three");
8658
+ var import_three26 = require("three");
8439
8659
  init_BlockStates();
8440
8660
  init_MineRenderError();
8441
8661
  init_util();
@@ -8513,7 +8733,7 @@ var BlockStateResolver = class {
8513
8733
  return variants[variants.length - 1];
8514
8734
  }
8515
8735
  static rotation(variant) {
8516
- const rotation = new import_three25.Euler();
8736
+ const rotation = new import_three26.Euler();
8517
8737
  if (typeof variant.x !== "undefined") {
8518
8738
  rotation.x = toRadians(clampRotationDegrees(variant.x));
8519
8739
  }
@@ -8620,7 +8840,7 @@ init_SceneObject();
8620
8840
  init_ModelObject();
8621
8841
  init_Models();
8622
8842
  var import_ts_deepmerge6 = __toESM(require_dist());
8623
- var import_three28 = require("three");
8843
+ var import_three29 = require("three");
8624
8844
  init_MineRenderError();
8625
8845
  init_InstanceReference();
8626
8846
  init_AssetKey();
@@ -8640,6 +8860,9 @@ var _BlockObject = class _BlockObject extends SceneObject {
8640
8860
  this._variants = [];
8641
8861
  this._models = [];
8642
8862
  this._cullMask = 0;
8863
+ this._entities = [];
8864
+ this._entityPlacement = new import_three29.Matrix4();
8865
+ this._entityGeneration = 0;
8643
8866
  this.options = (0, import_ts_deepmerge6.default)({}, _BlockObject.DEFAULT_OPTIONS, options ?? {});
8644
8867
  }
8645
8868
  async init() {
@@ -8659,6 +8882,8 @@ var _BlockObject = class _BlockObject extends SceneObject {
8659
8882
  }
8660
8883
  clearModels() {
8661
8884
  this.removeModels(this._models.splice(0));
8885
+ this._entityGeneration++;
8886
+ this.removeEntities(this._entities.splice(0));
8662
8887
  this._fluidKey = void 0;
8663
8888
  this._fluidModel = void 0;
8664
8889
  this._isInstanced = false;
@@ -8670,6 +8895,57 @@ var _BlockObject = class _BlockObject extends SceneObject {
8670
8895
  if (!isInstanceReference(model)) model.dispose();
8671
8896
  }
8672
8897
  }
8898
+ removeEntities(entities) {
8899
+ for (const entity of entities) {
8900
+ entity.removeFromScene();
8901
+ entity.dispose();
8902
+ }
8903
+ }
8904
+ /** Entity models drawn for this block instead of its block model; they are scene children, unlike the block. */
8905
+ get blockEntities() {
8906
+ return this._entities;
8907
+ }
8908
+ /**
8909
+ * Draws the block through the dataset's block-entity index. Returns false, leaving nothing behind,
8910
+ * when the block is not listed or one of its models cannot be loaded.
8911
+ */
8912
+ async createBlockEntities() {
8913
+ const key = this.blockState.key;
8914
+ if (!key || this.options.displayPosition) return false;
8915
+ const generation = this._entityGeneration;
8916
+ const created = [];
8917
+ let resolved;
8918
+ try {
8919
+ resolved = BlockEntities.resolve(await BlockEntities.getIndex(key.root), key.toNamespacedString(), this.state);
8920
+ if (!resolved) return false;
8921
+ for (const part of resolved.parts) {
8922
+ const [namespace, path] = part.model.includes(":") ? part.model.split(":") : [key.namespace, part.model];
8923
+ const texture = part.textureLocation === void 0 ? void 0 : AssetKey.parse("textures", part.textureLocation.replace(/^([^:]+:)?textures\//, "$1"));
8924
+ if (texture) texture.root = key.root;
8925
+ const entity = await Entities.getEntity(new BasicAssetKey(namespace, path), texture, { layer: part.layer });
8926
+ if (!entity) throw new MineRenderError(`Missing entity model ${part.model}`);
8927
+ created.push(await this.scene.addEntity(entity, { wireframe: this.options.wireframe }));
8928
+ }
8929
+ } catch (error) {
8930
+ console.warn(`Could not draw block entity ${key.toNamespacedString()}, using its block model`, error);
8931
+ this.removeEntities(created);
8932
+ return false;
8933
+ }
8934
+ if (generation !== this._entityGeneration) {
8935
+ this.removeEntities(created);
8936
+ return true;
8937
+ }
8938
+ BlockEntities.matrix(resolved, this._entityPlacement);
8939
+ this._entities = created;
8940
+ this.placeEntities();
8941
+ return true;
8942
+ }
8943
+ placeEntities() {
8944
+ const matrix = new import_three29.Matrix4().makeTranslation(this.position.x - 8, this.position.y - 8, this.position.z - 8).multiply(this._entityPlacement);
8945
+ for (const entity of this._entities) {
8946
+ matrix.decompose(entity.position, entity.quaternion, entity.scale);
8947
+ }
8948
+ }
8673
8949
  get isOccluding() {
8674
8950
  return this._models.some((model) => {
8675
8951
  const object = isInstanceReference(model) ? model.instanceable : model;
@@ -8684,12 +8960,12 @@ var _BlockObject = class _BlockObject extends SceneObject {
8684
8960
  getModelCullMask(model, worldMask) {
8685
8961
  const object = isInstanceReference(model) ? model.instanceable : model;
8686
8962
  if (object.options.displayPosition) return 0;
8687
- const position = new import_three28.Vector3();
8688
- const rotation = new import_three28.Quaternion();
8689
- const scale = new import_three28.Vector3();
8963
+ const position = new import_three29.Vector3();
8964
+ const rotation = new import_three29.Quaternion();
8965
+ const scale = new import_three29.Vector3();
8690
8966
  this.getModelMatrix(model).decompose(position, rotation, scale);
8691
- if (position.distanceToSquared(this.position) > 1e-10 || scale.distanceToSquared(new import_three28.Vector3(1, 1, 1)) > 1e-10) return 0;
8692
- return ModelCulling.toLocalMask(worldMask, new import_three28.Euler().setFromQuaternion(rotation));
8967
+ if (position.distanceToSquared(this.position) > 1e-10 || scale.distanceToSquared(new import_three29.Vector3(1, 1, 1)) > 1e-10) return 0;
8968
+ return ModelCulling.toLocalMask(worldMask, new import_three29.Euler().setFromQuaternion(rotation));
8693
8969
  }
8694
8970
  async setCullMask(worldMask) {
8695
8971
  worldMask &= 63;
@@ -8751,7 +9027,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
8751
9027
  () => new FluidModelObject2(kind, surface.sample, this.blockState.key, this.options)
8752
9028
  );
8753
9029
  const previous = this._fluidModel;
8754
- const matrix = previous ? this.getModelMatrix(previous) : new import_three28.Matrix4().makeTranslation(...this.position.toArray());
9030
+ const matrix = previous ? this.getModelMatrix(previous) : new import_three29.Matrix4().makeTranslation(...this.position.toArray());
8755
9031
  if (isInstanceReference(replacement)) replacement.setMatrix(matrix);
8756
9032
  else matrix.decompose(replacement.position, replacement.quaternion, replacement.scale);
8757
9033
  this._models = this._models.filter((model) => model !== previous);
@@ -8781,13 +9057,20 @@ var _BlockObject = class _BlockObject extends SceneObject {
8781
9057
  await this.updateFluid(this._fluidSampler);
8782
9058
  return;
8783
9059
  }
9060
+ const hasEntities = await this.createBlockEntities();
8784
9061
  const variantsToCreate = await this.mapStateToVariant(this.state);
8785
9062
  this._variants = variantsToCreate;
8786
9063
  for (let blockStateVariant of variantsToCreate) {
9064
+ if (hasEntities && !await this.hasGeometry(blockStateVariant)) continue;
8787
9065
  this._models.push(await this.createVariant(blockStateVariant));
8788
9066
  }
8789
9067
  await this.updateFluid(this._fluidSampler);
8790
9068
  }
9069
+ async hasGeometry(variant) {
9070
+ const modelKey = AssetKey.parse("models", variant.model);
9071
+ modelKey.root = this.blockState.key?.root;
9072
+ return !!(await Models.getMerged(modelKey))?.elements?.length;
9073
+ }
8791
9074
  getSingleVariant(variants) {
8792
9075
  return BlockStateResolver.choose(variants);
8793
9076
  }
@@ -8882,7 +9165,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
8882
9165
  setPositionRotationScaleAt(index, position, rotation, scale) {
8883
9166
  super.setPositionRotationScaleAt(index, position, rotation, scale);
8884
9167
  }
8885
- getMatrixAt(index, matrix = new import_three28.Matrix4()) {
9168
+ getMatrixAt(index, matrix = new import_three29.Matrix4()) {
8886
9169
  if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
8887
9170
  const child = this._models[0];
8888
9171
  if (child && isModelObject(child)) {
@@ -8907,6 +9190,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
8907
9190
  for (let model of this._models) {
8908
9191
  model.setPosition(position);
8909
9192
  }
9193
+ this.placeEntities();
8910
9194
  this.notifyDirty();
8911
9195
  }
8912
9196
  //TODO: should override rotation + scale methods
@@ -10752,7 +11036,7 @@ init_ModelObject();
10752
11036
  init_nbt();
10753
11037
 
10754
11038
  // src/renderer/MineRenderScene.ts
10755
- var import_three30 = require("three");
11039
+ var import_three31 = require("three");
10756
11040
  init_SceneObject();
10757
11041
  var import_ts_deepmerge8 = __toESM(require_dist());
10758
11042
  init_ModelObject();
@@ -11485,7 +11769,7 @@ var import_ts_deepmerge7 = __toESM(require_dist());
11485
11769
  init_util();
11486
11770
 
11487
11771
  // src/skin/SkinTextures.ts
11488
- var import_three29 = require("three");
11772
+ var import_three30 = require("three");
11489
11773
  init_Caching();
11490
11774
  init_CacheKey();
11491
11775
  init_MineRenderError();
@@ -11569,11 +11853,11 @@ var SkinTextures = class {
11569
11853
  });
11570
11854
  }
11571
11855
  static createMaterial(pixels, width, height, transparent = true) {
11572
- const texture = Textures.initTextureProps(new import_three29.DataTexture(pixels, width, height));
11573
- texture.colorSpace = import_three29.SRGBColorSpace;
11856
+ const texture = Textures.initTextureProps(new import_three30.DataTexture(pixels, width, height));
11857
+ texture.colorSpace = import_three30.SRGBColorSpace;
11574
11858
  texture.flipY = true;
11575
11859
  texture.needsUpdate = true;
11576
- return new import_three29.MeshBasicMaterial({ map: texture, transparent, side: transparent ? import_three29.DoubleSide : import_three29.FrontSide, alphaTest: transparent ? 0.1 : 0 });
11860
+ return new import_three30.MeshBasicMaterial({ map: texture, transparent, side: transparent ? import_three30.DoubleSide : import_three30.FrontSide, alphaTest: transparent ? 0.1 : 0 });
11577
11861
  }
11578
11862
  static isSlim(image, scale) {
11579
11863
  for (const [x, y] of [[46, 52], [54, 20]]) {
@@ -11801,7 +12085,7 @@ var SkinObject = class extends SceneObject {
11801
12085
  };
11802
12086
 
11803
12087
  // src/renderer/MineRenderScene.ts
11804
- var _MineRenderScene = class _MineRenderScene extends import_three30.Scene {
12088
+ var _MineRenderScene = class _MineRenderScene extends import_three31.Scene {
11805
12089
  constructor(options) {
11806
12090
  super();
11807
12091
  this.isMineRenderScene = true;
@@ -11928,7 +12212,7 @@ function isMineRenderScene(obj) {
11928
12212
  }
11929
12213
 
11930
12214
  // src/renderer/Renderer.ts
11931
- var import_three32 = require("three");
12215
+ var import_three33 = require("three");
11932
12216
  var import_ts_deepmerge9 = __toESM(require_dist());
11933
12217
  var import_stats = __toESM(require("stats.js"));
11934
12218
  var import_postprocessing = require("postprocessing");
@@ -11936,11 +12220,11 @@ init_util();
11936
12220
  init_three();
11937
12221
 
11938
12222
  // src/three/OrbitControls.js
11939
- var import_three31 = require("three");
12223
+ var import_three32 = require("three");
11940
12224
  var _changeEvent = { type: "change" };
11941
12225
  var _startEvent = { type: "start" };
11942
12226
  var _endEvent = { type: "end" };
11943
- var OrbitControls = class extends import_three31.EventDispatcher {
12227
+ var OrbitControls = class extends import_three32.EventDispatcher {
11944
12228
  constructor(object, domElement) {
11945
12229
  super();
11946
12230
  if (domElement === void 0) console.warn('THREE.OrbitControls: The second parameter "domElement" is now mandatory.');
@@ -11949,7 +12233,7 @@ var OrbitControls = class extends import_three31.EventDispatcher {
11949
12233
  this.domElement = domElement;
11950
12234
  this.domElement.style.touchAction = "none";
11951
12235
  this.enabled = true;
11952
- this.target = new import_three31.Vector3();
12236
+ this.target = new import_three32.Vector3();
11953
12237
  this.minDistance = 0;
11954
12238
  this.maxDistance = Infinity;
11955
12239
  this.minZoom = 0;
@@ -11971,8 +12255,8 @@ var OrbitControls = class extends import_three31.EventDispatcher {
11971
12255
  this.autoRotate = false;
11972
12256
  this.autoRotateSpeed = 2;
11973
12257
  this.keys = { LEFT: "ArrowLeft", UP: "ArrowUp", RIGHT: "ArrowRight", BOTTOM: "ArrowDown" };
11974
- this.mouseButtons = { LEFT: import_three31.MOUSE.ROTATE, MIDDLE: import_three31.MOUSE.DOLLY, RIGHT: import_three31.MOUSE.PAN };
11975
- this.touches = { ONE: import_three31.TOUCH.ROTATE, TWO: import_three31.TOUCH.DOLLY_PAN };
12258
+ this.mouseButtons = { LEFT: import_three32.MOUSE.ROTATE, MIDDLE: import_three32.MOUSE.DOLLY, RIGHT: import_three32.MOUSE.PAN };
12259
+ this.touches = { ONE: import_three32.TOUCH.ROTATE, TWO: import_three32.TOUCH.DOLLY_PAN };
11976
12260
  this.target0 = this.target.clone();
11977
12261
  this.position0 = this.object.position.clone();
11978
12262
  this.zoom0 = this.object.zoom;
@@ -12001,11 +12285,11 @@ var OrbitControls = class extends import_three31.EventDispatcher {
12001
12285
  state = STATE.NONE;
12002
12286
  };
12003
12287
  this.update = function() {
12004
- const offset = new import_three31.Vector3();
12005
- const quat = new import_three31.Quaternion().setFromUnitVectors(object.up, new import_three31.Vector3(0, 1, 0));
12288
+ const offset = new import_three32.Vector3();
12289
+ const quat = new import_three32.Quaternion().setFromUnitVectors(object.up, new import_three32.Vector3(0, 1, 0));
12006
12290
  const quatInverse = quat.clone().invert();
12007
- const lastPosition = new import_three31.Vector3();
12008
- const lastQuaternion = new import_three31.Quaternion();
12291
+ const lastPosition = new import_three32.Vector3();
12292
+ const lastQuaternion = new import_three32.Quaternion();
12009
12293
  const twoPI = 2 * Math.PI;
12010
12294
  return function update() {
12011
12295
  const position = scope.object.position;
@@ -12091,20 +12375,20 @@ var OrbitControls = class extends import_three31.EventDispatcher {
12091
12375
  };
12092
12376
  let state = STATE.NONE;
12093
12377
  const EPS = 1e-6;
12094
- const spherical = new import_three31.Spherical();
12095
- const sphericalDelta = new import_three31.Spherical();
12378
+ const spherical = new import_three32.Spherical();
12379
+ const sphericalDelta = new import_three32.Spherical();
12096
12380
  let scale = 1;
12097
- const panOffset = new import_three31.Vector3();
12381
+ const panOffset = new import_three32.Vector3();
12098
12382
  let zoomChanged = false;
12099
- const rotateStart = new import_three31.Vector2();
12100
- const rotateEnd = new import_three31.Vector2();
12101
- const rotateDelta = new import_three31.Vector2();
12102
- const panStart = new import_three31.Vector2();
12103
- const panEnd = new import_three31.Vector2();
12104
- const panDelta = new import_three31.Vector2();
12105
- const dollyStart = new import_three31.Vector2();
12106
- const dollyEnd = new import_three31.Vector2();
12107
- const dollyDelta = new import_three31.Vector2();
12383
+ const rotateStart = new import_three32.Vector2();
12384
+ const rotateEnd = new import_three32.Vector2();
12385
+ const rotateDelta = new import_three32.Vector2();
12386
+ const panStart = new import_three32.Vector2();
12387
+ const panEnd = new import_three32.Vector2();
12388
+ const panDelta = new import_three32.Vector2();
12389
+ const dollyStart = new import_three32.Vector2();
12390
+ const dollyEnd = new import_three32.Vector2();
12391
+ const dollyDelta = new import_three32.Vector2();
12108
12392
  const pointers = [];
12109
12393
  const pointerPositions = {};
12110
12394
  function getAutoRotationAngle() {
@@ -12120,7 +12404,7 @@ var OrbitControls = class extends import_three31.EventDispatcher {
12120
12404
  sphericalDelta.phi -= angle;
12121
12405
  }
12122
12406
  const panLeft = function() {
12123
- const v = new import_three31.Vector3();
12407
+ const v = new import_three32.Vector3();
12124
12408
  return function panLeft2(distance, objectMatrix) {
12125
12409
  v.setFromMatrixColumn(objectMatrix, 0);
12126
12410
  v.multiplyScalar(-distance);
@@ -12128,7 +12412,7 @@ var OrbitControls = class extends import_three31.EventDispatcher {
12128
12412
  };
12129
12413
  }();
12130
12414
  const panUp = function() {
12131
- const v = new import_three31.Vector3();
12415
+ const v = new import_three32.Vector3();
12132
12416
  return function panUp2(distance, objectMatrix) {
12133
12417
  if (scope.screenSpacePanning === true) {
12134
12418
  v.setFromMatrixColumn(objectMatrix, 1);
@@ -12141,7 +12425,7 @@ var OrbitControls = class extends import_three31.EventDispatcher {
12141
12425
  };
12142
12426
  }();
12143
12427
  const pan = function() {
12144
- const offset = new import_three31.Vector3();
12428
+ const offset = new import_three32.Vector3();
12145
12429
  return function pan2(deltaX, deltaY) {
12146
12430
  const element = scope.domElement;
12147
12431
  if (scope.object.isPerspectiveCamera) {
@@ -12390,12 +12674,12 @@ var OrbitControls = class extends import_three31.EventDispatcher {
12390
12674
  mouseAction = -1;
12391
12675
  }
12392
12676
  switch (mouseAction) {
12393
- case import_three31.MOUSE.DOLLY:
12677
+ case import_three32.MOUSE.DOLLY:
12394
12678
  if (scope.enableZoom === false) return;
12395
12679
  handleMouseDownDolly(event);
12396
12680
  state = STATE.DOLLY;
12397
12681
  break;
12398
- case import_three31.MOUSE.ROTATE:
12682
+ case import_three32.MOUSE.ROTATE:
12399
12683
  if (event.ctrlKey || event.metaKey || event.shiftKey) {
12400
12684
  if (scope.enablePan === false) return;
12401
12685
  handleMouseDownPan(event);
@@ -12406,7 +12690,7 @@ var OrbitControls = class extends import_three31.EventDispatcher {
12406
12690
  state = STATE.ROTATE;
12407
12691
  }
12408
12692
  break;
12409
- case import_three31.MOUSE.PAN:
12693
+ case import_three32.MOUSE.PAN:
12410
12694
  if (event.ctrlKey || event.metaKey || event.shiftKey) {
12411
12695
  if (scope.enableRotate === false) return;
12412
12696
  handleMouseDownRotate(event);
@@ -12462,12 +12746,12 @@ var OrbitControls = class extends import_three31.EventDispatcher {
12462
12746
  switch (pointers.length) {
12463
12747
  case 1:
12464
12748
  switch (scope.touches.ONE) {
12465
- case import_three31.TOUCH.ROTATE:
12749
+ case import_three32.TOUCH.ROTATE:
12466
12750
  if (scope.enableRotate === false) return;
12467
12751
  handleTouchStartRotate();
12468
12752
  state = STATE.TOUCH_ROTATE;
12469
12753
  break;
12470
- case import_three31.TOUCH.PAN:
12754
+ case import_three32.TOUCH.PAN:
12471
12755
  if (scope.enablePan === false) return;
12472
12756
  handleTouchStartPan();
12473
12757
  state = STATE.TOUCH_PAN;
@@ -12478,12 +12762,12 @@ var OrbitControls = class extends import_three31.EventDispatcher {
12478
12762
  break;
12479
12763
  case 2:
12480
12764
  switch (scope.touches.TWO) {
12481
- case import_three31.TOUCH.DOLLY_PAN:
12765
+ case import_three32.TOUCH.DOLLY_PAN:
12482
12766
  if (scope.enableZoom === false && scope.enablePan === false) return;
12483
12767
  handleTouchStartDollyPan();
12484
12768
  state = STATE.TOUCH_DOLLY_PAN;
12485
12769
  break;
12486
- case import_three31.TOUCH.DOLLY_ROTATE:
12770
+ case import_three32.TOUCH.DOLLY_ROTATE:
12487
12771
  if (scope.enableZoom === false && scope.enableRotate === false) return;
12488
12772
  handleTouchStartDollyRotate();
12489
12773
  state = STATE.TOUCH_DOLLY_ROTATE;
@@ -12550,7 +12834,7 @@ var OrbitControls = class extends import_three31.EventDispatcher {
12550
12834
  function trackPointer(event) {
12551
12835
  let position = pointerPositions[event.pointerId];
12552
12836
  if (position === void 0) {
12553
- position = new import_three31.Vector2();
12837
+ position = new import_three32.Vector2();
12554
12838
  pointerPositions[event.pointerId] = position;
12555
12839
  }
12556
12840
  position.set(event.pageX, event.pageY);
@@ -12570,10 +12854,10 @@ var MapControls = class extends OrbitControls {
12570
12854
  constructor(object, domElement) {
12571
12855
  super(object, domElement);
12572
12856
  this.screenSpacePanning = false;
12573
- this.mouseButtons.LEFT = import_three31.MOUSE.PAN;
12574
- this.mouseButtons.RIGHT = import_three31.MOUSE.ROTATE;
12575
- this.touches.ONE = import_three31.TOUCH.PAN;
12576
- this.touches.TWO = import_three31.TOUCH.DOLLY_ROTATE;
12857
+ this.mouseButtons.LEFT = import_three32.MOUSE.PAN;
12858
+ this.mouseButtons.RIGHT = import_three32.MOUSE.ROTATE;
12859
+ this.touches.ONE = import_three32.TOUCH.PAN;
12860
+ this.touches.TWO = import_three32.TOUCH.DOLLY_ROTATE;
12577
12861
  }
12578
12862
  };
12579
12863
 
@@ -12624,14 +12908,14 @@ var _Renderer = class _Renderer {
12624
12908
  switch (this.options.camera.type) {
12625
12909
  case "perspective":
12626
12910
  default:
12627
- return new import_three32.PerspectiveCamera(
12911
+ return new import_three33.PerspectiveCamera(
12628
12912
  this.options.camera.perspective.fov,
12629
12913
  this.options.camera.perspective.aspect ?? this.viewWidth / this.viewHeight,
12630
12914
  this.options.camera.near,
12631
12915
  this.options.camera.far
12632
12916
  );
12633
12917
  case "orthographic":
12634
- return new import_three32.OrthographicCamera(
12918
+ return new import_three33.OrthographicCamera(
12635
12919
  this.options.camera.orthographic.left ?? this.viewWidth / -2,
12636
12920
  this.options.camera.orthographic.right ?? this.viewWidth / 2,
12637
12921
  this.options.camera.orthographic.top ?? this.viewHeight / 2,
@@ -12642,7 +12926,7 @@ var _Renderer = class _Renderer {
12642
12926
  }
12643
12927
  }
12644
12928
  createRenderer() {
12645
- const renderer = new import_three32.WebGLRenderer({
12929
+ const renderer = new import_three33.WebGLRenderer({
12646
12930
  antialias: this.options.render.antialias,
12647
12931
  alpha: true,
12648
12932
  powerPreference: "high-performance",
@@ -12650,8 +12934,8 @@ var _Renderer = class _Renderer {
12650
12934
  });
12651
12935
  renderer.setClearColor(0, 0);
12652
12936
  renderer.shadowMap.enabled = true;
12653
- renderer.shadowMap.type = import_three32.PCFSoftShadowMap;
12654
- renderer.outputColorSpace = import_three32.SRGBColorSpace;
12937
+ renderer.shadowMap.type = import_three33.PCFSoftShadowMap;
12938
+ renderer.outputColorSpace = import_three33.SRGBColorSpace;
12655
12939
  renderer.setPixelRatio(this.options.render.pixelRatio ?? 1);
12656
12940
  renderer.setSize(this.viewWidth, this.viewHeight);
12657
12941
  return renderer;
@@ -12686,20 +12970,20 @@ var _Renderer = class _Renderer {
12686
12970
  window["__THREE_DEVTOOLS__"].dispatchEvent(new CustomEvent("observe", { detail: this.scene }));
12687
12971
  }
12688
12972
  if (this.options.debug.grid) {
12689
- const gridHelper = new import_three32.GridHelper(128, 16);
12973
+ const gridHelper = new import_three33.GridHelper(128, 16);
12690
12974
  this._debugHelpers.push(gridHelper);
12691
12975
  this.scene.add(gridHelper);
12692
- const gridHelper2 = new import_three32.GridHelper(128, 16);
12976
+ const gridHelper2 = new import_three33.GridHelper(128, 16);
12693
12977
  this._debugHelpers.push(gridHelper2);
12694
12978
  gridHelper2.rotation.x = 90 * (Math.PI / 180);
12695
12979
  this.scene.add(gridHelper2);
12696
- const gridHelper3 = new import_three32.GridHelper(128, 16);
12980
+ const gridHelper3 = new import_three33.GridHelper(128, 16);
12697
12981
  this._debugHelpers.push(gridHelper3);
12698
12982
  gridHelper3.rotation.z = 90 * (Math.PI / 180);
12699
12983
  this.scene.add(gridHelper3);
12700
12984
  }
12701
12985
  if (this.options.debug.axes) {
12702
- const axesHelper = new import_three32.AxesHelper(64);
12986
+ const axesHelper = new import_three33.AxesHelper(64);
12703
12987
  this._debugHelpers.push(axesHelper);
12704
12988
  this.scene.add(axesHelper);
12705
12989
  }
@@ -12958,8 +13242,8 @@ _Renderer.DEFAULT_OPTIONS = (0, import_ts_deepmerge9.default)({}, {
12958
13242
  top: void 0,
12959
13243
  bottom: void 0
12960
13244
  },
12961
- position: new import_three32.Vector3(50, 50, 50),
12962
- lookingAt: new import_three32.Vector3(0, 0, 0)
13245
+ position: new import_three33.Vector3(50, 50, 50),
13246
+ lookingAt: new import_three33.Vector3(0, 0, 0)
12963
13247
  },
12964
13248
  render: {
12965
13249
  fpsLimit: 60,
@@ -13423,19 +13707,19 @@ var AnvilParser = class {
13423
13707
  };
13424
13708
 
13425
13709
  // src/world/Chunk.ts
13426
- var import_three37 = require("three");
13710
+ var import_three38 = require("three");
13427
13711
  init_BlockStates();
13428
13712
  init_AssetKey();
13429
13713
 
13430
13714
  // src/world/MineRenderWorld.ts
13431
- var import_three35 = require("three");
13715
+ var import_three36 = require("three");
13432
13716
  init_BatchedExecutor();
13433
13717
  init_AssetKey();
13434
13718
  init_BlockStates();
13435
13719
  init_CubeFace();
13436
13720
 
13437
13721
  // src/world/SectionModels.ts
13438
- var import_three34 = require("three");
13722
+ var import_three35 = require("three");
13439
13723
  init_AssetKey();
13440
13724
  init_Models();
13441
13725
  init_CubeFace();
@@ -13501,12 +13785,12 @@ var SectionModels = class {
13501
13785
  });
13502
13786
  await object.init();
13503
13787
  const geometry = object.children[0].geometry;
13504
- geometry.applyMatrix4(new import_three34.Matrix4().makeRotationFromEuler(rotation));
13788
+ geometry.applyMatrix4(new import_three35.Matrix4().makeRotationFromEuler(rotation));
13505
13789
  object.clear();
13506
13790
  const cullFaces = CUBE_FACES.map((face) => {
13507
13791
  const local = CUBE_FACES.findIndex((name) => name === atlas.model.elements[0].faces[face]?.cullface);
13508
13792
  if (local < 0) return 0;
13509
- const normal = new import_three34.Vector3(...CUBE_FACE_OFFSETS[local]).applyEuler(rotation);
13793
+ const normal = new import_three35.Vector3(...CUBE_FACE_OFFSETS[local]).applyEuler(rotation);
13510
13794
  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);
13511
13795
  return 1 << world;
13512
13796
  });
@@ -13536,20 +13820,20 @@ var MineRenderWorld = class {
13536
13820
  }
13537
13821
  getBlockAt(posOrX, y, z) {
13538
13822
  if (typeof posOrX == "number") {
13539
- return this.getBlockAt(new import_three35.Vector3(posOrX, y, z));
13823
+ return this.getBlockAt(new import_three36.Vector3(posOrX, y, z));
13540
13824
  }
13541
13825
  if (isTripleArray(posOrX)) {
13542
- return this.getBlockAt(new import_three35.Vector3(posOrX[0], posOrX[1], posOrX[2]));
13826
+ return this.getBlockAt(new import_three36.Vector3(posOrX[0], posOrX[1], posOrX[2]));
13543
13827
  }
13544
13828
  this.validatePosBounds(posOrX);
13545
13829
  return this.getChunkAt(posOrX)?.getBlockAt(posOrX);
13546
13830
  }
13547
13831
  async setBlockAt(posOrX, yOrBlock, z, block) {
13548
13832
  if (typeof posOrX == "number") {
13549
- return this.setBlockAt(new import_three35.Vector3(posOrX, yOrBlock, z), block);
13833
+ return this.setBlockAt(new import_three36.Vector3(posOrX, yOrBlock, z), block);
13550
13834
  }
13551
13835
  if (isTripleArray(posOrX)) {
13552
- return this.setBlockAt(new import_three35.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
13836
+ return this.setBlockAt(new import_three36.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
13553
13837
  }
13554
13838
  return this.placeBlock(posOrX, yOrBlock);
13555
13839
  }
@@ -13570,7 +13854,7 @@ var MineRenderWorld = class {
13570
13854
  const collect = async (positions2) => {
13571
13855
  for (const pos of positions2) changes.set(pos.toArray().join(","), pos);
13572
13856
  };
13573
- const place = (block) => this.placeBlock(new import_three35.Vector3(...block.position), block, collect);
13857
+ const place = (block) => this.placeBlock(new import_three36.Vector3(...block.position), block, collect);
13574
13858
  const keys = /* @__PURE__ */ new Map();
13575
13859
  for (const block of multiblock.blocks) {
13576
13860
  if (Chunk.isAir(block)) continue;
@@ -13648,13 +13932,13 @@ var MineRenderWorld = class {
13648
13932
  for (const pos of positions) {
13649
13933
  this.pendingCulling.set(pos.toArray().join(","), pos.clone());
13650
13934
  for (const offset of CUBE_FACE_OFFSETS) {
13651
- const neighbor = pos.clone().add(new import_three35.Vector3(...offset));
13935
+ const neighbor = pos.clone().add(new import_three36.Vector3(...offset));
13652
13936
  this.pendingCulling.set(neighbor.toArray().join(","), neighbor);
13653
13937
  }
13654
13938
  for (let y = -1; y <= 1; y++) {
13655
13939
  for (let z = -1; z <= 1; z++) {
13656
13940
  for (let x = -1; x <= 1; x++) {
13657
- const neighbor = pos.clone().add(new import_three35.Vector3(x, y, z));
13941
+ const neighbor = pos.clone().add(new import_three36.Vector3(x, y, z));
13658
13942
  if (this.getBlockAt(neighbor)?.object?.fluidKind) {
13659
13943
  this.pendingCulling.set(neighbor.toArray().join(","), neighbor);
13660
13944
  }
@@ -13676,7 +13960,7 @@ var MineRenderWorld = class {
13676
13960
  if (!block) continue;
13677
13961
  if (block.object?.fluidKind) {
13678
13962
  await block.object.updateFluid((x, y, z) => {
13679
- const neighbor = pos.clone().add(new import_three35.Vector3(x, y, z));
13963
+ const neighbor = pos.clone().add(new import_three36.Vector3(x, y, z));
13680
13964
  const section = this.getChunkAt(neighbor);
13681
13965
  const object = section?.getBlockAt(neighbor)?.object;
13682
13966
  return {
@@ -13688,7 +13972,7 @@ var MineRenderWorld = class {
13688
13972
  }
13689
13973
  let mask = 0;
13690
13974
  for (const [face, offset] of CUBE_FACE_OFFSETS.entries()) {
13691
- const neighbor = pos.clone().add(new import_three35.Vector3(...offset));
13975
+ const neighbor = pos.clone().add(new import_three36.Vector3(...offset));
13692
13976
  if (this.getChunkAt(neighbor)?.isOccludingAt(neighbor)) {
13693
13977
  mask |= 1 << face;
13694
13978
  }
@@ -13722,14 +14006,14 @@ var MineRenderWorld = class {
13722
14006
  return this._chunks.get(this.worldPosToChunkKey(pos));
13723
14007
  }
13724
14008
  static worldToScenePosition(pos) {
13725
- return new import_three35.Vector3(
14009
+ return new import_three36.Vector3(
13726
14010
  pos.x * 16,
13727
14011
  pos.y * 16,
13728
14012
  pos.z * 16
13729
14013
  );
13730
14014
  }
13731
14015
  static sceneToWorldPosition(pos) {
13732
- return new import_three35.Vector3(
14016
+ return new import_three36.Vector3(
13733
14017
  pos.x / 16,
13734
14018
  pos.y / 16,
13735
14019
  pos.z / 16
@@ -13749,10 +14033,10 @@ var MineRenderWorld = class {
13749
14033
  };
13750
14034
 
13751
14035
  // src/world/SectionMesh.ts
13752
- var import_three36 = require("three");
14036
+ var import_three37 = require("three");
13753
14037
  init_CanvasCompat();
13754
14038
  init_Materials();
13755
- var SectionMesh = class _SectionMesh extends import_three36.Group {
14039
+ var SectionMesh = class _SectionMesh extends import_three37.Group {
13756
14040
  constructor() {
13757
14041
  super(...arguments);
13758
14042
  this.ownedMeshes = [];
@@ -13825,18 +14109,18 @@ var SectionMesh = class _SectionMesh extends import_three36.Group {
13825
14109
  for (let corner = 0; corner < 6; corner++) indices.push(start + sourceIndices.getX(face * 6 + corner) - face * 4);
13826
14110
  }
13827
14111
  }
13828
- const geometry = new import_three36.BufferGeometry();
13829
- geometry.setAttribute("position", new import_three36.Float32BufferAttribute(positions, 3));
13830
- geometry.setAttribute("normal", new import_three36.Float32BufferAttribute(normals, 3));
13831
- geometry.setAttribute("uv", new import_three36.Float32BufferAttribute(uvs, 2));
13832
- geometry.setAttribute("color", new import_three36.Float32BufferAttribute(colors, 3));
14112
+ const geometry = new import_three37.BufferGeometry();
14113
+ geometry.setAttribute("position", new import_three37.Float32BufferAttribute(positions, 3));
14114
+ geometry.setAttribute("normal", new import_three37.Float32BufferAttribute(normals, 3));
14115
+ geometry.setAttribute("uv", new import_three37.Float32BufferAttribute(uvs, 2));
14116
+ geometry.setAttribute("color", new import_three37.Float32BufferAttribute(colors, 3));
13833
14117
  geometry.setIndex(indices);
13834
14118
  geometry.computeBoundingBox();
13835
14119
  geometry.computeBoundingSphere();
13836
14120
  const material = Materials.createShadedCanvasMaterial(canvas, false);
13837
14121
  material.vertexColors = true;
13838
14122
  const texture = material.uniforms?.map?.value ?? material.map;
13839
- const mesh = new import_three36.Mesh(geometry, material);
14123
+ const mesh = new import_three37.Mesh(geometry, material);
13840
14124
  section.add(mesh);
13841
14125
  section.ownedMeshes.push({ mesh, texture });
13842
14126
  }
@@ -13870,10 +14154,10 @@ var Chunk = class _Chunk {
13870
14154
  }
13871
14155
  getBlockAt(posOrX, y, z) {
13872
14156
  if (typeof posOrX == "number") {
13873
- return this.getBlockAt(new import_three37.Vector3(posOrX, y, z));
14157
+ return this.getBlockAt(new import_three38.Vector3(posOrX, y, z));
13874
14158
  }
13875
14159
  if (isTripleArray(posOrX)) {
13876
- return this.getBlockAt(new import_three37.Vector3(posOrX[0], posOrX[1], posOrX[2]));
14160
+ return this.getBlockAt(new import_three38.Vector3(posOrX[0], posOrX[1], posOrX[2]));
13877
14161
  }
13878
14162
  const pos = this.worldPosToChunkPos(posOrX);
13879
14163
  const index = _Chunk.chunkPosToBlockIndex(pos);
@@ -13881,10 +14165,10 @@ var Chunk = class _Chunk {
13881
14165
  }
13882
14166
  async setBlockAt(posOrX, yOrBlock, z, block) {
13883
14167
  if (typeof posOrX == "number") {
13884
- return this.setBlockAt(new import_three37.Vector3(posOrX, yOrBlock, z), block);
14168
+ return this.setBlockAt(new import_three38.Vector3(posOrX, yOrBlock, z), block);
13885
14169
  }
13886
14170
  if (isTripleArray(posOrX)) {
13887
- return this.setBlockAt(new import_three37.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
14171
+ return this.setBlockAt(new import_three38.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
13888
14172
  }
13889
14173
  const worldPos = posOrX;
13890
14174
  const pos = this.worldPosToChunkPos(worldPos);
@@ -13913,7 +14197,8 @@ var Chunk = class _Chunk {
13913
14197
  this.data.set(index, void 0);
13914
14198
  return void 0;
13915
14199
  }
13916
- const template = getFluidKind(blockState.key, stored.properties) ? void 0 : await this.sectionModels?.get(blockState, stored.properties);
14200
+ const perBlock = !this.sectionModels || getFluidKind(blockState.key, stored.properties) || blockState.key && BlockEntities.entry(await BlockEntities.getIndex(blockState.key.root), blockState.key.toNamespacedString());
14201
+ const template = perBlock ? void 0 : await this.sectionModels.get(blockState, stored.properties);
13917
14202
  if (template) {
13918
14203
  this.sectionBlocks.set(index, { index, template, cullMask: 0 });
13919
14204
  this.meshDirty = true;
@@ -13969,7 +14254,7 @@ var Chunk = class _Chunk {
13969
14254
  }
13970
14255
  async clear(onBlocksChanged = this.onBlocksChanged) {
13971
14256
  const positions = [...this.renderedBlocks.keys()].map((index) => this.chunkPosToWorldPos(
13972
- new import_three37.Vector3(index % 16, Math.floor(index / 256), Math.floor(index / 16) % 16)
14257
+ new import_three38.Vector3(index % 16, Math.floor(index / 256), Math.floor(index / 16) % 16)
13973
14258
  ));
13974
14259
  for (const info of this.renderedBlocks.values()) info.object?.removeFromScene();
13975
14260
  this.sectionBlocks.clear();
@@ -13993,14 +14278,14 @@ var Chunk = class _Chunk {
13993
14278
  return pos.y * 16 * 16 + pos.z * 16 + pos.x;
13994
14279
  }
13995
14280
  worldPosToChunkPos(pos) {
13996
- return new import_three37.Vector3(
14281
+ return new import_three38.Vector3(
13997
14282
  pos.x - this.x * 16,
13998
14283
  pos.y - this.y * 16,
13999
14284
  pos.z - this.z * 16
14000
14285
  );
14001
14286
  }
14002
14287
  chunkPosToWorldPos(pos) {
14003
- return new import_three37.Vector3(
14288
+ return new import_three38.Vector3(
14004
14289
  this.x * 16 + pos.x,
14005
14290
  this.y * 16 + pos.y,
14006
14291
  this.z * 16 + pos.z