From 531065fbe263b4909c2ada3f8de429f5447917c3 Mon Sep 17 00:00:00 2001 From: rocketsarefast Date: Wed, 31 Oct 2018 14:54:50 -0500 Subject: [PATCH] bug: when calling pickShapesInRegion(), if there is a TriangleMesh in the pick region, the function fails and throws an exception. This is because "pickShapesInRegion()" uses a rectangle region to do picking, not a point. Instead, it makes a temporary frustum and checks if shapes are visible inside that frustum. This means that the pickRay property is null throughout the picking process. The "AbstractMesh.prototype.computePickPosition()" function will crash when the pickRay is null, but the result is only needed for normal "pick()". When using "pickShapesInRegion()", the result from computePickPosition() is ignored, and the temporary frustum is used instead. So we just need to add "if(dc.pickRay==null) {return null;}" to the top of the "AbstractMesh.prototype.computePickPosition()" function. This allows the code to move on and the pickShapesInRegion() function can complete successfully. This problem does not happen with WorldWind.Polygons, but does happen with WorldWind.TriangleMesh, and probably everything that inherits from WorldWind.AbstractMesh. --- src/shapes/AbstractMesh.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/shapes/AbstractMesh.js b/src/shapes/AbstractMesh.js index c92848a6d..9fc3c98be 100644 --- a/src/shapes/AbstractMesh.js +++ b/src/shapes/AbstractMesh.js @@ -493,6 +493,7 @@ define([ }; AbstractMesh.prototype.computePickPosition = function (dc) { + if(dc.pickRay == null) {return null;} var currentData = this.currentData, line = dc.pickRay, localLineOrigin = new Vec3(line.origin[0], line.origin[1], line.origin[2]).subtract(