minerender 2.1.0-alpha.29 → 2.1.0-alpha.30

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.
@@ -5604,10 +5604,10 @@ var SkinTextures = class {
5604
5604
  });
5605
5605
  return { material, slim, legacy: isLegacy };
5606
5606
  }
5607
- static async getCape(src) {
5607
+ static async getCape(src, layout = "minecraft") {
5608
5608
  const image = await ImageLoader.getData(src);
5609
5609
  const scale = image.width / 64;
5610
- if (!Number.isInteger(scale) || scale < 1 || image.height !== image.width / 2) {
5610
+ if (layout === "minecraft" && (!Number.isInteger(scale) || scale < 1 || image.height !== image.width / 2)) {
5611
5611
  throw new MineRenderError(`Invalid cape dimensions ${image.width}x${image.height}; expected 64x32 or an integer-scaled equivalent`);
5612
5612
  }
5613
5613
  return Caching.materialCache.get(`cape:${serializeImageKey({ src })}`, () => {
@@ -5676,6 +5676,13 @@ var SkinTextures = class {
5676
5676
  }
5677
5677
  };
5678
5678
 
5679
+ // src/skin/CapeLayout.ts
5680
+ var capeTextureSizes = {
5681
+ minecraft: [64, 32],
5682
+ optifine: [46, 22],
5683
+ labymod: [22, 17]
5684
+ };
5685
+
5679
5686
  // src/skin/scene/SkinObject.ts
5680
5687
  var SkinObject = class extends SceneObject {
5681
5688
  constructor(options) {
@@ -5761,8 +5768,8 @@ var SkinObject = class extends SceneObject {
5761
5768
  }
5762
5769
  this.notifyDirty();
5763
5770
  }
5764
- /** Load a vanilla cape texture, or pass undefined to remove the cape. */
5765
- async setCapeTexture(src) {
5771
+ /** Load a cape texture in the selected layout, or pass undefined to remove the cape. */
5772
+ async setCapeTexture(src, layout = "minecraft") {
5766
5773
  const load = ++this.capeLoad;
5767
5774
  if (src === void 0) {
5768
5775
  const group = this.getGroupByName("cape" /* CAPE */);
@@ -5770,20 +5777,22 @@ var SkinObject = class extends SceneObject {
5770
5777
  this.notifyDirty();
5771
5778
  return;
5772
5779
  }
5773
- const material = await SkinTextures.getCape(src);
5780
+ const material = await SkinTextures.getCape(src, layout);
5774
5781
  if (load !== this.capeLoad) return;
5782
+ const size = capeTextureSizes[layout];
5783
+ const geometry = this._getBoxGeometryFromDimensions(
5784
+ classicSkinGeometries.cape,
5785
+ classicSkinTextureCoordinates.cape,
5786
+ size,
5787
+ size
5788
+ );
5775
5789
  const mesh = this.getMeshByName("cape" /* CAPE */);
5776
5790
  if (mesh) {
5777
5791
  mesh.material = material;
5792
+ mesh.geometry = geometry;
5778
5793
  } else {
5779
5794
  const group = this.createAndAddGroup("cape" /* CAPE */, 0, 24, 2);
5780
5795
  group.rotation.set(toRadians(-6), Math.PI, 0);
5781
- const geometry = this._getBoxGeometryFromDimensions(
5782
- classicSkinGeometries.cape,
5783
- classicSkinTextureCoordinates.cape,
5784
- [64, 32],
5785
- [64, 32]
5786
- );
5787
5796
  const cape = this.createAndAddMesh("cape" /* CAPE */, group, geometry, material);
5788
5797
  cape.position.set(0, -8, -0.5);
5789
5798
  }
@@ -6991,13 +7000,10 @@ var Skins = class {
6991
7000
  return void 0;
6992
7001
  });
6993
7002
  }
6994
- static async capeFromCapesDev(uuid, capeType = "minecraft") {
6995
- return this.getCapesDev(uuid, capeType).then((cape) => {
6996
- if (cape) {
6997
- return cape?.stillImageUrl;
6998
- }
6999
- return void 0;
7000
- });
7003
+ /** Returns a full static cape texture for a username or UUID. */
7004
+ static async capeFromCapesDev(player, capeType = "minecraft") {
7005
+ const cape = await this.getCapesDev(player, capeType);
7006
+ return cape?.exists ? cape.imageUrls?.still?.full : void 0;
7001
7007
  }
7002
7008
  //</editor-fold>
7003
7009
  //<editor-fold desc="Helpers">
@@ -7071,18 +7077,15 @@ var Skins = class {
7071
7077
  return void 0;
7072
7078
  });
7073
7079
  }
7074
- static async getCapesDev(uuid, type = "all") {
7080
+ static async getCapesDev(player, type = "all") {
7075
7081
  return Requests.genericRequest({
7076
7082
  baseURL: "https://api.capes.dev",
7077
- url: "/load/" + uuid + "/" + type
7083
+ url: "/load/" + encodeURIComponent(player) + "/" + encodeURIComponent(type)
7078
7084
  }).then((res) => {
7079
7085
  if (res.status === 200) {
7080
7086
  return res.data;
7081
7087
  }
7082
7088
  return void 0;
7083
- }).catch((err) => {
7084
- console.warn(err);
7085
- return void 0;
7086
7089
  });
7087
7090
  }
7088
7091
  static getCrafatarSkinUrl(uuid) {
@@ -7432,6 +7435,7 @@ export {
7432
7435
  axisToVec3,
7433
7436
  base64decode,
7434
7437
  base64encode,
7438
+ capeTextureSizes,
7435
7439
  captureException,
7436
7440
  changeEvent,
7437
7441
  clampRotationDegrees,