Units/systems for vertices in GLTF models

Hi All,

I’m wondering in which coordinates system, vertices of GLTF objects should be expressed.

The context is the following : I start from GIS files containing buildings outlines, generally projected into UTM/WGS84, with meters coordinates;

each contour has two attributes absolute elevation and height.

I can easily convert from X/Y to Lon/Lat WGS84 in degrees or radians.

I’m able to create Gltf files containing extruded polygons.

The goal is then to place them on earth at the right place.

My question is :

  • in which coordinates system should model vertices be expressed ? lon/lat/height over ellipsoid ? lon/lat/Z ? metric with a top node to place them at the right place ?

  • generally model are placed onto the globe with something like :

var modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(

Cesium.Cartesian3.fromDegrees(-75.62898254394531, 40.02804946899414, 0.0));

var model = scene.primitives.add(Cesium.Model.fromGltf({

url : ‘http://luxcarta.net/3dportal/data/un2.gltf’,

modelMatrix : modelMatrix,

scale : 1.0

In my case, models are already placed - which matrix should I use ? identify ? None ?

I’m quite new to Cesium and GLTF, any hints / links are appreciated.

Thalks in advance,

Fred.

Hi Fred,

Most model we see are in a local coordinate system centered at the origin. The Transforms.eastNorthUpToFixedFrame will translate the model from the origin to the ellipsoid surface.

If your models are already placed, you shouldn’t need to use a model matrix.

Best,

Hannah

Hi Hannah,

thanks for your response.

Can you clarify some points :

Most model we see are in a local coordinate system centered at the origin.

Are you talking about a ‘metric’ cartographic system (UTM, NAD,…) where X/Y/Z are expressed in meters ?

If I understand correctly, I have to shift my original coordinates to recenter them (center of the bounding box ? ).

Then I can place them correctly on the earth using the CESIUM_RTC extensions.

Right ?

In which coordinates system have to be translation values of the ‘center’ in the CESIUM_RTC entry :

“extensions”: {

    "CESIUM_RTC": {

        "center": [

            105.78316682737683,

            21.051939811464116,

            47.5

        ]

    }

},

ECEF or Lon/Lat) ?

Most gltf sample I saw contains as the top node of the scene graph an Y_UP_NODE with a transformation matrix like :

  "yUpNode": {

        "meshes": [],

        "matrix": [

            1,

            0,

            0,

            0,

            0,

            0,

            -1,

            0,

            0,

            1,

            0,

            0,

            0,

            0,

            0,

            1

        ],

        "name": "yUpNode",

        "children": [

            "meshNode"

        ]

    },

Should I include one to ?

KR,

Fred.

Hello,

If you are using the CESIUM_RTC extension, I believe your model coordinates are expected to be in WGS84. So if you’re positions are on the globe already you shouldn’t need to shift them, you only need to specify the center. The center is a cartesian coordinate in WGS84.

I’m not entirely sure what the yUpNode is used for in that example you posted, sorry.

Hope this helps, let me know if you need more clarification =)

-Hannah

Hi Hannah,

Finally, I was able to create and position my gltf file.

As this may be useful for other people, here is what I do :

1/ First create the model in my original coordinates system (UTM/WGS 84 in my case).

2/ Convert all vertices into ECEF (for GDAL user, the PROJ4 parameters are : +proj=geocent +ellps=WGS84 +datum=WGS84), compute normals, …

3/ Recenter the model on its bounding box center

4/ In the GLTF model, use the CESIUM_RTC extensions (use the bounding box center in ECEF as “center” value) :

"extensions": {

    "CESIUM_RTC": {

        "center": [

            -1619756.21602778,

            5730509.6189170685,

            2276765.6413503443

        ]

    }

},

and use CESIUM_RTC_MODELVIEW as modelViewMatrix in the associated technique :

            "modelViewMatrix": {

                "type": 35676,

                "semantic": "CESIUM_RTC_MODELVIEW"

            },

5/ Include a top node in the scene graph as in BOX cesium sample, like this one :

“yUpNode”: {

        "meshes": [],

        "matrix": [

            1,

            0,

            0,

            0,

            0,

            0,

            -1,

            0,

            0,

            1,

            0,

            0,

            0,

            0,

            0,

            1

        ],

        "name": "yUpNode",

        "children": [

            "meshNode"

        ]

    },

With all of these, my GLTF file loads and display fine :

Thanks for your support !

KR,

Fred.

Looks great! Glad you were able to figure it out.

What kind of project are you working on?

-Hannah

According to the spec the vertices of a GLTF are meters on a cartesian axis where Y is up.