Hello,
I am having a problem using the Scene.pick functionality of
Cesium.
I have an application where I draw a bounding box form a
series of mouse clicks. I then display a bunch of billboard pins for each
coordinate of my data that falls within that bounding box. I am having trouble
trying to pick (with a left mouse click) any of these entities.
The following could be important: For a handler like the
following I can pick the rectangle ONLY if it is zoomed in enough to fill the
whole window!
I would like to know:
A)Why picking only returns a defined entity when It’s a the rectangle,
but only when it is zoomed enough to fill the whole window
B)Why picking any of the pins/billboards described below
will always return undefined
Any help would be appreciated!
Below are the specifics:
I have a viewer:
var viewer = new Cesium.Viewer(‘cesiumContainer’, {
``
sceneModePicker : false,
animation : false,
timeline : true,
navigationHelpButton : false,
baseLayerPicker : false,
geocoder : true,
homeButton : true,
infoBox : true,
fullscreenButton : false,
scene3DOnly : true,
showRenderLoopErrors : true
});
var
scene = viewer;
A
handler:
var handler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
handler.setInputAction(function
(movement) {
var pick = scene.pick(movement.position);
if (Cesium.defined(pick)) {
console.log(‘Mouse clicked rectangle.’);
}
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
A rectangle:
var coordinates array = ;
this.boundingBox =
{
name: “Bounding Box”,
id: ‘BoundBox’,
rectangle: {
coordinates: Cesium.Rectangle.fromCartographicArray(coordinates),
height: -100,
material: Cesium.Color.RED.withAlpha(0.1),
outline: true,
outlineColor: Cesium.Color.LIME
}
};
this.boundingBoxReference
= entities.add(this.boundingBox);
``
The billboards are created as follows:
var
pinBuilder = new Cesium.PinBuilder();
var report =
{
name : 'Report: ’ + sr.id,
id: ‘pin’ + sr.id + ‘Report’,
description : ,
position : Cesium.Cartesian3.fromRadians(sr.longitude, sr.latitude),
billboard : {
image : pinBuilder.fromText("Report", pinColor,
50).toDataURL(),
verticalOrigin : Cesium.VerticalOrigin.BOTTOM
}
}
viewer.entities.add(report);
``