peterqliu / threebox

A three.js plugin for Mapbox GL JS, with support for basic animation and advanced 3D rendering.
MIT License
526 stars 320 forks source link

filling in addGeoreferencedMesh #56

Open bennlich opened 5 years ago

bennlich commented 5 years ago

I see there's a stub for addGeoReferencedMesh. I'd like to render some georeferenced meshes, so I'm interested in filling this out :)

I could use some pointers though. What would an outline of this function look like?

My current plan to render a mesh from a bunch of geo-referenced points is to convert my [lng, lat] pairs to [x, y] pairs measured in meters from the object's origin point. Does that sound right? Are there currently utility functions that do this conversion?

bennlich commented 5 years ago

I've started rendering geolocated three.js TubeBufferGeometries. These geometries take a curve, which is represented by a list of segments. My process is:

1) Treat the first point of the first segment as the origin (lat, lng) 2) Convert every point in the curve from (lat, lng) to (x, y) meters relative to the origin 3) Add the mesh to the scene with threebox.addAtCoordinate at this same origin

I'm guessing there might be a more elegant way to do this (maybe without using threebox.addAtCoordinate).

peterqliu commented 5 years ago

@bennlich georeferenced meshes are on the horizon! as for tubes, I just merged a convenience method to generate them. Example at https://github.com/peterqliu/threebox/blob/master/examples/tube.html