minerender 2.1.0-alpha.54 → 2.1.0-alpha.59

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
  });
@@ -1725,6 +1729,11 @@ function addWireframeToMesh(geo, mesh, color = 16777215, w = 2) {
1725
1729
  mesh.add(wireframe);
1726
1730
  let axes = new import_three8.AxesHelper(1);
1727
1731
  mesh.add(axes);
1732
+ return () => {
1733
+ wireGeo.dispose();
1734
+ wireMat.dispose();
1735
+ axes.dispose();
1736
+ };
1728
1737
  }
1729
1738
  var import_three8;
1730
1739
  var init_model = __esm({
@@ -3084,10 +3093,10 @@ var init_InstanceReference = __esm({
3084
3093
  function isSceneObject(obj) {
3085
3094
  return obj.isSceneObject;
3086
3095
  }
3087
- var import_three10, import_ts_deepmerge3, p6, _SceneObject, SceneObject;
3096
+ var import_three11, import_ts_deepmerge3, p6, _SceneObject, SceneObject;
3088
3097
  var init_SceneObject = __esm({
3089
3098
  "src/renderer/SceneObject.ts"() {
3090
- import_three10 = require("three");
3099
+ import_three11 = require("three");
3091
3100
  init_Geometries();
3092
3101
  init_UVMapper();
3093
3102
  init_Axis();
@@ -3099,7 +3108,7 @@ var init_SceneObject = __esm({
3099
3108
  import_ts_deepmerge3 = __toESM(require_dist());
3100
3109
  init_log();
3101
3110
  p6 = prefix("SceneObject");
3102
- _SceneObject = class _SceneObject extends import_three10.Object3D {
3111
+ _SceneObject = class _SceneObject extends import_three11.Object3D {
3103
3112
  constructor(options) {
3104
3113
  super();
3105
3114
  this.isSceneObject = true;
@@ -3143,7 +3152,7 @@ var init_SceneObject = __esm({
3143
3152
  return group;
3144
3153
  }
3145
3154
  createGroup(name, x = 0, y = 0, z = 0, offsetAxis, offset = 0) {
3146
- const obj = new import_three10.Object3D();
3155
+ const obj = new import_three11.Object3D();
3147
3156
  if (name) {
3148
3157
  obj.name = `group:${name}`;
3149
3158
  }
@@ -3193,7 +3202,7 @@ var init_SceneObject = __esm({
3193
3202
  return mesh;
3194
3203
  }
3195
3204
  createMesh(name, geometry, material, offsetAxis, offset = 0) {
3196
- const mesh = new import_three10.Mesh(geometry, material);
3205
+ const mesh = new import_three11.Mesh(geometry, material);
3197
3206
  if (name) {
3198
3207
  mesh.name = `mesh:${name}`;
3199
3208
  }
@@ -3205,7 +3214,7 @@ var init_SceneObject = __esm({
3205
3214
  return mesh;
3206
3215
  }
3207
3216
  createInstancedMesh(name, geometry, material, count) {
3208
- const mesh = new import_three10.InstancedMesh(geometry, material, count);
3217
+ const mesh = new import_three11.InstancedMesh(geometry, material, count);
3209
3218
  mesh.count = 0;
3210
3219
  this.instanceMesh = mesh;
3211
3220
  this._isInstanced = true;
@@ -3285,11 +3294,11 @@ var init_SceneObject = __esm({
3285
3294
  this._instanceCounter = this.instanceReferences.size;
3286
3295
  mesh.count = Math.max(mesh.count, index + 1);
3287
3296
  if (mesh.instanceColor) {
3288
- mesh.setColorAt(index, new import_three10.Color(16777215));
3297
+ mesh.setColorAt(index, new import_three11.Color(16777215));
3289
3298
  mesh.instanceColor.needsUpdate = true;
3290
3299
  }
3291
3300
  if (this._scene) this._scene.stats.instanceCount++;
3292
- this.setMatrixAt(index, new import_three10.Matrix4());
3301
+ this.setMatrixAt(index, new import_three11.Matrix4());
3293
3302
  return reference;
3294
3303
  }
3295
3304
  /** Returns the live reference for a raycast hit on this object's instance mesh. */
@@ -3302,7 +3311,7 @@ var init_SceneObject = __esm({
3302
3311
  removeInstanceAt(index) {
3303
3312
  if (!this.instanceReferences.has(index)) return;
3304
3313
  const mesh = this.instanceMesh;
3305
- this.setMatrixAt(index, new import_three10.Matrix4().makeScale(0, 0, 0));
3314
+ this.setMatrixAt(index, new import_three11.Matrix4().makeScale(0, 0, 0));
3306
3315
  this.instanceReferences.delete(index);
3307
3316
  this.freeInstanceIndices.push(index);
3308
3317
  this._instanceCounter = this.instanceReferences.size;
@@ -3315,7 +3324,7 @@ var init_SceneObject = __esm({
3315
3324
  const grow = (attribute, fill) => {
3316
3325
  const array = new Float32Array(capacity * attribute.itemSize).fill(fill);
3317
3326
  array.set(attribute.array);
3318
- return new import_three10.InstancedBufferAttribute(array, attribute.itemSize, attribute.normalized, attribute.meshPerAttribute).setUsage(attribute.usage);
3327
+ return new import_three11.InstancedBufferAttribute(array, attribute.itemSize, attribute.normalized, attribute.meshPerAttribute).setUsage(attribute.usage);
3319
3328
  };
3320
3329
  const matrix = grow(mesh.instanceMatrix, 0);
3321
3330
  const color = mesh.instanceColor ? grow(mesh.instanceColor, 1) : null;
@@ -3332,7 +3341,7 @@ var init_SceneObject = __esm({
3332
3341
  }
3333
3342
  //</editor-fold>
3334
3343
  //<editor-fold desc="TRANSFORMATION">
3335
- getMatrixAt(index, matrix = new import_three10.Matrix4()) {
3344
+ getMatrixAt(index, matrix = new import_three11.Matrix4()) {
3336
3345
  if (!this.instanceReferences.has(index)) throw new MineRenderError("Instance is not active");
3337
3346
  this.instanceMesh.getMatrixAt(index, matrix);
3338
3347
  return matrix;
@@ -3348,16 +3357,16 @@ var init_SceneObject = __esm({
3348
3357
  }
3349
3358
  setPositionRotationScaleAt(index, position, rotation, scale) {
3350
3359
  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();
3360
+ const oldPosition = new import_three11.Vector3();
3361
+ const oldRotation = new import_three11.Quaternion();
3362
+ const oldScale = new import_three11.Vector3();
3363
+ const matrix = new import_three11.Matrix4();
3355
3364
  if (!scale || !rotation || !position) {
3356
3365
  this.getMatrixAt(index, matrix).decompose(oldPosition, oldRotation, oldScale);
3357
3366
  }
3358
3367
  matrix.compose(
3359
3368
  position ? position : oldPosition,
3360
- rotation ? new import_three10.Quaternion().setFromEuler(rotation) : oldRotation,
3369
+ rotation ? new import_three11.Quaternion().setFromEuler(rotation) : oldRotation,
3361
3370
  scale ? scale : oldScale
3362
3371
  );
3363
3372
  this.setMatrixAt(index, matrix);
@@ -3366,7 +3375,7 @@ var init_SceneObject = __esm({
3366
3375
  if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
3367
3376
  this.setPositionRotationScaleAt(index, position);
3368
3377
  }
3369
- getPositionAt(index, vector = new import_three10.Vector3()) {
3378
+ getPositionAt(index, vector = new import_three11.Vector3()) {
3370
3379
  if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
3371
3380
  const matrix = this.getMatrixAt(index);
3372
3381
  vector.setFromMatrixPosition(matrix);
@@ -3376,17 +3385,17 @@ var init_SceneObject = __esm({
3376
3385
  if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
3377
3386
  this.setPositionRotationScaleAt(index, void 0, rotation, void 0);
3378
3387
  }
3379
- getRotationAt(index, euler = new import_three10.Euler()) {
3388
+ getRotationAt(index, euler = new import_three11.Euler()) {
3380
3389
  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());
3390
+ const rotation = new import_three11.Quaternion();
3391
+ this.getMatrixAt(index).decompose(new import_three11.Vector3(), rotation, new import_three11.Vector3());
3383
3392
  return euler.setFromQuaternion(rotation);
3384
3393
  }
3385
3394
  setScaleAt(index, scale) {
3386
3395
  if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
3387
3396
  this.setPositionRotationScaleAt(index, void 0, void 0, scale);
3388
3397
  }
3389
- getScaleAt(index, vector = new import_three10.Vector3()) {
3398
+ getScaleAt(index, vector = new import_three11.Vector3()) {
3390
3399
  if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
3391
3400
  const matrix = this.getMatrixAt(index);
3392
3401
  vector.setFromMatrixScale(matrix);
@@ -3529,7 +3538,7 @@ function mergeBufferGeometries(geometries, useGroups = false) {
3529
3538
  const attributes = {};
3530
3539
  const morphAttributes = {};
3531
3540
  const morphTargetsRelative = geometries[0].morphTargetsRelative;
3532
- const mergedGeometry = new import_three19.BufferGeometry();
3541
+ const mergedGeometry = new import_three20.BufferGeometry();
3533
3542
  let offset = 0;
3534
3543
  for (let i = 0; i < geometries.length; ++i) {
3535
3544
  const geometry = geometries[i];
@@ -3653,7 +3662,7 @@ function mergeBufferAttributes(attributes) {
3653
3662
  array.set(attributes[i].array, offset);
3654
3663
  offset += attributes[i].array.length;
3655
3664
  }
3656
- return new import_three19.BufferAttribute(array, itemSize, normalized);
3665
+ return new import_three20.BufferAttribute(array, itemSize, normalized);
3657
3666
  }
3658
3667
  function interleaveAttributes(attributes) {
3659
3668
  let TypedArray;
@@ -3669,7 +3678,7 @@ function interleaveAttributes(attributes) {
3669
3678
  arrayLength += attribute.array.length;
3670
3679
  stride += attribute.itemSize;
3671
3680
  }
3672
- const interleavedBuffer = new import_three19.InterleavedBuffer(new TypedArray(arrayLength), stride);
3681
+ const interleavedBuffer = new import_three20.InterleavedBuffer(new TypedArray(arrayLength), stride);
3673
3682
  let offset = 0;
3674
3683
  const res = [];
3675
3684
  const getters = ["getX", "getY", "getZ", "getW"];
@@ -3678,7 +3687,7 @@ function interleaveAttributes(attributes) {
3678
3687
  const attribute = attributes[j];
3679
3688
  const itemSize = attribute.itemSize;
3680
3689
  const count = attribute.count;
3681
- const iba = new import_three19.InterleavedBufferAttribute(interleavedBuffer, itemSize, offset, attribute.normalized);
3690
+ const iba = new import_three20.InterleavedBufferAttribute(interleavedBuffer, itemSize, offset, attribute.normalized);
3682
3691
  res.push(iba);
3683
3692
  offset += itemSize;
3684
3693
  for (let c = 0; c < count; c++) {
@@ -3762,13 +3771,13 @@ function mergeVertices(geometry, tolerance = 1e-4) {
3762
3771
  const name = attributeNames[i];
3763
3772
  const oldAttribute = geometry.getAttribute(name);
3764
3773
  const buffer = new oldAttribute.array.constructor(attrArrays[name]);
3765
- const attribute = new import_three19.BufferAttribute(buffer, oldAttribute.itemSize, oldAttribute.normalized);
3774
+ const attribute = new import_three20.BufferAttribute(buffer, oldAttribute.itemSize, oldAttribute.normalized);
3766
3775
  result.setAttribute(name, attribute);
3767
3776
  if (name in morphAttrsArrays) {
3768
3777
  for (let j = 0; j < morphAttrsArrays[name].length; j++) {
3769
3778
  const oldMorphAttribute = geometry.morphAttributes[name][j];
3770
3779
  const buffer2 = new oldMorphAttribute.array.constructor(morphAttrsArrays[name][j]);
3771
- const morphAttribute = new import_three19.BufferAttribute(buffer2, oldMorphAttribute.itemSize, oldMorphAttribute.normalized);
3780
+ const morphAttribute = new import_three20.BufferAttribute(buffer2, oldMorphAttribute.itemSize, oldMorphAttribute.normalized);
3772
3781
  result.morphAttributes[name][j] = morphAttribute;
3773
3782
  }
3774
3783
  }
@@ -3777,11 +3786,11 @@ function mergeVertices(geometry, tolerance = 1e-4) {
3777
3786
  return result;
3778
3787
  }
3779
3788
  function toTrianglesDrawMode(geometry, drawMode) {
3780
- if (drawMode === import_three19.TrianglesDrawMode) {
3789
+ if (drawMode === import_three20.TrianglesDrawMode) {
3781
3790
  console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles.");
3782
3791
  return geometry;
3783
3792
  }
3784
- if (drawMode === import_three19.TriangleFanDrawMode || drawMode === import_three19.TriangleStripDrawMode) {
3793
+ if (drawMode === import_three20.TriangleFanDrawMode || drawMode === import_three20.TriangleStripDrawMode) {
3785
3794
  let index = geometry.getIndex();
3786
3795
  if (index === null) {
3787
3796
  const indices = [];
@@ -3799,7 +3808,7 @@ function toTrianglesDrawMode(geometry, drawMode) {
3799
3808
  }
3800
3809
  const numberOfTriangles = index.count - 2;
3801
3810
  const newIndices = [];
3802
- if (drawMode === import_three19.TriangleFanDrawMode) {
3811
+ if (drawMode === import_three20.TriangleFanDrawMode) {
3803
3812
  for (let i = 1; i <= numberOfTriangles; i++) {
3804
3813
  newIndices.push(index.getX(0));
3805
3814
  newIndices.push(index.getX(i));
@@ -3835,15 +3844,15 @@ function computeMorphedAttributes(object) {
3835
3844
  console.error("THREE.BufferGeometryUtils: Geometry is not of type BufferGeometry.");
3836
3845
  return null;
3837
3846
  }
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();
3847
+ const _vA = new import_three20.Vector3();
3848
+ const _vB = new import_three20.Vector3();
3849
+ const _vC = new import_three20.Vector3();
3850
+ const _tempA = new import_three20.Vector3();
3851
+ const _tempB = new import_three20.Vector3();
3852
+ const _tempC = new import_three20.Vector3();
3853
+ const _morphA = new import_three20.Vector3();
3854
+ const _morphB = new import_three20.Vector3();
3855
+ const _morphC = new import_three20.Vector3();
3847
3856
  function _calculateMorphedAttributeData(object2, material2, attribute, morphAttribute, morphTargetsRelative2, a2, b2, c2, modifiedAttributeArray) {
3848
3857
  _vA.fromBufferAttribute(attribute, a2);
3849
3858
  _vB.fromBufferAttribute(attribute, b2);
@@ -4038,8 +4047,8 @@ function computeMorphedAttributes(object) {
4038
4047
  }
4039
4048
  }
4040
4049
  }
4041
- const morphedPositionAttribute = new import_three19.Float32BufferAttribute(modifiedPosition, 3);
4042
- const morphedNormalAttribute = new import_three19.Float32BufferAttribute(modifiedNormal, 3);
4050
+ const morphedPositionAttribute = new import_three20.Float32BufferAttribute(modifiedPosition, 3);
4051
+ const morphedNormalAttribute = new import_three20.Float32BufferAttribute(modifiedNormal, 3);
4043
4052
  return {
4044
4053
  positionAttribute,
4045
4054
  normalAttribute,
@@ -4047,24 +4056,24 @@ function computeMorphedAttributes(object) {
4047
4056
  morphedNormalAttribute
4048
4057
  };
4049
4058
  }
4050
- var import_three19;
4059
+ var import_three20;
4051
4060
  var init_BufferGeometryUtils = __esm({
4052
4061
  "src/three/BufferGeometryUtils.js"() {
4053
- import_three19 = require("three");
4062
+ import_three20 = require("three");
4054
4063
  }
4055
4064
  });
4056
4065
 
4057
4066
  // src/model/ModelCulling.ts
4058
- var import_three20, ModelCulling;
4067
+ var import_three21, ModelCulling;
4059
4068
  var init_ModelCulling = __esm({
4060
4069
  "src/model/ModelCulling.ts"() {
4061
- import_three20 = require("three");
4070
+ import_three21 = require("three");
4062
4071
  init_CubeFace();
4063
4072
  ModelCulling = class {
4064
4073
  static toLocalMask(worldMask, rotation) {
4065
4074
  let localMask = 0;
4066
4075
  for (const [localFace, offset] of CUBE_FACE_OFFSETS.entries()) {
4067
- const normal = new import_three20.Vector3(...offset).applyEuler(rotation);
4076
+ const normal = new import_three21.Vector3(...offset).applyEuler(rotation);
4068
4077
  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
4078
  if (worldFace < 0) return 0;
4070
4079
  if (worldMask & 1 << worldFace) localMask |= 1 << localFace;
@@ -4100,13 +4109,13 @@ var init_ModelCulling = __esm({
4100
4109
  function isModelObject(obj) {
4101
4110
  return obj.isModelObject;
4102
4111
  }
4103
- var import_three21, import_ts_deepmerge5, p7, _ModelObject, ModelObject;
4112
+ var import_three22, import_ts_deepmerge5, p7, _ModelObject, ModelObject;
4104
4113
  var init_ModelObject = __esm({
4105
4114
  "src/model/scene/ModelObject.ts"() {
4106
4115
  init_SceneObject();
4107
4116
  init_Materials();
4108
4117
  init_UVMapper();
4109
- import_three21 = require("three");
4118
+ import_three22 = require("three");
4110
4119
  init_BufferGeometryUtils();
4111
4120
  init_model();
4112
4121
  import_ts_deepmerge5 = __toESM(require_dist());
@@ -4160,7 +4169,7 @@ var init_ModelObject = __esm({
4160
4169
  elGeo.clearGroups();
4161
4170
  }
4162
4171
  if (this.options.uvLockRotation) {
4163
- UVMapper.lockUvs(elGeo, el.faces, this.atlas, new import_three21.Euler(...this.options.uvLockRotation));
4172
+ UVMapper.lockUvs(elGeo, el.faces, this.atlas, new import_three22.Euler(...this.options.uvLockRotation));
4164
4173
  }
4165
4174
  if (this.options.tints) {
4166
4175
  const colors = new Float32Array(elGeo.getAttribute("position").count * 3).fill(1);
@@ -4169,19 +4178,19 @@ var init_ModelObject = __esm({
4169
4178
  if (tintIndex === void 0 || tintIndex < 0) continue;
4170
4179
  const tint = this.options.tints[tintIndex];
4171
4180
  if (tint === void 0) continue;
4172
- const color = new import_three21.Color(tint);
4181
+ const color = new import_three22.Color(tint);
4173
4182
  for (let vertex = 0; vertex < 4; vertex++) {
4174
4183
  color.toArray(colors, (faceIndex * 4 + vertex) * 3);
4175
4184
  }
4176
4185
  }
4177
- elGeo.setAttribute("color", new import_three21.BufferAttribute(colors, 3));
4186
+ elGeo.setAttribute("color", new import_three22.BufferAttribute(colors, 3));
4178
4187
  }
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]));
4188
+ 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));
4189
+ elGeo.applyMatrix4(new import_three22.Matrix4().makeTranslation(el.from[0], el.from[1], el.from[2]));
4181
4190
  if (el.rotation) {
4182
4191
  applyElementRotation(el.rotation, elGeo);
4183
4192
  }
4184
- elGeo.applyMatrix4(new import_three21.Matrix4().makeTranslation(-8, -8, -8));
4193
+ elGeo.applyMatrix4(new import_three22.Matrix4().makeTranslation(-8, -8, -8));
4185
4194
  if (displayTransform) DisplayTransforms.apply(elGeo, displayTransform);
4186
4195
  if (this.options.mergeMeshes) {
4187
4196
  allGeos.push(elGeo);
@@ -4203,7 +4212,7 @@ var init_ModelObject = __esm({
4203
4212
  if (allGeos.length > 0) {
4204
4213
  combinedGeo = mergeBufferGeometries(allGeos);
4205
4214
  } else {
4206
- combinedGeo = new import_three21.BoxGeometry(16, 16, 16);
4215
+ combinedGeo = new import_three22.BoxGeometry(16, 16, 16);
4207
4216
  if (displayTransform) DisplayTransforms.apply(combinedGeo, displayTransform);
4208
4217
  }
4209
4218
  combinedGeo.computeBoundingBox();
@@ -4313,7 +4322,7 @@ function ownHeight(sample) {
4313
4322
  return (level === 0 || level >= 8 ? 8 : 8 - level) / 9;
4314
4323
  }
4315
4324
  function createFluidGeometry(kind, sample) {
4316
- const geometry = new import_three26.BufferGeometry();
4325
+ const geometry = new import_three27.BufferGeometry();
4317
4326
  const positions = [], normals = [], uvs = [], indices = [];
4318
4327
  const self = sample(0, 0, 0);
4319
4328
  const height = (x, z) => {
@@ -4412,16 +4421,16 @@ function createFluidGeometry(kind, sample) {
4412
4421
  1
4413
4422
  );
4414
4423
  }
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));
4424
+ geometry.setAttribute("position", new import_three27.Float32BufferAttribute(positions, 3));
4425
+ geometry.setAttribute("normal", new import_three27.Float32BufferAttribute(normals, 3));
4426
+ geometry.setAttribute("uv", new import_three27.Float32BufferAttribute(uvs, 2));
4418
4427
  geometry.setIndex(indices);
4419
4428
  return geometry;
4420
4429
  }
4421
- var import_three26, fluidRules, HORIZONTAL, EPSILON;
4430
+ var import_three27, fluidRules, HORIZONTAL, EPSILON;
4422
4431
  var init_FluidGeometry = __esm({
4423
4432
  "src/model/fluid/FluidGeometry.ts"() {
4424
- import_three26 = require("three");
4433
+ import_three27 = require("three");
4425
4434
  init_fluidBlocks();
4426
4435
  fluidRules = fluidBlocks_default;
4427
4436
  HORIZONTAL = [[0, -1], [0, 1], [-1, 0], [1, 0]];
@@ -4450,10 +4459,10 @@ function sampleFluid(kind, sample) {
4450
4459
  }
4451
4460
  return { key: key.join(""), sample: (x, y, z) => cells[(y + 1) * 9 + (z + 1) * 3 + x + 1] };
4452
4461
  }
4453
- var import_three27, FluidModelObject;
4462
+ var import_three28, FluidModelObject;
4454
4463
  var init_FluidModelObject = __esm({
4455
4464
  "src/model/fluid/FluidModelObject.ts"() {
4456
- import_three27 = require("three");
4465
+ import_three28 = require("three");
4457
4466
  init_AssetKey();
4458
4467
  init_Materials();
4459
4468
  init_ModelObject();
@@ -4486,10 +4495,10 @@ var init_FluidModelObject = __esm({
4486
4495
  }
4487
4496
  }
4488
4497
  geometry.clearGroups();
4489
- const color = new import_three27.Color(this.options.tints?.[0] ?? (this.kind === "water" ? 4159204 : 16777215));
4498
+ const color = new import_three28.Color(this.options.tints?.[0] ?? (this.kind === "water" ? 4159204 : 16777215));
4490
4499
  const colors = new Float32Array(geometry.getAttribute("position").count * 3);
4491
4500
  for (let i = 0; i < colors.length; i += 3) color.toArray(colors, i);
4492
- geometry.setAttribute("color", new import_three27.BufferAttribute(colors, 3));
4501
+ geometry.setAttribute("color", new import_three28.BufferAttribute(colors, 3));
4493
4502
  geometry.computeBoundingBox();
4494
4503
  geometry.computeBoundingSphere();
4495
4504
  if (this.options.instanceMeshes) {
@@ -4503,7 +4512,7 @@ var init_FluidModelObject = __esm({
4503
4512
  super.applyTextures();
4504
4513
  this.iterateAllMeshes((mesh) => {
4505
4514
  const material = mesh.material;
4506
- material.side = import_three27.DoubleSide;
4515
+ material.side = import_three28.DoubleSide;
4507
4516
  material.forceSinglePass = true;
4508
4517
  material.depthWrite = !material.transparent;
4509
4518
  });
@@ -4534,6 +4543,7 @@ __export(index_browser_exports, {
4534
4543
  BUILTIN_GENERATED: () => BUILTIN_GENERATED,
4535
4544
  BasicAssetKey: () => BasicAssetKey,
4536
4545
  BatchedExecutor: () => BatchedExecutor,
4546
+ BlockEntities: () => BlockEntities,
4537
4547
  BlockObject: () => BlockObject,
4538
4548
  BlockStateResolver: () => BlockStateResolver,
4539
4549
  BlockStates: () => BlockStates,
@@ -4557,7 +4567,9 @@ __export(index_browser_exports, {
4557
4567
  DefaultBlockStates: () => DefaultBlockStates,
4558
4568
  DisplayPosition: () => DisplayPosition,
4559
4569
  DisplayTransforms: () => DisplayTransforms,
4570
+ ENTITY_ANIMATION_CHANNELS: () => ENTITY_ANIMATION_CHANNELS,
4560
4571
  Entities: () => Entities,
4572
+ EntityAnimationPlayer: () => EntityAnimationPlayer,
4561
4573
  EntityObject: () => EntityObject,
4562
4574
  Env: () => Env,
4563
4575
  FluidModelObject: () => FluidModelObject,
@@ -4631,6 +4643,7 @@ __export(index_browser_exports, {
4631
4643
  createCanvas: () => createCanvas,
4632
4644
  createFluidGeometry: () => createFluidGeometry,
4633
4645
  createImage: () => createImage,
4646
+ entityAnimationTime: () => entityAnimationTime,
4634
4647
  estimateBytesUsed: () => estimateBytesUsed,
4635
4648
  getBlockFluidState: () => getBlockFluidState,
4636
4649
  getFluidKind: () => getFluidKind,
@@ -4664,6 +4677,8 @@ __export(index_browser_exports, {
4664
4677
  prefix: () => prefix,
4665
4678
  probeImageSize: () => probeImageSize,
4666
4679
  registerBrowserEnv: () => registerBrowserEnv,
4680
+ sampleEntityAnimation: () => sampleEntityAnimation,
4681
+ sampleEntityKeyframes: () => sampleEntityKeyframes,
4667
4682
  sampleFluid: () => sampleFluid,
4668
4683
  serializeBoxGeometryKey: () => serializeBoxGeometryKey,
4669
4684
  serializeImageKey: () => serializeImageKey,
@@ -4959,6 +4974,59 @@ function shutdown() {
4959
4974
  init_AssetKey();
4960
4975
  init_AssetLoader();
4961
4976
  init_Assets();
4977
+
4978
+ // src/assets/BlockEntities.ts
4979
+ var import_three10 = require("three");
4980
+ init_AssetKey();
4981
+ init_AssetLoader();
4982
+ init_source();
4983
+ init_Caching();
4984
+ var BlockEntities = class {
4985
+ /**
4986
+ * Loads the block index of a version. Versions and sources without one yield an empty index, and so does
4987
+ * a failed load: the index is optional, and blocks must not retry or fail with it one by one. The empty
4988
+ * result is cached like any other; `Caching.clear()` or `AssetLoader.setVersion()` forces a new attempt.
4989
+ */
4990
+ static async getIndex(root) {
4991
+ const key = new AssetKey("entity-models", "blocks", void 0, void 0, void 0, ".json", root);
4992
+ key.rootType = void 0;
4993
+ const index = await Caching.blockEntityIndexCache.get(key.serialize(), async () => {
4994
+ try {
4995
+ return await AssetLoader.get(key, "json" /* JSON */) ?? {};
4996
+ } catch (error) {
4997
+ console.warn("Could not load the block entity index; block entities are drawn as plain block models", error);
4998
+ return {};
4999
+ }
5000
+ });
5001
+ return index ?? {};
5002
+ }
5003
+ /** The index entry of a block ID such as `minecraft:chest`. */
5004
+ static entry(index, block) {
5005
+ const entry = Object.prototype.hasOwnProperty.call(index, block) ? index[block] : void 0;
5006
+ return Array.isArray(entry?.parts) ? entry : void 0;
5007
+ }
5008
+ /** Selects the parts and placement for a block ID such as `minecraft:chest`; undefined when nothing is drawn. */
5009
+ static resolve(index, block, state = {}) {
5010
+ const entry = this.entry(index, block);
5011
+ if (!entry) return void 0;
5012
+ const value = (property) => String(state[property]).toLowerCase();
5013
+ const parts = entry.parts.filter((part) => Object.entries(part.when ?? {}).every(([property, values]) => String(values).split("|").includes(value(property))));
5014
+ if (!parts.length) return void 0;
5015
+ let rotation = 0;
5016
+ if (entry.rotation) {
5017
+ const selected = value(entry.rotation.property);
5018
+ rotation = "degrees" in entry.rotation ? entry.rotation.degrees[selected] : Number(selected) * entry.rotation.step;
5019
+ if (!Number.isFinite(rotation)) rotation = 0;
5020
+ }
5021
+ return { parts, rotation, translation: entry.translation ?? [0, 0, 0] };
5022
+ }
5023
+ /** Placement in block space (0..16 per axis), applied on top of the model's own transform. */
5024
+ static matrix(resolved, matrix = new import_three10.Matrix4()) {
5025
+ 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));
5026
+ }
5027
+ };
5028
+
5029
+ // src/assets/index.ts
4962
5030
  init_BlockStates();
4963
5031
 
4964
5032
  // src/assets/Entities.ts
@@ -5029,6 +5097,15 @@ var Entities = class {
5029
5097
  })));
5030
5098
  return { ...layers[names[0]], id: model.id, layers, ...model.transform && { transform: model.transform } };
5031
5099
  }
5100
+ /**
5101
+ * Vanilla's keyframe animations of a model by name, or undefined when the model or the selected version has none.
5102
+ */
5103
+ static async getAnimations(modelKey) {
5104
+ const path = isAssetKey(modelKey) ? modelKey.getFullPath() : modelKey.path;
5105
+ const key = new AssetKey(modelKey.namespace, path, void 0, void 0, "entity-models/animations", ".json");
5106
+ const file = await Caching.entityAnimationCache.get(key.serialize(), () => AssetLoader.get(key, "json" /* JSON */));
5107
+ return file?.animations;
5108
+ }
5032
5109
  static async resolveTexture(modelKey) {
5033
5110
  const path = isAssetKey(modelKey) ? modelKey.getFullPath() : modelKey.path;
5034
5111
  const key = new AssetKey(modelKey.namespace, path, void 0, void 0, "entity-models", ".json");
@@ -5105,11 +5182,124 @@ function trimCanvas(source) {
5105
5182
  return canvas;
5106
5183
  }
5107
5184
 
5185
+ // src/entity/EntityAnimation.ts
5186
+ var ENTITY_ANIMATION_CHANNELS = ["position", "rotation", "scale"];
5187
+ function catmullRom(delta, p0, p1, p22, p32) {
5188
+ 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);
5189
+ }
5190
+ function sampleEntityKeyframes(keyframes, time) {
5191
+ if (keyframes.length === 0) return [0, 0, 0];
5192
+ let low = 0, high = keyframes.length;
5193
+ while (low < high) {
5194
+ const middle = low + high >>> 1;
5195
+ if (time <= keyframes[middle].time) high = middle;
5196
+ else low = middle + 1;
5197
+ }
5198
+ const a = Math.max(0, low - 1);
5199
+ const b = Math.min(keyframes.length - 1, a + 1);
5200
+ const from = keyframes[a];
5201
+ const to = keyframes[b];
5202
+ const delta = a === b ? 0 : Math.min(1, Math.max(0, (time - from.time) / (to.time - from.time)));
5203
+ if (to.interpolation === "catmullrom") {
5204
+ const before = keyframes[Math.max(0, a - 1)].value;
5205
+ const after = keyframes[Math.min(keyframes.length - 1, b + 1)].value;
5206
+ return [0, 1, 2].map((i) => catmullRom(delta, before[i], from.value[i], to.value[i], after[i]));
5207
+ }
5208
+ const target = to.pre ?? to.value;
5209
+ return [0, 1, 2].map((i) => from.value[i] + (target[i] - from.value[i]) * delta);
5210
+ }
5211
+ function entityAnimationTime(animation, time, loop = animation.loop) {
5212
+ return loop && animation.length > 0 ? time % animation.length : time;
5213
+ }
5214
+ function sampleEntityAnimation(animation, time, loop = animation.loop) {
5215
+ const elapsed = entityAnimationTime(animation, time, loop);
5216
+ const pose = {};
5217
+ for (const [name, bone] of Object.entries(animation.bones)) {
5218
+ const sampled = pose[name] = {};
5219
+ for (const channel of ENTITY_ANIMATION_CHANNELS) {
5220
+ const keyframes = bone[channel];
5221
+ if (keyframes?.length) sampled[channel] = sampleEntityKeyframes(keyframes, elapsed);
5222
+ }
5223
+ }
5224
+ return pose;
5225
+ }
5226
+
5227
+ // src/entity/scene/EntityAnimationPlayer.ts
5228
+ var ZERO = [0, 0, 0];
5229
+ var EntityAnimationPlayer = class {
5230
+ constructor() {
5231
+ this.parts = [];
5232
+ this._time = 0;
5233
+ this.loop = false;
5234
+ this.speed = 1;
5235
+ }
5236
+ get animation() {
5237
+ return this._animation;
5238
+ }
5239
+ get time() {
5240
+ return this._time;
5241
+ }
5242
+ /**
5243
+ * Starts an animation on the named parts below each layer root. The current pose of a part becomes its default;
5244
+ * bones without a matching part are skipped.
5245
+ */
5246
+ play(layers, animation, options = {}) {
5247
+ this.stop();
5248
+ this._animation = animation;
5249
+ this._time = options.time ?? 0;
5250
+ this.loop = options.loop ?? animation.loop;
5251
+ this.speed = options.speed ?? 1;
5252
+ for (const layer of layers) {
5253
+ for (const bone of Object.keys(animation.bones)) {
5254
+ const object = layer.getObjectByName(`group:${bone}`);
5255
+ if (!object) continue;
5256
+ this.parts.push({ bone, object, position: object.position.clone(), rotation: object.rotation.clone(), scale: object.scale.clone() });
5257
+ }
5258
+ }
5259
+ this.apply();
5260
+ }
5261
+ /** Restores the default poses. Returns whether an animation was active. */
5262
+ stop() {
5263
+ if (!this._animation) return false;
5264
+ for (const part of this.parts) {
5265
+ part.object.position.copy(part.position);
5266
+ part.object.rotation.copy(part.rotation);
5267
+ part.object.scale.copy(part.scale);
5268
+ }
5269
+ this.clear();
5270
+ return true;
5271
+ }
5272
+ /** Forgets the animation without touching the parts, for parts that no longer exist. */
5273
+ clear() {
5274
+ this.parts = [];
5275
+ this._animation = void 0;
5276
+ this._time = 0;
5277
+ }
5278
+ setTime(seconds) {
5279
+ if (!this._animation) return false;
5280
+ this._time = seconds;
5281
+ this.apply();
5282
+ return true;
5283
+ }
5284
+ advance(deltaSeconds) {
5285
+ return this.setTime(this._time + deltaSeconds * this.speed);
5286
+ }
5287
+ apply() {
5288
+ const pose = sampleEntityAnimation(this._animation, this._time, this.loop);
5289
+ for (const part of this.parts) {
5290
+ const { position = ZERO, rotation = ZERO, scale = ZERO } = pose[part.bone];
5291
+ part.object.position.set(part.position.x + position[0], part.position.y + position[1], part.position.z + position[2]);
5292
+ part.object.rotation.set(part.rotation.x + rotation[0], part.rotation.y + rotation[1], part.rotation.z + rotation[2], part.rotation.order);
5293
+ part.object.scale.set(part.scale.x + scale[0], part.scale.y + scale[1], part.scale.z + scale[2]);
5294
+ }
5295
+ }
5296
+ };
5297
+
5108
5298
  // src/entity/scene/EntityObject.ts
5109
5299
  init_SceneObject();
5110
5300
  init_Caching();
5111
5301
  var import_ts_deepmerge4 = __toESM(require_dist());
5112
- var import_three12 = require("three");
5302
+ var import_three13 = require("three");
5113
5303
  init_Ticker();
5114
5304
  init_model();
5115
5305
  init_ModelTextures();
@@ -5122,11 +5312,16 @@ var _EntityObject = class _EntityObject extends SceneObject {
5122
5312
  this.entity = entity;
5123
5313
  this.isEntityObject = true;
5124
5314
  this.meshesCreated = false;
5315
+ this.geometries = /* @__PURE__ */ new Set();
5316
+ this.disposeWireframes = [];
5125
5317
  /** Scrolling materials are owned: their texture offset follows this entity's age. */
5126
5318
  this.scrollMaterials = [];
5127
5319
  /** Entity age in ticks, as vanilla's `ageInTicks`; drives the scrolling render modes. */
5128
5320
  this.age = 0;
5321
+ this.animationPlayer = new EntityAnimationPlayer();
5129
5322
  this.options = (0, import_ts_deepmerge4.default)({}, _EntityObject.DEFAULT_OPTIONS, options ?? {});
5323
+ this.addEventListener("added", () => this.updateScrollSubscription());
5324
+ this.addEventListener("removed", () => this.updateScrollSubscription());
5130
5325
  }
5131
5326
  async init() {
5132
5327
  this.createMeshes();
@@ -5137,6 +5332,10 @@ var _EntityObject = class _EntityObject extends SceneObject {
5137
5332
  }
5138
5333
  disposeAndRemoveAllChildren() {
5139
5334
  this.clearScrollMaterials();
5335
+ for (const geometry of this.geometries) geometry.dispose();
5336
+ this.geometries.clear();
5337
+ for (const dispose of this.disposeWireframes.splice(0)) dispose();
5338
+ this.animationPlayer.clear();
5140
5339
  super.disposeAndRemoveAllChildren();
5141
5340
  }
5142
5341
  clearScrollMaterials() {
@@ -5147,6 +5346,19 @@ var _EntityObject = class _EntityObject extends SceneObject {
5147
5346
  material.dispose();
5148
5347
  }
5149
5348
  }
5349
+ updateScrollSubscription() {
5350
+ if (this.parent && this.scrollMaterials.length) {
5351
+ if (this.scrollTicker === void 0) {
5352
+ this.scrollTicker = Ticker.add(() => {
5353
+ this.age++;
5354
+ this.updateScroll();
5355
+ });
5356
+ }
5357
+ } else {
5358
+ Ticker.remove(this.scrollTicker);
5359
+ this.scrollTicker = void 0;
5360
+ }
5361
+ }
5150
5362
  /** Applies the entity age to the scrolling materials; the ticker calls this 20 times per second. */
5151
5363
  updateScroll() {
5152
5364
  for (const { offset, speed } of this.scrollMaterials) {
@@ -5154,6 +5366,39 @@ var _EntityObject = class _EntityObject extends SceneObject {
5154
5366
  }
5155
5367
  this.notifyDirty();
5156
5368
  }
5369
+ //<editor-fold desc="ANIMATION">
5370
+ /** The animation started by {@link playAnimation}, until {@link stopAnimation} or disposal. */
5371
+ get animation() {
5372
+ return this.animationPlayer.animation;
5373
+ }
5374
+ /** Seconds since the animation started, before looping. */
5375
+ get animationTime() {
5376
+ return this.animationPlayer.time;
5377
+ }
5378
+ /**
5379
+ * Poses the object from a keyframe animation of {@link Entities.getAnimations}, replacing the current one.
5380
+ * Parts of every layer are matched by name and their current pose is the default the offsets add to.
5381
+ * The object owns no clock: call {@link advanceAnimation} per frame, or {@link setAnimationTime}.
5382
+ */
5383
+ playAnimation(animation, options) {
5384
+ this.createMeshes();
5385
+ const layers = Object.keys(this.entityLayers).map((name) => this.getLayerGroup(name)).filter((layer) => !!layer);
5386
+ this.animationPlayer.play(layers, animation, options);
5387
+ this.notifyDirty();
5388
+ }
5389
+ /** Stops the animation and restores the default pose. */
5390
+ stopAnimation() {
5391
+ if (this.animationPlayer.stop()) this.notifyDirty();
5392
+ }
5393
+ /** Poses the object at an explicit time in seconds. Has no effect without an animation. */
5394
+ setAnimationTime(seconds) {
5395
+ if (this.animationPlayer.setTime(seconds)) this.notifyDirty();
5396
+ }
5397
+ /** Advances the animation by a frame delta in seconds, scaled by its speed. Has no effect without an animation. */
5398
+ advanceAnimation(deltaSeconds) {
5399
+ if (this.animationPlayer.advance(deltaSeconds)) this.notifyDirty();
5400
+ }
5401
+ //</editor-fold>
5157
5402
  getLayerGroup(name) {
5158
5403
  return super.getGroupByName(`layer:${name}`);
5159
5404
  }
@@ -5183,14 +5428,14 @@ var _EntityObject = class _EntityObject extends SceneObject {
5183
5428
  }
5184
5429
  createMeshes(force = false) {
5185
5430
  if (this.meshesCreated && !force) return;
5186
- const modelRoot = new import_three12.Object3D();
5431
+ const modelRoot = new import_three13.Object3D();
5187
5432
  const transform = this.options.flip === void 0 ? this.entity.transform : void 0;
5188
5433
  if (transform) {
5189
5434
  for (const op of transform) {
5190
- const matrix = new import_three12.Matrix4();
5435
+ const matrix = new import_three13.Matrix4();
5191
5436
  if ("scale" in op) matrix.makeScale(...op.scale);
5192
5437
  else if ("translate" in op) matrix.makeTranslation(...op.translate);
5193
- else matrix.makeRotationFromEuler(new import_three12.Euler(...op.rotate, "ZYX"));
5438
+ else matrix.makeRotationFromEuler(new import_three13.Euler(...op.rotate, "ZYX"));
5194
5439
  modelRoot.matrix.multiply(matrix);
5195
5440
  }
5196
5441
  modelRoot.matrixAutoUpdate = false;
@@ -5224,6 +5469,7 @@ var _EntityObject = class _EntityObject extends SceneObject {
5224
5469
  depth + growZ * 2,
5225
5470
  uv
5226
5471
  ).clone();
5472
+ this.geometries.add(geometry);
5227
5473
  geometry.translate(cube.origin[0] + width / 2, cube.origin[1] + height / 2, cube.origin[2] + depth / 2);
5228
5474
  if (inward && Math.min(width + growX * 2, height + growY * 2, depth + growZ * 2) > 0) {
5229
5475
  const index = Array.from(geometry.getIndex().array);
@@ -5232,7 +5478,7 @@ var _EntityObject = class _EntityObject extends SceneObject {
5232
5478
  const mesh = this.createMesh(name, geometry, material);
5233
5479
  mesh.renderOrder = renderOrder;
5234
5480
  anchor.add(mesh);
5235
- if (this.options.wireframe) addWireframeToMesh(geometry, mesh);
5481
+ if (this.options.wireframe) this.disposeWireframes.push(addWireframeToMesh(geometry, mesh));
5236
5482
  }
5237
5483
  for (const [childName, child] of Object.entries(part.children)) {
5238
5484
  this.createPart(childName, child, anchor, size, material, renderOrder, inward);
@@ -5245,7 +5491,7 @@ var _EntityObject = class _EntityObject extends SceneObject {
5245
5491
  const tint = layer.tint === void 0 ? void 0 : this.options.tints?.[layer.tint];
5246
5492
  const scroll = Materials.entityModeScroll(mode);
5247
5493
  const assetKeyStr = this.getTextureKey(layer).serialize();
5248
- const keyStr = `entity:${mode}:${tint === void 0 ? "" : new import_three12.Color(tint).getHexString()}:${assetKeyStr}`;
5494
+ const keyStr = `entity:${mode}:${tint === void 0 ? "" : new import_three13.Color(tint).getHexString()}:${assetKeyStr}`;
5249
5495
  let mat = scroll ? void 0 : Caching.materialCache.getIfPresent(keyStr);
5250
5496
  if (!mat) {
5251
5497
  const cachedAsset = Caching.textureAssetCache.getIfPresent(assetKeyStr);
@@ -5266,11 +5512,8 @@ var _EntityObject = class _EntityObject extends SceneObject {
5266
5512
  this.clearScrollMaterials();
5267
5513
  } else if (this.scrollMaterials.length) {
5268
5514
  this.updateScroll();
5269
- this.scrollTicker = Ticker.add(() => {
5270
- this.age++;
5271
- this.updateScroll();
5272
- });
5273
5515
  }
5516
+ this.updateScrollSubscription();
5274
5517
  this.notifyDirty();
5275
5518
  }
5276
5519
  };
@@ -5284,27 +5527,27 @@ function isEntityObject(obj) {
5284
5527
  init_MineRenderError();
5285
5528
 
5286
5529
  // src/export/SceneExporter.ts
5287
- var import_three18 = require("three");
5530
+ var import_three19 = require("three");
5288
5531
 
5289
5532
  // ../../node_modules/three/examples/jsm/exporters/OBJExporter.js
5290
- var import_three14 = require("three");
5533
+ var import_three15 = require("three");
5291
5534
  var OBJExporter = class {
5292
5535
  parse(object) {
5293
5536
  let output = "";
5294
5537
  let indexVertex = 0;
5295
5538
  let indexVertexUvs = 0;
5296
5539
  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();
5540
+ const vertex = new import_three15.Vector3();
5541
+ const color = new import_three15.Color();
5542
+ const normal = new import_three15.Vector3();
5543
+ const uv = new import_three15.Vector2();
5301
5544
  const face = [];
5302
5545
  function parseMesh(mesh) {
5303
5546
  let nbVertex = 0;
5304
5547
  let nbNormals = 0;
5305
5548
  let nbVertexUvs = 0;
5306
5549
  const geometry = mesh.geometry;
5307
- const normalMatrixWorld = new import_three14.Matrix3();
5550
+ const normalMatrixWorld = new import_three15.Matrix3();
5308
5551
  const vertices = geometry.getAttribute("position");
5309
5552
  const normals = geometry.getAttribute("normal");
5310
5553
  const uvs = geometry.getAttribute("uv");
@@ -5423,7 +5666,7 @@ var OBJExporter = class {
5423
5666
  };
5424
5667
 
5425
5668
  // ../../node_modules/three/examples/jsm/exporters/PLYExporter.js
5426
- var import_three15 = require("three");
5669
+ var import_three16 = require("three");
5427
5670
  var PLYExporter = class {
5428
5671
  parse(object, onDone, options = {}) {
5429
5672
  function traverseMeshes(cb) {
@@ -5480,7 +5723,7 @@ var PLYExporter = class {
5480
5723
  includeIndices = false;
5481
5724
  }
5482
5725
  });
5483
- const tempColor = new import_three15.Color();
5726
+ const tempColor = new import_three16.Color();
5484
5727
  includeIndices = includeIndices && excludeAttributes.indexOf("index") === -1;
5485
5728
  includeNormals = includeNormals && excludeAttributes.indexOf("normal") === -1;
5486
5729
  includeColors = includeColors && excludeAttributes.indexOf("color") === -1;
@@ -5514,8 +5757,8 @@ property list uchar int vertex_index
5514
5757
  `;
5515
5758
  }
5516
5759
  header += "end_header\n";
5517
- const vertex = new import_three15.Vector3();
5518
- const normalMatrixWorld = new import_three15.Matrix3();
5760
+ const vertex = new import_three16.Vector3();
5761
+ const normalMatrixWorld = new import_three16.Matrix3();
5519
5762
  let result = null;
5520
5763
  if (options.binary === true) {
5521
5764
  const headerBin = new TextEncoder().encode(header);
@@ -5689,18 +5932,18 @@ property list uchar int vertex_index
5689
5932
  };
5690
5933
 
5691
5934
  // ../../node_modules/three/examples/jsm/exporters/GLTFExporter.js
5692
- var import_three17 = require("three");
5935
+ var import_three18 = require("three");
5693
5936
 
5694
5937
  // ../../node_modules/three/examples/jsm/utils/TextureUtils.js
5695
- var import_three16 = require("three");
5938
+ var import_three17 = require("three");
5696
5939
  var _renderer;
5697
5940
  var fullscreenQuadGeometry;
5698
5941
  var fullscreenQuadMaterial;
5699
5942
  var fullscreenQuad;
5700
5943
  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) },
5944
+ if (!fullscreenQuadGeometry) fullscreenQuadGeometry = new import_three17.PlaneGeometry(2, 2, 1, 1);
5945
+ if (!fullscreenQuadMaterial) fullscreenQuadMaterial = new import_three17.ShaderMaterial({
5946
+ uniforms: { blitTexture: new import_three17.Uniform(texture) },
5704
5947
  vertexShader: `
5705
5948
  varying vec2 vUv;
5706
5949
  void main(){
@@ -5722,22 +5965,22 @@ function decompress(texture, maxTextureSize = Infinity, renderer = null) {
5722
5965
  }`
5723
5966
  });
5724
5967
  fullscreenQuadMaterial.uniforms.blitTexture.value = texture;
5725
- fullscreenQuadMaterial.defines.IS_SRGB = texture.colorSpace == import_three16.SRGBColorSpace;
5968
+ fullscreenQuadMaterial.defines.IS_SRGB = texture.colorSpace == import_three17.SRGBColorSpace;
5726
5969
  fullscreenQuadMaterial.needsUpdate = true;
5727
5970
  if (!fullscreenQuad) {
5728
- fullscreenQuad = new import_three16.Mesh(fullscreenQuadGeometry, fullscreenQuadMaterial);
5971
+ fullscreenQuad = new import_three17.Mesh(fullscreenQuadGeometry, fullscreenQuadMaterial);
5729
5972
  fullscreenQuad.frustrumCulled = false;
5730
5973
  }
5731
- const _camera = new import_three16.PerspectiveCamera();
5732
- const _scene = new import_three16.Scene();
5974
+ const _camera = new import_three17.PerspectiveCamera();
5975
+ const _scene = new import_three17.Scene();
5733
5976
  _scene.add(fullscreenQuad);
5734
5977
  if (!renderer) {
5735
- renderer = _renderer = new import_three16.WebGLRenderer({ antialias: false });
5978
+ renderer = _renderer = new import_three17.WebGLRenderer({ antialias: false });
5736
5979
  }
5737
5980
  renderer.setSize(Math.min(texture.image.width, maxTextureSize), Math.min(texture.image.height, maxTextureSize));
5738
5981
  renderer.clear();
5739
5982
  renderer.render(_scene, _camera);
5740
- const readableTexture = new import_three16.Texture(renderer.domElement);
5983
+ const readableTexture = new import_three17.Texture(renderer.domElement);
5741
5984
  readableTexture.minFilter = texture.minFilter;
5742
5985
  readableTexture.magFilter = texture.magFilter;
5743
5986
  readableTexture.wrapS = texture.wrapS;
@@ -5883,22 +6126,22 @@ var WEBGL_CONSTANTS = {
5883
6126
  };
5884
6127
  var KHR_MESH_QUANTIZATION = "KHR_mesh_quantization";
5885
6128
  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;
6129
+ THREE_TO_WEBGL[import_three18.NearestFilter] = WEBGL_CONSTANTS.NEAREST;
6130
+ THREE_TO_WEBGL[import_three18.NearestMipmapNearestFilter] = WEBGL_CONSTANTS.NEAREST_MIPMAP_NEAREST;
6131
+ THREE_TO_WEBGL[import_three18.NearestMipmapLinearFilter] = WEBGL_CONSTANTS.NEAREST_MIPMAP_LINEAR;
6132
+ THREE_TO_WEBGL[import_three18.LinearFilter] = WEBGL_CONSTANTS.LINEAR;
6133
+ THREE_TO_WEBGL[import_three18.LinearMipmapNearestFilter] = WEBGL_CONSTANTS.LINEAR_MIPMAP_NEAREST;
6134
+ THREE_TO_WEBGL[import_three18.LinearMipmapLinearFilter] = WEBGL_CONSTANTS.LINEAR_MIPMAP_LINEAR;
6135
+ THREE_TO_WEBGL[import_three18.ClampToEdgeWrapping] = WEBGL_CONSTANTS.CLAMP_TO_EDGE;
6136
+ THREE_TO_WEBGL[import_three18.RepeatWrapping] = WEBGL_CONSTANTS.REPEAT;
6137
+ THREE_TO_WEBGL[import_three18.MirroredRepeatWrapping] = WEBGL_CONSTANTS.MIRRORED_REPEAT;
5895
6138
  var PATH_PROPERTIES = {
5896
6139
  scale: "scale",
5897
6140
  position: "translation",
5898
6141
  quaternion: "rotation",
5899
6142
  morphTargetInfluences: "weights"
5900
6143
  };
5901
- var DEFAULT_SPECULAR_COLOR = new import_three17.Color();
6144
+ var DEFAULT_SPECULAR_COLOR = new import_three18.Color();
5902
6145
  var GLB_HEADER_BYTES = 12;
5903
6146
  var GLB_HEADER_MAGIC = 1179937895;
5904
6147
  var GLB_VERSION = 2;
@@ -5932,7 +6175,7 @@ function getMinMax(attribute, start, count) {
5932
6175
  else if (a === 2) value = attribute.getZ(i);
5933
6176
  else if (a === 3) value = attribute.getW(i);
5934
6177
  if (attribute.normalized === true) {
5935
- value = import_three17.MathUtils.normalize(value, attribute.array);
6178
+ value = import_three18.MathUtils.normalize(value, attribute.array);
5936
6179
  }
5937
6180
  }
5938
6181
  output.min[a] = Math.min(output.min[a], value);
@@ -6138,7 +6381,7 @@ var GLTFWriter = class {
6138
6381
  isNormalizedNormalAttribute(normal) {
6139
6382
  const cache = this.cache;
6140
6383
  if (cache.attributesNormalized.has(normal)) return false;
6141
- const v = new import_three17.Vector3();
6384
+ const v = new import_three18.Vector3();
6142
6385
  for (let i = 0, il = normal.count; i < il; i++) {
6143
6386
  if (Math.abs(v.fromBufferAttribute(normal, i).length() - 1) > 5e-4) return false;
6144
6387
  }
@@ -6155,7 +6398,7 @@ var GLTFWriter = class {
6155
6398
  const cache = this.cache;
6156
6399
  if (cache.attributesNormalized.has(normal)) return cache.attributesNormalized.get(normal);
6157
6400
  const attribute = normal.clone();
6158
- const v = new import_three17.Vector3();
6401
+ const v = new import_three18.Vector3();
6159
6402
  for (let i = 0, il = attribute.count; i < il; i++) {
6160
6403
  v.fromBufferAttribute(attribute, i);
6161
6404
  if (v.x === 0 && v.y === 0 && v.z === 0) {
@@ -6199,7 +6442,7 @@ var GLTFWriter = class {
6199
6442
  buildMetalRoughTexture(metalnessMap, roughnessMap) {
6200
6443
  if (metalnessMap === roughnessMap) return metalnessMap;
6201
6444
  function getEncodingConversion(map) {
6202
- if (map.colorSpace === import_three17.SRGBColorSpace) {
6445
+ if (map.colorSpace === import_three18.SRGBColorSpace) {
6203
6446
  return function SRGBToLinear(c) {
6204
6447
  return c < 0.04045 ? c * 0.0773993808 : Math.pow(c * 0.9478672986 + 0.0521327014, 2.4);
6205
6448
  };
@@ -6209,10 +6452,10 @@ var GLTFWriter = class {
6209
6452
  };
6210
6453
  }
6211
6454
  console.warn("THREE.GLTFExporter: Merged metalnessMap and roughnessMap textures.");
6212
- if (metalnessMap instanceof import_three17.CompressedTexture) {
6455
+ if (metalnessMap instanceof import_three18.CompressedTexture) {
6213
6456
  metalnessMap = decompress(metalnessMap);
6214
6457
  }
6215
- if (roughnessMap instanceof import_three17.CompressedTexture) {
6458
+ if (roughnessMap instanceof import_three18.CompressedTexture) {
6216
6459
  roughnessMap = decompress(roughnessMap);
6217
6460
  }
6218
6461
  const metalness = metalnessMap ? metalnessMap.image : null;
@@ -6245,8 +6488,8 @@ var GLTFWriter = class {
6245
6488
  context.putImageData(composite, 0, 0);
6246
6489
  const reference = metalnessMap || roughnessMap;
6247
6490
  const texture = reference.clone();
6248
- texture.source = new import_three17.Source(canvas);
6249
- texture.colorSpace = import_three17.NoColorSpace;
6491
+ texture.source = new import_three18.Source(canvas);
6492
+ texture.colorSpace = import_three18.NoColorSpace;
6250
6493
  texture.channel = (metalnessMap || roughnessMap).channel;
6251
6494
  if (metalnessMap && roughnessMap && metalnessMap.channel !== roughnessMap.channel) {
6252
6495
  console.warn("THREE.GLTFExporter: UV channels for metalnessMap and roughnessMap textures must match.");
@@ -6304,7 +6547,7 @@ var GLTFWriter = class {
6304
6547
  else if (a === 2) value = attribute.getZ(i);
6305
6548
  else if (a === 3) value = attribute.getW(i);
6306
6549
  if (attribute.normalized === true) {
6307
- value = import_three17.MathUtils.normalize(value, attribute.array);
6550
+ value = import_three18.MathUtils.normalize(value, attribute.array);
6308
6551
  }
6309
6552
  }
6310
6553
  if (componentType === WEBGL_CONSTANTS.FLOAT) {
@@ -6454,7 +6697,7 @@ var GLTFWriter = class {
6454
6697
  ctx.scale(1, -1);
6455
6698
  }
6456
6699
  if (image.data !== void 0) {
6457
- if (format !== import_three17.RGBAFormat) {
6700
+ if (format !== import_three18.RGBAFormat) {
6458
6701
  console.error("GLTFExporter: Only RGBAFormat is supported.", format);
6459
6702
  }
6460
6703
  if (image.width > options.maxTextureSize || image.height > options.maxTextureSize) {
@@ -6523,7 +6766,7 @@ var GLTFWriter = class {
6523
6766
  const json = this.json;
6524
6767
  if (cache.textures.has(map)) return cache.textures.get(map);
6525
6768
  if (!json.textures) json.textures = [];
6526
- if (map instanceof import_three17.CompressedTexture) {
6769
+ if (map instanceof import_three18.CompressedTexture) {
6527
6770
  map = decompress(map, options.maxTextureSize);
6528
6771
  }
6529
6772
  let mimeType = map.userData.mimeType;
@@ -6631,7 +6874,7 @@ var GLTFWriter = class {
6631
6874
  materialDef.alphaCutoff = material.alphaTest;
6632
6875
  }
6633
6876
  }
6634
- if (material.side === import_three17.DoubleSide) materialDef.doubleSided = true;
6877
+ if (material.side === import_three18.DoubleSide) materialDef.doubleSided = true;
6635
6878
  if (material.name !== "") materialDef.name = material.name;
6636
6879
  this.serializeUserData(material, materialDef);
6637
6880
  this._invokeAll(function(ext) {
@@ -6705,7 +6948,7 @@ var GLTFWriter = class {
6705
6948
  const array = attribute.array;
6706
6949
  if (attributeName === "JOINTS_0" && !(array instanceof Uint16Array) && !(array instanceof Uint8Array)) {
6707
6950
  console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.');
6708
- modifiedAttribute = new import_three17.BufferAttribute(new Uint16Array(array), attribute.itemSize, attribute.normalized);
6951
+ modifiedAttribute = new import_three18.BufferAttribute(new Uint16Array(array), attribute.itemSize, attribute.normalized);
6709
6952
  }
6710
6953
  const accessor = this.processAccessor(modifiedAttribute || attribute, geometry);
6711
6954
  if (accessor !== null) {
@@ -6865,7 +7108,7 @@ var GLTFWriter = class {
6865
7108
  } else {
6866
7109
  cameraDef.perspective = {
6867
7110
  aspectRatio: camera.aspect,
6868
- yfov: import_three17.MathUtils.degToRad(camera.fov),
7111
+ yfov: import_three18.MathUtils.degToRad(camera.fov),
6869
7112
  zfar: camera.far <= 0 ? 1e-3 : camera.far,
6870
7113
  znear: camera.near < 0 ? 0 : camera.near
6871
7114
  };
@@ -6893,8 +7136,8 @@ var GLTFWriter = class {
6893
7136
  const samplers = [];
6894
7137
  for (let i = 0; i < tracks.length; ++i) {
6895
7138
  const track = tracks[i];
6896
- const trackBinding = import_three17.PropertyBinding.parseTrackName(track.name);
6897
- let trackNode = import_three17.PropertyBinding.findNode(root, trackBinding.nodeName);
7139
+ const trackBinding = import_three18.PropertyBinding.parseTrackName(track.name);
7140
+ let trackNode = import_three18.PropertyBinding.findNode(root, trackBinding.nodeName);
6898
7141
  const trackProperty = PATH_PROPERTIES[trackBinding.propertyName];
6899
7142
  if (trackBinding.objectName === "bones") {
6900
7143
  if (trackNode.isSkinnedMesh === true) {
@@ -6916,14 +7159,14 @@ var GLTFWriter = class {
6916
7159
  if (track.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline === true) {
6917
7160
  interpolation = "CUBICSPLINE";
6918
7161
  outputItemSize /= 3;
6919
- } else if (track.getInterpolation() === import_three17.InterpolateDiscrete) {
7162
+ } else if (track.getInterpolation() === import_three18.InterpolateDiscrete) {
6920
7163
  interpolation = "STEP";
6921
7164
  } else {
6922
7165
  interpolation = "LINEAR";
6923
7166
  }
6924
7167
  samplers.push({
6925
- input: this.processAccessor(new import_three17.BufferAttribute(track.times, inputItemSize)),
6926
- output: this.processAccessor(new import_three17.BufferAttribute(track.values, outputItemSize)),
7168
+ input: this.processAccessor(new import_three18.BufferAttribute(track.times, inputItemSize)),
7169
+ output: this.processAccessor(new import_three18.BufferAttribute(track.values, outputItemSize)),
6927
7170
  interpolation
6928
7171
  });
6929
7172
  channels.push({
@@ -6955,7 +7198,7 @@ var GLTFWriter = class {
6955
7198
  if (rootJoint === void 0) return null;
6956
7199
  const joints = [];
6957
7200
  const inverseBindMatrices = new Float32Array(skeleton.bones.length * 16);
6958
- const temporaryBoneInverse = new import_three17.Matrix4();
7201
+ const temporaryBoneInverse = new import_three18.Matrix4();
6959
7202
  for (let i = 0; i < skeleton.bones.length; ++i) {
6960
7203
  joints.push(nodeMap.get(skeleton.bones[i]));
6961
7204
  temporaryBoneInverse.copy(skeleton.boneInverses[i]);
@@ -6963,7 +7206,7 @@ var GLTFWriter = class {
6963
7206
  }
6964
7207
  if (json.skins === void 0) json.skins = [];
6965
7208
  json.skins.push({
6966
- inverseBindMatrices: this.processAccessor(new import_three17.BufferAttribute(inverseBindMatrices, 16)),
7209
+ inverseBindMatrices: this.processAccessor(new import_three18.BufferAttribute(inverseBindMatrices, 16)),
6967
7210
  joints,
6968
7211
  skeleton: nodeMap.get(rootJoint)
6969
7212
  });
@@ -7059,7 +7302,7 @@ var GLTFWriter = class {
7059
7302
  * @param {Array} objects List of objects to process
7060
7303
  */
7061
7304
  processObjects(objects) {
7062
- const scene = new import_three17.Scene();
7305
+ const scene = new import_three18.Scene();
7063
7306
  scene.name = "AuxScene";
7064
7307
  for (let i = 0; i < objects.length; i++) {
7065
7308
  scene.children.push(objects[i]);
@@ -7077,7 +7320,7 @@ var GLTFWriter = class {
7077
7320
  });
7078
7321
  const objectsWithoutScene = [];
7079
7322
  for (let i = 0; i < input.length; i++) {
7080
- if (input[i] instanceof import_three17.Scene) {
7323
+ if (input[i] instanceof import_three18.Scene) {
7081
7324
  this.processScene(input[i]);
7082
7325
  } else {
7083
7326
  objectsWithoutScene.push(input[i]);
@@ -7421,10 +7664,10 @@ var GLTFMeshGpuInstancing = class {
7421
7664
  const translationAttr = new Float32Array(mesh.count * 3);
7422
7665
  const rotationAttr = new Float32Array(mesh.count * 4);
7423
7666
  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();
7667
+ const matrix = new import_three18.Matrix4();
7668
+ const position = new import_three18.Vector3();
7669
+ const quaternion = new import_three18.Quaternion();
7670
+ const scale = new import_three18.Vector3();
7428
7671
  for (let i = 0; i < mesh.count; i++) {
7429
7672
  mesh.getMatrixAt(i, matrix);
7430
7673
  matrix.decompose(position, quaternion, scale);
@@ -7433,9 +7676,9 @@ var GLTFMeshGpuInstancing = class {
7433
7676
  scale.toArray(scaleAttr, i * 3);
7434
7677
  }
7435
7678
  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))
7679
+ TRANSLATION: writer.processAccessor(new import_three18.BufferAttribute(translationAttr, 3)),
7680
+ ROTATION: writer.processAccessor(new import_three18.BufferAttribute(rotationAttr, 4)),
7681
+ SCALE: writer.processAccessor(new import_three18.BufferAttribute(scaleAttr, 3))
7439
7682
  };
7440
7683
  if (mesh.instanceColor)
7441
7684
  attributes._COLOR_0 = writer.processAccessor(mesh.instanceColor);
@@ -7500,8 +7743,8 @@ GLTFExporter.Utils = {
7500
7743
  const sourceTracks = clip.tracks;
7501
7744
  for (let i = 0; i < sourceTracks.length; ++i) {
7502
7745
  let sourceTrack = sourceTracks[i];
7503
- const sourceTrackBinding = import_three17.PropertyBinding.parseTrackName(sourceTrack.name);
7504
- const sourceTrackNode = import_three17.PropertyBinding.findNode(root, sourceTrackBinding.nodeName);
7746
+ const sourceTrackBinding = import_three18.PropertyBinding.parseTrackName(sourceTrack.name);
7747
+ const sourceTrackNode = import_three18.PropertyBinding.findNode(root, sourceTrackBinding.nodeName);
7505
7748
  if (sourceTrackBinding.propertyName !== "morphTargetInfluences" || sourceTrackBinding.propertyIndex === void 0) {
7506
7749
  tracks.push(sourceTrack);
7507
7750
  continue;
@@ -7512,7 +7755,7 @@ GLTFExporter.Utils = {
7512
7755
  }
7513
7756
  console.warn("THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead.");
7514
7757
  sourceTrack = sourceTrack.clone();
7515
- sourceTrack.setInterpolation(import_three17.InterpolateLinear);
7758
+ sourceTrack.setInterpolation(import_three18.InterpolateLinear);
7516
7759
  }
7517
7760
  const targetCount = sourceTrackNode.morphTargetInfluences.length;
7518
7761
  const targetIndex = sourceTrackNode.morphTargetDictionary[sourceTrackBinding.propertyIndex];
@@ -7595,10 +7838,10 @@ var SceneExporter = class {
7595
7838
  }
7596
7839
  };
7597
7840
  function localMatrix(object) {
7598
- return object.matrixAutoUpdate ? new import_three18.Matrix4().compose(object.position, object.quaternion, object.scale) : object.matrix.clone();
7841
+ return object.matrixAutoUpdate ? new import_three19.Matrix4().compose(object.position, object.quaternion, object.scale) : object.matrix.clone();
7599
7842
  }
7600
7843
  function createSnapshot(root, gltf, bakeColors = false) {
7601
- const scene = new import_three18.Scene();
7844
+ const scene = new import_three19.Scene();
7602
7845
  const geometries = [];
7603
7846
  const materials = [];
7604
7847
  const textures = [];
@@ -7616,7 +7859,7 @@ function createSnapshot(root, gltf, bakeColors = false) {
7616
7859
  if (!uniforms.map?.value?.isTexture || !uniforms.SHADE || !uniforms.BRIGHTNESS || !uniforms.EMISSIVE) {
7617
7860
  throw new MineRenderError("glTF export does not support this custom ShaderMaterial");
7618
7861
  }
7619
- material = new import_three18.MeshBasicMaterial({
7862
+ material = new import_three19.MeshBasicMaterial({
7620
7863
  map: uniforms.map.value,
7621
7864
  vertexColors: source.vertexColors,
7622
7865
  transparent: source.transparent,
@@ -7626,7 +7869,7 @@ function createSnapshot(root, gltf, bakeColors = false) {
7626
7869
  });
7627
7870
  material.name = source.name;
7628
7871
  } else if (shader.isShaderMaterial) {
7629
- material = new import_three18.MeshBasicMaterial({ vertexColors: source.vertexColors });
7872
+ material = new import_three19.MeshBasicMaterial({ vertexColors: source.vertexColors });
7630
7873
  material.name = source.name;
7631
7874
  } else {
7632
7875
  const copySource = Object.create(source);
@@ -7680,11 +7923,11 @@ function createSnapshot(root, gltf, bakeColors = false) {
7680
7923
  const material = copyMaterial(sourceMaterial, geometry);
7681
7924
  if (!sourceMaterial.vertexColors) geometry.deleteAttribute("color");
7682
7925
  if (bakeColors || instanceColor) {
7683
- const tint = (material.color ?? new import_three18.Color()).clone();
7926
+ const tint = (material.color ?? new import_three19.Color()).clone();
7684
7927
  if (instanceColor) tint.multiply(instanceColor);
7685
7928
  if (bakeColors) {
7686
7929
  const original = geometry.getAttribute("color");
7687
- const colors = new import_three18.Float32BufferAttribute(new Float32Array(geometry.getAttribute("position").count * 3), 3);
7930
+ const colors = new import_three19.Float32BufferAttribute(new Float32Array(geometry.getAttribute("position").count * 3), 3);
7688
7931
  for (let i = 0; i < colors.count; i++) {
7689
7932
  colors.setXYZ(i, (original?.getX(i) ?? 1) * tint.r, (original?.getY(i) ?? 1) * tint.g, (original?.getZ(i) ?? 1) * tint.b);
7690
7933
  }
@@ -7693,7 +7936,7 @@ function createSnapshot(root, gltf, bakeColors = false) {
7693
7936
  material.color.copy(tint);
7694
7937
  }
7695
7938
  }
7696
- const copy = new import_three18.Mesh(geometry, material);
7939
+ const copy = new import_three19.Mesh(geometry, material);
7697
7940
  copy.name = mesh.name;
7698
7941
  copy.renderOrder = mesh.renderOrder;
7699
7942
  scene.add(copy);
@@ -7707,9 +7950,9 @@ function createSnapshot(root, gltf, bakeColors = false) {
7707
7950
  const instanced = mesh;
7708
7951
  if (instanced.isInstancedMesh) {
7709
7952
  for (let i = 0; i < instanced.count; i++) {
7710
- const matrix = new import_three18.Matrix4();
7953
+ const matrix = new import_three19.Matrix4();
7711
7954
  instanced.getMatrixAt(i, matrix);
7712
- const color = instanced.instanceColor ? new import_three18.Color().fromBufferAttribute(instanced.instanceColor, i) : void 0;
7955
+ const color = instanced.instanceColor ? new import_three19.Color().fromBufferAttribute(instanced.instanceColor, i) : void 0;
7713
7956
  addMesh(mesh, world.clone().multiply(matrix), color);
7714
7957
  }
7715
7958
  } else {
@@ -7721,7 +7964,7 @@ function createSnapshot(root, gltf, bakeColors = false) {
7721
7964
  try {
7722
7965
  const ancestors = [];
7723
7966
  for (let parent = root.parent; parent; parent = parent.parent) ancestors.unshift(parent);
7724
- const world = new import_three18.Matrix4();
7967
+ const world = new import_three19.Matrix4();
7725
7968
  for (const ancestor of ancestors) {
7726
7969
  if (!ancestor.visible) return { scene, dispose };
7727
7970
  world.multiply(localMatrix(ancestor));
@@ -7735,7 +7978,7 @@ function createSnapshot(root, gltf, bakeColors = false) {
7735
7978
  }
7736
7979
  function selectAlphaMode(material, geometry) {
7737
7980
  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;
7981
+ 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
7982
  const uv = geometry.getAttribute(texture.channel === 0 ? "uv" : `uv${texture.channel}`);
7740
7983
  const colors = geometry.getAttribute("color");
7741
7984
  if (!uv || material.vertexColors && colors?.itemSize === 4) return;
@@ -7772,7 +8015,7 @@ function selectAlphaMode(material, geometry) {
7772
8015
  }
7773
8016
  function copyDataTexture(source) {
7774
8017
  const image = source.image;
7775
- if (source.format !== import_three18.RGBAFormat || source.type !== import_three18.UnsignedByteType) {
8018
+ if (source.format !== import_three19.RGBAFormat || source.type !== import_three19.UnsignedByteType) {
7776
8019
  throw new MineRenderError("glTF export requires RGBA unsigned-byte data textures");
7777
8020
  }
7778
8021
  const canvas = createCanvas(image.width, image.height);
@@ -7783,8 +8026,8 @@ function copyDataTexture(source) {
7783
8026
  context.putImageData(pixels, 0, 0);
7784
8027
  const copySource = Object.create(source);
7785
8028
  copySource.userData = {};
7786
- copySource.source = new import_three18.Source(canvas);
7787
- return new import_three18.Texture().copy(copySource);
8029
+ copySource.source = new import_three19.Source(canvas);
8030
+ return new import_three19.Texture().copy(copySource);
7788
8031
  }
7789
8032
 
7790
8033
  // src/gui/GuiHelper.ts
@@ -7854,7 +8097,7 @@ var GuiHelper = class {
7854
8097
  };
7855
8098
 
7856
8099
  // src/gui/scene/GuiObject.ts
7857
- var import_three22 = require("three");
8100
+ var import_three23 = require("three");
7858
8101
  init_AssetKey();
7859
8102
  init_ModelTextures();
7860
8103
  init_Models();
@@ -7878,7 +8121,7 @@ var GuiObject = class extends SceneObject {
7878
8121
  this.textureLayers = textureLayers;
7879
8122
  this.isGuiObject = true;
7880
8123
  /** Local bounds in GUI pixels, with y growing down from the origin. */
7881
- this.bounds = new import_three22.Box2();
8124
+ this.bounds = new import_three23.Box2();
7882
8125
  this.geometries = /* @__PURE__ */ new Set();
7883
8126
  this.ownedMaterials = /* @__PURE__ */ new Set();
7884
8127
  this.initialized = false;
@@ -7895,7 +8138,7 @@ var GuiObject = class extends SceneObject {
7895
8138
  item.position.set(x + width2 / 2, -y - height2 / 2, 0);
7896
8139
  item.scale.set(width2 / 16, height2 / 16, width2 / 16);
7897
8140
  item.updateMatrix();
7898
- const bounds = new import_three22.Box3();
8141
+ const bounds = new import_three23.Box3();
7899
8142
  item.iterateAllMeshes((mesh2) => {
7900
8143
  mesh2.geometry.computeBoundingBox();
7901
8144
  bounds.union(mesh2.geometry.boundingBox);
@@ -7903,10 +8146,10 @@ var GuiObject = class extends SceneObject {
7903
8146
  bounds.applyMatrix4(item.matrix);
7904
8147
  item.position.z = depth - bounds.min.z;
7905
8148
  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));
8149
+ this.bounds.expandByPoint(new import_three23.Vector2(x, y));
8150
+ this.bounds.expandByPoint(new import_three23.Vector2(x + width2, y + height2));
8151
+ this.bounds.expandByPoint(new import_three23.Vector2(bounds.min.x, -bounds.max.y));
8152
+ this.bounds.expandByPoint(new import_three23.Vector2(bounds.max.x, -bounds.min.y));
7910
8153
  continue;
7911
8154
  }
7912
8155
  const key = typeof layer.texture === "string" ? AssetKey.parse("textures", layer.texture) : layer.texture;
@@ -7914,7 +8157,7 @@ var GuiObject = class extends SceneObject {
7914
8157
  const image = material.map.image;
7915
8158
  const [cropX, cropY, cropWidth, cropHeight] = layer.crop ?? [0, 0, image.width, image.height];
7916
8159
  const [width, height] = layer.size ?? [cropWidth, cropHeight];
7917
- const geometry = new import_three22.PlaneGeometry(width, height);
8160
+ const geometry = new import_three23.PlaneGeometry(width, height);
7918
8161
  this.geometries.add(geometry);
7919
8162
  const uv = geometry.getAttribute("uv");
7920
8163
  for (let i = 0; i < uv.count; i++) {
@@ -7924,13 +8167,13 @@ var GuiObject = class extends SceneObject {
7924
8167
  1 - (cropY + (1 - uv.getY(i)) * cropHeight) / image.height
7925
8168
  );
7926
8169
  }
7927
- const mesh = new import_three22.Mesh(geometry, material);
8170
+ const mesh = new import_three23.Mesh(geometry, material);
7928
8171
  mesh.name = `mesh:${layer.name ?? index}`;
7929
8172
  mesh.position.set(x + width / 2, -y - height / 2, depth);
7930
8173
  mesh.renderOrder = index;
7931
8174
  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));
8175
+ this.bounds.expandByPoint(new import_three23.Vector2(x, y));
8176
+ this.bounds.expandByPoint(new import_three23.Vector2(x + width, y + height));
7934
8177
  depth += 0.01;
7935
8178
  }
7936
8179
  for (const child of this.children) child.position.z -= depth - 0.01;
@@ -8005,7 +8248,7 @@ function isGuiObject(obj) {
8005
8248
  init_image();
8006
8249
 
8007
8250
  // src/inspector/SceneInspector.ts
8008
- var import_three23 = require("three");
8251
+ var import_three24 = require("three");
8009
8252
  init_SceneObject();
8010
8253
  init_util();
8011
8254
  init_log();
@@ -8015,11 +8258,11 @@ var help = "<span>Ctrl/Cmd+Click to Select<br/></span><br/>";
8015
8258
  var SceneInspector = class {
8016
8259
  constructor(renderer) {
8017
8260
  this.renderer = renderer;
8018
- this.mouse = new import_three23.Vector2();
8261
+ this.mouse = new import_three24.Vector2();
8019
8262
  this.listeners = new AbortController();
8020
8263
  this.objectInfoContainer = document.createElement("div");
8021
8264
  this.objectControlsContainer = document.createElement("div");
8022
- this.raycaster = new import_three23.Raycaster();
8265
+ this.raycaster = new import_three24.Raycaster();
8023
8266
  this.init();
8024
8267
  }
8025
8268
  init() {
@@ -8435,7 +8678,7 @@ init_ModelGenerator();
8435
8678
  init_ModelMerger();
8436
8679
 
8437
8680
  // src/model/block/BlockStateResolver.ts
8438
- var import_three25 = require("three");
8681
+ var import_three26 = require("three");
8439
8682
  init_BlockStates();
8440
8683
  init_MineRenderError();
8441
8684
  init_util();
@@ -8513,7 +8756,7 @@ var BlockStateResolver = class {
8513
8756
  return variants[variants.length - 1];
8514
8757
  }
8515
8758
  static rotation(variant) {
8516
- const rotation = new import_three25.Euler();
8759
+ const rotation = new import_three26.Euler();
8517
8760
  if (typeof variant.x !== "undefined") {
8518
8761
  rotation.x = toRadians(clampRotationDegrees(variant.x));
8519
8762
  }
@@ -8620,7 +8863,7 @@ init_SceneObject();
8620
8863
  init_ModelObject();
8621
8864
  init_Models();
8622
8865
  var import_ts_deepmerge6 = __toESM(require_dist());
8623
- var import_three28 = require("three");
8866
+ var import_three29 = require("three");
8624
8867
  init_MineRenderError();
8625
8868
  init_InstanceReference();
8626
8869
  init_AssetKey();
@@ -8640,6 +8883,9 @@ var _BlockObject = class _BlockObject extends SceneObject {
8640
8883
  this._variants = [];
8641
8884
  this._models = [];
8642
8885
  this._cullMask = 0;
8886
+ this._entities = [];
8887
+ this._entityPlacement = new import_three29.Matrix4();
8888
+ this._entityGeneration = 0;
8643
8889
  this.options = (0, import_ts_deepmerge6.default)({}, _BlockObject.DEFAULT_OPTIONS, options ?? {});
8644
8890
  }
8645
8891
  async init() {
@@ -8659,6 +8905,8 @@ var _BlockObject = class _BlockObject extends SceneObject {
8659
8905
  }
8660
8906
  clearModels() {
8661
8907
  this.removeModels(this._models.splice(0));
8908
+ this._entityGeneration++;
8909
+ this.removeEntities(this._entities.splice(0));
8662
8910
  this._fluidKey = void 0;
8663
8911
  this._fluidModel = void 0;
8664
8912
  this._isInstanced = false;
@@ -8670,6 +8918,57 @@ var _BlockObject = class _BlockObject extends SceneObject {
8670
8918
  if (!isInstanceReference(model)) model.dispose();
8671
8919
  }
8672
8920
  }
8921
+ removeEntities(entities) {
8922
+ for (const entity of entities) {
8923
+ entity.removeFromScene();
8924
+ entity.dispose();
8925
+ }
8926
+ }
8927
+ /** Entity models drawn for this block instead of its block model; they are scene children, unlike the block. */
8928
+ get blockEntities() {
8929
+ return this._entities;
8930
+ }
8931
+ /**
8932
+ * Draws the block through the dataset's block-entity index. Returns false, leaving nothing behind,
8933
+ * when the block is not listed or one of its models cannot be loaded.
8934
+ */
8935
+ async createBlockEntities() {
8936
+ const key = this.blockState.key;
8937
+ if (!key || this.options.displayPosition) return false;
8938
+ const generation = this._entityGeneration;
8939
+ const created = [];
8940
+ let resolved;
8941
+ try {
8942
+ resolved = BlockEntities.resolve(await BlockEntities.getIndex(key.root), key.toNamespacedString(), this.state);
8943
+ if (!resolved) return false;
8944
+ for (const part of resolved.parts) {
8945
+ const [namespace, path] = part.model.includes(":") ? part.model.split(":") : [key.namespace, part.model];
8946
+ const texture = part.textureLocation === void 0 ? void 0 : AssetKey.parse("textures", part.textureLocation.replace(/^([^:]+:)?textures\//, "$1"));
8947
+ if (texture) texture.root = key.root;
8948
+ const entity = await Entities.getEntity(new BasicAssetKey(namespace, path), texture, { layer: part.layer });
8949
+ if (!entity) throw new MineRenderError(`Missing entity model ${part.model}`);
8950
+ created.push(await this.scene.addEntity(entity, { wireframe: this.options.wireframe }));
8951
+ }
8952
+ } catch (error) {
8953
+ console.warn(`Could not draw block entity ${key.toNamespacedString()}, using its block model`, error);
8954
+ this.removeEntities(created);
8955
+ return false;
8956
+ }
8957
+ if (generation !== this._entityGeneration) {
8958
+ this.removeEntities(created);
8959
+ return true;
8960
+ }
8961
+ BlockEntities.matrix(resolved, this._entityPlacement);
8962
+ this._entities = created;
8963
+ this.placeEntities();
8964
+ return true;
8965
+ }
8966
+ placeEntities() {
8967
+ const matrix = new import_three29.Matrix4().makeTranslation(this.position.x - 8, this.position.y - 8, this.position.z - 8).multiply(this._entityPlacement);
8968
+ for (const entity of this._entities) {
8969
+ matrix.decompose(entity.position, entity.quaternion, entity.scale);
8970
+ }
8971
+ }
8673
8972
  get isOccluding() {
8674
8973
  return this._models.some((model) => {
8675
8974
  const object = isInstanceReference(model) ? model.instanceable : model;
@@ -8684,12 +8983,12 @@ var _BlockObject = class _BlockObject extends SceneObject {
8684
8983
  getModelCullMask(model, worldMask) {
8685
8984
  const object = isInstanceReference(model) ? model.instanceable : model;
8686
8985
  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();
8986
+ const position = new import_three29.Vector3();
8987
+ const rotation = new import_three29.Quaternion();
8988
+ const scale = new import_three29.Vector3();
8690
8989
  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));
8990
+ if (position.distanceToSquared(this.position) > 1e-10 || scale.distanceToSquared(new import_three29.Vector3(1, 1, 1)) > 1e-10) return 0;
8991
+ return ModelCulling.toLocalMask(worldMask, new import_three29.Euler().setFromQuaternion(rotation));
8693
8992
  }
8694
8993
  async setCullMask(worldMask) {
8695
8994
  worldMask &= 63;
@@ -8751,7 +9050,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
8751
9050
  () => new FluidModelObject2(kind, surface.sample, this.blockState.key, this.options)
8752
9051
  );
8753
9052
  const previous = this._fluidModel;
8754
- const matrix = previous ? this.getModelMatrix(previous) : new import_three28.Matrix4().makeTranslation(...this.position.toArray());
9053
+ const matrix = previous ? this.getModelMatrix(previous) : new import_three29.Matrix4().makeTranslation(...this.position.toArray());
8755
9054
  if (isInstanceReference(replacement)) replacement.setMatrix(matrix);
8756
9055
  else matrix.decompose(replacement.position, replacement.quaternion, replacement.scale);
8757
9056
  this._models = this._models.filter((model) => model !== previous);
@@ -8781,13 +9080,20 @@ var _BlockObject = class _BlockObject extends SceneObject {
8781
9080
  await this.updateFluid(this._fluidSampler);
8782
9081
  return;
8783
9082
  }
9083
+ const hasEntities = await this.createBlockEntities();
8784
9084
  const variantsToCreate = await this.mapStateToVariant(this.state);
8785
9085
  this._variants = variantsToCreate;
8786
9086
  for (let blockStateVariant of variantsToCreate) {
9087
+ if (hasEntities && !await this.hasGeometry(blockStateVariant)) continue;
8787
9088
  this._models.push(await this.createVariant(blockStateVariant));
8788
9089
  }
8789
9090
  await this.updateFluid(this._fluidSampler);
8790
9091
  }
9092
+ async hasGeometry(variant) {
9093
+ const modelKey = AssetKey.parse("models", variant.model);
9094
+ modelKey.root = this.blockState.key?.root;
9095
+ return !!(await Models.getMerged(modelKey))?.elements?.length;
9096
+ }
8791
9097
  getSingleVariant(variants) {
8792
9098
  return BlockStateResolver.choose(variants);
8793
9099
  }
@@ -8882,7 +9188,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
8882
9188
  setPositionRotationScaleAt(index, position, rotation, scale) {
8883
9189
  super.setPositionRotationScaleAt(index, position, rotation, scale);
8884
9190
  }
8885
- getMatrixAt(index, matrix = new import_three28.Matrix4()) {
9191
+ getMatrixAt(index, matrix = new import_three29.Matrix4()) {
8886
9192
  if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
8887
9193
  const child = this._models[0];
8888
9194
  if (child && isModelObject(child)) {
@@ -8907,6 +9213,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
8907
9213
  for (let model of this._models) {
8908
9214
  model.setPosition(position);
8909
9215
  }
9216
+ this.placeEntities();
8910
9217
  this.notifyDirty();
8911
9218
  }
8912
9219
  //TODO: should override rotation + scale methods
@@ -10752,7 +11059,7 @@ init_ModelObject();
10752
11059
  init_nbt();
10753
11060
 
10754
11061
  // src/renderer/MineRenderScene.ts
10755
- var import_three30 = require("three");
11062
+ var import_three31 = require("three");
10756
11063
  init_SceneObject();
10757
11064
  var import_ts_deepmerge8 = __toESM(require_dist());
10758
11065
  init_ModelObject();
@@ -11485,7 +11792,7 @@ var import_ts_deepmerge7 = __toESM(require_dist());
11485
11792
  init_util();
11486
11793
 
11487
11794
  // src/skin/SkinTextures.ts
11488
- var import_three29 = require("three");
11795
+ var import_three30 = require("three");
11489
11796
  init_Caching();
11490
11797
  init_CacheKey();
11491
11798
  init_MineRenderError();
@@ -11569,11 +11876,11 @@ var SkinTextures = class {
11569
11876
  });
11570
11877
  }
11571
11878
  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;
11879
+ const texture = Textures.initTextureProps(new import_three30.DataTexture(pixels, width, height));
11880
+ texture.colorSpace = import_three30.SRGBColorSpace;
11574
11881
  texture.flipY = true;
11575
11882
  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 });
11883
+ return new import_three30.MeshBasicMaterial({ map: texture, transparent, side: transparent ? import_three30.DoubleSide : import_three30.FrontSide, alphaTest: transparent ? 0.1 : 0 });
11577
11884
  }
11578
11885
  static isSlim(image, scale) {
11579
11886
  for (const [x, y] of [[46, 52], [54, 20]]) {
@@ -11801,7 +12108,7 @@ var SkinObject = class extends SceneObject {
11801
12108
  };
11802
12109
 
11803
12110
  // src/renderer/MineRenderScene.ts
11804
- var _MineRenderScene = class _MineRenderScene extends import_three30.Scene {
12111
+ var _MineRenderScene = class _MineRenderScene extends import_three31.Scene {
11805
12112
  constructor(options) {
11806
12113
  super();
11807
12114
  this.isMineRenderScene = true;
@@ -11928,7 +12235,7 @@ function isMineRenderScene(obj) {
11928
12235
  }
11929
12236
 
11930
12237
  // src/renderer/Renderer.ts
11931
- var import_three32 = require("three");
12238
+ var import_three33 = require("three");
11932
12239
  var import_ts_deepmerge9 = __toESM(require_dist());
11933
12240
  var import_stats = __toESM(require("stats.js"));
11934
12241
  var import_postprocessing = require("postprocessing");
@@ -11936,11 +12243,11 @@ init_util();
11936
12243
  init_three();
11937
12244
 
11938
12245
  // src/three/OrbitControls.js
11939
- var import_three31 = require("three");
12246
+ var import_three32 = require("three");
11940
12247
  var _changeEvent = { type: "change" };
11941
12248
  var _startEvent = { type: "start" };
11942
12249
  var _endEvent = { type: "end" };
11943
- var OrbitControls = class extends import_three31.EventDispatcher {
12250
+ var OrbitControls = class extends import_three32.EventDispatcher {
11944
12251
  constructor(object, domElement) {
11945
12252
  super();
11946
12253
  if (domElement === void 0) console.warn('THREE.OrbitControls: The second parameter "domElement" is now mandatory.');
@@ -11949,7 +12256,7 @@ var OrbitControls = class extends import_three31.EventDispatcher {
11949
12256
  this.domElement = domElement;
11950
12257
  this.domElement.style.touchAction = "none";
11951
12258
  this.enabled = true;
11952
- this.target = new import_three31.Vector3();
12259
+ this.target = new import_three32.Vector3();
11953
12260
  this.minDistance = 0;
11954
12261
  this.maxDistance = Infinity;
11955
12262
  this.minZoom = 0;
@@ -11971,8 +12278,8 @@ var OrbitControls = class extends import_three31.EventDispatcher {
11971
12278
  this.autoRotate = false;
11972
12279
  this.autoRotateSpeed = 2;
11973
12280
  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 };
12281
+ this.mouseButtons = { LEFT: import_three32.MOUSE.ROTATE, MIDDLE: import_three32.MOUSE.DOLLY, RIGHT: import_three32.MOUSE.PAN };
12282
+ this.touches = { ONE: import_three32.TOUCH.ROTATE, TWO: import_three32.TOUCH.DOLLY_PAN };
11976
12283
  this.target0 = this.target.clone();
11977
12284
  this.position0 = this.object.position.clone();
11978
12285
  this.zoom0 = this.object.zoom;
@@ -12001,11 +12308,11 @@ var OrbitControls = class extends import_three31.EventDispatcher {
12001
12308
  state = STATE.NONE;
12002
12309
  };
12003
12310
  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));
12311
+ const offset = new import_three32.Vector3();
12312
+ const quat = new import_three32.Quaternion().setFromUnitVectors(object.up, new import_three32.Vector3(0, 1, 0));
12006
12313
  const quatInverse = quat.clone().invert();
12007
- const lastPosition = new import_three31.Vector3();
12008
- const lastQuaternion = new import_three31.Quaternion();
12314
+ const lastPosition = new import_three32.Vector3();
12315
+ const lastQuaternion = new import_three32.Quaternion();
12009
12316
  const twoPI = 2 * Math.PI;
12010
12317
  return function update() {
12011
12318
  const position = scope.object.position;
@@ -12091,20 +12398,20 @@ var OrbitControls = class extends import_three31.EventDispatcher {
12091
12398
  };
12092
12399
  let state = STATE.NONE;
12093
12400
  const EPS = 1e-6;
12094
- const spherical = new import_three31.Spherical();
12095
- const sphericalDelta = new import_three31.Spherical();
12401
+ const spherical = new import_three32.Spherical();
12402
+ const sphericalDelta = new import_three32.Spherical();
12096
12403
  let scale = 1;
12097
- const panOffset = new import_three31.Vector3();
12404
+ const panOffset = new import_three32.Vector3();
12098
12405
  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();
12406
+ const rotateStart = new import_three32.Vector2();
12407
+ const rotateEnd = new import_three32.Vector2();
12408
+ const rotateDelta = new import_three32.Vector2();
12409
+ const panStart = new import_three32.Vector2();
12410
+ const panEnd = new import_three32.Vector2();
12411
+ const panDelta = new import_three32.Vector2();
12412
+ const dollyStart = new import_three32.Vector2();
12413
+ const dollyEnd = new import_three32.Vector2();
12414
+ const dollyDelta = new import_three32.Vector2();
12108
12415
  const pointers = [];
12109
12416
  const pointerPositions = {};
12110
12417
  function getAutoRotationAngle() {
@@ -12120,7 +12427,7 @@ var OrbitControls = class extends import_three31.EventDispatcher {
12120
12427
  sphericalDelta.phi -= angle;
12121
12428
  }
12122
12429
  const panLeft = function() {
12123
- const v = new import_three31.Vector3();
12430
+ const v = new import_three32.Vector3();
12124
12431
  return function panLeft2(distance, objectMatrix) {
12125
12432
  v.setFromMatrixColumn(objectMatrix, 0);
12126
12433
  v.multiplyScalar(-distance);
@@ -12128,7 +12435,7 @@ var OrbitControls = class extends import_three31.EventDispatcher {
12128
12435
  };
12129
12436
  }();
12130
12437
  const panUp = function() {
12131
- const v = new import_three31.Vector3();
12438
+ const v = new import_three32.Vector3();
12132
12439
  return function panUp2(distance, objectMatrix) {
12133
12440
  if (scope.screenSpacePanning === true) {
12134
12441
  v.setFromMatrixColumn(objectMatrix, 1);
@@ -12141,7 +12448,7 @@ var OrbitControls = class extends import_three31.EventDispatcher {
12141
12448
  };
12142
12449
  }();
12143
12450
  const pan = function() {
12144
- const offset = new import_three31.Vector3();
12451
+ const offset = new import_three32.Vector3();
12145
12452
  return function pan2(deltaX, deltaY) {
12146
12453
  const element = scope.domElement;
12147
12454
  if (scope.object.isPerspectiveCamera) {
@@ -12390,12 +12697,12 @@ var OrbitControls = class extends import_three31.EventDispatcher {
12390
12697
  mouseAction = -1;
12391
12698
  }
12392
12699
  switch (mouseAction) {
12393
- case import_three31.MOUSE.DOLLY:
12700
+ case import_three32.MOUSE.DOLLY:
12394
12701
  if (scope.enableZoom === false) return;
12395
12702
  handleMouseDownDolly(event);
12396
12703
  state = STATE.DOLLY;
12397
12704
  break;
12398
- case import_three31.MOUSE.ROTATE:
12705
+ case import_three32.MOUSE.ROTATE:
12399
12706
  if (event.ctrlKey || event.metaKey || event.shiftKey) {
12400
12707
  if (scope.enablePan === false) return;
12401
12708
  handleMouseDownPan(event);
@@ -12406,7 +12713,7 @@ var OrbitControls = class extends import_three31.EventDispatcher {
12406
12713
  state = STATE.ROTATE;
12407
12714
  }
12408
12715
  break;
12409
- case import_three31.MOUSE.PAN:
12716
+ case import_three32.MOUSE.PAN:
12410
12717
  if (event.ctrlKey || event.metaKey || event.shiftKey) {
12411
12718
  if (scope.enableRotate === false) return;
12412
12719
  handleMouseDownRotate(event);
@@ -12462,12 +12769,12 @@ var OrbitControls = class extends import_three31.EventDispatcher {
12462
12769
  switch (pointers.length) {
12463
12770
  case 1:
12464
12771
  switch (scope.touches.ONE) {
12465
- case import_three31.TOUCH.ROTATE:
12772
+ case import_three32.TOUCH.ROTATE:
12466
12773
  if (scope.enableRotate === false) return;
12467
12774
  handleTouchStartRotate();
12468
12775
  state = STATE.TOUCH_ROTATE;
12469
12776
  break;
12470
- case import_three31.TOUCH.PAN:
12777
+ case import_three32.TOUCH.PAN:
12471
12778
  if (scope.enablePan === false) return;
12472
12779
  handleTouchStartPan();
12473
12780
  state = STATE.TOUCH_PAN;
@@ -12478,12 +12785,12 @@ var OrbitControls = class extends import_three31.EventDispatcher {
12478
12785
  break;
12479
12786
  case 2:
12480
12787
  switch (scope.touches.TWO) {
12481
- case import_three31.TOUCH.DOLLY_PAN:
12788
+ case import_three32.TOUCH.DOLLY_PAN:
12482
12789
  if (scope.enableZoom === false && scope.enablePan === false) return;
12483
12790
  handleTouchStartDollyPan();
12484
12791
  state = STATE.TOUCH_DOLLY_PAN;
12485
12792
  break;
12486
- case import_three31.TOUCH.DOLLY_ROTATE:
12793
+ case import_three32.TOUCH.DOLLY_ROTATE:
12487
12794
  if (scope.enableZoom === false && scope.enableRotate === false) return;
12488
12795
  handleTouchStartDollyRotate();
12489
12796
  state = STATE.TOUCH_DOLLY_ROTATE;
@@ -12550,7 +12857,7 @@ var OrbitControls = class extends import_three31.EventDispatcher {
12550
12857
  function trackPointer(event) {
12551
12858
  let position = pointerPositions[event.pointerId];
12552
12859
  if (position === void 0) {
12553
- position = new import_three31.Vector2();
12860
+ position = new import_three32.Vector2();
12554
12861
  pointerPositions[event.pointerId] = position;
12555
12862
  }
12556
12863
  position.set(event.pageX, event.pageY);
@@ -12570,10 +12877,10 @@ var MapControls = class extends OrbitControls {
12570
12877
  constructor(object, domElement) {
12571
12878
  super(object, domElement);
12572
12879
  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;
12880
+ this.mouseButtons.LEFT = import_three32.MOUSE.PAN;
12881
+ this.mouseButtons.RIGHT = import_three32.MOUSE.ROTATE;
12882
+ this.touches.ONE = import_three32.TOUCH.PAN;
12883
+ this.touches.TWO = import_three32.TOUCH.DOLLY_ROTATE;
12577
12884
  }
12578
12885
  };
12579
12886
 
@@ -12624,14 +12931,14 @@ var _Renderer = class _Renderer {
12624
12931
  switch (this.options.camera.type) {
12625
12932
  case "perspective":
12626
12933
  default:
12627
- return new import_three32.PerspectiveCamera(
12934
+ return new import_three33.PerspectiveCamera(
12628
12935
  this.options.camera.perspective.fov,
12629
12936
  this.options.camera.perspective.aspect ?? this.viewWidth / this.viewHeight,
12630
12937
  this.options.camera.near,
12631
12938
  this.options.camera.far
12632
12939
  );
12633
12940
  case "orthographic":
12634
- return new import_three32.OrthographicCamera(
12941
+ return new import_three33.OrthographicCamera(
12635
12942
  this.options.camera.orthographic.left ?? this.viewWidth / -2,
12636
12943
  this.options.camera.orthographic.right ?? this.viewWidth / 2,
12637
12944
  this.options.camera.orthographic.top ?? this.viewHeight / 2,
@@ -12642,7 +12949,7 @@ var _Renderer = class _Renderer {
12642
12949
  }
12643
12950
  }
12644
12951
  createRenderer() {
12645
- const renderer = new import_three32.WebGLRenderer({
12952
+ const renderer = new import_three33.WebGLRenderer({
12646
12953
  antialias: this.options.render.antialias,
12647
12954
  alpha: true,
12648
12955
  powerPreference: "high-performance",
@@ -12650,8 +12957,8 @@ var _Renderer = class _Renderer {
12650
12957
  });
12651
12958
  renderer.setClearColor(0, 0);
12652
12959
  renderer.shadowMap.enabled = true;
12653
- renderer.shadowMap.type = import_three32.PCFSoftShadowMap;
12654
- renderer.outputColorSpace = import_three32.SRGBColorSpace;
12960
+ renderer.shadowMap.type = import_three33.PCFSoftShadowMap;
12961
+ renderer.outputColorSpace = import_three33.SRGBColorSpace;
12655
12962
  renderer.setPixelRatio(this.options.render.pixelRatio ?? 1);
12656
12963
  renderer.setSize(this.viewWidth, this.viewHeight);
12657
12964
  return renderer;
@@ -12686,20 +12993,20 @@ var _Renderer = class _Renderer {
12686
12993
  window["__THREE_DEVTOOLS__"].dispatchEvent(new CustomEvent("observe", { detail: this.scene }));
12687
12994
  }
12688
12995
  if (this.options.debug.grid) {
12689
- const gridHelper = new import_three32.GridHelper(128, 16);
12996
+ const gridHelper = new import_three33.GridHelper(128, 16);
12690
12997
  this._debugHelpers.push(gridHelper);
12691
12998
  this.scene.add(gridHelper);
12692
- const gridHelper2 = new import_three32.GridHelper(128, 16);
12999
+ const gridHelper2 = new import_three33.GridHelper(128, 16);
12693
13000
  this._debugHelpers.push(gridHelper2);
12694
13001
  gridHelper2.rotation.x = 90 * (Math.PI / 180);
12695
13002
  this.scene.add(gridHelper2);
12696
- const gridHelper3 = new import_three32.GridHelper(128, 16);
13003
+ const gridHelper3 = new import_three33.GridHelper(128, 16);
12697
13004
  this._debugHelpers.push(gridHelper3);
12698
13005
  gridHelper3.rotation.z = 90 * (Math.PI / 180);
12699
13006
  this.scene.add(gridHelper3);
12700
13007
  }
12701
13008
  if (this.options.debug.axes) {
12702
- const axesHelper = new import_three32.AxesHelper(64);
13009
+ const axesHelper = new import_three33.AxesHelper(64);
12703
13010
  this._debugHelpers.push(axesHelper);
12704
13011
  this.scene.add(axesHelper);
12705
13012
  }
@@ -12958,8 +13265,8 @@ _Renderer.DEFAULT_OPTIONS = (0, import_ts_deepmerge9.default)({}, {
12958
13265
  top: void 0,
12959
13266
  bottom: void 0
12960
13267
  },
12961
- position: new import_three32.Vector3(50, 50, 50),
12962
- lookingAt: new import_three32.Vector3(0, 0, 0)
13268
+ position: new import_three33.Vector3(50, 50, 50),
13269
+ lookingAt: new import_three33.Vector3(0, 0, 0)
12963
13270
  },
12964
13271
  render: {
12965
13272
  fpsLimit: 60,
@@ -13423,19 +13730,19 @@ var AnvilParser = class {
13423
13730
  };
13424
13731
 
13425
13732
  // src/world/Chunk.ts
13426
- var import_three37 = require("three");
13733
+ var import_three38 = require("three");
13427
13734
  init_BlockStates();
13428
13735
  init_AssetKey();
13429
13736
 
13430
13737
  // src/world/MineRenderWorld.ts
13431
- var import_three35 = require("three");
13738
+ var import_three36 = require("three");
13432
13739
  init_BatchedExecutor();
13433
13740
  init_AssetKey();
13434
13741
  init_BlockStates();
13435
13742
  init_CubeFace();
13436
13743
 
13437
13744
  // src/world/SectionModels.ts
13438
- var import_three34 = require("three");
13745
+ var import_three35 = require("three");
13439
13746
  init_AssetKey();
13440
13747
  init_Models();
13441
13748
  init_CubeFace();
@@ -13501,12 +13808,12 @@ var SectionModels = class {
13501
13808
  });
13502
13809
  await object.init();
13503
13810
  const geometry = object.children[0].geometry;
13504
- geometry.applyMatrix4(new import_three34.Matrix4().makeRotationFromEuler(rotation));
13811
+ geometry.applyMatrix4(new import_three35.Matrix4().makeRotationFromEuler(rotation));
13505
13812
  object.clear();
13506
13813
  const cullFaces = CUBE_FACES.map((face) => {
13507
13814
  const local = CUBE_FACES.findIndex((name) => name === atlas.model.elements[0].faces[face]?.cullface);
13508
13815
  if (local < 0) return 0;
13509
- const normal = new import_three34.Vector3(...CUBE_FACE_OFFSETS[local]).applyEuler(rotation);
13816
+ const normal = new import_three35.Vector3(...CUBE_FACE_OFFSETS[local]).applyEuler(rotation);
13510
13817
  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
13818
  return 1 << world;
13512
13819
  });
@@ -13536,20 +13843,20 @@ var MineRenderWorld = class {
13536
13843
  }
13537
13844
  getBlockAt(posOrX, y, z) {
13538
13845
  if (typeof posOrX == "number") {
13539
- return this.getBlockAt(new import_three35.Vector3(posOrX, y, z));
13846
+ return this.getBlockAt(new import_three36.Vector3(posOrX, y, z));
13540
13847
  }
13541
13848
  if (isTripleArray(posOrX)) {
13542
- return this.getBlockAt(new import_three35.Vector3(posOrX[0], posOrX[1], posOrX[2]));
13849
+ return this.getBlockAt(new import_three36.Vector3(posOrX[0], posOrX[1], posOrX[2]));
13543
13850
  }
13544
13851
  this.validatePosBounds(posOrX);
13545
13852
  return this.getChunkAt(posOrX)?.getBlockAt(posOrX);
13546
13853
  }
13547
13854
  async setBlockAt(posOrX, yOrBlock, z, block) {
13548
13855
  if (typeof posOrX == "number") {
13549
- return this.setBlockAt(new import_three35.Vector3(posOrX, yOrBlock, z), block);
13856
+ return this.setBlockAt(new import_three36.Vector3(posOrX, yOrBlock, z), block);
13550
13857
  }
13551
13858
  if (isTripleArray(posOrX)) {
13552
- return this.setBlockAt(new import_three35.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
13859
+ return this.setBlockAt(new import_three36.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
13553
13860
  }
13554
13861
  return this.placeBlock(posOrX, yOrBlock);
13555
13862
  }
@@ -13570,7 +13877,7 @@ var MineRenderWorld = class {
13570
13877
  const collect = async (positions2) => {
13571
13878
  for (const pos of positions2) changes.set(pos.toArray().join(","), pos);
13572
13879
  };
13573
- const place = (block) => this.placeBlock(new import_three35.Vector3(...block.position), block, collect);
13880
+ const place = (block) => this.placeBlock(new import_three36.Vector3(...block.position), block, collect);
13574
13881
  const keys = /* @__PURE__ */ new Map();
13575
13882
  for (const block of multiblock.blocks) {
13576
13883
  if (Chunk.isAir(block)) continue;
@@ -13648,13 +13955,13 @@ var MineRenderWorld = class {
13648
13955
  for (const pos of positions) {
13649
13956
  this.pendingCulling.set(pos.toArray().join(","), pos.clone());
13650
13957
  for (const offset of CUBE_FACE_OFFSETS) {
13651
- const neighbor = pos.clone().add(new import_three35.Vector3(...offset));
13958
+ const neighbor = pos.clone().add(new import_three36.Vector3(...offset));
13652
13959
  this.pendingCulling.set(neighbor.toArray().join(","), neighbor);
13653
13960
  }
13654
13961
  for (let y = -1; y <= 1; y++) {
13655
13962
  for (let z = -1; z <= 1; z++) {
13656
13963
  for (let x = -1; x <= 1; x++) {
13657
- const neighbor = pos.clone().add(new import_three35.Vector3(x, y, z));
13964
+ const neighbor = pos.clone().add(new import_three36.Vector3(x, y, z));
13658
13965
  if (this.getBlockAt(neighbor)?.object?.fluidKind) {
13659
13966
  this.pendingCulling.set(neighbor.toArray().join(","), neighbor);
13660
13967
  }
@@ -13676,7 +13983,7 @@ var MineRenderWorld = class {
13676
13983
  if (!block) continue;
13677
13984
  if (block.object?.fluidKind) {
13678
13985
  await block.object.updateFluid((x, y, z) => {
13679
- const neighbor = pos.clone().add(new import_three35.Vector3(x, y, z));
13986
+ const neighbor = pos.clone().add(new import_three36.Vector3(x, y, z));
13680
13987
  const section = this.getChunkAt(neighbor);
13681
13988
  const object = section?.getBlockAt(neighbor)?.object;
13682
13989
  return {
@@ -13688,7 +13995,7 @@ var MineRenderWorld = class {
13688
13995
  }
13689
13996
  let mask = 0;
13690
13997
  for (const [face, offset] of CUBE_FACE_OFFSETS.entries()) {
13691
- const neighbor = pos.clone().add(new import_three35.Vector3(...offset));
13998
+ const neighbor = pos.clone().add(new import_three36.Vector3(...offset));
13692
13999
  if (this.getChunkAt(neighbor)?.isOccludingAt(neighbor)) {
13693
14000
  mask |= 1 << face;
13694
14001
  }
@@ -13722,14 +14029,14 @@ var MineRenderWorld = class {
13722
14029
  return this._chunks.get(this.worldPosToChunkKey(pos));
13723
14030
  }
13724
14031
  static worldToScenePosition(pos) {
13725
- return new import_three35.Vector3(
14032
+ return new import_three36.Vector3(
13726
14033
  pos.x * 16,
13727
14034
  pos.y * 16,
13728
14035
  pos.z * 16
13729
14036
  );
13730
14037
  }
13731
14038
  static sceneToWorldPosition(pos) {
13732
- return new import_three35.Vector3(
14039
+ return new import_three36.Vector3(
13733
14040
  pos.x / 16,
13734
14041
  pos.y / 16,
13735
14042
  pos.z / 16
@@ -13749,10 +14056,10 @@ var MineRenderWorld = class {
13749
14056
  };
13750
14057
 
13751
14058
  // src/world/SectionMesh.ts
13752
- var import_three36 = require("three");
14059
+ var import_three37 = require("three");
13753
14060
  init_CanvasCompat();
13754
14061
  init_Materials();
13755
- var SectionMesh = class _SectionMesh extends import_three36.Group {
14062
+ var SectionMesh = class _SectionMesh extends import_three37.Group {
13756
14063
  constructor() {
13757
14064
  super(...arguments);
13758
14065
  this.ownedMeshes = [];
@@ -13825,18 +14132,18 @@ var SectionMesh = class _SectionMesh extends import_three36.Group {
13825
14132
  for (let corner = 0; corner < 6; corner++) indices.push(start + sourceIndices.getX(face * 6 + corner) - face * 4);
13826
14133
  }
13827
14134
  }
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));
14135
+ const geometry = new import_three37.BufferGeometry();
14136
+ geometry.setAttribute("position", new import_three37.Float32BufferAttribute(positions, 3));
14137
+ geometry.setAttribute("normal", new import_three37.Float32BufferAttribute(normals, 3));
14138
+ geometry.setAttribute("uv", new import_three37.Float32BufferAttribute(uvs, 2));
14139
+ geometry.setAttribute("color", new import_three37.Float32BufferAttribute(colors, 3));
13833
14140
  geometry.setIndex(indices);
13834
14141
  geometry.computeBoundingBox();
13835
14142
  geometry.computeBoundingSphere();
13836
14143
  const material = Materials.createShadedCanvasMaterial(canvas, false);
13837
14144
  material.vertexColors = true;
13838
14145
  const texture = material.uniforms?.map?.value ?? material.map;
13839
- const mesh = new import_three36.Mesh(geometry, material);
14146
+ const mesh = new import_three37.Mesh(geometry, material);
13840
14147
  section.add(mesh);
13841
14148
  section.ownedMeshes.push({ mesh, texture });
13842
14149
  }
@@ -13870,10 +14177,10 @@ var Chunk = class _Chunk {
13870
14177
  }
13871
14178
  getBlockAt(posOrX, y, z) {
13872
14179
  if (typeof posOrX == "number") {
13873
- return this.getBlockAt(new import_three37.Vector3(posOrX, y, z));
14180
+ return this.getBlockAt(new import_three38.Vector3(posOrX, y, z));
13874
14181
  }
13875
14182
  if (isTripleArray(posOrX)) {
13876
- return this.getBlockAt(new import_three37.Vector3(posOrX[0], posOrX[1], posOrX[2]));
14183
+ return this.getBlockAt(new import_three38.Vector3(posOrX[0], posOrX[1], posOrX[2]));
13877
14184
  }
13878
14185
  const pos = this.worldPosToChunkPos(posOrX);
13879
14186
  const index = _Chunk.chunkPosToBlockIndex(pos);
@@ -13881,10 +14188,10 @@ var Chunk = class _Chunk {
13881
14188
  }
13882
14189
  async setBlockAt(posOrX, yOrBlock, z, block) {
13883
14190
  if (typeof posOrX == "number") {
13884
- return this.setBlockAt(new import_three37.Vector3(posOrX, yOrBlock, z), block);
14191
+ return this.setBlockAt(new import_three38.Vector3(posOrX, yOrBlock, z), block);
13885
14192
  }
13886
14193
  if (isTripleArray(posOrX)) {
13887
- return this.setBlockAt(new import_three37.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
14194
+ return this.setBlockAt(new import_three38.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
13888
14195
  }
13889
14196
  const worldPos = posOrX;
13890
14197
  const pos = this.worldPosToChunkPos(worldPos);
@@ -13913,7 +14220,8 @@ var Chunk = class _Chunk {
13913
14220
  this.data.set(index, void 0);
13914
14221
  return void 0;
13915
14222
  }
13916
- const template = getFluidKind(blockState.key, stored.properties) ? void 0 : await this.sectionModels?.get(blockState, stored.properties);
14223
+ const perBlock = !this.sectionModels || getFluidKind(blockState.key, stored.properties) || blockState.key && BlockEntities.entry(await BlockEntities.getIndex(blockState.key.root), blockState.key.toNamespacedString());
14224
+ const template = perBlock ? void 0 : await this.sectionModels.get(blockState, stored.properties);
13917
14225
  if (template) {
13918
14226
  this.sectionBlocks.set(index, { index, template, cullMask: 0 });
13919
14227
  this.meshDirty = true;
@@ -13969,7 +14277,7 @@ var Chunk = class _Chunk {
13969
14277
  }
13970
14278
  async clear(onBlocksChanged = this.onBlocksChanged) {
13971
14279
  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)
14280
+ new import_three38.Vector3(index % 16, Math.floor(index / 256), Math.floor(index / 16) % 16)
13973
14281
  ));
13974
14282
  for (const info of this.renderedBlocks.values()) info.object?.removeFromScene();
13975
14283
  this.sectionBlocks.clear();
@@ -13993,14 +14301,14 @@ var Chunk = class _Chunk {
13993
14301
  return pos.y * 16 * 16 + pos.z * 16 + pos.x;
13994
14302
  }
13995
14303
  worldPosToChunkPos(pos) {
13996
- return new import_three37.Vector3(
14304
+ return new import_three38.Vector3(
13997
14305
  pos.x - this.x * 16,
13998
14306
  pos.y - this.y * 16,
13999
14307
  pos.z - this.z * 16
14000
14308
  );
14001
14309
  }
14002
14310
  chunkPosToWorldPos(pos) {
14003
- return new import_three37.Vector3(
14311
+ return new import_three38.Vector3(
14004
14312
  this.x * 16 + pos.x,
14005
14313
  this.y * 16 + pos.y,
14006
14314
  this.z * 16 + pos.z