minerender 2.1.0-alpha.125 → 2.1.0-alpha.126

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.
@@ -1534,6 +1534,11 @@ var init_DisplayTransforms = __esm({
1534
1534
  }
1535
1535
  /** Build a display pose for geometry already centered at the model's [8, 8, 8] pivot. */
1536
1536
  static getMatrix(display, position) {
1537
+ const transform = this.getTransform(display, position);
1538
+ return new Matrix4().compose(transform.position, transform.quaternion, transform.scale);
1539
+ }
1540
+ /** Position, rotation, and scale of a display pose for geometry already centered at the model's [8, 8, 8] pivot. */
1541
+ static getTransform(display, position) {
1537
1542
  const transform = this.withHandFallbacks(display)?.[position] ?? {};
1538
1543
  const left = position === "firstperson_lefthand" /* FIRSTPERSON_LEFTHAND */ || position === "thirdperson_lefthand" /* THIRDPERSON_LEFTHAND */;
1539
1544
  const sign = left ? -1 : 1;
@@ -1542,7 +1547,7 @@ var init_DisplayTransforms = __esm({
1542
1547
  const translation = new Vector32(...transform.translation ?? [0, 0, 0]).clampScalar(-80, 80);
1543
1548
  translation.x *= sign;
1544
1549
  const scale = new Vector32(...transform.scale ?? [1, 1, 1]).clampScalar(-4, 4);
1545
- return new Matrix4().compose(translation, rotation, scale);
1550
+ return { position: translation, quaternion: rotation, scale };
1546
1551
  }
1547
1552
  /** Transforms geometry in place and reverses triangle winding when the matrix reflects it. */
1548
1553
  static apply(geometry, matrix) {
@@ -7116,16 +7121,21 @@ var init_ModelObject = __esm({
7116
7121
  const special = this.originalModel.special;
7117
7122
  if (special) {
7118
7123
  const parts2 = await SpecialItems.getParts(special, this.originalModel.key?.root, this.originalModel.components);
7119
- const transform = this.options.displayPosition ? DisplayTransforms.getMatrix(this.originalModel.display, this.options.displayPosition) : new Matrix48();
7120
- transform.multiply(new Matrix48().makeTranslation(-8, -8, -8));
7124
+ const display = new SceneObject();
7125
+ if (this.options.displayPosition) {
7126
+ const transform = DisplayTransforms.getTransform(this.originalModel.display, this.options.displayPosition);
7127
+ display.position.copy(transform.position);
7128
+ display.quaternion.copy(transform.quaternion);
7129
+ display.scale.copy(transform.scale);
7130
+ }
7131
+ this.add(display);
7132
+ const offset = new Matrix48().makeTranslation(-8, -8, -8);
7121
7133
  try {
7122
7134
  const targets = [];
7123
7135
  for (const part of parts2) {
7124
7136
  const object4 = new EntityObject(part.model, { flip: false, wireframe: this.options.wireframe, tints: part.tints, faces: part.faces });
7125
- object4.matrix.copy(transform).multiply(part.transform);
7126
- object4.matrixWorldNeedsUpdate = true;
7127
- object4.matrixAutoUpdate = false;
7128
- this.add(object4);
7137
+ object4.matrix.multiplyMatrices(offset, part.transform).decompose(object4.position, object4.quaternion, object4.scale);
7138
+ display.add(object4);
7129
7139
  await object4.init(part.material);
7130
7140
  object4.iterateAllMeshes((mesh) => {
7131
7141
  const source = mesh.material;