minerender 2.1.0-alpha.22 → 2.1.0-alpha.24

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.
@@ -405,7 +405,7 @@ var Caching = class _Caching {
405
405
  this.blockTintCache = _Caching.createAssetCache();
406
406
  }
407
407
  static {
408
- this.entityModelsCache = _Caching.createAssetCache();
408
+ this.entityModelCache = _Caching.createAssetCache();
409
409
  }
410
410
  static createAssetCache() {
411
411
  return Caches.builder().expireAfterWrite(Time.minutes(10)).expireAfterAccess(Time.minutes(5)).expirationInterval(Time.seconds(30)).buildAsync();
@@ -430,7 +430,7 @@ var Caching = class _Caching {
430
430
  this.listAssetCache,
431
431
  this.defaultBlockStatesCache,
432
432
  this.blockTintCache,
433
- this.entityModelsCache
433
+ this.entityModelCache
434
434
  ];
435
435
  }
436
436
  static clear() {
@@ -1405,7 +1405,7 @@ var BlockStates = class {
1405
1405
  void 0,
1406
1406
  "assets",
1407
1407
  ".json",
1408
- DEFAULT_ROOT
1408
+ AssetLoader.ROOT
1409
1409
  );
1410
1410
  return Caching.listAssetCache.get(key.serialize(), () => {
1411
1411
  return AssetLoader.get(key, "list" /* LIST */);
@@ -1540,14 +1540,6 @@ function applyElementRotation(rotation, geometry) {
1540
1540
  }
1541
1541
  geometry.translate(origin.x, origin.y, origin.z);
1542
1542
  }
1543
- function applyModelPartRotation(modelPart, geometry) {
1544
- const origin = new Vector33(modelPart.pivotX, modelPart.pivotY, modelPart.pivotZ);
1545
- geometry.translate(-origin.x, -origin.y, -origin.z);
1546
- geometry.rotateX(toRadians(modelPart.pitch));
1547
- geometry.rotateY(toRadians(modelPart.yaw));
1548
- geometry.rotateZ(toRadians(modelPart.roll));
1549
- geometry.translate(origin.x, origin.y, origin.z);
1550
- }
1551
1543
  function applyGenericRotation(axis, rotation, obj) {
1552
1544
  switch (axis) {
1553
1545
  case "x" /* X */:
@@ -1722,17 +1714,17 @@ var HostedAssetSource = class _HostedAssetSource extends AssetSource {
1722
1714
  if (typeof namespaced !== "undefined") {
1723
1715
  return namespaced;
1724
1716
  }
1725
- if (typeof key.root !== "undefined" && key.root !== DEFAULT_ROOT || typeof this.root !== "undefined" && this.root !== DEFAULT_ROOT) {
1717
+ if (typeof key.root !== "undefined" && key.root !== AssetLoader.ROOT || typeof this.root !== "undefined" && this.root !== AssetLoader.ROOT) {
1726
1718
  console.info(p3, "Retrying", key, "with default root+namespace");
1727
- const namespacedRootedKey = new AssetKey(DEFAULT_NAMESPACE, key.path, key.assetType, key.type, key.rootType, key.extension, DEFAULT_ROOT);
1719
+ const namespacedRootedKey = new AssetKey(DEFAULT_NAMESPACE, key.path, key.assetType, key.type, key.rootType, key.extension, AssetLoader.ROOT);
1728
1720
  const namespacedRooted = await this.load(namespacedRootedKey, parser);
1729
1721
  if (typeof namespacedRooted !== "undefined") {
1730
1722
  return namespacedRooted;
1731
1723
  }
1732
1724
  }
1733
- } else if (typeof key.root !== "undefined" && key.root !== DEFAULT_ROOT || typeof this.root !== "undefined" && this.root !== DEFAULT_ROOT) {
1725
+ } else if (typeof key.root !== "undefined" && key.root !== AssetLoader.ROOT || typeof this.root !== "undefined" && this.root !== AssetLoader.ROOT) {
1734
1726
  console.info(p3, "Retrying", key, "with default root");
1735
- const rootKey = new AssetKey(key.namespace, key.path, key.assetType, key.type, key.rootType, key.extension, DEFAULT_ROOT);
1727
+ const rootKey = new AssetKey(key.namespace, key.path, key.assetType, key.type, key.rootType, key.extension, AssetLoader.ROOT);
1736
1728
  const rooted = await this.load(rootKey, parser);
1737
1729
  if (typeof rooted !== "undefined") {
1738
1730
  return rooted;
@@ -1866,6 +1858,20 @@ var AssetLoader = class {
1866
1858
  static {
1867
1859
  this._SOURCES = [];
1868
1860
  }
1861
+ static get version() {
1862
+ return this.ROOT.substring(this.ROOT.lastIndexOf("/") + 1);
1863
+ }
1864
+ static setVersion(version) {
1865
+ this.ROOT = `https://assets.mcasset.cloud/${version}`;
1866
+ const source = new HostedAssetSource(this.ROOT, { retryDefaults: false });
1867
+ const index = this._SOURCES.findIndex((s) => s.key === "mcassets");
1868
+ if (index !== -1) {
1869
+ this._SOURCES[index] = { key: "mcassets", source };
1870
+ } else {
1871
+ this.addSource("mcassets", source);
1872
+ }
1873
+ Caching.clear();
1874
+ }
1869
1875
  static addSource(key, source, override = true) {
1870
1876
  if (override) {
1871
1877
  const existing = this.removeSource(key);
@@ -1888,7 +1894,7 @@ var AssetLoader = class {
1888
1894
  }
1889
1895
  static {
1890
1896
  this.addSource("mcassets-fallback", new HostedAssetSource("https://raw.githubusercontent.com/InventivetalentDev/minerender-fallback-assets/master", { retryDefaults: false }));
1891
- this.addSource("mcassets", new HostedAssetSource(DEFAULT_ROOT, { retryDefaults: false }));
1897
+ this.addSource("mcassets", new HostedAssetSource(this.ROOT, { retryDefaults: false }));
1892
1898
  }
1893
1899
  static async getAll(key, parser) {
1894
1900
  let promises = [];
@@ -2590,18 +2596,18 @@ var MinecraftCubeTexture = class {
2590
2596
  }
2591
2597
  getUvEast(w, h, l) {
2592
2598
  return [
2593
- [this.mapW(this.u), this.mapH(this.v + l + h)],
2594
- [this.mapW(this.u + l), this.mapH(this.v + l + h)],
2595
- [this.mapW(this.u), this.mapH(this.v + l)],
2596
- [this.mapW(this.u + l), this.mapH(this.v + l)]
2599
+ [this.mapW(this.u + l + w + l), this.mapH(this.v + l + h)],
2600
+ [this.mapW(this.u + l + w), this.mapH(this.v + l + h)],
2601
+ [this.mapW(this.u + l + w + l), this.mapH(this.v + l)],
2602
+ [this.mapW(this.u + l + w), this.mapH(this.v + l)]
2597
2603
  ];
2598
2604
  }
2599
2605
  getUvWest(w, h, l) {
2600
2606
  return [
2601
- [this.mapW(this.u + l + w), this.mapH(this.v + l + h)],
2602
- [this.mapW(this.u + l + w + l), this.mapH(this.v + l + h)],
2603
- [this.mapW(this.u + l + w), this.mapH(this.v + l)],
2604
- [this.mapW(this.u + l + w + l), this.mapH(this.v + l)]
2607
+ [this.mapW(this.u + l), this.mapH(this.v + l + h)],
2608
+ [this.mapW(this.u), this.mapH(this.v + l + h)],
2609
+ [this.mapW(this.u + l), this.mapH(this.v + l)],
2610
+ [this.mapW(this.u), this.mapH(this.v + l)]
2605
2611
  ];
2606
2612
  }
2607
2613
  getUvUp(w, h, l) {
@@ -2614,26 +2620,26 @@ var MinecraftCubeTexture = class {
2614
2620
  }
2615
2621
  getUvDown(w, h, l) {
2616
2622
  return [
2617
- [this.mapW(this.u + l), this.mapH(this.v + l)],
2618
- [this.mapW(this.u + l + w), this.mapH(this.v + l)],
2619
2623
  [this.mapW(this.u + l), this.mapH(this.v)],
2620
- [this.mapW(this.u + l + w), this.mapH(this.v)]
2624
+ [this.mapW(this.u + l + w), this.mapH(this.v)],
2625
+ [this.mapW(this.u + l), this.mapH(this.v + l)],
2626
+ [this.mapW(this.u + l + w), this.mapH(this.v + l)]
2621
2627
  ];
2622
2628
  }
2623
2629
  getUvSouth(w, h, l) {
2624
2630
  return [
2625
- [this.mapW(this.u + l + w + l), this.mapH(this.v + l + h)],
2626
2631
  [this.mapW(this.u + l + w + l + w), this.mapH(this.v + l + h)],
2627
- [this.mapW(this.u + l + w + l), this.mapH(this.v + l)],
2628
- [this.mapW(this.u + l + w + l + w), this.mapH(this.v + l)]
2632
+ [this.mapW(this.u + l + w + l), this.mapH(this.v + l + h)],
2633
+ [this.mapW(this.u + l + w + l + w), this.mapH(this.v + l)],
2634
+ [this.mapW(this.u + l + w + l), this.mapH(this.v + l)]
2629
2635
  ];
2630
2636
  }
2631
2637
  getUvNorth(w, h, l) {
2632
2638
  return [
2633
- [this.mapW(this.u + l), this.mapH(this.v + l + h)],
2634
2639
  [this.mapW(this.u + l + w), this.mapH(this.v + l + h)],
2635
- [this.mapW(this.u + l), this.mapH(this.v + l)],
2636
- [this.mapW(this.u + l + w), this.mapH(this.v + l)]
2640
+ [this.mapW(this.u + l), this.mapH(this.v + l + h)],
2641
+ [this.mapW(this.u + l + w), this.mapH(this.v + l)],
2642
+ [this.mapW(this.u + l), this.mapH(this.v + l)]
2637
2643
  ];
2638
2644
  }
2639
2645
  getFaceUv(face, w, h, l) {
@@ -2652,10 +2658,12 @@ var MinecraftCubeTexture = class {
2652
2658
  return this.getUvNorth(w, h, l);
2653
2659
  }
2654
2660
  }
2655
- toUvArray(w, h, l) {
2661
+ toUvArray(w, h, l, mirror = false) {
2656
2662
  const uv = [];
2657
2663
  for (let i = 0; i < CUBE_FACES.length; i++) {
2658
- UVMapper.setFaceUvInArray(uv, i * 4, this.getFaceUv(CUBE_FACES[i], w, h, l));
2664
+ const face = mirror && i < 2 ? CUBE_FACES[1 - i] : CUBE_FACES[i];
2665
+ const corners = this.getFaceUv(face, w, h, l);
2666
+ UVMapper.setFaceUvInArray(uv, i * 4, mirror ? [corners[1], corners[0], corners[3], corners[2]] : corners);
2659
2667
  }
2660
2668
  return uv;
2661
2669
  }
@@ -2685,69 +2693,51 @@ function shutdown() {
2685
2693
  Caching.end();
2686
2694
  }
2687
2695
 
2688
- // src/assets/Entities.ts
2689
- var Entities = class {
2690
- static async getBlockEntityModels() {
2691
- const key = AssetKey.parse("models", "minerender:blockEntityModels");
2692
- console.log(key);
2693
- return Caching.entityModelsCache.get(key.serialize(), () => {
2694
- return AssetLoader.get(key, "json" /* JSON */);
2695
- });
2696
- }
2697
- static async getEntityModels() {
2698
- const key = AssetKey.parse("models", "minerender:entityModels");
2699
- console.log(key);
2700
- return Caching.entityModelsCache.get(key.serialize(), () => {
2701
- return AssetLoader.get(key, "json" /* JSON */);
2702
- });
2696
+ // src/error/MineRenderError.ts
2697
+ var MineRenderError = class _MineRenderError extends Error {
2698
+ constructor(msg) {
2699
+ super(msg);
2700
+ Object.setPrototypeOf(this, _MineRenderError.prototype);
2703
2701
  }
2704
- // BlockEntity names are hardcoded
2705
- static async getBlockList() {
2706
- const models = await this.getBlockEntityModels();
2707
- if (!models) {
2708
- return [];
2709
- }
2710
- return Object.keys(models);
2702
+ get name() {
2703
+ return "MineRenderError";
2711
2704
  }
2705
+ };
2706
+
2707
+ // src/assets/Entities.ts
2708
+ var Entities = class {
2712
2709
  static async getEntityList() {
2713
- const models = await this.getEntityModels();
2714
- if (!models) {
2715
- return [];
2716
- }
2717
- return Object.keys(models);
2718
- }
2719
- static async getBlock(modelKey, textureKey) {
2720
- const models = await this.getBlockEntityModels();
2721
- if (!models) {
2722
- return void 0;
2723
- }
2724
- if (!textureKey) {
2725
- textureKey = modelKey;
2726
- }
2727
- const baseKey = modelKey.path.includes("/") ? new BasicAssetKey(modelKey.namespace, modelKey.path.split("/")[0]) : modelKey;
2728
- return {
2729
- key: textureKey,
2730
- parts: models[baseKey.toNamespacedString()]
2710
+ const collect = async (path) => {
2711
+ const prefix2 = path ? `${path}/` : "";
2712
+ const key = new AssetKey(DEFAULT_NAMESPACE, `${prefix2}_list`, void 0, void 0, "entity-models", ".json");
2713
+ const list = await Caching.listAssetCache.get(key.serialize(), () => AssetLoader.get(key, "list" /* LIST */));
2714
+ if (!list) return [];
2715
+ const files = list.files.filter((file) => file.endsWith(".json") && file !== "_list.json").map((file) => `${prefix2}${file.slice(0, -5)}`);
2716
+ const children = await Promise.all(list.directories.map((directory) => collect(`${prefix2}${directory}`)));
2717
+ return [...files, ...children.flat()];
2731
2718
  };
2719
+ return collect("");
2732
2720
  }
2733
- static async getEntity(modelKey, textureKey) {
2734
- const models = await this.getEntityModels();
2735
- if (!models) {
2736
- return void 0;
2737
- }
2738
- if (!textureKey) {
2739
- textureKey = modelKey;
2721
+ static async getEntity(modelKey, textureKey, options) {
2722
+ const path = isAssetKey(modelKey) ? modelKey.getFullPath() : modelKey.path;
2723
+ const key = new AssetKey(modelKey.namespace, path, void 0, void 0, "entity-models", ".json");
2724
+ const model = await Caching.entityModelCache.get(key.serialize(), () => AssetLoader.get(key, "json" /* JSON */));
2725
+ if (!model) return void 0;
2726
+ const layerName = options?.layer ?? "main";
2727
+ const layer = model.layers[layerName];
2728
+ if (!layer) {
2729
+ throw new MineRenderError(`Entity ${model.id} has no layer "${layerName}". Available layers: ${Object.keys(model.layers).join(", ")}`);
2740
2730
  }
2741
- const baseKey = modelKey.path.includes("/") ? new BasicAssetKey(modelKey.namespace, modelKey.path.split("/")[0]) : modelKey;
2742
- return {
2743
- key: textureKey,
2744
- parts: models[baseKey.toNamespacedString()]
2745
- };
2731
+ return { key: textureKey ?? modelKey, layer, id: model.id };
2732
+ }
2733
+ /** @deprecated Use getEntityList(); block entities share the entity dataset. */
2734
+ static getBlockList() {
2735
+ return this.getEntityList();
2736
+ }
2737
+ /** @deprecated Use getEntity(); block entities share the entity dataset. */
2738
+ static getBlock(modelKey, textureKey, options) {
2739
+ return this.getEntity(modelKey, textureKey, options);
2746
2740
  }
2747
- };
2748
- var EntityModels = class {
2749
- };
2750
- var BlockEntityModels = class {
2751
2741
  };
2752
2742
 
2753
2743
  // src/renderer/SceneObject.ts
@@ -2796,17 +2786,6 @@ function isInstanceReference(obj) {
2796
2786
  return obj.isInstanceReference;
2797
2787
  }
2798
2788
 
2799
- // src/error/MineRenderError.ts
2800
- var MineRenderError = class _MineRenderError extends Error {
2801
- constructor(msg) {
2802
- super(msg);
2803
- Object.setPrototypeOf(this, _MineRenderError.prototype);
2804
- }
2805
- get name() {
2806
- return "MineRenderError";
2807
- }
2808
- };
2809
-
2810
2789
  // src/renderer/SceneObject.ts
2811
2790
  var import_ts_deepmerge3 = __toESM(require_dist());
2812
2791
  var p6 = prefix("SceneObject");
@@ -2940,15 +2919,8 @@ var SceneObject = class _SceneObject extends Object3D2 {
2940
2919
  return this.toggleObjectVisibility(this.getMeshByName(name), visible);
2941
2920
  }
2942
2921
  iterateAllMeshes(cb) {
2943
- this.children.forEach((obj) => {
2944
- if (obj.isMesh) {
2945
- cb(obj);
2946
- }
2947
- obj.children.forEach((obj1) => {
2948
- if (obj1.isMesh) {
2949
- cb(obj1);
2950
- }
2951
- });
2922
+ this.traverse((obj) => {
2923
+ if (isMesh(obj)) cb(obj);
2952
2924
  });
2953
2925
  }
2954
2926
  //</editor-fold>
@@ -3186,17 +3158,16 @@ function isSceneObject(obj) {
3186
3158
  // src/entity/scene/EntityObject.ts
3187
3159
  var import_ts_deepmerge4 = __toESM(require_dist());
3188
3160
  import { Object3D as Object3D3 } from "three";
3189
- import * as THREE3 from "three";
3190
- var EntityObject = class extends SceneObject {
3161
+ var EntityObject = class _EntityObject extends SceneObject {
3191
3162
  constructor(entity, options) {
3192
3163
  super();
3193
3164
  this.entity = entity;
3194
3165
  this.isEntityObject = true;
3195
3166
  this.meshesCreated = false;
3196
- this.options = (0, import_ts_deepmerge4.default)({}, SceneObject.DEFAULT_OPTIONS, options ?? {});
3167
+ this.options = (0, import_ts_deepmerge4.default)({}, _EntityObject.DEFAULT_OPTIONS, options ?? {});
3197
3168
  }
3198
3169
  static {
3199
- this.DEFAULT_OPTIONS = (0, import_ts_deepmerge4.default)({}, SceneObject.DEFAULT_OPTIONS, {});
3170
+ this.DEFAULT_OPTIONS = (0, import_ts_deepmerge4.default)({}, SceneObject.DEFAULT_OPTIONS, { flip: true });
3200
3171
  }
3201
3172
  async init() {
3202
3173
  this.createMeshes();
@@ -3206,10 +3177,10 @@ var EntityObject = class extends SceneObject {
3206
3177
  super.dispose();
3207
3178
  }
3208
3179
  get textureKey() {
3180
+ const key = this.entity.key;
3209
3181
  return new AssetKey(
3210
- this.entity.key?.namespace ?? DEFAULT_NAMESPACE,
3211
- this.entity.key.path,
3212
- //TODO: texture may differ from entity name; most of them are in subdirectories for multiple variants etc.
3182
+ key.namespace,
3183
+ isAssetKey(key) ? key.getFullPath() : key.path,
3213
3184
  "textures",
3214
3185
  "entity",
3215
3186
  "assets",
@@ -3219,36 +3190,41 @@ var EntityObject = class extends SceneObject {
3219
3190
  async loadTextures() {
3220
3191
  this.imageData = await ModelTextures.get(this.textureKey);
3221
3192
  }
3222
- //TODO: abstract this, since extracted model data can be used for entities, blocks, players
3223
3193
  createMeshes(force = false) {
3224
3194
  if (this.meshesCreated && !force) return;
3225
- const mat = Materials.MISSING_TEXTURE;
3226
- for (let partName in this.entity.parts) {
3227
- const part = this.entity.parts[partName];
3228
- const texture = new MinecraftCubeTexture(part.textureOffsetU, part.textureOffsetV, part.textureWidth, part.textureHeight);
3229
- const partAnchor = new Object3D3();
3230
- partAnchor.position.x = part.pivotX;
3231
- partAnchor.position.y = part.pivotY;
3232
- partAnchor.position.z = part.pivotZ;
3233
- for (let cube of part.cubes) {
3234
- const w = cube.maxX - cube.minX;
3235
- const h = cube.maxY - cube.minY;
3236
- const l = cube.maxZ - cube.minZ;
3237
- const uv = texture.toUvArray(w, h, l);
3238
- const cubeGeo = this._getBoxGeometryForDimensionsAndUv(w, h, l, uv).clone();
3239
- cubeGeo.applyMatrix4(new THREE3.Matrix4().makeTranslation(w / 2, h / 2, l / 2));
3240
- cubeGeo.applyMatrix4(new THREE3.Matrix4().makeTranslation(cube.minX, cube.minY, cube.minZ));
3241
- applyModelPartRotation(part, cubeGeo);
3242
- const mesh = this.createMesh(partName, cubeGeo, mat);
3243
- partAnchor.add(mesh);
3244
- if (this.options.wireframe) {
3245
- addWireframeToMesh(cubeGeo, mesh);
3246
- }
3247
- }
3248
- this.add(partAnchor);
3249
- }
3195
+ const modelRoot = new Object3D3();
3196
+ if (this.options.flip) modelRoot.scale.set(-1, -1, 1);
3197
+ this.add(modelRoot);
3198
+ this.createPart("root", this.entity.layer.root, modelRoot, this.entity.layer.texture, Materials.MISSING_TEXTURE);
3250
3199
  this.meshesCreated = true;
3251
3200
  }
3201
+ createPart(name, part, parent, textureSize, material) {
3202
+ const anchor = this.createGroup(name);
3203
+ anchor.position.fromArray(part.pose.offset);
3204
+ anchor.rotation.set(...part.pose.rotation, "ZYX");
3205
+ anchor.scale.fromArray(part.pose.scale ?? [1, 1, 1]);
3206
+ parent.add(anchor);
3207
+ const size = part.texture ?? textureSize;
3208
+ for (const cube of part.cubes) {
3209
+ const [width, height, depth] = cube.size;
3210
+ const [growX, growY, growZ] = cube.grow ?? [0, 0, 0];
3211
+ const texture = new MinecraftCubeTexture(...cube.uv, ...size);
3212
+ const uv = size[0] === 0 || size[1] === 0 ? new Array(48).fill(0) : texture.toUvArray(width, height, depth, cube.mirror);
3213
+ const geometry = this._getBoxGeometryForDimensionsAndUv(
3214
+ width + growX * 2,
3215
+ height + growY * 2,
3216
+ depth + growZ * 2,
3217
+ uv
3218
+ ).clone();
3219
+ geometry.translate(cube.origin[0] + width / 2, cube.origin[1] + height / 2, cube.origin[2] + depth / 2);
3220
+ const mesh = this.createMesh(name, geometry, material);
3221
+ anchor.add(mesh);
3222
+ if (this.options.wireframe) addWireframeToMesh(geometry, mesh);
3223
+ }
3224
+ for (const [childName, child] of Object.entries(part.children)) {
3225
+ this.createPart(childName, child, anchor, size, material);
3226
+ }
3227
+ }
3252
3228
  async applyTextures() {
3253
3229
  const assetKeyStr = this.textureKey.serialize();
3254
3230
  const keyStr = `entity:${assetKeyStr}`;
@@ -3799,7 +3775,7 @@ var BlockTints = class {
3799
3775
  };
3800
3776
 
3801
3777
  // src/model/scene/ModelObject.ts
3802
- import { BoxGeometry as BoxGeometry5, BufferAttribute as BufferAttribute4, Color as Color3, Euler as Euler5, Matrix4 as Matrix46 } from "three";
3778
+ import { BoxGeometry as BoxGeometry5, BufferAttribute as BufferAttribute4, Color as Color3, Euler as Euler4, Matrix4 as Matrix44 } from "three";
3803
3779
 
3804
3780
  // src/three/BufferGeometryUtils.js
3805
3781
  import {
@@ -3811,7 +3787,7 @@ import {
3811
3787
  TriangleFanDrawMode,
3812
3788
  TriangleStripDrawMode,
3813
3789
  TrianglesDrawMode,
3814
- Vector3 as Vector37
3790
+ Vector3 as Vector36
3815
3791
  } from "three";
3816
3792
  function computeTangents(geometry) {
3817
3793
  geometry.computeTangents();
@@ -4130,15 +4106,15 @@ function computeMorphedAttributes(object) {
4130
4106
  console.error("THREE.BufferGeometryUtils: Geometry is not of type BufferGeometry.");
4131
4107
  return null;
4132
4108
  }
4133
- const _vA = new Vector37();
4134
- const _vB = new Vector37();
4135
- const _vC = new Vector37();
4136
- const _tempA = new Vector37();
4137
- const _tempB = new Vector37();
4138
- const _tempC = new Vector37();
4139
- const _morphA = new Vector37();
4140
- const _morphB = new Vector37();
4141
- const _morphC = new Vector37();
4109
+ const _vA = new Vector36();
4110
+ const _vB = new Vector36();
4111
+ const _vC = new Vector36();
4112
+ const _tempA = new Vector36();
4113
+ const _tempB = new Vector36();
4114
+ const _tempC = new Vector36();
4115
+ const _morphA = new Vector36();
4116
+ const _morphB = new Vector36();
4117
+ const _morphC = new Vector36();
4142
4118
  function _calculateMorphedAttributeData(object2, material2, attribute, morphAttribute, morphTargetsRelative2, a2, b2, c2, modifiedAttributeArray) {
4143
4119
  _vA.fromBufferAttribute(attribute, a2);
4144
4120
  _vB.fromBufferAttribute(attribute, b2);
@@ -4385,7 +4361,7 @@ var ModelObject = class _ModelObject extends SceneObject {
4385
4361
  this.atlas.model.elements?.forEach((el) => {
4386
4362
  const elGeo = this._getBoxGeometryFromElement(el).clone();
4387
4363
  if (this.options.uvLockRotation) {
4388
- UVMapper.lockUvs(elGeo, el.faces, this.atlas, new Euler5(...this.options.uvLockRotation));
4364
+ UVMapper.lockUvs(elGeo, el.faces, this.atlas, new Euler4(...this.options.uvLockRotation));
4389
4365
  }
4390
4366
  if (this.options.tints) {
4391
4367
  const colors = new Float32Array(elGeo.getAttribute("position").count * 3).fill(1);
@@ -4401,12 +4377,12 @@ var ModelObject = class _ModelObject extends SceneObject {
4401
4377
  }
4402
4378
  elGeo.setAttribute("color", new BufferAttribute4(colors, 3));
4403
4379
  }
4404
- elGeo.applyMatrix4(new Matrix46().makeTranslation((el.to[0] - el.from[0]) / 2, (el.to[1] - el.from[1]) / 2, (el.to[2] - el.from[2]) / 2));
4405
- elGeo.applyMatrix4(new Matrix46().makeTranslation(el.from[0], el.from[1], el.from[2]));
4380
+ elGeo.applyMatrix4(new Matrix44().makeTranslation((el.to[0] - el.from[0]) / 2, (el.to[1] - el.from[1]) / 2, (el.to[2] - el.from[2]) / 2));
4381
+ elGeo.applyMatrix4(new Matrix44().makeTranslation(el.from[0], el.from[1], el.from[2]));
4406
4382
  if (el.rotation) {
4407
4383
  applyElementRotation(el.rotation, elGeo);
4408
4384
  }
4409
- elGeo.applyMatrix4(new Matrix46().makeTranslation(-8, -8, -8));
4385
+ elGeo.applyMatrix4(new Matrix44().makeTranslation(-8, -8, -8));
4410
4386
  if (displayTransform) DisplayTransforms.apply(elGeo, displayTransform);
4411
4387
  if (this.options.mergeMeshes) {
4412
4388
  allGeos.push(elGeo);
@@ -4481,7 +4457,7 @@ function isModelObject(obj) {
4481
4457
 
4482
4458
  // src/model/block/scene/BlockObject.ts
4483
4459
  var import_ts_deepmerge6 = __toESM(require_dist());
4484
- import { Euler as Euler6, Matrix4 as Matrix47, Vector3 as Vector38 } from "three";
4460
+ import { Euler as Euler5, Matrix4 as Matrix45, Vector3 as Vector37 } from "three";
4485
4461
  var p10 = prefix("BlockObject");
4486
4462
  function matchesCondition(condition, state) {
4487
4463
  return Object.entries(condition).every(([key, value]) => {
@@ -4543,7 +4519,7 @@ var BlockObject = class _BlockObject extends SceneObject {
4543
4519
  if (isModelObject(model)) {
4544
4520
  model.removeFromScene();
4545
4521
  } else if (isInstanceReference(model)) {
4546
- model.setScale(new Vector38(0, 0, 0));
4522
+ model.setScale(new Vector37(0, 0, 0));
4547
4523
  }
4548
4524
  }
4549
4525
  super.removeFromScene();
@@ -4604,7 +4580,7 @@ var BlockObject = class _BlockObject extends SceneObject {
4604
4580
  }
4605
4581
  for (let model of this._models) {
4606
4582
  if (isInstanceReference(model)) {
4607
- model.setScale(new Vector38(0, 0, 0));
4583
+ model.setScale(new Vector37(0, 0, 0));
4608
4584
  } else {
4609
4585
  model.dispose();
4610
4586
  }
@@ -4641,7 +4617,7 @@ var BlockObject = class _BlockObject extends SceneObject {
4641
4617
  await this.createVariant(variant);
4642
4618
  }
4643
4619
  async createVariant(variant) {
4644
- const rotation = new Euler6();
4620
+ const rotation = new Euler5();
4645
4621
  if (typeof variant.x !== "undefined") {
4646
4622
  rotation.x = toRadians(clampRotationDegrees(variant.x));
4647
4623
  }
@@ -4728,7 +4704,7 @@ var BlockObject = class _BlockObject extends SceneObject {
4728
4704
  setPositionRotationScaleAt(index, position, rotation, scale) {
4729
4705
  super.setPositionRotationScaleAt(index, position, rotation, scale);
4730
4706
  }
4731
- getMatrixAt(index, matrix = new Matrix47()) {
4707
+ getMatrixAt(index, matrix = new Matrix45()) {
4732
4708
  if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
4733
4709
  const child = this._models[0];
4734
4710
  if (child && isModelObject(child)) {
@@ -5771,7 +5747,7 @@ function isMineRenderScene(obj) {
5771
5747
  }
5772
5748
 
5773
5749
  // src/renderer/Renderer.ts
5774
- import { AxesHelper as AxesHelper3, GridHelper, OrthographicCamera, PCFSoftShadowMap, PerspectiveCamera, SRGBColorSpace as SRGBColorSpace3, Vector3 as Vector310, WebGLRenderer } from "three";
5750
+ import { AxesHelper as AxesHelper2, GridHelper, OrthographicCamera, PCFSoftShadowMap, PerspectiveCamera, SRGBColorSpace as SRGBColorSpace3, Vector3 as Vector39, WebGLRenderer } from "three";
5775
5751
  var import_ts_deepmerge9 = __toESM(require_dist());
5776
5752
  import Stats from "stats.js";
5777
5753
  import { EffectComposer, RenderPass } from "postprocessing";
@@ -5784,7 +5760,7 @@ import {
5784
5760
  Spherical,
5785
5761
  TOUCH,
5786
5762
  Vector2 as Vector23,
5787
- Vector3 as Vector39
5763
+ Vector3 as Vector38
5788
5764
  } from "three";
5789
5765
  var _changeEvent = { type: "change" };
5790
5766
  var _startEvent = { type: "start" };
@@ -5798,7 +5774,7 @@ var OrbitControls = class extends EventDispatcher {
5798
5774
  this.domElement = domElement;
5799
5775
  this.domElement.style.touchAction = "none";
5800
5776
  this.enabled = true;
5801
- this.target = new Vector39();
5777
+ this.target = new Vector38();
5802
5778
  this.minDistance = 0;
5803
5779
  this.maxDistance = Infinity;
5804
5780
  this.minZoom = 0;
@@ -5850,10 +5826,10 @@ var OrbitControls = class extends EventDispatcher {
5850
5826
  state = STATE.NONE;
5851
5827
  };
5852
5828
  this.update = function() {
5853
- const offset = new Vector39();
5854
- const quat = new Quaternion4().setFromUnitVectors(object.up, new Vector39(0, 1, 0));
5829
+ const offset = new Vector38();
5830
+ const quat = new Quaternion4().setFromUnitVectors(object.up, new Vector38(0, 1, 0));
5855
5831
  const quatInverse = quat.clone().invert();
5856
- const lastPosition = new Vector39();
5832
+ const lastPosition = new Vector38();
5857
5833
  const lastQuaternion = new Quaternion4();
5858
5834
  const twoPI = 2 * Math.PI;
5859
5835
  return function update() {
@@ -5943,7 +5919,7 @@ var OrbitControls = class extends EventDispatcher {
5943
5919
  const spherical = new Spherical();
5944
5920
  const sphericalDelta = new Spherical();
5945
5921
  let scale = 1;
5946
- const panOffset = new Vector39();
5922
+ const panOffset = new Vector38();
5947
5923
  let zoomChanged = false;
5948
5924
  const rotateStart = new Vector23();
5949
5925
  const rotateEnd = new Vector23();
@@ -5969,7 +5945,7 @@ var OrbitControls = class extends EventDispatcher {
5969
5945
  sphericalDelta.phi -= angle;
5970
5946
  }
5971
5947
  const panLeft = function() {
5972
- const v = new Vector39();
5948
+ const v = new Vector38();
5973
5949
  return function panLeft2(distance, objectMatrix) {
5974
5950
  v.setFromMatrixColumn(objectMatrix, 0);
5975
5951
  v.multiplyScalar(-distance);
@@ -5977,7 +5953,7 @@ var OrbitControls = class extends EventDispatcher {
5977
5953
  };
5978
5954
  }();
5979
5955
  const panUp = function() {
5980
- const v = new Vector39();
5956
+ const v = new Vector38();
5981
5957
  return function panUp2(distance, objectMatrix) {
5982
5958
  if (scope.screenSpacePanning === true) {
5983
5959
  v.setFromMatrixColumn(objectMatrix, 1);
@@ -5990,7 +5966,7 @@ var OrbitControls = class extends EventDispatcher {
5990
5966
  };
5991
5967
  }();
5992
5968
  const pan = function() {
5993
- const offset = new Vector39();
5969
+ const offset = new Vector38();
5994
5970
  return function pan2(deltaX, deltaY) {
5995
5971
  const element = scope.domElement;
5996
5972
  if (scope.object.isPerspectiveCamera) {
@@ -6467,8 +6443,8 @@ var Renderer = class _Renderer {
6467
6443
  top: void 0,
6468
6444
  bottom: void 0
6469
6445
  },
6470
- position: new Vector310(50, 50, 50),
6471
- lookingAt: new Vector310(0, 0, 0)
6446
+ position: new Vector39(50, 50, 50),
6447
+ lookingAt: new Vector39(0, 0, 0)
6472
6448
  },
6473
6449
  render: {
6474
6450
  fpsLimit: 60,
@@ -6572,7 +6548,7 @@ var Renderer = class _Renderer {
6572
6548
  this.scene.add(gridHelper3);
6573
6549
  }
6574
6550
  if (this.options.debug.axes) {
6575
- const axesHelper = new AxesHelper3(64);
6551
+ const axesHelper = new AxesHelper2(64);
6576
6552
  this._debugHelpers.push(axesHelper);
6577
6553
  this.scene.add(axesHelper);
6578
6554
  }
@@ -6933,10 +6909,10 @@ var Skins = class {
6933
6909
  };
6934
6910
 
6935
6911
  // src/world/Chunk.ts
6936
- import { Box3 as Box32, Object3D as Object3D6, Vector3 as Vector312 } from "three";
6912
+ import { Box3 as Box32, Object3D as Object3D6, Vector3 as Vector311 } from "three";
6937
6913
 
6938
6914
  // src/world/MineRenderWorld.ts
6939
- import { Vector3 as Vector311 } from "three";
6915
+ import { Vector3 as Vector310 } from "three";
6940
6916
  var MineRenderWorld = class {
6941
6917
  constructor(scene) {
6942
6918
  this._size = 4;
@@ -6947,10 +6923,10 @@ var MineRenderWorld = class {
6947
6923
  }
6948
6924
  getBlockAt(posOrX, y, z) {
6949
6925
  if (typeof posOrX == "number") {
6950
- return this.getBlockAt(new Vector311(posOrX, y, z));
6926
+ return this.getBlockAt(new Vector310(posOrX, y, z));
6951
6927
  }
6952
6928
  if (isTripleArray(posOrX)) {
6953
- return this.getBlockAt(new Vector311(posOrX[0], posOrX[1], posOrX[2]));
6929
+ return this.getBlockAt(new Vector310(posOrX[0], posOrX[1], posOrX[2]));
6954
6930
  }
6955
6931
  const chunk = this.getChunkAt(posOrX);
6956
6932
  if (typeof chunk === "undefined") {
@@ -6961,10 +6937,10 @@ var MineRenderWorld = class {
6961
6937
  }
6962
6938
  async setBlockAt(posOrX, yOrBlock, z, block) {
6963
6939
  if (typeof posOrX == "number") {
6964
- return this.setBlockAt(new Vector311(posOrX, yOrBlock, z), block);
6940
+ return this.setBlockAt(new Vector310(posOrX, yOrBlock, z), block);
6965
6941
  }
6966
6942
  if (isTripleArray(posOrX)) {
6967
- return this.setBlockAt(new Vector311(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
6943
+ return this.setBlockAt(new Vector310(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
6968
6944
  }
6969
6945
  this.validatePosBounds(posOrX);
6970
6946
  const chunk = this.getOrCreateChunkAt(posOrX);
@@ -7010,14 +6986,14 @@ var MineRenderWorld = class {
7010
6986
  return this._chunks[index];
7011
6987
  }
7012
6988
  static worldToScenePosition(pos) {
7013
- return new Vector311(
6989
+ return new Vector310(
7014
6990
  pos.x * 16,
7015
6991
  pos.y * 16,
7016
6992
  pos.z * 16
7017
6993
  );
7018
6994
  }
7019
6995
  static sceneToWorldPosition(pos) {
7020
- return new Vector311(
6996
+ return new Vector310(
7021
6997
  pos.x / 16,
7022
6998
  pos.y / 16,
7023
6999
  pos.z / 16
@@ -7059,7 +7035,7 @@ var Chunk = class _Chunk {
7059
7035
  scene.add(anchor);
7060
7036
  anchor.position.set(this.x * 256 + 128 - 8, this.y * 256 + 128 - 8, this.z * 256 + 128 - 8);
7061
7037
  addBox3WireframeToObject(
7062
- new Box32(new Vector312(0, 0, 0), new Vector312(256, 256, 256)),
7038
+ new Box32(new Vector311(0, 0, 0), new Vector311(256, 256, 256)),
7063
7039
  anchor,
7064
7040
  16776960,
7065
7041
  4
@@ -7067,10 +7043,10 @@ var Chunk = class _Chunk {
7067
7043
  }
7068
7044
  getBlockAt(posOrX, y, z) {
7069
7045
  if (typeof posOrX == "number") {
7070
- return this.getBlockAt(new Vector312(posOrX, y, z));
7046
+ return this.getBlockAt(new Vector311(posOrX, y, z));
7071
7047
  }
7072
7048
  if (isTripleArray(posOrX)) {
7073
- return this.getBlockAt(new Vector312(posOrX[0], posOrX[1], posOrX[2]));
7049
+ return this.getBlockAt(new Vector311(posOrX[0], posOrX[1], posOrX[2]));
7074
7050
  }
7075
7051
  const pos = this.worldPosToChunkPos(posOrX);
7076
7052
  const index = _Chunk.chunkPosToBlockIndex(pos);
@@ -7078,10 +7054,10 @@ var Chunk = class _Chunk {
7078
7054
  }
7079
7055
  async setBlockAt(posOrX, yOrBlock, z, block) {
7080
7056
  if (typeof posOrX == "number") {
7081
- return this.setBlockAt(new Vector312(posOrX, yOrBlock, z), block);
7057
+ return this.setBlockAt(new Vector311(posOrX, yOrBlock, z), block);
7082
7058
  }
7083
7059
  if (isTripleArray(posOrX)) {
7084
- return this.setBlockAt(new Vector312(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
7060
+ return this.setBlockAt(new Vector311(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
7085
7061
  }
7086
7062
  const worldPos = posOrX;
7087
7063
  const pos = this.worldPosToChunkPos(worldPos);
@@ -7127,7 +7103,7 @@ var Chunk = class _Chunk {
7127
7103
  }
7128
7104
  async clear() {
7129
7105
  let promises = [];
7130
- let pos = new Vector312();
7106
+ let pos = new Vector311();
7131
7107
  for (let x = 0; x < 16; x++) {
7132
7108
  for (let z = 0; z < 16; z++) {
7133
7109
  for (let y = 0; y < 16; y++) {
@@ -7146,14 +7122,14 @@ var Chunk = class _Chunk {
7146
7122
  return pos.y * 16 * 16 + pos.z * 16 + pos.x;
7147
7123
  }
7148
7124
  worldPosToChunkPos(pos) {
7149
- return new Vector312(
7125
+ return new Vector311(
7150
7126
  pos.x - this.x * 16,
7151
7127
  pos.y - this.y * 16,
7152
7128
  pos.z - this.z * 16
7153
7129
  );
7154
7130
  }
7155
7131
  chunkPosToWorldPos(pos) {
7156
- return new Vector312(
7132
+ return new Vector311(
7157
7133
  this.x * 16 + pos.x,
7158
7134
  this.y * 16 + pos.y,
7159
7135
  this.z * 16 + pos.z
@@ -7174,7 +7150,6 @@ export {
7174
7150
  BUILTIN_GENERATED,
7175
7151
  BasicAssetKey,
7176
7152
  BatchedExecutor,
7177
- BlockEntityModels,
7178
7153
  BlockObject,
7179
7154
  BlockStates,
7180
7155
  BlockTints,
@@ -7194,7 +7169,6 @@ export {
7194
7169
  DisplayPosition,
7195
7170
  DisplayTransforms,
7196
7171
  Entities,
7197
- EntityModels,
7198
7172
  EntityObject,
7199
7173
  Env,
7200
7174
  Geometries,
@@ -7248,7 +7222,6 @@ export {
7248
7222
  addWireframeToObject,
7249
7223
  applyElementRotation,
7250
7224
  applyGenericRotation,
7251
- applyModelPartRotation,
7252
7225
  axisToVec3,
7253
7226
  base64decode,
7254
7227
  base64encode,