CesiumGS / CesiumGS/cesium

pickFromRay or drillPickFromRay Can only be executed once successfully

Open
#7,759 20 comments 0 reactions 0 assignees View on GitHub
category - picking type - bug
Dominant language
JavaScript
Stars
15.8k
Forks
3.9k
Avg merge
4d 6h
Merged PRs (30d)
34

Description

pickFromRay or drillPickFromRay Can only be executed once successfully, the second time will die in a while loop
this is the test code:
`
function PointVsibilityAnalysis () {
var positions = [];
var pointsEntity = [];
var vaHandler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
vaHandler.setInputAction(function (movement) {
var cartesian = viewer.scene.pickPosition(movement.position);
var cartographic = Cesium.Ellipsoid.WGS84.cartesianToCartographic(cartesian);
var lng = Cesium.Math.toDegrees(cartographic.longitude);
var lat = Cesium.Math.toDegrees(cartographic.latitude);

var height = cartographic.height;
height = height < 0 ? 0 : height;
cartesian = Cesium.Cartesian3.fromDegreesArrayHeights([lng, lat, height])[0];
var point = viewer.entities.add({
position: cartesian,
point: {
pixelSize: 5,
color: Cesium.Color.RED,
outlineColor: Cesium.Color.WHITE,
outlineWidth: 2,
heightReference: Cesium.HeightReference.none
}
});
pointsEntity.push(point);
positions.push(cartesian);
if (positions.length == 2) {
vaHandler.destroy();
vaHandler = null;
var drillPick = true;
var obj2Excute = pointsEntity;

var start = positions[0];
var end = positions[1];
var direction = Cesium.Cartesian3.normalize(Cesium.Cartesian3.subtract(end, start, new Cesium.Cartesian3()), new Cesium.Cartesian3());
var ray = new Cesium.Ray(start, direction);
var results = [];
if (drillPick) {
results = viewer.scene.drillPickFromRay(ray, 10, obj2Excute);
}
else {
var result = viewer.scene.pickFromRay(ray, obj2Excute);
if (Cesium.defined(result)) {
results = [result];
}
}
if (results.length != 0) {
var vEntity = viewer.entities.add({
position: results[0].position,
point: {
pixelSize: 5,
color: Cesium.Color.YELLOW,
outlineColor: Cesium.Color.RED,
outlineWidth: 1,
heightReference: Cesium.HeightReference.none,
disableDepthTestDistance: Number.POSITIVE_INFINITY
}
});
positions.splice(1, 0, results[0].position);
var options = {
polyline: {
show: true,
positions: [positions[0], positions[1]],
material: Cesium.Color.BLUE,
width: 3
}
};
var vBlueEntity = viewer.entities.add(options);
var options2 = {
polyline: {
show: true,
positions: [positions[1], positions[2]],
material: Cesium.Color.RED,
width: 3
}
};
var vRedEntity = viewer.entities.add(options2);
}
}

}, Cesium.ScreenSpaceEventType.LEFT_CLICK);`

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the supplied PointVsibilityAnalysis example and compare the first and second calls to scene.pickFromRay or scene.drillPickFromRay. Focus on the ray-picking path and its handling of the supplied entities; done means repeated executions return or complete normally instead of remaining in a while loop.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
computer-graphics
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.