Skip to content

Commit 9e808cd

Browse files
committed
support new model element rotation format
1 parent 7bc42c5 commit 9e808cd

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/Model/Element.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ class Element
3131
* @param ModelGuiLight $light
3232
* @param TextureList $textures
3333
* @param ModelDisplaySettings $displaySettings
34-
* @param Tinterface|null $tinter
3534
* @return Element
3635
* @throws Exception
3736
*/
@@ -52,8 +51,20 @@ public static function fromModelData(
5251

5352
$rotation = $data->rotation_rc ?? $data->rotation ?? null;
5453
if ($rotation) {
55-
$element->rotate(new Vector3(...$rotation->origin), Axis::from($rotation->axis), $rotation->angle / 180 * pi());
54+
$origin = new Vector3(...$rotation->origin);
55+
if (isset($rotation->axis) && isset($rotation->angle)) {
56+
$element->rotate($origin, Axis::from($rotation->axis), $rotation->angle / 180 * pi());
57+
} else {
58+
foreach (Axis::cases() as $axis) {
59+
if (!isset($rotation->{$axis->value})) {
60+
continue;
61+
}
62+
$angle = $rotation->{strtolower($axis->name)};
63+
$element->rotate($origin, $axis, $angle / 180 * pi());
64+
}
65+
}
5666
}
67+
5768
$element->scale($displaySettings->getScale());
5869
$element->rotate(Vector3::center(), Axis::Y, $displaySettings->getRotation()->y / 180 * pi());
5970
$element->rotate(Vector3::center(), Axis::X, $displaySettings->getRotation()->x / 180 * pi());

0 commit comments

Comments
 (0)