Skip to content

fix: apply orientation attribute to <extra-model> elements#5177

Merged
diegoteran merged 1 commit into
google:masterfrom
Frank3K:fix/extra-model-orientation
Jun 11, 2026
Merged

fix: apply orientation attribute to <extra-model> elements#5177
diegoteran merged 1 commit into
google:masterfrom
Frank3K:fix/extra-model-orientation

Conversation

@Frank3K

@Frank3K Frank3K commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Description

The multi-model feature introduced in #5134 is a really nice feature — this PR fixes a small gap in the initial implementation.

<extra-model orientation="..."> had no effect. The updateModelTransforms method in ModelScene.ts accepted an orientation parameter but never applied it — it was prefixed _orientation, signalling intentional non-use. Only offset and scale were wired up, leaving models always in their default rotation regardless of the declared attribute.

Root cause

updateModelTransforms (source) received the orientation string from the extra-model-changed event but did not parse or apply it to the model's quaternion.

A secondary issue: the multimodel example used bare numbers (orientation="0 30 0").

Changes

packages/model-viewer/src/three-components/ModelScene.ts

  • Renamed _orientationorientation and implemented parsing using the existing parseExpressions / normalizeUnit utilities — the same infrastructure used by applyTransform.
  • Applies the result using the documented $roll $pitch $yaw convention: model.quaternion.setFromEuler(new Euler(pitch, yaw, roll, 'YXZ')), consistent with the main orientation attribute behaviour.

packages/modelviewer.dev/examples/multimodel/index.html

  • Updated orientation attribute values to use explicit deg units and correct roll/pitch/yaw ordering. A 30° yaw (Y-axis) rotation is now "0deg 0deg 30deg" (third term), matching the documented $roll $pitch $yaw format.

Before / After

Before

image

After

image

Robot and Astronaut now rotate around their Y-axis as declared, facing slightly toward the scene center.

Testing

Verified visually in the multimodel example page. The robot (left, orientation="0deg 0deg 30deg") and the astronaut (right, orientation="0deg 0deg -30deg") each rotate 30° around the Y-axis toward the center.

@google-cla

google-cla Bot commented Jun 8, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

`updateModelTransforms` accepted an `orientation` parameter but never
used it, so `<extra-model orientation="...">` had no effect. Parse the
value with `parseExpressions`/`normalizeUnit` (supporting `deg`/`rad`
units) and apply it as an Euler rotation on the model's quaternion,
using the same `$roll $pitch $yaw` → `Euler(pitch, yaw, roll, 'YXZ')`
convention as `applyTransform` and the documented `orientation` attribute.

Also fix the multimodel example: bare numbers are treated as radians by
the unit parser, and the axis ordering follows roll/pitch/yaw, so update
the orientation attributes to `"0deg 0deg 30deg"` / `"0deg 0deg -30deg"`
(yaw = third term) to produce the intended 30° Y-axis rotation.

Add a test covering both initial application and dynamic updates of the
orientation attribute.
@Frank3K Frank3K force-pushed the fix/extra-model-orientation branch from 5ff1d0a to bccc603 Compare June 9, 2026 04:59

@diegoteran diegoteran left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@diegoteran diegoteran merged commit 33e5562 into google:master Jun 11, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants