Methods
static Cesium.IntersectionTests.grazingAltitudeLocation(ray, ellipsoid) → Cartesian3
提供射线上距离椭球最近的点。
| Name | Type | Description |
|---|---|---|
ray |
Ray | 射线。 |
ellipsoid |
Ellipsoid | 椭球。 |
Returns:
射线上最近的测地(planetodetic)点。
static Cesium.IntersectionTests.lineSegmentPlane(endPoint0, endPoint1, plane, result) → Cartesian3
计算线段与平面之间的交点。
| Name | Type | Description |
|---|---|---|
endPoint0 |
Cartesian3 | 线段的一个端点。 |
endPoint1 |
Cartesian3 | 线段的另一个端点。 |
plane |
Plane | 平面。 |
result |
Cartesian3 | optional 用于存储结果的对象。 |
Returns:
交点;如果没有交点,则为 undefined。
Example:
const origin = Cesium.Cartesian3.fromDegrees(-75.59777, 40.03883);
const normal = ellipsoid.geodeticSurfaceNormal(origin);
const plane = Cesium.Plane.fromPointNormal(origin, normal);
const p0 = new Cesium.Cartesian3(...);
const p1 = new Cesium.Cartesian3(...);
// find the intersection of the line segment from p0 to p1 and the tangent plane at origin.
const intersection = Cesium.IntersectionTests.lineSegmentPlane(p0, p1, plane);
static Cesium.IntersectionTests.lineSegmentSphere(p0, p1, sphere, result) → Interval
计算线段与球体的交点。
| Name | Type | Description |
|---|---|---|
p0 |
Cartesian3 | 线段的一个端点。 |
p1 |
Cartesian3 | 线段的另一个端点。 |
sphere |
BoundingSphere | 球体。 |
result |
Interval | optional 用于存储结果的 result。 |
Returns:
包含沿射线标量点的区间;如果没有交点,则为 undefined。
static Cesium.IntersectionTests.lineSegmentTriangle(v0, v1, p0, p1, p2, cullBackFaces, result) → Cartesian3
计算线段与三角形之间的交点。
| Name | Type | Default | Description |
|---|---|---|---|
v0 |
Cartesian3 | 线段的一个端点。 | |
v1 |
Cartesian3 | 线段的另一个端点。 | |
p0 |
Cartesian3 | 三角形的第一个顶点。 | |
p1 |
Cartesian3 | 三角形的第二个顶点。 | |
p2 |
Cartesian3 | 三角形的第三个顶点。 | |
cullBackFaces |
boolean |
false
|
optional
如果为 true,则只计算与三角形正面的交点,
对于与背面的交点返回 undefined。 |
result |
Cartesian3 |
optional
用于存储结果的 Cartesian3。 |
Returns:
交点;如果没有交点,则为 undefined。
计算射线与轴对齐包围盒(axis-aligned bounding box)的交点。(轴对齐是指与射线处于同一坐标系中)
| Name | Type | Description |
|---|---|---|
ray |
Ray | 射线。 |
box |
AxisAlignedBoundingBox | 轴对齐包围盒。 |
result |
Interval | undefined | 包含沿射线标量点的区间;如果没有交点,则为 undefined。 |
static Cesium.IntersectionTests.rayEllipsoid(ray, ellipsoid) → Interval
计算射线与椭球的交点。
| Name | Type | Description |
|---|---|---|
ray |
Ray | 射线。 |
ellipsoid |
Ellipsoid | 椭球。 |
Returns:
包含沿射线标量点的区间;如果没有交点,则为 undefined。
static Cesium.IntersectionTests.rayPlane(ray, plane, result) → Cartesian3
计算射线与平面之间的交点。
| Name | Type | Description |
|---|---|---|
ray |
Ray | 射线。 |
plane |
Plane | 平面。 |
result |
Cartesian3 | optional 用于存储结果的对象。 |
Returns:
交点;如果没有交点,则为 undefined。
static Cesium.IntersectionTests.raySphere(ray, sphere, result) → Interval
计算射线与球体的交点。
| Name | Type | Description |
|---|---|---|
ray |
Ray | 射线。 |
sphere |
BoundingSphere | 球体。 |
result |
Interval | optional 用于存储结果的 result。 |
Returns:
包含沿射线标量点的区间;如果没有交点,则为 undefined。
static Cesium.IntersectionTests.rayTriangle(ray, p0, p1, p2, cullBackFaces, result) → Cartesian3
计算射线与三角形的交点,结果为 Cartesian3 坐标。
实现了 Tomas Moller 和 Ben Trumbore 的 Fast Minimum Storage Ray/Triangle Intersection。
| Name | Type | Default | Description |
|---|---|---|---|
ray |
Ray | 射线。 | |
p0 |
Cartesian3 | 三角形的第一个顶点。 | |
p1 |
Cartesian3 | 三角形的第二个顶点。 | |
p2 |
Cartesian3 | 三角形的第三个顶点。 | |
cullBackFaces |
boolean |
false
|
optional
如果为 true,则只计算与三角形正面的交点,
对于与背面的交点返回 undefined。 |
result |
Cartesian3 |
optional
用于存储结果的 Cartesian3。 |
Returns:
交点;如果没有交点,则为 undefined。
计算射线与三角形的交点,结果为沿输入射线的参数化距离。当三角形位于射线后方时,结果为负值。
实现了 Tomas Moller 和 Ben Trumbore 的 Fast Minimum Storage Ray/Triangle Intersection。
| Name | Type | Default | Description |
|---|---|---|---|
ray |
Ray | 射线。 | |
p0 |
Cartesian3 | 三角形的第一个顶点。 | |
p1 |
Cartesian3 | 三角形的第二个顶点。 | |
p2 |
Cartesian3 | 三角形的第三个顶点。 | |
cullBackFaces |
boolean |
false
|
optional
如果为 true,则只计算与三角形正面的交点,
对于与背面的交点返回 undefined。 |
Returns:
沿射线的参数化距离形式的交点;如果没有交点,则为 undefined。
计算三角形与平面之间的交点
| Name | Type | Description |
|---|---|---|
p0 |
Cartesian3 | 三角形的第一个点 |
p1 |
Cartesian3 | 三角形的第二个点 |
p2 |
Cartesian3 | 三角形的第三个点 |
plane |
Plane | 相交平面 |
Returns:
一个带有
positions 和 indices 属性的对象,这两个数组表示不穿过该平面的三个三角形。(如果不存在交点,则为 undefined)
Example:
const origin = Cesium.Cartesian3.fromDegrees(-75.59777, 40.03883);
const normal = ellipsoid.geodeticSurfaceNormal(origin);
const plane = Cesium.Plane.fromPointNormal(origin, normal);
const p0 = new Cesium.Cartesian3(...);
const p1 = new Cesium.Cartesian3(...);
const p2 = new Cesium.Cartesian3(...);
// convert the triangle composed of points (p0, p1, p2) to three triangles that don't cross the plane
const triangles = Cesium.IntersectionTests.trianglePlaneIntersection(p0, p1, p2, plane);
