Occluder

创建从对象的位置和半径以及相机位置派生的封堵器。封堵器可用于确定其他对象是否可见或隐藏在由封堵器和相机位置定义的可见地平线之后。
new Occluder(occluderBoundingSphere, cameraPosition)
Parameters:
occluderBoundingSphere (BoundingSphere) 围绕封堵器的边界球体。
cameraPosition (Cartesian3) 观察者/照相机的坐标。
Example
// Construct an occluder one unit away from the origin with a radius of one.
var cameraPosition = bmgl.Cartesian3.ZERO;
var occluderBoundingSphere = new bmgl.BoundingSphere(new bmgl.Cartesian3(0, 0, -1), 1);
var occluder = new bmgl.Occluder(occluderBoundingSphere, cameraPosition);

Members

cameraPosition : Cartesian3

相机的位置。

position : Cartesian3

封堵器的位置。

radius : Number

封堵器的半径。

Methods

(static) computeOccludeePoint(occluderBoundingSphere, occludeePosition, positions) → {Object}
计算一个点,该点可用作可见性函数的遮掩位置。使用半径为零作为遮挡半径。通常,用户计算用于可见性的对象周围的边界球;但是,也可以计算一个点,如果看到/不看到,也会指示对象是否可见/不可见。对于相对于遮光罩不移动且较大的对象(如一块地形),更好地调用此函数。最好不要这样称呼,不要将对象的边界球用于卫星或地面车辆等对象。
Parameters:
occluderBoundingSphere (BoundingSphere) 围绕封堵器的边界球体。
occludeePosition (Cartesian3) 封堵器(半径为0的边界球)所在的点。
positions (Array.<Cartesian3>) 遮光罩表面附近地平线上的高度点列表。
Example
var cameraPosition = new bmgl.Cartesian3(0, 0, 0);
var occluderBoundingSphere = new bmgl.BoundingSphere(new bmgl.Cartesian3(0, 0, -8), 2);
var occluder = new bmgl.Occluder(occluderBoundingSphere, cameraPosition);
var positions = [new bmgl.Cartesian3(-0.25, 0, -5.3), new bmgl.Cartesian3(0.25, 0, -5.3)];
var tileOccluderSphere = bmgl.BoundingSphere.fromPoints(positions);
var occludeePosition = tileOccluderSphere.center;
var occludeePt = bmgl.Occluder.computeOccludeePoint(occluderBoundingSphere, occludeePosition, positions);
Throws
  • DeveloperError : positions必须至少包含一个元素。
  • DeveloperError : occludeePosition必须具有除occluderBoundingSphere.center以外的值。
(static) computeOccludeePointFromRectangle(rectangle, ellipsoid) → {Object}
计算一个点,该点可用作矩形中可见性函数的遮挡位置。
Parameters:
rectangle (Rectangle) 用于创建边界球体的矩形。
ellipsoid (Ellipsoid) (default Ellipsoid.WGS84) 用于确定矩形位置的椭圆体。
(static) fromBoundingSphere(occluderBoundingSphere, cameraPosition, result) → {Occluder}
从边界球体和相机位置创建遮光罩。
Parameters:
occluderBoundingSphere (BoundingSphere) 围绕封堵器的边界球体。
cameraPosition (Cartesian3) 观察者/照相机的坐标。
result (Occluder) 存储结果的对象。
computeVisibility(occludeeBS) → {Number}
确定封堵器的可见程度(不可见、部分可见或完全可见)。
Parameters:
occludeeBS (BoundingSphere) 封堵器的边界球。
Example
var sphere1 = new bmgl.BoundingSphere(new bmgl.Cartesian3(0, 0, -1.5), 0.5);
var sphere2 = new bmgl.BoundingSphere(new bmgl.Cartesian3(0, 0, -2.5), 0.5);
var cameraPosition = new bmgl.Cartesian3(0, 0, 0);
var occluder = new bmgl.Occluder(sphere1, cameraPosition);
occluder.computeVisibility(sphere2); //returns Visibility.NONE
See:
  • Occluder#isVisible
isBoundingSphereVisible(occludee) → {Boolean}
确定遮挡器是否隐藏了一个球体,即occludee
Parameters:
occludee (BoundingSphere) 围绕被遮挡对象的边界球体。
Example
var cameraPosition = new bmgl.Cartesian3(0, 0, 0);
var littleSphere = new bmgl.BoundingSphere(new bmgl.Cartesian3(0, 0, -1), 0.25);
var occluder = new bmgl.Occluder(littleSphere, cameraPosition);
var bigSphere = new bmgl.BoundingSphere(new bmgl.Cartesian3(0, 0, -3), 1);
occluder.isBoundingSphereVisible(bigSphere); //returns true
See:
isPointVisible(occludee) → {Boolean}
确定遮挡器是否隐藏了一个点,即occludee
Parameters:
occludee (Cartesian3) 围绕被遮挡对象的点。
Example
var cameraPosition = new bmgl.Cartesian3(0, 0, 0);
var littleSphere = new bmgl.BoundingSphere(new bmgl.Cartesian3(0, 0, -1), 0.25);
var occluder = new bmgl.Occluder(littleSphere, cameraPosition);
var point = new bmgl.Cartesian3(0, 0, -3);
occluder.isPointVisible(point); //returns true
See: