創建從對象的位置和半徑以及相機位置派生的封堵器。封堵器可用于確定其他對象是否可見或隱藏在由封堵器和相機位置定義的可見地平線之后。
new Occluder(occluderBoundingSphere, cameraPosition)
Parameters:
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:
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
必須至少包含一個元素。
計算一個點,該點可用作矩形中可見性函數的遮擋位置。
Parameters:
從邊界球體和相機位置創建遮光罩。
Parameters:
確定封堵器的可見程度(不可見、部分可見或完全可見)。
Parameters:
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
- Occluder#isVisible
See:
確定遮擋器是否隱藏了一個球體,即
occludee
。
Parameters:
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
確定遮擋器是否隱藏了一個點,即
occludee
。