WorldWindEarth / worldwindjs

WorldWindJS is a community maintained fork of the WebWorldWind virtual globe SDK from NASA - an interactive 3D globe library featuring maps, imagery and terrain plus 2D map projections.
https://worldwind.earth/worldwindjs/
38 stars 9 forks source link

KML icons rotated according to IconStyle heading tag #61

Closed lowswaplab closed 3 years ago

lowswaplab commented 3 years ago

Description of the Change

KML icons rotated according to IconStyle heading tag

Why Should This Be In Core?

To improve KML parsing.

Benefits

To improve KML parsing.

Potential Drawbacks

None.

Applicable Issues

None.

lowswaplab commented 3 years ago

There is one problem. A non-square icon is "sheared" instead of simply rotated.

lowswaplab commented 3 years ago

Update: It's not quite sheared... It's rotated within the icon's height and width. So, for example, an icon 310px wide by 175px high rotated 90 degrees: the image is rotated and squished so it is still 310px wide by 175px high rendered on the screen.

lowswaplab commented 3 years ago

Placemark.js has a bunch of WebGL matrix transforms for rotation and tilt... I haven't worked with WebGL enough to know if the problem is in there...

ComBatVision commented 3 years ago

What do you mean? Does this PR incorrect?

Show me screenshot.

ComBatVision commented 3 years ago

If you want Placemark to be placed on terrain and rotated according to surface, then it should be not a Placemark, but surface image.

Should we reject this PR?

lowswaplab commented 3 years ago

We should not reject this PR. We need to fix rotation though. Rotating a square works properly. Rotating a rectangle rotates it, but it's aspect ratio is wrong. I'll post a screenshot...

ComBatVision commented 3 years ago

Yes, please, attach a screenshot. I can not understand what is the issue.

lowswaplab commented 3 years ago

Screenshot 2021-06-06 at 08-53-49 Screenshot

using a random rectangular png heading = 0 scale = 5

lowswaplab commented 3 years ago

Screenshot 2021-06-06 at 08-54-46 Screenshot

heading = 90 scale = 5

lowswaplab commented 3 years ago

Screenshot 2021-06-06 at 08-56-37 Screenshot

heading = 45 scale = 5

ComBatVision commented 3 years ago

Have you checked standard examples of renderable.imageRotation attribute? How it is supposed to be used?

lowswaplab commented 3 years ago

I didn't find any examples that use imageRotation.

ComBatVision commented 3 years ago

According to my research, screen compass uses the same rotation logic (Matrix.multiplyByRotation) and it looks ok. As I understand if image canvas is square, then it rotates correctly.

Probably we should resize canvas of image to become square before rotation using maximal image dimension. This is not a KML processing issue, so I will do it out of this PR scope as separate enhanceement. Android code base has the same issue.

I have only one question regarding this PR - do you receive acceptable result when you rotate square Placemark and tilt globe camera? Is it OK for you, that icon faced screen surface, not a terrain surface and its rotation looks like not related to globe north in this view perspective?

ComBatVision commented 3 years ago

I have created an issue ticked for the problem with Placemark rotation https://github.com/WorldWindEarth/worldwindjs/issues/63 If you will have ideas, let's discuss them there. It is a global issue with non-square images rotation in Android and JS code base.