minerender 2.1.0-alpha.32 → 2.1.0-alpha.34

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.
@@ -2879,26 +2879,40 @@ var Entities = class {
2879
2879
  };
2880
2880
  return collect("");
2881
2881
  }
2882
- static async getEntity(modelKey, textureKey, options) {
2882
+ static async getModelFile(modelKey) {
2883
2883
  const path = isAssetKey(modelKey) ? modelKey.getFullPath() : modelKey.path;
2884
2884
  const key = new AssetKey(modelKey.namespace, path, void 0, void 0, "entity-models", ".json");
2885
- const model = await Caching.entityModelCache.get(key.serialize(), () => AssetLoader.get(key, "json" /* JSON */));
2885
+ return Caching.entityModelCache.get(key.serialize(), () => AssetLoader.get(key, "json" /* JSON */));
2886
+ }
2887
+ static async getLayerList(modelKey) {
2888
+ return Object.keys((await this.getModelFile(modelKey))?.layers ?? {});
2889
+ }
2890
+ static async getEntity(modelKey, textureKey, options) {
2891
+ const model = await this.getModelFile(modelKey);
2886
2892
  if (!model) return void 0;
2887
- const layerName = options?.layer ?? "main";
2888
- const layer = model.layers[layerName];
2889
- if (!layer) {
2890
- throw new MineRenderError(`Entity ${model.id} has no layer "${layerName}". Available layers: ${Object.keys(model.layers).join(", ")}`);
2891
- }
2892
- let texture;
2893
- if (textureKey) {
2894
- const path2 = isAssetKey(textureKey) ? textureKey.getFullPath() : textureKey.path;
2895
- texture = isAssetKey(textureKey) && textureKey.assetType === "textures" && path2.startsWith("entity/") ? textureKey : new AssetKey(textureKey.namespace, path2, "textures", "entity", "assets", ".png", isAssetKey(textureKey) ? textureKey.root : void 0);
2896
- } else if (layer.textureLocation !== void 0) {
2897
- texture = AssetKey.parse("textures", layer.textureLocation.replace(/^([^:]+:)?textures\//, "$1"));
2898
- } else {
2899
- texture = await this.resolveTexture(modelKey);
2900
- }
2901
- return { key: textureKey ?? modelKey, texture, layer, id: model.id };
2893
+ const names = [...new Set(options?.layers ?? [options?.layer ?? "main"])];
2894
+ if (names.length === 0) throw new MineRenderError(`Entity ${model.id} requires at least one layer`);
2895
+ const selected = names.map((name) => {
2896
+ const layer = model.layers[name];
2897
+ if (!layer) {
2898
+ throw new MineRenderError(`Entity ${model.id} has no layer "${name}". Available layers: ${Object.keys(model.layers).join(", ")}`);
2899
+ }
2900
+ return { name, layer };
2901
+ });
2902
+ const layers = Object.fromEntries(await Promise.all(selected.map(async ({ name, layer }, index) => {
2903
+ const override = options?.textures?.[name] ?? (index === 0 ? textureKey : void 0);
2904
+ let texture;
2905
+ if (override) {
2906
+ const path = isAssetKey(override) ? override.getFullPath() : override.path;
2907
+ texture = isAssetKey(override) && override.assetType === "textures" && path.startsWith("entity/") ? override : new AssetKey(override.namespace, path, "textures", "entity", "assets", ".png", isAssetKey(override) ? override.root : void 0);
2908
+ } else if (layer.textureLocation !== void 0) {
2909
+ texture = AssetKey.parse("textures", layer.textureLocation.replace(/^([^:]+:)?textures\//, "$1"));
2910
+ } else {
2911
+ texture = await this.resolveTexture(modelKey);
2912
+ }
2913
+ return [name, { key: override ?? modelKey, texture, layer }];
2914
+ })));
2915
+ return { ...layers[names[0]], id: model.id, layers };
2902
2916
  }
2903
2917
  static async resolveTexture(modelKey) {
2904
2918
  const path = isAssetKey(modelKey) ? modelKey.getFullPath() : modelKey.path;
@@ -2944,32 +2958,42 @@ var InstanceReference = class {
2944
2958
  nextInstance() {
2945
2959
  return this.instanceable.nextInstance();
2946
2960
  }
2961
+ get activeInstanceable() {
2962
+ if (!this.instanceable.isInstanceActive(this.index, this)) throw new MineRenderError("Instance has been removed");
2963
+ return this.instanceable;
2964
+ }
2965
+ removeFromScene() {
2966
+ if (this.instanceable.isInstanceActive(this.index, this)) this.instanceable.removeInstanceAt(this.index);
2967
+ }
2968
+ dispose() {
2969
+ this.removeFromScene();
2970
+ }
2947
2971
  getMatrix(matrix) {
2948
- return this.instanceable.getMatrixAt(this.index, matrix);
2972
+ return this.activeInstanceable.getMatrixAt(this.index, matrix);
2949
2973
  }
2950
2974
  setMatrix(matrix) {
2951
- this.instanceable.setMatrixAt(this.index, matrix);
2975
+ this.activeInstanceable.setMatrixAt(this.index, matrix);
2952
2976
  }
2953
2977
  setPositionRotationScale(position, rotation, scale) {
2954
- this.instanceable.setPositionRotationScaleAt(this.index, position, rotation, scale);
2978
+ this.activeInstanceable.setPositionRotationScaleAt(this.index, position, rotation, scale);
2955
2979
  }
2956
2980
  setPosition(position) {
2957
- this.instanceable.setPositionAt(this.index, position);
2981
+ this.activeInstanceable.setPositionAt(this.index, position);
2958
2982
  }
2959
2983
  getPosition() {
2960
- return this.instanceable.getPositionAt(this.index);
2984
+ return this.activeInstanceable.getPositionAt(this.index);
2961
2985
  }
2962
2986
  setRotation(rotation) {
2963
- this.instanceable.setRotationAt(this.index, rotation);
2987
+ this.activeInstanceable.setRotationAt(this.index, rotation);
2964
2988
  }
2965
2989
  getRotation() {
2966
- return this.instanceable.getRotationAt(this.index);
2990
+ return this.activeInstanceable.getRotationAt(this.index);
2967
2991
  }
2968
2992
  setScale(scale) {
2969
- this.instanceable.setScaleAt(this.index, scale);
2993
+ this.activeInstanceable.setScaleAt(this.index, scale);
2970
2994
  }
2971
2995
  getScale() {
2972
- return this.instanceable.getScaleAt(this.index);
2996
+ return this.activeInstanceable.getScaleAt(this.index);
2973
2997
  }
2974
2998
  //TODO: support for custom methods e.g. setting block variants
2975
2999
  };
@@ -2987,6 +3011,8 @@ var _SceneObject = class _SceneObject extends import_three10.Object3D {
2987
3011
  this.materialCallbacks = {};
2988
3012
  this._isInstanced = false;
2989
3013
  this._instanceCounter = 0;
3014
+ this.instanceReferences = /* @__PURE__ */ new Map();
3015
+ this.freeInstanceIndices = [];
2990
3016
  this.options = (0, import_ts_deepmerge3.default)({}, _SceneObject.DEFAULT_OPTIONS, options ?? {});
2991
3017
  console.log("SceneObject options", this.options);
2992
3018
  }
@@ -3082,6 +3108,8 @@ var _SceneObject = class _SceneObject extends import_three10.Object3D {
3082
3108
  createInstancedMesh(name, geometry, material, count) {
3083
3109
  const mesh = new import_three10.InstancedMesh(geometry, material, count);
3084
3110
  mesh.count = 0;
3111
+ this.instanceMesh = mesh;
3112
+ this._isInstanced = true;
3085
3113
  if (name) {
3086
3114
  mesh.name = `mesh:${name}`;
3087
3115
  }
@@ -3149,40 +3177,70 @@ var _SceneObject = class _SceneObject extends import_three10.Object3D {
3149
3177
  return new InstanceReference(this, i);
3150
3178
  }
3151
3179
  nextInstance() {
3152
- if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
3153
- const i = this._instanceCounter++;
3154
- this.setMatrixAt(i, new import_three10.Matrix4());
3155
- const mesh = this.children[0];
3156
- if (mesh && isInstancedMesh(mesh)) {
3157
- mesh.count = Math.min(this._instanceCounter, mesh.instanceMatrix.count);
3158
- }
3159
- console.debug(p6, "nextInstance " + i);
3160
- if (i === this.options.maxInstanceCount) {
3161
- console.warn(p6, "Max instance count reached for " + this);
3162
- }
3163
- if (this.scene) {
3164
- this.scene.stats.instanceCount++;
3180
+ const mesh = this.instanceMesh;
3181
+ if (!mesh) throw new MineRenderError("Object is not instanced");
3182
+ const index = this.freeInstanceIndices.pop() ?? mesh.count;
3183
+ if (index >= mesh.instanceMatrix.count) this.growInstances(index + 1);
3184
+ const reference = this.constructInstanceReference(index);
3185
+ this.instanceReferences.set(index, reference);
3186
+ this._instanceCounter = this.instanceReferences.size;
3187
+ mesh.count = Math.max(mesh.count, index + 1);
3188
+ if (mesh.instanceColor) {
3189
+ mesh.setColorAt(index, new import_three10.Color(16777215));
3190
+ mesh.instanceColor.needsUpdate = true;
3191
+ }
3192
+ if (this._scene) this._scene.stats.instanceCount++;
3193
+ this.setMatrixAt(index, new import_three10.Matrix4());
3194
+ return reference;
3195
+ }
3196
+ isInstanceActive(index, reference) {
3197
+ return this.instanceReferences.get(index) === reference;
3198
+ }
3199
+ removeInstanceAt(index) {
3200
+ if (!this.instanceReferences.has(index)) return;
3201
+ const mesh = this.instanceMesh;
3202
+ this.setMatrixAt(index, new import_three10.Matrix4().makeScale(0, 0, 0));
3203
+ this.instanceReferences.delete(index);
3204
+ this.freeInstanceIndices.push(index);
3205
+ this._instanceCounter = this.instanceReferences.size;
3206
+ while (mesh.count > 0 && !this.instanceReferences.has(mesh.count - 1)) mesh.count--;
3207
+ if (this._scene) this._scene.stats.instanceCount--;
3208
+ }
3209
+ growInstances(required) {
3210
+ const mesh = this.instanceMesh;
3211
+ const capacity = Math.max(required, mesh.instanceMatrix.count * 2);
3212
+ const grow = (attribute, fill) => {
3213
+ const array = new Float32Array(capacity * attribute.itemSize).fill(fill);
3214
+ array.set(attribute.array);
3215
+ return new import_three10.InstancedBufferAttribute(array, attribute.itemSize, attribute.normalized, attribute.meshPerAttribute).setUsage(attribute.usage);
3216
+ };
3217
+ const matrix = grow(mesh.instanceMatrix, 0);
3218
+ const color = mesh.instanceColor ? grow(mesh.instanceColor, 1) : null;
3219
+ mesh.dispose();
3220
+ mesh.instanceMatrix = matrix;
3221
+ mesh.instanceColor = color;
3222
+ }
3223
+ *activeInstanceIndices() {
3224
+ if (this.instanceMesh) {
3225
+ yield* this.instanceReferences.keys();
3226
+ } else {
3227
+ for (let i = 0; i < this.instanceCounter; i++) yield i;
3165
3228
  }
3166
- this.notifyDirty();
3167
- return this.constructInstanceReference(i);
3168
3229
  }
3169
3230
  //</editor-fold>
3170
3231
  //<editor-fold desc="TRANSFORMATION">
3171
3232
  getMatrixAt(index, matrix = new import_three10.Matrix4()) {
3172
- if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
3173
- const child = this.children[0];
3174
- if (child && isInstancedMesh(child)) {
3175
- child.getMatrixAt(index, matrix);
3176
- }
3233
+ if (!this.instanceReferences.has(index)) throw new MineRenderError("Instance is not active");
3234
+ this.instanceMesh.getMatrixAt(index, matrix);
3177
3235
  return matrix;
3178
3236
  }
3179
3237
  setMatrixAt(index, matrix) {
3180
- if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
3181
- const child = this.children[0];
3182
- if (child && isInstancedMesh(child)) {
3183
- child.setMatrixAt(index, matrix);
3184
- child.instanceMatrix.needsUpdate = true;
3185
- }
3238
+ if (!this.instanceReferences.has(index)) throw new MineRenderError("Instance is not active");
3239
+ const mesh = this.instanceMesh;
3240
+ mesh.setMatrixAt(index, matrix);
3241
+ mesh.instanceMatrix.needsUpdate = true;
3242
+ mesh.boundingBox = null;
3243
+ mesh.boundingSphere = null;
3186
3244
  this.notifyDirty();
3187
3245
  }
3188
3246
  setPositionRotationScaleAt(index, position, rotation, scale) {
@@ -3233,7 +3291,7 @@ var _SceneObject = class _SceneObject extends import_three10.Object3D {
3233
3291
  }
3234
3292
  setPositionRotationScale(position, rotation, scale) {
3235
3293
  if (this.isInstanced) {
3236
- for (let i = 0; i < this.instanceCounter; i++) {
3294
+ for (const i of this.activeInstanceIndices()) {
3237
3295
  this.setPositionRotationScaleAt(i, position, rotation, scale);
3238
3296
  }
3239
3297
  } else {
@@ -3251,7 +3309,7 @@ var _SceneObject = class _SceneObject extends import_three10.Object3D {
3251
3309
  }
3252
3310
  setPosition(position) {
3253
3311
  if (this.isInstanced) {
3254
- for (let i = 0; i < this.instanceCounter; i++) {
3312
+ for (const i of this.activeInstanceIndices()) {
3255
3313
  this.setPositionRotationScaleAt(i, position);
3256
3314
  }
3257
3315
  } else {
@@ -3261,14 +3319,14 @@ var _SceneObject = class _SceneObject extends import_three10.Object3D {
3261
3319
  }
3262
3320
  getPosition() {
3263
3321
  if (this.isInstanced) {
3264
- return this.getPositionAt(0);
3322
+ return this.getPositionAt(this.instanceReferences.keys().next().value ?? 0);
3265
3323
  } else {
3266
3324
  return this.position;
3267
3325
  }
3268
3326
  }
3269
3327
  setRotation(rotation) {
3270
3328
  if (this.isInstanced) {
3271
- for (let i = 0; i < this.instanceCounter; i++) {
3329
+ for (const i of this.activeInstanceIndices()) {
3272
3330
  this.setPositionRotationScaleAt(i, void 0, rotation);
3273
3331
  }
3274
3332
  } else {
@@ -3278,14 +3336,14 @@ var _SceneObject = class _SceneObject extends import_three10.Object3D {
3278
3336
  }
3279
3337
  getRotation() {
3280
3338
  if (this.isInstanced) {
3281
- return this.getRotationAt(0);
3339
+ return this.getRotationAt(this.instanceReferences.keys().next().value ?? 0);
3282
3340
  } else {
3283
3341
  return this.rotation;
3284
3342
  }
3285
3343
  }
3286
3344
  setScale(scale) {
3287
3345
  if (this.isInstanced) {
3288
- for (let i = 0; i < this.instanceCounter; i++) {
3346
+ for (const i of this.activeInstanceIndices()) {
3289
3347
  this.setPositionRotationScaleAt(i, void 0, void 0, scale);
3290
3348
  }
3291
3349
  } else {
@@ -3295,7 +3353,7 @@ var _SceneObject = class _SceneObject extends import_three10.Object3D {
3295
3353
  }
3296
3354
  getScale() {
3297
3355
  if (this.isInstanced) {
3298
- return this.getScaleAt(0);
3356
+ return this.getScaleAt(this.instanceReferences.keys().next().value ?? 0);
3299
3357
  } else {
3300
3358
  return this.scale;
3301
3359
  }
@@ -3319,6 +3377,17 @@ var _SceneObject = class _SceneObject extends import_three10.Object3D {
3319
3377
  this.notifyDirty();
3320
3378
  }
3321
3379
  disposeAndRemoveAllChildren() {
3380
+ if (this.instanceMesh) {
3381
+ if (this._scene) this._scene.stats.instanceCount -= this.instanceReferences.size;
3382
+ this.instanceReferences.clear();
3383
+ this.freeInstanceIndices.length = 0;
3384
+ this._instanceCounter = 0;
3385
+ this.instanceMesh.count = 0;
3386
+ this.instanceMesh.dispose();
3387
+ this.instanceMesh.removeFromParent();
3388
+ this.instanceMesh = void 0;
3389
+ this._isInstanced = false;
3390
+ }
3322
3391
  while (this.children.length > 0) {
3323
3392
  let c = this.children[0];
3324
3393
  if (isDisposable(c)) {
@@ -3363,9 +3432,21 @@ var _EntityObject = class _EntityObject extends SceneObject {
3363
3432
  dispose() {
3364
3433
  super.dispose();
3365
3434
  }
3366
- get textureKey() {
3367
- if (this.entity.texture) return this.entity.texture;
3368
- const key = this.entity.key;
3435
+ getLayerGroup(name) {
3436
+ return super.getGroupByName(`layer:${name}`);
3437
+ }
3438
+ getGroupByName(name, layerName) {
3439
+ return layerName === void 0 ? super.getGroupByName(name) : this.getLayerGroup(layerName)?.getObjectByName(`group:${name}`);
3440
+ }
3441
+ getMeshByName(name, layerName) {
3442
+ return layerName === void 0 ? super.getMeshByName(name) : this.getLayerGroup(layerName)?.getObjectByName(`mesh:${name}`);
3443
+ }
3444
+ get entityLayers() {
3445
+ return this.entity.layers ?? { main: this.entity };
3446
+ }
3447
+ getTextureKey(layer) {
3448
+ if (layer.texture) return layer.texture;
3449
+ const key = layer.key;
3369
3450
  return new AssetKey(
3370
3451
  key.namespace,
3371
3452
  isAssetKey(key) ? key.getFullPath() : key.path,
@@ -3375,18 +3456,22 @@ var _EntityObject = class _EntityObject extends SceneObject {
3375
3456
  ".png"
3376
3457
  );
3377
3458
  }
3378
- async loadTextures() {
3379
- this.imageData = await ModelTextures.get(this.textureKey);
3459
+ async loadTextures(layer = this.entity) {
3460
+ return ModelTextures.get(this.getTextureKey(layer));
3380
3461
  }
3381
3462
  createMeshes(force = false) {
3382
3463
  if (this.meshesCreated && !force) return;
3383
3464
  const modelRoot = new import_three12.Object3D();
3384
3465
  if (this.options.flip) modelRoot.scale.set(-1, -1, 1);
3385
3466
  this.add(modelRoot);
3386
- this.createPart("root", this.entity.layer.root, modelRoot, this.entity.layer.texture, Materials.MISSING_TEXTURE);
3467
+ Object.entries(this.entityLayers).forEach(([name, layer], index) => {
3468
+ const group = this.createGroup(`layer:${name}`);
3469
+ modelRoot.add(group);
3470
+ this.createPart("root", layer.layer.root, group, layer.layer.texture, Materials.MISSING_TEXTURE, index);
3471
+ });
3387
3472
  this.meshesCreated = true;
3388
3473
  }
3389
- createPart(name, part, parent, textureSize, material) {
3474
+ createPart(name, part, parent, textureSize, material, renderOrder) {
3390
3475
  const anchor = this.createGroup(name);
3391
3476
  anchor.position.fromArray(part.pose.offset);
3392
3477
  anchor.rotation.set(...part.pose.rotation, "ZYX");
@@ -3406,30 +3491,31 @@ var _EntityObject = class _EntityObject extends SceneObject {
3406
3491
  ).clone();
3407
3492
  geometry.translate(cube.origin[0] + width / 2, cube.origin[1] + height / 2, cube.origin[2] + depth / 2);
3408
3493
  const mesh = this.createMesh(name, geometry, material);
3494
+ mesh.renderOrder = renderOrder;
3409
3495
  anchor.add(mesh);
3410
3496
  if (this.options.wireframe) addWireframeToMesh(geometry, mesh);
3411
3497
  }
3412
3498
  for (const [childName, child] of Object.entries(part.children)) {
3413
- this.createPart(childName, child, anchor, size, material);
3499
+ this.createPart(childName, child, anchor, size, material, renderOrder);
3414
3500
  }
3415
3501
  }
3416
3502
  async applyTextures() {
3417
- const assetKeyStr = this.textureKey.serialize();
3418
- const keyStr = `entity:${assetKeyStr}`;
3419
- let mat = Caching.materialCache.getIfPresent(keyStr);
3420
- if (!mat) {
3421
- const pending = this.loadTextures();
3422
- const cachedAsset = Caching.textureAssetCache.getIfPresent(assetKeyStr);
3423
- await pending;
3424
- if (!this.imageData) return;
3425
- const canvas = this.imageData.data.canvas;
3426
- const createMaterial = () => Materials.createBasicCanvasMaterial(canvas);
3427
- mat = cachedAsset && Caching.textureAssetCache.getIfPresent(assetKeyStr) === cachedAsset ? Caching.materialCache.get(keyStr, createMaterial) : createMaterial();
3428
- this.imageData = void 0;
3429
- }
3430
- this.iterateAllMeshes((mesh) => {
3431
- mesh.material = mat;
3432
- });
3503
+ await Promise.all(Object.entries(this.entityLayers).map(async ([name, layer]) => {
3504
+ const assetKeyStr = this.getTextureKey(layer).serialize();
3505
+ const keyStr = `entity:${assetKeyStr}`;
3506
+ let mat = Caching.materialCache.getIfPresent(keyStr);
3507
+ if (!mat) {
3508
+ const cachedAsset = Caching.textureAssetCache.getIfPresent(assetKeyStr);
3509
+ const imageData = await this.loadTextures(layer);
3510
+ if (!imageData) return;
3511
+ const canvas = imageData.data.canvas;
3512
+ const createMaterial = () => Materials.createBasicCanvasMaterial(canvas);
3513
+ mat = cachedAsset && Caching.textureAssetCache.getIfPresent(assetKeyStr) === cachedAsset ? Caching.materialCache.get(keyStr, createMaterial) : createMaterial();
3514
+ }
3515
+ this.getLayerGroup(name)?.traverse((object) => {
3516
+ if (isMesh(object)) object.material = mat;
3517
+ });
3518
+ }));
3433
3519
  this.notifyDirty();
3434
3520
  }
3435
3521
  };
@@ -3445,16 +3531,16 @@ var GuiObject = class extends SceneObject {
3445
3531
  };
3446
3532
 
3447
3533
  // src/inspector/SceneInspector.ts
3448
- var import_three13 = require("three");
3534
+ var import_three14 = require("three");
3449
3535
  var p7 = prefix("SceneInspector");
3450
3536
  var help = "<span>Ctrl+Click to Select<br/></span><br/>";
3451
3537
  var SceneInspector = class {
3452
3538
  constructor(renderer) {
3453
3539
  this.renderer = renderer;
3454
- this.mouse = new import_three13.Vector2();
3540
+ this.mouse = new import_three14.Vector2();
3455
3541
  this.objectInfoContainer = document.createElement("div");
3456
3542
  this.objectControlsContainer = document.createElement("div");
3457
- this.raycaster = new import_three13.Raycaster();
3543
+ this.raycaster = new import_three14.Raycaster();
3458
3544
  this.init();
3459
3545
  }
3460
3546
  init() {
@@ -3965,10 +4051,10 @@ var BlockTints = class {
3965
4051
  };
3966
4052
 
3967
4053
  // src/model/scene/ModelObject.ts
3968
- var import_three16 = require("three");
4054
+ var import_three17 = require("three");
3969
4055
 
3970
4056
  // src/three/BufferGeometryUtils.js
3971
- var import_three15 = require("three");
4057
+ var import_three16 = require("three");
3972
4058
  function computeTangents(geometry) {
3973
4059
  geometry.computeTangents();
3974
4060
  console.warn("THREE.BufferGeometryUtils: .computeTangents() has been removed. Use BufferGeometry.computeTangents() instead.");
@@ -3980,7 +4066,7 @@ function mergeBufferGeometries(geometries, useGroups = false) {
3980
4066
  const attributes = {};
3981
4067
  const morphAttributes = {};
3982
4068
  const morphTargetsRelative = geometries[0].morphTargetsRelative;
3983
- const mergedGeometry = new import_three15.BufferGeometry();
4069
+ const mergedGeometry = new import_three16.BufferGeometry();
3984
4070
  let offset = 0;
3985
4071
  for (let i = 0; i < geometries.length; ++i) {
3986
4072
  const geometry = geometries[i];
@@ -4104,7 +4190,7 @@ function mergeBufferAttributes(attributes) {
4104
4190
  array.set(attributes[i].array, offset);
4105
4191
  offset += attributes[i].array.length;
4106
4192
  }
4107
- return new import_three15.BufferAttribute(array, itemSize, normalized);
4193
+ return new import_three16.BufferAttribute(array, itemSize, normalized);
4108
4194
  }
4109
4195
  function interleaveAttributes(attributes) {
4110
4196
  let TypedArray;
@@ -4120,7 +4206,7 @@ function interleaveAttributes(attributes) {
4120
4206
  arrayLength += attribute.array.length;
4121
4207
  stride += attribute.itemSize;
4122
4208
  }
4123
- const interleavedBuffer = new import_three15.InterleavedBuffer(new TypedArray(arrayLength), stride);
4209
+ const interleavedBuffer = new import_three16.InterleavedBuffer(new TypedArray(arrayLength), stride);
4124
4210
  let offset = 0;
4125
4211
  const res = [];
4126
4212
  const getters = ["getX", "getY", "getZ", "getW"];
@@ -4129,7 +4215,7 @@ function interleaveAttributes(attributes) {
4129
4215
  const attribute = attributes[j];
4130
4216
  const itemSize = attribute.itemSize;
4131
4217
  const count = attribute.count;
4132
- const iba = new import_three15.InterleavedBufferAttribute(interleavedBuffer, itemSize, offset, attribute.normalized);
4218
+ const iba = new import_three16.InterleavedBufferAttribute(interleavedBuffer, itemSize, offset, attribute.normalized);
4133
4219
  res.push(iba);
4134
4220
  offset += itemSize;
4135
4221
  for (let c = 0; c < count; c++) {
@@ -4213,13 +4299,13 @@ function mergeVertices(geometry, tolerance = 1e-4) {
4213
4299
  const name = attributeNames[i];
4214
4300
  const oldAttribute = geometry.getAttribute(name);
4215
4301
  const buffer = new oldAttribute.array.constructor(attrArrays[name]);
4216
- const attribute = new import_three15.BufferAttribute(buffer, oldAttribute.itemSize, oldAttribute.normalized);
4302
+ const attribute = new import_three16.BufferAttribute(buffer, oldAttribute.itemSize, oldAttribute.normalized);
4217
4303
  result.setAttribute(name, attribute);
4218
4304
  if (name in morphAttrsArrays) {
4219
4305
  for (let j = 0; j < morphAttrsArrays[name].length; j++) {
4220
4306
  const oldMorphAttribute = geometry.morphAttributes[name][j];
4221
4307
  const buffer2 = new oldMorphAttribute.array.constructor(morphAttrsArrays[name][j]);
4222
- const morphAttribute = new import_three15.BufferAttribute(buffer2, oldMorphAttribute.itemSize, oldMorphAttribute.normalized);
4308
+ const morphAttribute = new import_three16.BufferAttribute(buffer2, oldMorphAttribute.itemSize, oldMorphAttribute.normalized);
4223
4309
  result.morphAttributes[name][j] = morphAttribute;
4224
4310
  }
4225
4311
  }
@@ -4228,11 +4314,11 @@ function mergeVertices(geometry, tolerance = 1e-4) {
4228
4314
  return result;
4229
4315
  }
4230
4316
  function toTrianglesDrawMode(geometry, drawMode) {
4231
- if (drawMode === import_three15.TrianglesDrawMode) {
4317
+ if (drawMode === import_three16.TrianglesDrawMode) {
4232
4318
  console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles.");
4233
4319
  return geometry;
4234
4320
  }
4235
- if (drawMode === import_three15.TriangleFanDrawMode || drawMode === import_three15.TriangleStripDrawMode) {
4321
+ if (drawMode === import_three16.TriangleFanDrawMode || drawMode === import_three16.TriangleStripDrawMode) {
4236
4322
  let index = geometry.getIndex();
4237
4323
  if (index === null) {
4238
4324
  const indices = [];
@@ -4250,7 +4336,7 @@ function toTrianglesDrawMode(geometry, drawMode) {
4250
4336
  }
4251
4337
  const numberOfTriangles = index.count - 2;
4252
4338
  const newIndices = [];
4253
- if (drawMode === import_three15.TriangleFanDrawMode) {
4339
+ if (drawMode === import_three16.TriangleFanDrawMode) {
4254
4340
  for (let i = 1; i <= numberOfTriangles; i++) {
4255
4341
  newIndices.push(index.getX(0));
4256
4342
  newIndices.push(index.getX(i));
@@ -4286,15 +4372,15 @@ function computeMorphedAttributes(object) {
4286
4372
  console.error("THREE.BufferGeometryUtils: Geometry is not of type BufferGeometry.");
4287
4373
  return null;
4288
4374
  }
4289
- const _vA = new import_three15.Vector3();
4290
- const _vB = new import_three15.Vector3();
4291
- const _vC = new import_three15.Vector3();
4292
- const _tempA = new import_three15.Vector3();
4293
- const _tempB = new import_three15.Vector3();
4294
- const _tempC = new import_three15.Vector3();
4295
- const _morphA = new import_three15.Vector3();
4296
- const _morphB = new import_three15.Vector3();
4297
- const _morphC = new import_three15.Vector3();
4375
+ const _vA = new import_three16.Vector3();
4376
+ const _vB = new import_three16.Vector3();
4377
+ const _vC = new import_three16.Vector3();
4378
+ const _tempA = new import_three16.Vector3();
4379
+ const _tempB = new import_three16.Vector3();
4380
+ const _tempC = new import_three16.Vector3();
4381
+ const _morphA = new import_three16.Vector3();
4382
+ const _morphB = new import_three16.Vector3();
4383
+ const _morphC = new import_three16.Vector3();
4298
4384
  function _calculateMorphedAttributeData(object2, material2, attribute, morphAttribute, morphTargetsRelative2, a2, b2, c2, modifiedAttributeArray) {
4299
4385
  _vA.fromBufferAttribute(attribute, a2);
4300
4386
  _vB.fromBufferAttribute(attribute, b2);
@@ -4489,8 +4575,8 @@ function computeMorphedAttributes(object) {
4489
4575
  }
4490
4576
  }
4491
4577
  }
4492
- const morphedPositionAttribute = new import_three15.Float32BufferAttribute(modifiedPosition, 3);
4493
- const morphedNormalAttribute = new import_three15.Float32BufferAttribute(modifiedNormal, 3);
4578
+ const morphedPositionAttribute = new import_three16.Float32BufferAttribute(modifiedPosition, 3);
4579
+ const morphedNormalAttribute = new import_three16.Float32BufferAttribute(modifiedNormal, 3);
4494
4580
  return {
4495
4581
  positionAttribute,
4496
4582
  normalAttribute,
@@ -4517,10 +4603,6 @@ var _ModelObject = class _ModelObject extends SceneObject {
4517
4603
  this.createMeshes();
4518
4604
  this.applyTextures();
4519
4605
  }
4520
- dispose() {
4521
- super.dispose();
4522
- this.atlas?.dispose();
4523
- }
4524
4606
  get textureAtlas() {
4525
4607
  return this.atlas;
4526
4608
  }
@@ -4538,7 +4620,7 @@ var _ModelObject = class _ModelObject extends SceneObject {
4538
4620
  this.atlas.model.elements?.forEach((el) => {
4539
4621
  const elGeo = this._getBoxGeometryFromElement(el).clone();
4540
4622
  if (this.options.uvLockRotation) {
4541
- UVMapper.lockUvs(elGeo, el.faces, this.atlas, new import_three16.Euler(...this.options.uvLockRotation));
4623
+ UVMapper.lockUvs(elGeo, el.faces, this.atlas, new import_three17.Euler(...this.options.uvLockRotation));
4542
4624
  }
4543
4625
  if (this.options.tints) {
4544
4626
  const colors = new Float32Array(elGeo.getAttribute("position").count * 3).fill(1);
@@ -4547,19 +4629,19 @@ var _ModelObject = class _ModelObject extends SceneObject {
4547
4629
  if (tintIndex === void 0 || tintIndex < 0) continue;
4548
4630
  const tint = this.options.tints[tintIndex];
4549
4631
  if (tint === void 0) continue;
4550
- const color = new import_three16.Color(tint);
4632
+ const color = new import_three17.Color(tint);
4551
4633
  for (let vertex = 0; vertex < 4; vertex++) {
4552
4634
  color.toArray(colors, (faceIndex * 4 + vertex) * 3);
4553
4635
  }
4554
4636
  }
4555
- elGeo.setAttribute("color", new import_three16.BufferAttribute(colors, 3));
4637
+ elGeo.setAttribute("color", new import_three17.BufferAttribute(colors, 3));
4556
4638
  }
4557
- elGeo.applyMatrix4(new import_three16.Matrix4().makeTranslation((el.to[0] - el.from[0]) / 2, (el.to[1] - el.from[1]) / 2, (el.to[2] - el.from[2]) / 2));
4558
- elGeo.applyMatrix4(new import_three16.Matrix4().makeTranslation(el.from[0], el.from[1], el.from[2]));
4639
+ elGeo.applyMatrix4(new import_three17.Matrix4().makeTranslation((el.to[0] - el.from[0]) / 2, (el.to[1] - el.from[1]) / 2, (el.to[2] - el.from[2]) / 2));
4640
+ elGeo.applyMatrix4(new import_three17.Matrix4().makeTranslation(el.from[0], el.from[1], el.from[2]));
4559
4641
  if (el.rotation) {
4560
4642
  applyElementRotation(el.rotation, elGeo);
4561
4643
  }
4562
- elGeo.applyMatrix4(new import_three16.Matrix4().makeTranslation(-8, -8, -8));
4644
+ elGeo.applyMatrix4(new import_three17.Matrix4().makeTranslation(-8, -8, -8));
4563
4645
  if (displayTransform) DisplayTransforms.apply(elGeo, displayTransform);
4564
4646
  if (this.options.mergeMeshes) {
4565
4647
  allGeos.push(elGeo);
@@ -4581,7 +4663,7 @@ var _ModelObject = class _ModelObject extends SceneObject {
4581
4663
  if (allGeos.length > 0) {
4582
4664
  combinedGeo = mergeBufferGeometries(allGeos);
4583
4665
  } else {
4584
- combinedGeo = new import_three16.BoxGeometry(16, 16, 16);
4666
+ combinedGeo = new import_three17.BoxGeometry(16, 16, 16);
4585
4667
  if (displayTransform) DisplayTransforms.apply(combinedGeo, displayTransform);
4586
4668
  }
4587
4669
  combinedGeo.computeBoundingBox();
@@ -4636,7 +4718,7 @@ function isModelObject(obj) {
4636
4718
 
4637
4719
  // src/model/block/scene/BlockObject.ts
4638
4720
  var import_ts_deepmerge6 = __toESM(require_dist());
4639
- var import_three17 = require("three");
4721
+ var import_three18 = require("three");
4640
4722
  var p10 = prefix("BlockObject");
4641
4723
  function matchesCondition(condition, state) {
4642
4724
  return Object.entries(condition).every(([key, value]) => {
@@ -4686,18 +4768,21 @@ var _BlockObject = class _BlockObject extends SceneObject {
4686
4768
  }
4687
4769
  }
4688
4770
  dispose() {
4771
+ this.clearModels();
4689
4772
  super.dispose();
4690
4773
  }
4691
4774
  removeFromScene() {
4692
- for (let model of this._models) {
4693
- if (isModelObject(model)) {
4694
- model.removeFromScene();
4695
- } else if (isInstanceReference(model)) {
4696
- model.setScale(new import_three17.Vector3(0, 0, 0));
4697
- }
4698
- }
4775
+ this.clearModels();
4699
4776
  super.removeFromScene();
4700
4777
  }
4778
+ clearModels() {
4779
+ for (const model of this._models.splice(0)) {
4780
+ model.removeFromScene();
4781
+ if (!isInstanceReference(model)) model.dispose();
4782
+ }
4783
+ this._isInstanced = false;
4784
+ this._instanceCounter = 0;
4785
+ }
4701
4786
  get state() {
4702
4787
  return this._state;
4703
4788
  }
@@ -4746,22 +4831,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
4746
4831
  return out;
4747
4832
  }
4748
4833
  async recreateModels() {
4749
- const instanceInfo = [];
4750
- if (this.isInstanced) {
4751
- for (let i = 0; i < this.instanceCounter; i++) {
4752
- instanceInfo[i] = this.getMatrixAt(i);
4753
- }
4754
- }
4755
- for (let model of this._models) {
4756
- if (isInstanceReference(model)) {
4757
- model.setScale(new import_three17.Vector3(0, 0, 0));
4758
- } else {
4759
- model.dispose();
4760
- }
4761
- }
4762
- while (this._models.length > 0) {
4763
- this._models.shift();
4764
- }
4834
+ this.clearModels();
4765
4835
  const variantsToCreate = await this.mapStateToVariant(this.state);
4766
4836
  this._variants = variantsToCreate;
4767
4837
  for (let blockStateVariant of variantsToCreate) {
@@ -4791,7 +4861,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
4791
4861
  await this.createVariant(variant);
4792
4862
  }
4793
4863
  async createVariant(variant) {
4794
- const rotation = new import_three17.Euler();
4864
+ const rotation = new import_three18.Euler();
4795
4865
  if (typeof variant.x !== "undefined") {
4796
4866
  rotation.x = toRadians(clampRotationDegrees(variant.x));
4797
4867
  }
@@ -4812,6 +4882,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
4812
4882
  this._instanceCounter = 1;
4813
4883
  }
4814
4884
  obj.setRotation(rotation);
4885
+ obj.setPosition(this.position);
4815
4886
  return obj;
4816
4887
  }
4817
4888
  async resetState() {
@@ -4880,7 +4951,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
4880
4951
  setPositionRotationScaleAt(index, position, rotation, scale) {
4881
4952
  super.setPositionRotationScaleAt(index, position, rotation, scale);
4882
4953
  }
4883
- getMatrixAt(index, matrix = new import_three17.Matrix4()) {
4954
+ getMatrixAt(index, matrix = new import_three18.Matrix4()) {
4884
4955
  if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
4885
4956
  const child = this._models[0];
4886
4957
  if (child && isModelObject(child)) {
@@ -4959,7 +5030,7 @@ var StructureParser = class {
4959
5030
  };
4960
5031
 
4961
5032
  // src/renderer/MineRenderScene.ts
4962
- var import_three19 = require("three");
5033
+ var import_three20 = require("three");
4963
5034
  var import_ts_deepmerge8 = __toESM(require_dist());
4964
5035
 
4965
5036
  // src/skin/SkinPart.ts
@@ -5684,7 +5755,7 @@ var slimSkinGeometries = {
5684
5755
  var import_ts_deepmerge7 = __toESM(require_dist());
5685
5756
 
5686
5757
  // src/skin/SkinTextures.ts
5687
- var import_three18 = require("three");
5758
+ var import_three19 = require("three");
5688
5759
 
5689
5760
  // src/skin/SkinImage.ts
5690
5761
  var SkinImage = class {
@@ -5761,11 +5832,11 @@ var SkinTextures = class {
5761
5832
  });
5762
5833
  }
5763
5834
  static createMaterial(pixels, width, height, transparent = true) {
5764
- const texture = Textures.initTextureProps(new import_three18.DataTexture(pixels, width, height));
5765
- texture.colorSpace = import_three18.SRGBColorSpace;
5835
+ const texture = Textures.initTextureProps(new import_three19.DataTexture(pixels, width, height));
5836
+ texture.colorSpace = import_three19.SRGBColorSpace;
5766
5837
  texture.flipY = true;
5767
5838
  texture.needsUpdate = true;
5768
- return new import_three18.MeshBasicMaterial({ map: texture, transparent, side: transparent ? import_three18.DoubleSide : import_three18.FrontSide, alphaTest: transparent ? 0.1 : 0 });
5839
+ return new import_three19.MeshBasicMaterial({ map: texture, transparent, side: transparent ? import_three19.DoubleSide : import_three19.FrontSide, alphaTest: transparent ? 0.1 : 0 });
5769
5840
  }
5770
5841
  static isSlim(image, scale) {
5771
5842
  for (const [x, y] of [[46, 52], [54, 20]]) {
@@ -5992,7 +6063,7 @@ var SkinObject = class extends SceneObject {
5992
6063
  };
5993
6064
 
5994
6065
  // src/renderer/MineRenderScene.ts
5995
- var _MineRenderScene = class _MineRenderScene extends import_three19.Scene {
6066
+ var _MineRenderScene = class _MineRenderScene extends import_three20.Scene {
5996
6067
  constructor(options) {
5997
6068
  super();
5998
6069
  this.isMineRenderScene = true;
@@ -6115,17 +6186,17 @@ function isMineRenderScene(obj) {
6115
6186
  }
6116
6187
 
6117
6188
  // src/renderer/Renderer.ts
6118
- var import_three21 = require("three");
6189
+ var import_three22 = require("three");
6119
6190
  var import_ts_deepmerge9 = __toESM(require_dist());
6120
6191
  var import_stats = __toESM(require("stats.js"));
6121
6192
  var import_postprocessing = require("postprocessing");
6122
6193
 
6123
6194
  // src/three/OrbitControls.js
6124
- var import_three20 = require("three");
6195
+ var import_three21 = require("three");
6125
6196
  var _changeEvent = { type: "change" };
6126
6197
  var _startEvent = { type: "start" };
6127
6198
  var _endEvent = { type: "end" };
6128
- var OrbitControls = class extends import_three20.EventDispatcher {
6199
+ var OrbitControls = class extends import_three21.EventDispatcher {
6129
6200
  constructor(object, domElement) {
6130
6201
  super();
6131
6202
  if (domElement === void 0) console.warn('THREE.OrbitControls: The second parameter "domElement" is now mandatory.');
@@ -6134,7 +6205,7 @@ var OrbitControls = class extends import_three20.EventDispatcher {
6134
6205
  this.domElement = domElement;
6135
6206
  this.domElement.style.touchAction = "none";
6136
6207
  this.enabled = true;
6137
- this.target = new import_three20.Vector3();
6208
+ this.target = new import_three21.Vector3();
6138
6209
  this.minDistance = 0;
6139
6210
  this.maxDistance = Infinity;
6140
6211
  this.minZoom = 0;
@@ -6156,8 +6227,8 @@ var OrbitControls = class extends import_three20.EventDispatcher {
6156
6227
  this.autoRotate = false;
6157
6228
  this.autoRotateSpeed = 2;
6158
6229
  this.keys = { LEFT: "ArrowLeft", UP: "ArrowUp", RIGHT: "ArrowRight", BOTTOM: "ArrowDown" };
6159
- this.mouseButtons = { LEFT: import_three20.MOUSE.ROTATE, MIDDLE: import_three20.MOUSE.DOLLY, RIGHT: import_three20.MOUSE.PAN };
6160
- this.touches = { ONE: import_three20.TOUCH.ROTATE, TWO: import_three20.TOUCH.DOLLY_PAN };
6230
+ this.mouseButtons = { LEFT: import_three21.MOUSE.ROTATE, MIDDLE: import_three21.MOUSE.DOLLY, RIGHT: import_three21.MOUSE.PAN };
6231
+ this.touches = { ONE: import_three21.TOUCH.ROTATE, TWO: import_three21.TOUCH.DOLLY_PAN };
6161
6232
  this.target0 = this.target.clone();
6162
6233
  this.position0 = this.object.position.clone();
6163
6234
  this.zoom0 = this.object.zoom;
@@ -6186,11 +6257,11 @@ var OrbitControls = class extends import_three20.EventDispatcher {
6186
6257
  state = STATE.NONE;
6187
6258
  };
6188
6259
  this.update = function() {
6189
- const offset = new import_three20.Vector3();
6190
- const quat = new import_three20.Quaternion().setFromUnitVectors(object.up, new import_three20.Vector3(0, 1, 0));
6260
+ const offset = new import_three21.Vector3();
6261
+ const quat = new import_three21.Quaternion().setFromUnitVectors(object.up, new import_three21.Vector3(0, 1, 0));
6191
6262
  const quatInverse = quat.clone().invert();
6192
- const lastPosition = new import_three20.Vector3();
6193
- const lastQuaternion = new import_three20.Quaternion();
6263
+ const lastPosition = new import_three21.Vector3();
6264
+ const lastQuaternion = new import_three21.Quaternion();
6194
6265
  const twoPI = 2 * Math.PI;
6195
6266
  return function update() {
6196
6267
  const position = scope.object.position;
@@ -6276,20 +6347,20 @@ var OrbitControls = class extends import_three20.EventDispatcher {
6276
6347
  };
6277
6348
  let state = STATE.NONE;
6278
6349
  const EPS = 1e-6;
6279
- const spherical = new import_three20.Spherical();
6280
- const sphericalDelta = new import_three20.Spherical();
6350
+ const spherical = new import_three21.Spherical();
6351
+ const sphericalDelta = new import_three21.Spherical();
6281
6352
  let scale = 1;
6282
- const panOffset = new import_three20.Vector3();
6353
+ const panOffset = new import_three21.Vector3();
6283
6354
  let zoomChanged = false;
6284
- const rotateStart = new import_three20.Vector2();
6285
- const rotateEnd = new import_three20.Vector2();
6286
- const rotateDelta = new import_three20.Vector2();
6287
- const panStart = new import_three20.Vector2();
6288
- const panEnd = new import_three20.Vector2();
6289
- const panDelta = new import_three20.Vector2();
6290
- const dollyStart = new import_three20.Vector2();
6291
- const dollyEnd = new import_three20.Vector2();
6292
- const dollyDelta = new import_three20.Vector2();
6355
+ const rotateStart = new import_three21.Vector2();
6356
+ const rotateEnd = new import_three21.Vector2();
6357
+ const rotateDelta = new import_three21.Vector2();
6358
+ const panStart = new import_three21.Vector2();
6359
+ const panEnd = new import_three21.Vector2();
6360
+ const panDelta = new import_three21.Vector2();
6361
+ const dollyStart = new import_three21.Vector2();
6362
+ const dollyEnd = new import_three21.Vector2();
6363
+ const dollyDelta = new import_three21.Vector2();
6293
6364
  const pointers = [];
6294
6365
  const pointerPositions = {};
6295
6366
  function getAutoRotationAngle() {
@@ -6305,7 +6376,7 @@ var OrbitControls = class extends import_three20.EventDispatcher {
6305
6376
  sphericalDelta.phi -= angle;
6306
6377
  }
6307
6378
  const panLeft = function() {
6308
- const v = new import_three20.Vector3();
6379
+ const v = new import_three21.Vector3();
6309
6380
  return function panLeft2(distance, objectMatrix) {
6310
6381
  v.setFromMatrixColumn(objectMatrix, 0);
6311
6382
  v.multiplyScalar(-distance);
@@ -6313,7 +6384,7 @@ var OrbitControls = class extends import_three20.EventDispatcher {
6313
6384
  };
6314
6385
  }();
6315
6386
  const panUp = function() {
6316
- const v = new import_three20.Vector3();
6387
+ const v = new import_three21.Vector3();
6317
6388
  return function panUp2(distance, objectMatrix) {
6318
6389
  if (scope.screenSpacePanning === true) {
6319
6390
  v.setFromMatrixColumn(objectMatrix, 1);
@@ -6326,7 +6397,7 @@ var OrbitControls = class extends import_three20.EventDispatcher {
6326
6397
  };
6327
6398
  }();
6328
6399
  const pan = function() {
6329
- const offset = new import_three20.Vector3();
6400
+ const offset = new import_three21.Vector3();
6330
6401
  return function pan2(deltaX, deltaY) {
6331
6402
  const element = scope.domElement;
6332
6403
  if (scope.object.isPerspectiveCamera) {
@@ -6575,12 +6646,12 @@ var OrbitControls = class extends import_three20.EventDispatcher {
6575
6646
  mouseAction = -1;
6576
6647
  }
6577
6648
  switch (mouseAction) {
6578
- case import_three20.MOUSE.DOLLY:
6649
+ case import_three21.MOUSE.DOLLY:
6579
6650
  if (scope.enableZoom === false) return;
6580
6651
  handleMouseDownDolly(event);
6581
6652
  state = STATE.DOLLY;
6582
6653
  break;
6583
- case import_three20.MOUSE.ROTATE:
6654
+ case import_three21.MOUSE.ROTATE:
6584
6655
  if (event.ctrlKey || event.metaKey || event.shiftKey) {
6585
6656
  if (scope.enablePan === false) return;
6586
6657
  handleMouseDownPan(event);
@@ -6591,7 +6662,7 @@ var OrbitControls = class extends import_three20.EventDispatcher {
6591
6662
  state = STATE.ROTATE;
6592
6663
  }
6593
6664
  break;
6594
- case import_three20.MOUSE.PAN:
6665
+ case import_three21.MOUSE.PAN:
6595
6666
  if (event.ctrlKey || event.metaKey || event.shiftKey) {
6596
6667
  if (scope.enableRotate === false) return;
6597
6668
  handleMouseDownRotate(event);
@@ -6647,12 +6718,12 @@ var OrbitControls = class extends import_three20.EventDispatcher {
6647
6718
  switch (pointers.length) {
6648
6719
  case 1:
6649
6720
  switch (scope.touches.ONE) {
6650
- case import_three20.TOUCH.ROTATE:
6721
+ case import_three21.TOUCH.ROTATE:
6651
6722
  if (scope.enableRotate === false) return;
6652
6723
  handleTouchStartRotate();
6653
6724
  state = STATE.TOUCH_ROTATE;
6654
6725
  break;
6655
- case import_three20.TOUCH.PAN:
6726
+ case import_three21.TOUCH.PAN:
6656
6727
  if (scope.enablePan === false) return;
6657
6728
  handleTouchStartPan();
6658
6729
  state = STATE.TOUCH_PAN;
@@ -6663,12 +6734,12 @@ var OrbitControls = class extends import_three20.EventDispatcher {
6663
6734
  break;
6664
6735
  case 2:
6665
6736
  switch (scope.touches.TWO) {
6666
- case import_three20.TOUCH.DOLLY_PAN:
6737
+ case import_three21.TOUCH.DOLLY_PAN:
6667
6738
  if (scope.enableZoom === false && scope.enablePan === false) return;
6668
6739
  handleTouchStartDollyPan();
6669
6740
  state = STATE.TOUCH_DOLLY_PAN;
6670
6741
  break;
6671
- case import_three20.TOUCH.DOLLY_ROTATE:
6742
+ case import_three21.TOUCH.DOLLY_ROTATE:
6672
6743
  if (scope.enableZoom === false && scope.enableRotate === false) return;
6673
6744
  handleTouchStartDollyRotate();
6674
6745
  state = STATE.TOUCH_DOLLY_ROTATE;
@@ -6735,7 +6806,7 @@ var OrbitControls = class extends import_three20.EventDispatcher {
6735
6806
  function trackPointer(event) {
6736
6807
  let position = pointerPositions[event.pointerId];
6737
6808
  if (position === void 0) {
6738
- position = new import_three20.Vector2();
6809
+ position = new import_three21.Vector2();
6739
6810
  pointerPositions[event.pointerId] = position;
6740
6811
  }
6741
6812
  position.set(event.pageX, event.pageY);
@@ -6755,10 +6826,10 @@ var MapControls = class extends OrbitControls {
6755
6826
  constructor(object, domElement) {
6756
6827
  super(object, domElement);
6757
6828
  this.screenSpacePanning = false;
6758
- this.mouseButtons.LEFT = import_three20.MOUSE.PAN;
6759
- this.mouseButtons.RIGHT = import_three20.MOUSE.ROTATE;
6760
- this.touches.ONE = import_three20.TOUCH.PAN;
6761
- this.touches.TWO = import_three20.TOUCH.DOLLY_ROTATE;
6829
+ this.mouseButtons.LEFT = import_three21.MOUSE.PAN;
6830
+ this.mouseButtons.RIGHT = import_three21.MOUSE.ROTATE;
6831
+ this.touches.ONE = import_three21.TOUCH.PAN;
6832
+ this.touches.TWO = import_three21.TOUCH.DOLLY_ROTATE;
6762
6833
  }
6763
6834
  };
6764
6835
 
@@ -6795,14 +6866,14 @@ var _Renderer = class _Renderer {
6795
6866
  switch (this.options.camera.type) {
6796
6867
  case "perspective":
6797
6868
  default:
6798
- return new import_three21.PerspectiveCamera(
6869
+ return new import_three22.PerspectiveCamera(
6799
6870
  this.options.camera.perspective.fov,
6800
6871
  this.options.camera.perspective.aspect ?? this.viewWidth / this.viewHeight,
6801
6872
  this.options.camera.near,
6802
6873
  this.options.camera.far
6803
6874
  );
6804
6875
  case "orthographic":
6805
- return new import_three21.OrthographicCamera(
6876
+ return new import_three22.OrthographicCamera(
6806
6877
  this.options.camera.orthographic.left ?? this.viewWidth / -2,
6807
6878
  this.options.camera.orthographic.right ?? this.viewWidth / 2,
6808
6879
  this.options.camera.orthographic.top ?? this.viewHeight / 2,
@@ -6813,7 +6884,7 @@ var _Renderer = class _Renderer {
6813
6884
  }
6814
6885
  }
6815
6886
  createRenderer() {
6816
- const renderer = new import_three21.WebGLRenderer({
6887
+ const renderer = new import_three22.WebGLRenderer({
6817
6888
  antialias: this.options.render.antialias,
6818
6889
  alpha: true,
6819
6890
  powerPreference: "high-performance",
@@ -6821,8 +6892,8 @@ var _Renderer = class _Renderer {
6821
6892
  });
6822
6893
  renderer.setClearColor(0, 0);
6823
6894
  renderer.shadowMap.enabled = true;
6824
- renderer.shadowMap.type = import_three21.PCFSoftShadowMap;
6825
- renderer.outputColorSpace = import_three21.SRGBColorSpace;
6895
+ renderer.shadowMap.type = import_three22.PCFSoftShadowMap;
6896
+ renderer.outputColorSpace = import_three22.SRGBColorSpace;
6826
6897
  renderer.setSize(this.viewWidth, this.viewHeight);
6827
6898
  return renderer;
6828
6899
  }
@@ -6856,20 +6927,20 @@ var _Renderer = class _Renderer {
6856
6927
  window["__THREE_DEVTOOLS__"].dispatchEvent(new CustomEvent("observe", { detail: this.scene }));
6857
6928
  }
6858
6929
  if (this.options.debug.grid) {
6859
- const gridHelper = new import_three21.GridHelper(128, 16);
6930
+ const gridHelper = new import_three22.GridHelper(128, 16);
6860
6931
  this._debugHelpers.push(gridHelper);
6861
6932
  this.scene.add(gridHelper);
6862
- const gridHelper2 = new import_three21.GridHelper(128, 16);
6933
+ const gridHelper2 = new import_three22.GridHelper(128, 16);
6863
6934
  this._debugHelpers.push(gridHelper2);
6864
6935
  gridHelper2.rotation.x = 90 * (Math.PI / 180);
6865
6936
  this.scene.add(gridHelper2);
6866
- const gridHelper3 = new import_three21.GridHelper(128, 16);
6937
+ const gridHelper3 = new import_three22.GridHelper(128, 16);
6867
6938
  this._debugHelpers.push(gridHelper3);
6868
6939
  gridHelper3.rotation.z = 90 * (Math.PI / 180);
6869
6940
  this.scene.add(gridHelper3);
6870
6941
  }
6871
6942
  if (this.options.debug.axes) {
6872
- const axesHelper = new import_three21.AxesHelper(64);
6943
+ const axesHelper = new import_three22.AxesHelper(64);
6873
6944
  this._debugHelpers.push(axesHelper);
6874
6945
  this.scene.add(axesHelper);
6875
6946
  }
@@ -7073,8 +7144,8 @@ _Renderer.DEFAULT_OPTIONS = (0, import_ts_deepmerge9.default)({}, {
7073
7144
  top: void 0,
7074
7145
  bottom: void 0
7075
7146
  },
7076
- position: new import_three21.Vector3(50, 50, 50),
7077
- lookingAt: new import_three21.Vector3(0, 0, 0)
7147
+ position: new import_three22.Vector3(50, 50, 50),
7148
+ lookingAt: new import_three22.Vector3(0, 0, 0)
7078
7149
  },
7079
7150
  render: {
7080
7151
  fpsLimit: 60,
@@ -7262,10 +7333,10 @@ var Skins = class {
7262
7333
  };
7263
7334
 
7264
7335
  // src/world/Chunk.ts
7265
- var import_three24 = require("three");
7336
+ var import_three25 = require("three");
7266
7337
 
7267
7338
  // src/world/MineRenderWorld.ts
7268
- var import_three23 = require("three");
7339
+ var import_three24 = require("three");
7269
7340
  var MineRenderWorld = class {
7270
7341
  constructor(scene) {
7271
7342
  this._size = 4;
@@ -7276,10 +7347,10 @@ var MineRenderWorld = class {
7276
7347
  }
7277
7348
  getBlockAt(posOrX, y, z) {
7278
7349
  if (typeof posOrX == "number") {
7279
- return this.getBlockAt(new import_three23.Vector3(posOrX, y, z));
7350
+ return this.getBlockAt(new import_three24.Vector3(posOrX, y, z));
7280
7351
  }
7281
7352
  if (isTripleArray(posOrX)) {
7282
- return this.getBlockAt(new import_three23.Vector3(posOrX[0], posOrX[1], posOrX[2]));
7353
+ return this.getBlockAt(new import_three24.Vector3(posOrX[0], posOrX[1], posOrX[2]));
7283
7354
  }
7284
7355
  const chunk = this.getChunkAt(posOrX);
7285
7356
  if (typeof chunk === "undefined") {
@@ -7290,10 +7361,10 @@ var MineRenderWorld = class {
7290
7361
  }
7291
7362
  async setBlockAt(posOrX, yOrBlock, z, block) {
7292
7363
  if (typeof posOrX == "number") {
7293
- return this.setBlockAt(new import_three23.Vector3(posOrX, yOrBlock, z), block);
7364
+ return this.setBlockAt(new import_three24.Vector3(posOrX, yOrBlock, z), block);
7294
7365
  }
7295
7366
  if (isTripleArray(posOrX)) {
7296
- return this.setBlockAt(new import_three23.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
7367
+ return this.setBlockAt(new import_three24.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
7297
7368
  }
7298
7369
  this.validatePosBounds(posOrX);
7299
7370
  const chunk = this.getOrCreateChunkAt(posOrX);
@@ -7339,14 +7410,14 @@ var MineRenderWorld = class {
7339
7410
  return this._chunks[index];
7340
7411
  }
7341
7412
  static worldToScenePosition(pos) {
7342
- return new import_three23.Vector3(
7413
+ return new import_three24.Vector3(
7343
7414
  pos.x * 16,
7344
7415
  pos.y * 16,
7345
7416
  pos.z * 16
7346
7417
  );
7347
7418
  }
7348
7419
  static sceneToWorldPosition(pos) {
7349
- return new import_three23.Vector3(
7420
+ return new import_three24.Vector3(
7350
7421
  pos.x / 16,
7351
7422
  pos.y / 16,
7352
7423
  pos.z / 16
@@ -7383,12 +7454,12 @@ var Chunk = class _Chunk {
7383
7454
  this.x = x;
7384
7455
  this.y = y;
7385
7456
  this.z = z;
7386
- let anchor = new import_three24.Object3D();
7457
+ let anchor = new import_three25.Object3D();
7387
7458
  this._anchor = anchor;
7388
7459
  scene.add(anchor);
7389
7460
  anchor.position.set(this.x * 256 + 128 - 8, this.y * 256 + 128 - 8, this.z * 256 + 128 - 8);
7390
7461
  addBox3WireframeToObject(
7391
- new import_three24.Box3(new import_three24.Vector3(0, 0, 0), new import_three24.Vector3(256, 256, 256)),
7462
+ new import_three25.Box3(new import_three25.Vector3(0, 0, 0), new import_three25.Vector3(256, 256, 256)),
7392
7463
  anchor,
7393
7464
  16776960,
7394
7465
  4
@@ -7396,10 +7467,10 @@ var Chunk = class _Chunk {
7396
7467
  }
7397
7468
  getBlockAt(posOrX, y, z) {
7398
7469
  if (typeof posOrX == "number") {
7399
- return this.getBlockAt(new import_three24.Vector3(posOrX, y, z));
7470
+ return this.getBlockAt(new import_three25.Vector3(posOrX, y, z));
7400
7471
  }
7401
7472
  if (isTripleArray(posOrX)) {
7402
- return this.getBlockAt(new import_three24.Vector3(posOrX[0], posOrX[1], posOrX[2]));
7473
+ return this.getBlockAt(new import_three25.Vector3(posOrX[0], posOrX[1], posOrX[2]));
7403
7474
  }
7404
7475
  const pos = this.worldPosToChunkPos(posOrX);
7405
7476
  const index = _Chunk.chunkPosToBlockIndex(pos);
@@ -7407,10 +7478,10 @@ var Chunk = class _Chunk {
7407
7478
  }
7408
7479
  async setBlockAt(posOrX, yOrBlock, z, block) {
7409
7480
  if (typeof posOrX == "number") {
7410
- return this.setBlockAt(new import_three24.Vector3(posOrX, yOrBlock, z), block);
7481
+ return this.setBlockAt(new import_three25.Vector3(posOrX, yOrBlock, z), block);
7411
7482
  }
7412
7483
  if (isTripleArray(posOrX)) {
7413
- return this.setBlockAt(new import_three24.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
7484
+ return this.setBlockAt(new import_three25.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
7414
7485
  }
7415
7486
  const worldPos = posOrX;
7416
7487
  const pos = this.worldPosToChunkPos(worldPos);
@@ -7456,7 +7527,7 @@ var Chunk = class _Chunk {
7456
7527
  }
7457
7528
  async clear() {
7458
7529
  let promises = [];
7459
- let pos = new import_three24.Vector3();
7530
+ let pos = new import_three25.Vector3();
7460
7531
  for (let x = 0; x < 16; x++) {
7461
7532
  for (let z = 0; z < 16; z++) {
7462
7533
  for (let y = 0; y < 16; y++) {
@@ -7475,14 +7546,14 @@ var Chunk = class _Chunk {
7475
7546
  return pos.y * 16 * 16 + pos.z * 16 + pos.x;
7476
7547
  }
7477
7548
  worldPosToChunkPos(pos) {
7478
- return new import_three24.Vector3(
7549
+ return new import_three25.Vector3(
7479
7550
  pos.x - this.x * 16,
7480
7551
  pos.y - this.y * 16,
7481
7552
  pos.z - this.z * 16
7482
7553
  );
7483
7554
  }
7484
7555
  chunkPosToWorldPos(pos) {
7485
- return new import_three24.Vector3(
7556
+ return new import_three25.Vector3(
7486
7557
  this.x * 16 + pos.x,
7487
7558
  this.y * 16 + pos.y,
7488
7559
  this.z * 16 + pos.z