cesium中的四种拾取pick

cesium中有好多种物体拾取,在这里记录一下,方便查阅。

1、viewer.scene.pick(windowPosition);
  官网介绍:

Returns an object with a `primitive` property that contains the first (top) primitive in the scene at a particular window coordinate or undefined if nothing is at the location. 
Other properties may potentially be set depending on the type of primitive and may be used to further identify the picked object.
When a feature of a 3D Tiles tileset is picked, pick returns a Cesium3DTileFeature object

  返回scene中指定位置的顶端的primitive属性的的一个对象。
  适用于选取3D tiles,改变3Dtiles的属性,比如颜色等。

2、 viewer.scene.globe.pick(ray, viewer.scene);

  其中 var ray = viewer.camera.getPickRay(movement.position);

  官网介绍:

Find an intersection between a ray and the globe surface that was rendered. The ray must be given in world coordinates.

  返回y一个ray和地球表面的一个交点的Cartesian3坐标。

  适用于拾取有地形高程的点,但不包括模型、倾斜摄影等表面高度。需要开启深度测试 depthTestAgainstTerrain = true。

3、viewer.scene.camera.pickEllipsoid(movement.position, ellipsoid);

  官网介绍:

Pick an ellipsoid or map.
Returns:
If the ellipsoid or map was picked, returns the point on the surface of the ellipsoid or map in world coordinates. If the ellipsoid or map was not picked, returns undefined.

  返回的是椭圆球体表面的一个Cartesian3坐标。

  适用于裸球表面的选取,是基于数学模型的椭圆球体。

4、viewer.scene.pickPosition(movement.position);

  官网介绍:

Returns the cartesian position reconstructed from the depth buffer and window position.

  返回一个被屏幕坐标和深度缓存指定的点。

  适用于模型表面位置的选取,通俗的说就是camera看过去第一个被挡住的模型(如entity)上的坐标,通常结合其他的选取方式一块用于选取模型和球上的点。

  

  

.
原文地址:https://www.cnblogs.com/airduce/p/14663927.html