ol-cesium icon indicating copy to clipboard operation
ol-cesium copied to clipboard

Text from a KML/vector layer is not correctly rendered in 3D mode

Open jmgomezpoveda opened this issue 9 years ago • 10 comments

Text defined in the style of items in a vector layer is not correctly rendered when in 3D mode.

  • The text appears much larger compared to the feature images than it was in 2D mode.
  • The text appears behind the feature images, so it can only be partially seen (this is critical when the text may just be one or two digits).

jmgomezpoveda avatar Apr 11 '16 11:04 jmgomezpoveda

Do you have a screenshot?

gberaudo avatar Apr 11 '16 11:04 gberaudo

Screenshots attached. This is the same map, just enabling the 3d mode.

vector-text-2d vector-text-3d

jmgomezpoveda avatar Apr 11 '16 12:04 jmgomezpoveda

Text style is handled in src/featureconverter.js, in olcs.FeatureConverter.prototype.olGeometry4326TextPartToCesium.

For having texts above the circles, there is the https://cesiumjs.org/Cesium/Build/Documentation/Label.html?classFilter=label#eyeOffset property in Cesium.

gberaudo avatar Apr 11 '16 12:04 gberaudo

The vectors sample shows the same issue as above (text labels are too big and behind the feature), plus an additional issue, that letter within a piece of text are not vertically aligned (some letters are higher than others).

screenshot from 2016-05-02 09-38-33

jmgomezpoveda avatar May 02 '16 08:05 jmgomezpoveda

Regarding the size of the text, there is certainly some adjustement we should do. Regarding alignment, it may be related to https://github.com/AnalyticalGraphicsInc/cesium/issues/3166 Regarding order, maybe we could put an eyeoffset: https://cesiumjs.org/Cesium/Build/Documentation/Billboard.html#eyeOffset.

gberaudo avatar May 02 '16 08:05 gberaudo

Indeed, the alignment issue seems to be the one reported in https://github.com/AnalyticalGraphicsInc/cesium/issues/3166.

On the order, as per the documentation, eyeOffset seems to move the billboard in the y axis, but does not seem to change the z order.

As a workaround I was thinking more along the lines of defining the style as two separate styles for the image and the text, hoping that one will be drawn after the other, though I am not sure if that is supported by style functions.

jmgomezpoveda avatar May 02 '16 20:05 jmgomezpoveda

The documentation example is: b.eyeOffset = new Cartesian3(0.0, 8000000.0, 0.0); which moves in the y direction. Having non zero value for z will move in the z direction.

gberaudo avatar May 03 '16 07:05 gberaudo

As suggested, adding options.eyeOffset = new Cesium.Cartesian3(0.0, 0.0, -5.0); to olGeometry4326TextPartToCesium solves the issue with the z-order. Though, that -5 seems a bit arbitrary (I have tried smaller values, -1 and -2, and in those cases the text was still behind the polygon). Should I send a PR?

jmgomezpoveda avatar May 09 '16 18:05 jmgomezpoveda

I don't see an easy and general way to handle this. So I would skip the PR for the moment.

gberaudo avatar May 09 '16 20:05 gberaudo

Ok, let me know if you have any other ideas or you want me to test anything.

jmgomezpoveda avatar May 10 '16 08:05 jmgomezpoveda