Hi! I faced with some issue that can’t solve.
The aim - add 3d models to the map by it’s coordinates.
I make it in several steps:
the first one is to add a layer to the map, in onAdd method i initialize scene, engine, matrix.
I pass the initial coordinates to the matrix (the coordinates on which map is loaded).
After that i need to add models to the existing layer, i do it dynamically after receive a data from BD
I calculate the location of the models of the map taking into account the initial coordinates that i passed to the matrix in onAdd method.
The question is that the models that located near the initial coordinates look great, but the further the model is from these coordinates, the more broken it is:
I prepared the simplified example (link below this post). Here a use setTimeOut method inside the onAdd just to reproduce the behavior. The map is loading in initial coordinates [-118.3851, 34.0223]
, also i have an array from 4 items with coordinates
const dronesArray = [
{ x: 51.409782245926316, y: 5.456434410227905, z: 0 }, // Netherlands
{ x: 34.02383270026034, y: -118.37519963081964, z: 0 }, // LA
{ x: 34.022482149490365, y: -118.38511801360747, z: 0 }, // LA
{ x: 44.63058800723914, y: 10.42298214926346, z: 0 } // Italy
];
, where i need to place my models, and in 7 seconds i replace my models with a new coordinates, on each place i put a pin, so that it will be easy to find a location (just zoom out the map and zoom in to any pin to see the model).
In the result we see the situation, that the model that are located near the initial coordinated look good, but models that are located in Netherlands and Italy look broken.
I can’t figure out the problem, please help if you have some idea how to fix it and why it is happenning
Codesanbox example: babylon-mapbox (forked) - CodeSandbox