Blender to Sandbox export camera rotation problem

Hello,
I’m exporting simple scene with 1 mesh and camera to .babylon file.
View from Blender camera is rotated in different way than in sandbox https://sandbox.babylonjs.com/

I’m using:
Blender version: 2.93.0 with Exporter version 2.93.4
latest from GitHub - BabylonJS/BlenderExporter: Exports From Blender to Babylon.JS in JSON / .babylon format

now can I get same rotation of camera in Blender and Sandbox?
Thank You for help :slight_smile:

Probably going to depend on the camera type being exported as. Was always tricky to arcrotate camera to match up, but you can easily adjust. What type are you exporting as?

from .babylon file json “type”: “UniversalCamera”
I experimented with other camera types but I was not able to get desired view from camera

How I can easily adjust?

I looked at this, this morning for a while, but no easy changes. This was put in before me, and then edited by someone else later to handle being in quaternion mode.

The one thing I did was the arc rotate camera export, which basically side steps angles, if that type of camera is acceptable, it seems to work. If so, change to arc camera in the exporter section of Camera data properties. Then add a Track To modifier, selecting the target. This is only used by the exporter to get the mesh. All the other settings are not consulted by the exporter, so unless you actually want to do this in Blender, I do not think changing them make any difference.

trackTo

1 Like

Hi @mickwadev just checking in, have Palmer’s suggestions helped you? :slight_smile:

The sandbox will usually be “backward” compared to how it will look in your scene. I believe it’s due to the camera targeting the center of the mesh which makes the camera rotate. It took me a while to figure it out, but in Blender this is how you should be setting up your objects:

If you’re looking “forward” the x-axis (red arrow) should be pointing to the left, and the y-axis should be pointing towards you. When you export you should have these settings as default when exporting a gltf/glb:

Note the “+Y Up”. I believe with that enabled what ends up happening is that the Z-axis ends up rotating forward and the Y-axis now points up. If you used this cube as is in the Sandbox this is how it would appear:


Note that I rotated slightly to show the extrusion on the front of the cube

Here is the same cube in my project with a basic camera, no target assigned or rotation applied:

again I rotated slightly to show the front of the cube now pointing away from me in the same direction as the camera would be pointing in.

I’ve attached a zip file of the cube in GLB format along with the Blend file so you can see how this should be setup. Hope that helps!

cube.zip (88.7 KB)

I am not seeing a camera in your file wo it would follow the gltf convention. @bghgary might be able to confirm.

@sebavan I don’t think @jgonzosan is saying anything is wrong with the glTF. I think @jgonzosan is saying that the glTF is being exported correctly while the Babylon export is not.

I don’t usually use the camera from the exported models. Typically I’ll create a camera in BabylonJS directly. I also don’t use the Babylon exporter for Blender, I just export as a gltf/glb file. I’m sure some of these issues with orientation could be fixed if you exported out the camera within Blender then using that as the camera in Babylon.

I’ve attached the same blend file with the camera in Blender renamed to “BlenderCamera”. I also included a glb file with just the cube exported out and another with everything including the camera. You can switch the cameras used in the Sandbox when clicking the camera icon at the bottom right of the window.


cube.zip (177.9 KB)

Sorry, now I’m confused. In the OP, you said you are exporting to .babylon using the Babylon exporter.

If you are actually taking about .gltf and not .babylon, then we can look at the spec.

glTF uses a right-handed coordinate system. glTF defines +Y as up, +Z as forward, and -X as right; the front of a glTF asset faces +Z.

The Babylon glTF loader follows this convention.

Are you referencing me or the OP? I didn’t post the question I was just following up with my own solution.

Ahh, sorry, I didn’t realize you are not OP, lol. :slight_smile:

1 Like

Hello,

partialy yes, but Palmer’s method adds some rotation. I don’t want to follow specific object but just look at fixed direction.

Just confirming, you have a camera on Blender looking down a fixed direction, and you want to export it to .babylon, load it and have it be the same as the direction on Blender?