glTF exporting with +Y Up adds rotation to camera #105388

Closed
opened 2024-07-06 23:04:34 +02:00 by gloutch · 3 comments

System Information
Operating system: macOS-14.3-arm64-arm-64bit 64 Bits
Graphics card: Metal API Apple M2 1.2

Blender Version
Broken: version: 4.1.1, branch: blender-v4.1-release, commit date: 2024-04-15 15:11, hash: e1743a0317bc
Worked: (newest version of Blender that worked as expected)

Short description of error
When exporting a scene to a .glb file with options

  • Transform: +Y Up (default)
  • Include: Cameras

the camera node has an added 90° rotation (and not the others nodes)

Exact steps for others to reproduce the error
In the attached .blend file, the scene has 2 objects, a camera and a cube along the Z axis, and no rotation

First, watch the .glb file without "+Y Up"
File > Export > glTF 2.0 (.glb/.gltf), on the right side of the window

  • unfold the "Include" tab and check "Cameras"
  • unfold the "Transform" tab and uncheck "+Y Up"
  • hit the Export glTF 2.0 button

See the JSON chunk in the exported file (using cmd strings) and look for the "nodes" property

"nodes":[
  {
    "name":"Cube",
    "translation":[0,0,2]
  },{
    "name":"Camera",
    "translation":[0,0,10]
  }
]

Second, redo the previous steps with "+Y Up" checked

"nodes":[
  {
    "name":"Cube",
    "translation":[0,2,0]
  },{
    "name":"Camera",
    "translation":[0,10,0],
    "rotation":[-0.7071068286895752,0,0,0.7071068286895752] // -90° on X axis
  }
]

Notice how the "translation" coordinates changed as expected, however the camera has an additional rotation which should not be here (for comparison, the cube doesn't have one)

**System Information** Operating system: macOS-14.3-arm64-arm-64bit 64 Bits Graphics card: Metal API Apple M2 1.2 **Blender Version** Broken: version: 4.1.1, branch: blender-v4.1-release, commit date: 2024-04-15 15:11, hash: `e1743a0317bc` Worked: (newest version of Blender that worked as expected) **Short description of error** When exporting a scene to a .glb file with options - Transform: +Y Up (default) - Include: Cameras the camera node has an added 90° rotation (and not the others nodes) **Exact steps for others to reproduce the error** In the attached .blend file, the scene has 2 objects, a camera and a cube along the Z axis, and no rotation First, watch the .glb file **without** "+Y Up" File > Export > glTF 2.0 (.glb/.gltf), on the right side of the window - unfold the "Include" tab and check "Cameras" - unfold the "Transform" tab and **uncheck** "+Y Up" - hit the Export glTF 2.0 button See the JSON chunk in the exported file (using cmd `strings`) and look for the "nodes" property ```json "nodes":[ { "name":"Cube", "translation":[0,0,2] },{ "name":"Camera", "translation":[0,0,10] } ] ``` Second, redo the previous steps with "**+Y Up**" checked ```json "nodes":[ { "name":"Cube", "translation":[0,2,0] },{ "name":"Camera", "translation":[0,10,0], "rotation":[-0.7071068286895752,0,0,0.7071068286895752] // -90° on X axis } ] ``` Notice how the "translation" coordinates changed as expected, however the camera has an additional rotation which should not be here (for comparison, the cube doesn't have one)
gloutch added the
Status
Needs Triage
Priority
Normal
Type
Report
labels 2024-07-06 23:04:35 +02:00

This is not a bug. The rotation is correct. It corrects for the differing convention between Blender and glTF in which axis the camera points along.

You can open the glTF in a viewer like https://gltf-viewer.donmccurdy.com/ and check that the Camera is indeed looking at the correct place. If there were no rotation, it would be wrong.

This is not a bug. The rotation is correct. It corrects for the differing convention between Blender and glTF in which axis the camera points along. You can open the glTF in a viewer like https://gltf-viewer.donmccurdy.com/ and check that the Camera is indeed looking at the correct place. If there were no rotation, it would be wrong.

I wouldn't call it a bug (i tested it with blender 4.1), at least not when i view the models in blender after reimport (i modified the shape a bit to highlight the orientations).
+Y-Up checked:

+Y-Up not checked:

If i would delete the x rotation the camera would face away:

What confuses me most is why "rotation":[-0.7071068286895752,0,0,0.7071068286895752] instead of the simpler "rotation":[1,1,0,0], as both should yield the same results. Probably due to the location, but currently don't want to do the quaternion math to check.

I wouldn't call it a bug (i tested it with blender 4.1), at least not when i view the models in blender after reimport (i modified the shape a bit to highlight the orientations). +Y-Up checked: <img src="/attachments/e009a00f-61b4-4ca4-9ba1-72dc9028cc10" width="300"> +Y-Up not checked: <img src="/attachments/ae8f94dc-2ba2-41bb-bc59-c8306b078f1e" width="300"> If i would delete the x rotation the camera would face away: <img src="/attachments/2165fa2c-d4ca-438c-a809-b7f2077ad5d2" width="300"> What confuses me most is why `"rotation":[-0.7071068286895752,0,0,0.7071068286895752]` instead of the simpler `"rotation":[1,1,0,0]`, as both should yield the same results. Probably due to the location, but currently don't want to do the quaternion math to check.
Author

What a quick reactions, indeed it is not a but!
I've been confused with the swap of axis, reading your responses helps me to better understand how exporting is handled.
Thx!

What a quick reactions, indeed **it is not a but**! I've been confused with the swap of axis, reading your responses helps me to better understand how exporting is handled. Thx!
Blender Bot added
Status
Archived
and removed
Status
Needs Triage
labels 2024-07-07 01:13:37 +02:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender-addons#105388
No description provided.