Hello!
Imagine I want to put a model at the place, where the user clicks.
How do I convert mouse coordinates to Cartesian3 coordinates?
I tried following approaches and none of them works.
1)
var handler = new Cesium.ScreenSpaceEventHandler(viewer.canvas);
handler.setInputAction(function(movement) {
var cartesianCoordinates = Cesium.Cartesian3.clone(movement.position);
}, Cesium.ScreenSpaceEventType.LEFT_DOWN);
2)
var handler = new Cesium.ScreenSpaceEventHandler(canvas);
handler.setInputAction(function(movement) {
var canvas = viewer.canvas;
var cartesianCoordinates = new Cesium.Cartesian3(
movement.position.x / canvas.clientWidth,
movement.position.y / canvas.clientHeight,
0.
);
}, Cesium.ScreenSpaceEventType.LEFT_DOWN);
3)
var handler = new Cesium.ScreenSpaceEventHandler(viewer.canvas);
handler.setInputAction(function(movement) {
var canvas = viewer.canvas;
var cartesianCoordinates = new Cesium.Cartesian3(
movement.position.x / canvas.clientWidth,
- movement.position.y / canvas.clientHeight,
0.);
}, Cesium.ScreenSpaceEventType.LEFT_DOWN);
So how do I it correctly?
Thanks in advance
Dmitri Pisarenko