CesiumGS / cesium

An open-source JavaScript library for world-class 3D globes and maps :earth_americas:
https://cesium.com/cesiumjs/
Apache License 2.0
12.79k stars 3.46k forks source link

Add heading option for a billboard #6165

Open welchyd opened 6 years ago

welchyd commented 6 years ago

When I have a billboard with an image that is facing north, I can tilt the camera so the image is flipped. This is not what I would've expected, and there doesn't seem to be a way to keep the billboard's direction locked. Please fix.

Expected behavior - image pointing north: screen shot 2018-01-26 at 12 56 30 pm

After a slight camera tilt, it then faces more southward: screen shot 2018-01-26 at 12 56 51 pm

At a more extreme tilt, it seems to be pointing into the earth: screen shot 2018-01-26 at 1 01 04 pm

I've been able to get it to happen in this workspace: https://cesiumjs.org/Cesium/Apps/Sandcastle/?src=Hello%20World.html&label=Showcases&gist=6f6710474236e3ffb99d41673e7b3632

schmidtk commented 6 years ago

This is similar to the issue fixed in #2487, but I believe what's needed is a way to render the billboard parallel to the Earth. This was asked in the forum awhile back, and I haven't been able to find a solution either. Using an entity with a material to display the icon has the desired rotation effect, but doesn't maintain constant pixel dimensions like a billboard.

hpinkos commented 6 years ago

@welchyd the billboard is behaving as expected. The reason it seems to be flipping when you tilt the globe beyond a certain point is because the Z axis is now pointing down in screen space (ie the north pole is below the south pole) so the billboard rotates so it continues to point along the positive Z axis.

It seems like what you want is to set heading: 0 for the billboard. We don't currently have that option, but I'll re-label this issue for us to consider adding it.

welchyd commented 6 years ago

A heading would be awesome! Thanks @hpinkos I did try working around this by drawing the icon as a material on a rectangle geometry, but that doesn't really scale with zoom nicely. Would love to see this added to the Billboard!

esparano commented 6 years ago

There is a related problem where the "aligned axis" does not work as expected, and billboards that are near the edges of the screen behave as if their rotations are calculated from the center of the screen.

For example, we have a grid of billboards whose alignedAxes are tangent to the Earth's surface, pointing north, with 0 rotation: image

While it looks fine or "close enough" at some angles, at other angles the billboards are not rendered correctly. The camera is pointed south in the following picture: image One would expect the billboards to the right (west) to point down-right, and the billboards to the left (east) to point down-left.

There is a problem in the BillboardCollection shader where the billboards near the center of the screen are rendered correctly, and all other billboards render as if they are at the center of the screen. You can see what I mean by the "red circle" on the previous picture. IF the billboards were all located at the center of the screen, their orientations would be correct.

I want to emphasize that this is different from a heading option for billboards and is a bug in the rendering based on the alignedAxis/rotation. The BillboardCollection shader code does not take screen location of the billboard into account.

hpinkos commented 6 years ago

Also requested by @hieeyh in #6825

himby commented 3 years ago

Bumping this one. This feature would be really nice, I'm currently working on an app that shows ships moving around in different directions, and as a workaround I have created polygons instead. but as pointed out these don't scale. So to come around that problem i use PointGraphics instead when zooming out. Billboards with heading seems perfect for the job. I've tried to modify BillboardCollectionVS.glsl to force billboards to lay flat on the ground, but this shader is a bit complex and I'm currently struggling to adjust it to how I want. Could someone else give it a try please?

MishkaRogachev commented 2 years ago

Hi! Have same needs, but maybe it is better to have a new separated graphics for oriented SVGs using Cesium.HeadingPitchRoll?

image

abigstupidbear commented 2 years ago

now do you have any solution to solve it??

sersanchus commented 1 year ago

I faced this exactly problem and I come to this sollution, see if that suites you too. It's based on updating the rotation of the billoboard acording to camera's actual heading.

const self = this;

style.billboard.rotation = new Cesium.CallbackProperty(function (time, result) {
    return self.map.scene.camera.heading;
}, false);
ellmatt commented 10 months ago

I faced the same issue recently and came up with the following approach to solve this problem in sandcastle. Sandcastle