w3reality/three-geo

Add geometries

JohnCoene opened this issue · 6 comments

Thank you so much for the awesome library.

I was toying with the idea of adding geometries, e.g.: a point.

var dotGeometry = new THREE.Geometry();
dotGeometry.vertices.push(new THREE.Vector3( longitude, elevation, latitude));
var dotMaterial = new THREE.PointsMaterial( { size: 1, sizeAttenuation: false } );
var dot = new THREE.Points( dotGeometry, dotMaterial );
scene.add( dot );

However doing the above places the points way off, I assume there is some rescaling done internally but looking through the source code I cannot find out where or how.

How should I go about doing this?

Thanks for the question!

We need an API for geo-to-WebGL coordinate mapping to get your use case working.

I just noticed that it's been undocumented although we already have the functionality. I am going to update the doc and create a simple example for this.

For the moment, here's a quick demo. Basically, we are using the getProjection() API, where

  • proj() is for geo-to-WebGL coordinate mapping, and
  • unitsPerMeter for scaling (e.g. of elevations).

Screen Shot 2019-10-12 at 17 40 17

This is really cool Jay, thank you very much!

Just another thought, it would be great to also be able to get the elevation given coordinates. Then again, my limited knowledge of JavaScript keeps me from making the PR myself, apologies.

Most people have lat/lon data but not elevation, it can be obtained via APIs but these are costly (Google Elevation API = $, Mapbox API = time). Being able to just get the elavation (not in meters but as on the projection) would make it much easier to layer three.js points/lines/text on top of the visualisation.

Being able to just get the elevation (not in meters but as on the projection) would make it much easier

I really agree with this insight.

At this moment, I am 🚧 overhauling/refining the internal implementation of this projection stuff (and officially documenting it for the next point release). I will plan to 'upgrade' the proj() function so it can also resolve the elevation on demand.

Looking forward to this!