hkn
hkn

Reputation: 371

Getting wrong coordinate from Cesium-DrawHelper shape created event

i am using cesium with drawHelper plugin on GWT (Cesium Terrain Server for terrain). i am drawing shapes(marker , polyline , polygon..) to my 3d map. I can draw shapes to the map with exact coordinates where my mouse is pointing but when i change the angle of camera look , i cannot draw shapes where my mouse pointing because i am getting wrong coordinates and this leads to draw my shapes on wrong coordinates. (i get coordinates from DrawHelpers shape create event for instance 'markerCreated' returns position)

Upvotes: 1

Views: 809

Answers (1)

hkn
hkn

Reputation: 371

I solved my problem with editing DrawHelper.js , it was getting position with scene.camera.pickEllipsoid function , i changed it with creating a ray and picking position via globe.pick. Code :

var cartesian = scene.camera.pickEllipsoid(movement.position,ellipsoid)

Replaced it with

var ray = scene.camera.getPickRay(movement.position);
var pickedPosition = scene.globe.pick(ray,scene);
if(pickedPosition){
markers.addBillBoard(pickedPosition);
_self.stopDrawing();
options.callback(pickedPosition);

Adding marker on terrain to the coordinates which pointing from mouse fixed like this...

Upvotes: 3

Related Questions