minerender 2.1.0-alpha.95 → 2.1.0-alpha.96

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.
package/dist/bundle.js CHANGED
@@ -33058,14 +33058,14 @@ void main() {
33058
33058
  init_dirname();
33059
33059
  init_buffer2();
33060
33060
  init_process2();
33061
- CubeFace = /* @__PURE__ */ ((CubeFace2) => {
33062
- CubeFace2["EAST"] = "east";
33063
- CubeFace2["WEST"] = "west";
33064
- CubeFace2["UP"] = "up";
33065
- CubeFace2["DOWN"] = "down";
33066
- CubeFace2["SOUTH"] = "south";
33067
- CubeFace2["NORTH"] = "north";
33068
- return CubeFace2;
33061
+ CubeFace = /* @__PURE__ */ ((CubeFace3) => {
33062
+ CubeFace3["EAST"] = "east";
33063
+ CubeFace3["WEST"] = "west";
33064
+ CubeFace3["UP"] = "up";
33065
+ CubeFace3["DOWN"] = "down";
33066
+ CubeFace3["SOUTH"] = "south";
33067
+ CubeFace3["NORTH"] = "north";
33068
+ return CubeFace3;
33069
33069
  })(CubeFace || {});
33070
33070
  CubeFaceIndex = /* @__PURE__ */ ((CubeFaceIndex2) => {
33071
33071
  CubeFaceIndex2[CubeFaceIndex2["EAST"] = 0] = "EAST";
@@ -42879,6 +42879,9 @@ void main() {
42879
42879
  });
42880
42880
 
42881
42881
  // src/assets/AssetKey.ts
42882
+ function isResourceLocation(value) {
42883
+ return typeof value === "string" && /^(?:[a-z0-9_.-]+:)?[a-z0-9_./-]+$/.test(value);
42884
+ }
42882
42885
  function isBasicAssetKey(obj) {
42883
42886
  return obj !== null && typeof obj === "object" && typeof obj.namespace === "string" && typeof obj.path === "string";
42884
42887
  }
@@ -43286,7 +43289,7 @@ void main() {
43286
43289
  return model ? restore(model) : void 0;
43287
43290
  }
43288
43291
  static contextIdentifier(id) {
43289
- if (typeof id !== "string" || !/^(?:[a-z0-9_.-]+:)?[a-z0-9_./-]+$/.test(id)) {
43292
+ if (!isResourceLocation(id)) {
43290
43293
  throw new Error(`Invalid item-preview identifier: ${id}`);
43291
43294
  }
43292
43295
  return id.includes(":") ? id : `minecraft:${id}`;
@@ -43431,6 +43434,8 @@ void main() {
43431
43434
  case "minecraft:trident":
43432
43435
  case "conduit":
43433
43436
  case "minecraft:conduit":
43437
+ case "decorated_pot":
43438
+ case "minecraft:decorated_pot":
43434
43439
  return { model: node.base, special };
43435
43440
  case "shulker_box":
43436
43441
  case "minecraft:shulker_box":
@@ -101132,6 +101137,58 @@ ${key}` : key;
101132
101137
  }
101133
101138
  });
101134
101139
 
101140
+ // src/assets/DecoratedPots.ts
101141
+ var POTTERY_SHERDS, DecoratedPots;
101142
+ var init_DecoratedPots = __esm({
101143
+ "src/assets/DecoratedPots.ts"() {
101144
+ init_dirname();
101145
+ init_buffer2();
101146
+ init_process2();
101147
+ init_AssetKey();
101148
+ POTTERY_SHERDS = Object.freeze([
101149
+ "angler",
101150
+ "archer",
101151
+ "arms_up",
101152
+ "blade",
101153
+ "brewer",
101154
+ "burn",
101155
+ "danger",
101156
+ "explorer",
101157
+ "flow",
101158
+ "friend",
101159
+ "guster",
101160
+ "heart",
101161
+ "heartbreak",
101162
+ "howl",
101163
+ "miner",
101164
+ "mourner",
101165
+ "plenty",
101166
+ "prize",
101167
+ "scrape",
101168
+ "sheaf",
101169
+ "shelter",
101170
+ "skull",
101171
+ "snort"
101172
+ ].map((pattern2) => `minecraft:${pattern2}_pottery_sherd`));
101173
+ DecoratedPots = class {
101174
+ /** Reads up to four item IDs in back, left, right, front order; missing and unmapped items use plain sides. */
101175
+ static getSideTextures(value, root) {
101176
+ const items = value === void 0 ? [] : value;
101177
+ if (!Array.isArray(items) || items.length > 4) throw new Error("pot_decorations must be an array of at most four item IDs");
101178
+ const textures = items.map((item) => {
101179
+ if (!isResourceLocation(item)) throw new Error("Pot decorations must be item identifiers");
101180
+ const id = item.includes(":") ? item : `minecraft:${item}`;
101181
+ return POTTERY_SHERDS.includes(id) ? id.slice("minecraft:".length).replace(/_sherd$/, "_pattern") : "decorated_pot_side";
101182
+ });
101183
+ return Object.fromEntries(["back", "left", "right", "front"].map((side, index) => [
101184
+ side,
101185
+ new AssetKey("minecraft", `decorated_pot/${textures[index] ?? "decorated_pot_side"}`, "textures", "entity", "assets", ".png", root)
101186
+ ]));
101187
+ }
101188
+ };
101189
+ }
101190
+ });
101191
+
101135
101192
  // src/error/MineRenderError.ts
101136
101193
  var MineRenderError;
101137
101194
  var init_MineRenderError = __esm({
@@ -102009,6 +102066,7 @@ ${key}` : key;
102009
102066
  init_AssetKey();
102010
102067
  init_Materials();
102011
102068
  init_MinecraftCubeTexture();
102069
+ init_CubeFace();
102012
102070
  init_three();
102013
102071
  init_EntityAnimationPlayer();
102014
102072
  _EntityObject = class _EntityObject extends SceneObject {
@@ -102183,11 +102241,11 @@ ${key}` : key;
102183
102241
  const group = this.createGroup(`layer:${name2}`);
102184
102242
  modelRoot.add(group);
102185
102243
  const inward = !Materials.entityModeCulls(layer.render ?? layer.layer.render);
102186
- this.createPart("root", layer.layer.root, group, layer.layer.texture, Materials.MISSING_TEXTURE, index, inward);
102244
+ this.createPart("root", layer.layer.root, group, layer.layer.texture, Materials.MISSING_TEXTURE, index, inward, this.options.faces?.[name2]);
102187
102245
  });
102188
102246
  this.meshesCreated = true;
102189
102247
  }
102190
- createPart(name2, part, parent, textureSize, material, renderOrder, inward = true) {
102248
+ createPart(name2, part, parent, textureSize, material, renderOrder, inward = true, faces) {
102191
102249
  const anchor = this.createGroup(name2);
102192
102250
  anchor.position.fromArray(part.pose.offset);
102193
102251
  anchor.rotation.set(...part.pose.rotation, "ZYX");
@@ -102208,6 +102266,10 @@ ${key}` : key;
102208
102266
  ).clone();
102209
102267
  this.geometries.add(geometry);
102210
102268
  geometry.translate(cube.origin[0] + width / 2, cube.origin[1] + height / 2, cube.origin[2] + depth / 2);
102269
+ if (faces) {
102270
+ geometry.setIndex(Array.from(geometry.getIndex().array).filter((_4, index) => faces.includes(CUBE_FACES[Math.floor(index / 6)])));
102271
+ geometry.clearGroups();
102272
+ }
102211
102273
  if (inward && Math.min(width + growX * 2, height + growY * 2, depth + growZ * 2) > 0) {
102212
102274
  const index = Array.from(geometry.getIndex().array);
102213
102275
  geometry.setIndex(index.concat(index.slice().reverse()));
@@ -102218,7 +102280,7 @@ ${key}` : key;
102218
102280
  if (this.options.wireframe) this.disposeWireframes.push(addWireframeToMesh(geometry, mesh));
102219
102281
  }
102220
102282
  for (const [childName, child] of Object.entries(part.children)) {
102221
- this.createPart(childName, child, anchor, size, material, renderOrder, inward);
102283
+ this.createPart(childName, child, anchor, size, material, renderOrder, inward, faces);
102222
102284
  }
102223
102285
  }
102224
102286
  async applyTextures() {
@@ -102856,7 +102918,9 @@ ${key}` : key;
102856
102918
  init_AssetKey();
102857
102919
  init_Entities();
102858
102920
  init_BannerPatterns();
102921
+ init_DecoratedPots();
102859
102922
  init_ModelTextures();
102923
+ init_CubeFace();
102860
102924
  SpecialItems = class {
102861
102925
  /** Resolves the static entity parts drawn by a special item renderer, in model units. */
102862
102926
  static async getParts(special, root, components = {}) {
@@ -102882,6 +102946,34 @@ ${key}` : key;
102882
102946
  return { model, transform, rotations };
102883
102947
  };
102884
102948
  switch (special.type) {
102949
+ case "minecraft:decorated_pot":
102950
+ case "decorated_pot": {
102951
+ const sideTextures = DecoratedPots.getSideTextures(components["minecraft:pot_decorations"], root);
102952
+ const baseTexture = texture("decorated_pot_base", "decorated_pot");
102953
+ const [base, sides] = await Promise.all([
102954
+ load("decorated_pot_base", baseTexture, new Matrix4()),
102955
+ load("decorated_pot_sides", texture("decorated_pot_side", "decorated_pot"), new Matrix4())
102956
+ ]);
102957
+ const layers = {
102958
+ base: { key: base.model.key, texture: baseTexture, layer: base.model.layer, render: "solid" }
102959
+ };
102960
+ for (const side of ["front", "back", "left", "right"]) {
102961
+ const part = sides.model.layer.root.children[side];
102962
+ if (!part) throw new Error(`Decorated-pot entity model is missing its ${side} side`);
102963
+ layers[side] = { key: sides.model.key, texture: sideTextures[side], render: "solid", layer: {
102964
+ ...sides.model.layer,
102965
+ root: { ...sides.model.layer.root, cubes: [], children: {
102966
+ [side]: part
102967
+ } }
102968
+ } };
102969
+ }
102970
+ await Promise.all([...new Map(Object.values(layers).map((layer) => [layer.texture.serialize(), layer.texture])).values()].map(async (key) => {
102971
+ if (!await ModelTextures.preload(key)) throw new Error(`Missing special item texture ${key.toNamespacedString()}`);
102972
+ }));
102973
+ base.model = { ...base.model, ...layers.base, layers };
102974
+ base.faces = { front: ["north" /* NORTH */], back: ["north" /* NORTH */], left: ["north" /* NORTH */], right: ["north" /* NORTH */] };
102975
+ return [base];
102976
+ }
102885
102977
  case "minecraft:trident":
102886
102978
  case "trident":
102887
102979
  case "minecraft:conduit":
@@ -103254,7 +103346,7 @@ ${shader.fragmentShader}`.replace(
103254
103346
  transform.multiply(new Matrix4().makeTranslation(-8, -8, -8));
103255
103347
  try {
103256
103348
  for (const part of parts2) {
103257
- const object3 = new EntityObject(part.model, { flip: false, wireframe: this.options.wireframe, tints: part.tints });
103349
+ const object3 = new EntityObject(part.model, { flip: false, wireframe: this.options.wireframe, tints: part.tints, faces: part.faces });
103258
103350
  object3.matrix.copy(transform).multiply(part.transform);
103259
103351
  object3.matrixWorldNeedsUpdate = true;
103260
103352
  object3.matrixAutoUpdate = false;
@@ -106553,6 +106645,7 @@ ${shader.fragmentShader}`.replace(
106553
106645
  DEFAULT_UV: () => DEFAULT_UV,
106554
106646
  DISPLAY_POSITIONS: () => DISPLAY_POSITIONS,
106555
106647
  DYE_COLORS: () => DYE_COLORS,
106648
+ DecoratedPots: () => DecoratedPots,
106556
106649
  DefaultBlockStates: () => DefaultBlockStates,
106557
106650
  DisplayPosition: () => DisplayPosition,
106558
106651
  DisplayTransforms: () => DisplayTransforms,
@@ -106670,6 +106763,7 @@ ${shader.fragmentShader}`.replace(
106670
106763
  isOrthographicCamera: () => isOrthographicCamera,
106671
106764
  isPerspectiveCamera: () => isPerspectiveCamera,
106672
106765
  isQuadArray: () => isQuadArray,
106766
+ isResourceLocation: () => isResourceLocation,
106673
106767
  isSceneObject: () => isSceneObject,
106674
106768
  isTransformable: () => isTransformable,
106675
106769
  isTripleArray: () => isTripleArray,
@@ -107036,6 +107130,7 @@ ${shader.fragmentShader}`.replace(
107036
107130
 
107037
107131
  // src/assets/index.ts
107038
107132
  init_BlockStates();
107133
+ init_DecoratedPots();
107039
107134
  init_Entities();
107040
107135
 
107041
107136
  // src/assets/Fonts.ts