Are the coordinates of an object in blender the same in babylon.js

Hello guys,

I’ve a metro station model that I import it from blender to BJS, now I need to use a specific points in exact locations. doest the coordinates in blender are the same in BJS canvas ?

thank you

I’ve encountered this problem before. In Blender Z axis is up and in Babylon the Y axis up. Luckily there is a handy check box in the export options that will tell Blender to set the Y axis as up, then everything should line up nicely.

Another trick I use is to create empties in the Blender scene and place them where I want them and give them an obvious name. When using the babylon scene loader you can loop through the imported transforms and get the ones you want. That way you know for sure your in the right spot.

here’s a little example:

BABYLON.SceneLoader.Append('', './src/assets/car.gltf', scene, function (model) {
    let car
    let wheelMeshes = []
    let drivingPosition

    model.transformNodes.forEach((transform) => {
        if (transform.name.includes('wheel')) {
            wheelMeshes.push(transform)
        } 
        else if (transform.name === 'car') {
            car = transform
        } 
        else if (transform.name == 'driving_position') {
            drivingPosition = transform
        }
    })
}.bind(this))

Hope this helps

I have in mind to create a diagram in the doc showing axys references, something which could looks like this one.

However, here a first ugly draft I’ve just started, it could help:

[edit] forgot to mention: note that in gltf workflow you can play with absolutePosition instead of position (relative to the default __root__)

the problem is that I want a specific points coordinates to plot a path from A to B for example, in blender I can see my metro station so it is easy for me to define (x,y,z) coordinates, but if I want to use them in BJS code, worried it’s not the same.

I didn’t find where to check the export option in order to reverse z and y axes.

thank you

You can find the Y up option in the bottom left hand corner under the general export setting.

blender-y-up

As for seeing where your putting things in Babylon you could try using the scene explorer to move the objects where you want them in your metro station and just copy the coordinates and place that in your code.

There is a handy video series on Youtube on how to use the Babylon scene explorer that should give you an idea of what to do.

1 Like

If you use the excellent Babylon Exporter created by @JCPalmer and @Deltakosh there is no problem. The co-ordinates fit quite happily with what BJS needs - and a whole lot more!

cheers, gryff :slight_smile:

Gahh Z-up vs. Y-up.

This is just so annoying :S We’ve had several bugs in the glTF exporter related to this, and they are usually quite obscure and hard to fix - the kind that gives you nightmares about matrix math.

Anyway if you encounter new issues, please file at: Issues · KhronosGroup/glTF-Blender-IO · GitHub