Hello,
I am trying to find how big a non-scaling billboard item would be in meters in the current zoom level.
I tried the sizeInMeters property but that seems to be working.
( image is distorted )
Thanks for ideas.
Hello,
I am trying to find how big a non-scaling billboard item would be in meters in the current zoom level.
I tried the sizeInMeters property but that seems to be working.
( image is distorted )
Thanks for ideas.
I think when you have sizeInMeters: true
, and then you pass height: 10
to the billboard, that sets it to a height of 10 meters.
You should be able to verify this by measuring it with the measurement tools on Cesium ion (see https://cesium.com/docs/tutorials/stories-introduction/).
Sorry, I misspelled my initial question. I missed a not.
as in ( I tried the sizeInMeters property but that seems not to be working )
Here is some simple code I tried:
var viewer = new Cesium.Viewer("cesiumContainer");
viewer.entities.add({
position: Cesium.Cartesian3.fromDegrees(-75.59777, 40.03883),
billboard: {
image: "../images/Cesium_Logo_overlay.png", // default: undefined
width: 100000000,
height: 25000000,
sizeInMeters:true
},
});
Here is the relevant sandcastle link:
That’s a huge billboard! Perhaps try something like width: 20, height: 10 and make sure the bottom half is not buried in the ground, so something like position: Cesium.Cartesian3.fromDegrees(-75.59777, 40.03883,50); should raise it 50 meters off the ground. Lots of other properties can be set https://cesium.com/docs/cesiumjs-ref-doc/Billboard.html
Ok. To explain:
I would need the billboard item to be visible at all zoom-levels.
The only reason I am using sizeInMeters is because I need to calculate its size in meters while zooming to be able to render another item correctly.
However doing that would mean:
a: the item would scale with zoom, which i dont want
b: it does not display correctly anyway.
So I need to re-phrase the original question in the post header.
How can I get the size of an entity if it stays a constant size, like a billboard item without “sizeInMeters” set to true?
By constant size I suppose you mean constant ‘screen size’, like how the airplane model here remains the the same screen size as you travel farther away from it, but in order to stay the same screen size it must be getting larger relative to the Earth, so you want the size in relation to the Earth as it increases in size?
https://sandcastle.cesium.com/?src=3D%20Models.html
Thats correct, constant screen size,
but not exactly like that 3D model, whichs scales once you are close enough.
Thanks
Good question. It’s possible that’s it’s not publicly exposed. Might be in one of the private vars (which I think are still publicly accessible, just not intended to be.) Can search for ‘this._’ in
github.com/CesiumGS/cesium/blob/1.71/Source/Scene/Billboard.js
Maybe this._labelDimensions, just a guess (actually I’m not even sure that’s used, maybe in another file)
Will try to find it within the source
I don’t know if there’s an easy way to do this, but since you’re going from 2D / screen coordinates to 3D / world coordinates, I think you’re going to be stuck with Scene#pickPosition. This gives you a Cartesian3 that corresponds to the screen pixel you supply. So, if you know the screen position of your billboard, you can use the (pixel) height/width to get 2D coordinates for the edges, then “pick” a Cartesian3 on either side and measure the distance between them to get your 3D size in meters.
Is there an answer to this question?