iTowns / itowns.github.io

iTowns public web site
Other
3 stars 7 forks source link

Red GPX-Line disappears when zooming in (Example) #19

Open wOOx92 opened 5 years ago

wOOx92 commented 5 years ago

Hello,

I hope this is the right place for asking that kind of question:

Why is the red line in the following example disappearing, when zooming in to close? http://www.itowns-project.org/itowns/examples/gpx.html

Is this a bug or a feature? If so, how can I prevent the GPX-Path from disappearing?

P.S. I already tried to set the "frustumCulled" to false, with no success. :(

I appreciate any help - thank you!

zarov commented 5 years ago

Hello ! I would qualify this as a bug: the mesh of surface is getting more refined when zooming in, but this is not the case for the GPX path. If we had a more precised GPX path we could solve this problem, but unfortunately this is not the case.

mwingler commented 5 years ago

Hello @zarov ,

thanks for your reply! Is there a way (maybe over Three.js) to manually refine the surface of the GPX path?

Or do you know any other (simple) way of drawing a line from an array of coordinates on the GlobeView surface?

Death111 commented 5 years ago

If we hide the globe the line appears: grafik Show it again: grafik

zarov commented 5 years ago

Is there a way (maybe over Three.js) to manually refine the surface of the GPX path?

I think you could split the GPX path into segments shorter than vertices of the layer level 20 (well for the case of France, I don't know what you are using), then recompute the altitude of each point using DEMUtils and redraw the GPX path. I didn't test it, but it seems plausible.

Or do you know any other (simple) way of drawing a line from an array of coordinates on the GlobeView surface?

Yes, you can, instead of displaying a GeometryLayer, display a ColorLayer: see here for example

If we hide the globe the line appears [...]

This is a known problem unfortunately, but I think it has to do with the previous issues.

FIY, you shouldn't use the current GpxParser that only gives a specific output, and is not really usable after. I hope to have time to change it some time soon.

mwingler commented 5 years ago

Hi @zarov,

thanks for the information. As a workaround I solved this by adding the line as a simple THREE.Line:

var geometry = new THREE.Geometry(); for (const point of linePoints) { const currentPoint = new itowns.Coordinates(EPSG_4326, point.longitude, point.latitude, point.altitude).as(EPSG_4978); geometry.vertices.push(new THREE.Vector3(currentPoint.x(), currentPoint.y(), currentPoint.z())); } var material = new THREE.LineBasicMaterial({ color: 0xff0000}); var theLine= new THREE.Line(geometry, material); view.scene.add(theLine);

This line doesn't disappear when zooming in. 👍

wOOx92 commented 5 years ago

Thx @mwingler - this worked for me!

zarov commented 5 years ago

Ok, good to know it's working, thanks !