Gltf model position to match polygons position

Hi all,
I have a situation where I have geojson data that makes a building footprint. Besides that, I have a GLTF model that represents the building. The problem that I have is to position the .gltf to match the footprint. So I have coordinates from geojson, and have GLTF. I am not sure that pivot of the .gltf is on the same place for every building I have ( That is up to modelers and I can not change that fact ).

I have some ideas:

  1. To find the bounding box of geojson and .gltf, find the biggest sides of both and try to position the .gltf to match the longest side of the geojson.
  2. To find somehow angle between magnetic north point and geojson bbox and to apply it on GLTF.

If someone have suggestion how to achieve some of my ideas or have better idea, please give me a hint or some code samples…

This is how it looks now:

1 Like


Thank you for your detailed post! The two ideas that you proposed seem great. In particular, the first is exactly what I would have suggested. Give them a try and let me know how everything goes!



Thank you for your reply.

I couldn’t find a way to get bbox of the GLTF model to be like square shape. I found getBoundingSpehre method in the API but it is not what I need, it gives me data like circle/sphere. Is there a way to get square shape or not in the API? Can it be somehow calculated from modelMatrix? Thank you!

Hi @Mil,

Can I ask for more details about your use case? Will this building footprint and model stay stationary throughout your program, or do you need the model to dynamically move with the building footprint?

Best regards,

Hi @janine,

Usecase: I have a footprint (geojson) in the correct position (see image). The footprint is not movable and that is how it should stay. The issue is the positioning of the GLTF model that represents the building. So, the goal is to somehow manage the .gltf model to place itself as much as possible to match the footprint. The issue is that I only have coordinates from the geojson (footprint) and don’t know how much should move and rotate the model.

Manual repositioning and rotating of buildings is not a solution because there are thousands of buildings. I have to make it as much as possible to be automatic. Of course, if a small percent does not perfectly match the footprint that can be fixed one by one.

I hope the explanation was clear enough :slight_smile:

Best regards,