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)上的坐標,通常結合其他的選取方式一塊用於選取模型和球上的點。

  

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM