Hello,
I used to work on sceneMode: SceneMode.SCENE3D , and now, due to new requirements, I have to change my code to support SceneMode.SCENE2D.
My task is simple, I have a place where a img of entity is located, and when the user drag this img, by the calculation of the mouse up position, the entity will be placed.
My code is working fine for SceneMode.SCENE3D, but when I changed to 2D, something went wrong and I don’t know for sure what it is.
My onDrop function code that handle calculation of the entity position is:
// calculate new object drop area
const dim = this.refs.map.getClientRects()[0],
x = (event.clientX - dim.left),
y = (event.clientY - dim.top);
// calculate location
const mousePosition = new Cartesian2(x, y),
cartesian = this.viewer.camera.pickEllipsoid(mousePosition, this.viewer.scene.globe.ellipsoid);
if (cartesian) {
let addEntityData;
const cartographic = Cartographic.fromCartesian(cartesian),
longitudeString = CesiumMath.toDegrees(cartographic.longitude),
latitudeString = CesiumMath.toDegrees(cartographic.latitude);
and then finaly the code to initialize the new entity position is look like:
position : {
height : this.defaultHeight,
latitude : latitudeString,
longitude : longitudeString,
}
can anyone tell me what I am doing wrong?
is there another way to achieve the same calculation, like I did in 3d mode ?
Thank you.