In an attempt to accurately scale my geometry to match real-world dimensions in my 3D scene, I am facing some challenges.
I extract the coordinates of the top left and top right corners of my map, convert them into points using Google Maps projection, and calculate the difference between these points to determine the map's delta.
Next, I divide this delta by the deltaX of my geometry's bounding box.
However, the current code implementation is not yielding the desired scaling results.
When zooming in on the map, the scale decreases, while zooming out increases the scale - which is opposite of what is expected.
Moreover, I am unsure if this approach accurately reflects real-life scaling.
The current process involves:
var bounds = MAP3D.map.getBounds();
var projection = MAP3D.map.getProjection();
var x1Length = projection.fromLatLngToPoint(new google.maps.LatLng(
bounds.getNorthEast().lat(),
bounds.getSouthWest().lng()
));
var x2Length = projection.fromLatLngToPoint(new google.maps.LatLng(
bounds.getNorthEast().lat(),
bounds.getNorthEast().lng()
));
var ThreeUnitsX = Math.abs(x2Length.x - x1Length.x);
if (
MAP3D.ObjectManager.WellList[i].LOD.objects[0]
.object.geometry.boundingBox == null
) {
MAP3D.ObjectManager.WellList[i].LOD.objects[0]
.object.geometry.computeBoundingBox();
}
var boundingBox = MAP3D.ObjectManager.WellList[i].LOD.objects[0]
.object.geometry.boundingBox;
var deltaX = boundingBox.max.x - boundingBox.min.x;
var scaleX = ThreeUnitsX / deltaX;
me.WellList[i].LOD.scale.set(scaleX, scaleX, scaleX);
I extend my gratitude to chandlerp
from the #THREE.JS
irc channel for invaluable assistance.