Skip to content

KBE3D / KBCore / Cesium / OrientedBoundingBox

类: OrientedBoundingBox

Creates an instance of an OrientedBoundingBox. An OrientedBoundingBox of some object is a closed and convex rectangular cuboid. It can provide a tighter bounding volume than BoundingSphere or AxisAlignedBoundingBox in many cases.

示例

ts
// Create an OrientedBoundingBox using a transformation matrix, a position where the box will be translated, and a scale.
const center = new Cesium.Cartesian3(1.0, 0.0, 0.0);
const halfAxes = Cesium.Matrix3.fromScale(new Cesium.Cartesian3(1.0, 3.0, 2.0), new Cesium.Matrix3());

const obb = new Cesium.OrientedBoundingBox(center, halfAxes);

参数

The center of the box.

参数

The three orthogonal half-axes of the bounding box. Equivalently, the transformation matrix, to rotate and scale a 2x2x2 cube centered at the origin.

属性

packedLength

static packedLength: number

The number of elements used to pack the object into an array.


center

center: Cartesian3

The center of the box.


halfAxes

halfAxes: Matrix3

The three orthogonal half-axes of the bounding box. Equivalently, the transformation matrix, to rotate and scale a 2x2x2 cube centered at the origin.

方法

pack()

static pack(value: OrientedBoundingBox, array: number[], startingIndex?: number): number[]

Stores the provided instance into the provided array.

参数

value

OrientedBoundingBox

The value to pack.

array

number[]

The array to pack into.

startingIndex?

number

The index into the array at which to start packing the elements.

返回

number[]

The array that was packed into


unpack()

static unpack(array: number[], startingIndex?: number, result?: OrientedBoundingBox): OrientedBoundingBox

Retrieves an instance from a packed array.

参数

array

number[]

The packed array.

startingIndex?

number

The starting index of the element to be unpacked.

result?

OrientedBoundingBox

The object into which to store the result.

返回

OrientedBoundingBox

The modified result parameter or a new OrientedBoundingBox instance if one was not provided.


fromPoints()

static fromPoints(positions?: Cartesian3[], result?: OrientedBoundingBox): OrientedBoundingBox

Computes an instance of an OrientedBoundingBox of the given positions. This is an implementation of Stefan Gottschalk's Collision Queries using Oriented Bounding Boxes solution (PHD thesis). Reference: http://gamma.cs.unc.edu/users/gottschalk/main.pdf

参数

positions?

Cartesian3[]

List of Cartesian3 points that the bounding box will enclose.

result?

OrientedBoundingBox

The object onto which to store the result.

返回

OrientedBoundingBox

The modified result parameter or a new OrientedBoundingBox instance if one was not provided.

示例

ts
// Compute an object oriented bounding box enclosing two points.
const box = Cesium.OrientedBoundingBox.fromPoints([new Cesium.Cartesian3(2, 0, 0), new Cesium.Cartesian3(-2, 0, 0)]);

fromRectangle()

static fromRectangle(rectangle: Rectangle, minimumHeight?: number, maximumHeight?: number, ellipsoid?: Ellipsoid, result?: OrientedBoundingBox): OrientedBoundingBox

Computes an OrientedBoundingBox that bounds a Rectangle on the surface of an Ellipsoid. There are no guarantees about the orientation of the bounding box.

参数

rectangle

Rectangle

The cartographic rectangle on the surface of the ellipsoid.

minimumHeight?

number

The minimum height (elevation) within the tile.

maximumHeight?

number

The maximum height (elevation) within the tile.

ellipsoid?

Ellipsoid

The ellipsoid on which the rectangle is defined.

result?

OrientedBoundingBox

The object onto which to store the result.

返回

OrientedBoundingBox

The modified result parameter or a new OrientedBoundingBox instance if none was provided.


fromTransformation()

static fromTransformation(transformation: Matrix4, result?: OrientedBoundingBox): OrientedBoundingBox

Computes an OrientedBoundingBox that bounds an affine transformation.

参数

transformation

Matrix4

The affine transformation.

result?

OrientedBoundingBox

The object onto which to store the result.

返回

OrientedBoundingBox

The modified result parameter or a new OrientedBoundingBox instance if none was provided.


clone()

static clone(box: OrientedBoundingBox, result?: OrientedBoundingBox): OrientedBoundingBox

Duplicates a OrientedBoundingBox instance.

参数

box

OrientedBoundingBox

The bounding box to duplicate.

result?

OrientedBoundingBox

The object onto which to store the result.

返回

OrientedBoundingBox

The modified result parameter or a new OrientedBoundingBox instance if none was provided. (Returns undefined if box is undefined)


intersectPlane()

static intersectPlane(box: OrientedBoundingBox, plane: Plane): Intersect

Determines which side of a plane the oriented bounding box is located.

参数

box

OrientedBoundingBox

The oriented bounding box to test.

plane

Plane

The plane to test against.

返回

Intersect

Intersect.INSIDE if the entire box is on the side of the plane the normal is pointing, Intersect.OUTSIDE if the entire box is on the opposite side, and Intersect.INTERSECTING if the box intersects the plane.


distanceSquaredTo()

static distanceSquaredTo(box: OrientedBoundingBox, cartesian: Cartesian3): number

Computes the estimated distance squared from the closest point on a bounding box to a point.

参数

box

OrientedBoundingBox

The box.

cartesian

Cartesian3

The point

返回

number

The distance squared from the oriented bounding box to the point. Returns 0 if the point is inside the box.

示例

ts
// Sort bounding boxes from back to front
boxes.sort(function(a, b) {
    return Cesium.OrientedBoundingBox.distanceSquaredTo(b, camera.positionWC) - Cesium.OrientedBoundingBox.distanceSquaredTo(a, camera.positionWC);
});

computePlaneDistances()

static computePlaneDistances(box: OrientedBoundingBox, position: Cartesian3, direction: Cartesian3, result?: Interval): Interval

The distances calculated by the vector from the center of the bounding box to position projected onto direction. <br> If you imagine the infinite number of planes with normal direction, this computes the smallest distance to the closest and farthest planes from position that intersect the bounding box.

参数

box

OrientedBoundingBox

The bounding box to calculate the distance to.

position

Cartesian3

The position to calculate the distance from.

direction

Cartesian3

The direction from position.

result?

Interval

A Interval to store the nearest and farthest distances.

返回

Interval

The nearest and farthest distances on the bounding box from position in direction.


computeCorners()

static computeCorners(box: OrientedBoundingBox, result?: Cartesian3[]): Cartesian3[]

Computes the eight corners of an oriented bounding box. The corners are ordered by (-X, -Y, -Z), (-X, -Y, +Z), (-X, +Y, -Z), (-X, +Y, +Z), (+X, -Y, -Z), (+X, -Y, +Z), (+X, +Y, -Z), (+X, +Y, +Z).

参数

box

OrientedBoundingBox

The oriented bounding box.

result?

Cartesian3[]

An array of eight Cartesian3 instances onto which to store the corners.

返回

Cartesian3[]

The modified result parameter or a new array if none was provided.


computeTransformation()

static computeTransformation(box: OrientedBoundingBox, result: Matrix4): Matrix4

Computes a transformation matrix from an oriented bounding box.

参数

box

OrientedBoundingBox

The oriented bounding box.

result

Matrix4

The object onto which to store the result.

返回

Matrix4

The modified result parameter or a new Matrix4 instance if none was provided.


isOccluded()

static isOccluded(box: OrientedBoundingBox, occluder: Occluder): boolean

Determines whether or not a bounding box is hidden from view by the occluder.

参数

box

OrientedBoundingBox

The bounding box surrounding the occludee object.

occluder

Occluder

The occluder.

返回

boolean

true if the box is not visible; otherwise false.


equals()

static equals(left?: OrientedBoundingBox, right?: OrientedBoundingBox): boolean

Compares the provided OrientedBoundingBox componentwise and returns <code>true</code> if they are equal, <code>false</code> otherwise.

参数

left?

OrientedBoundingBox

The first OrientedBoundingBox.

OrientedBoundingBox

The second OrientedBoundingBox.

返回

boolean

true if left and right are equal, false otherwise.


intersectPlane()

intersectPlane(plane: Plane): Intersect

Determines which side of a plane the oriented bounding box is located.

参数

plane

Plane

The plane to test against.

返回

Intersect

Intersect.INSIDE if the entire box is on the side of the plane the normal is pointing, Intersect.OUTSIDE if the entire box is on the opposite side, and Intersect.INTERSECTING if the box intersects the plane.


distanceSquaredTo()

distanceSquaredTo(cartesian: Cartesian3): number

Computes the estimated distance squared from the closest point on a bounding box to a point.

参数

cartesian

Cartesian3

The point

返回

number

The estimated distance squared from the bounding sphere to the point.

示例

ts
// Sort bounding boxes from back to front
boxes.sort(function(a, b) {
    return b.distanceSquaredTo(camera.positionWC) - a.distanceSquaredTo(camera.positionWC);
});

computePlaneDistances()

computePlaneDistances(position: Cartesian3, direction: Cartesian3, result?: Interval): Interval

The distances calculated by the vector from the center of the bounding box to position projected onto direction. <br> If you imagine the infinite number of planes with normal direction, this computes the smallest distance to the closest and farthest planes from position that intersect the bounding box.

参数

position

Cartesian3

The position to calculate the distance from.

direction

Cartesian3

The direction from position.

result?

Interval

A Interval to store the nearest and farthest distances.

返回

Interval

The nearest and farthest distances on the bounding box from position in direction.


computeCorners()

computeCorners(result?: Cartesian3[]): Cartesian3[]

Computes the eight corners of an oriented bounding box. The corners are ordered by (-X, -Y, -Z), (-X, -Y, +Z), (-X, +Y, -Z), (-X, +Y, +Z), (+X, -Y, -Z), (+X, -Y, +Z), (+X, +Y, -Z), (+X, +Y, +Z).

参数

result?

Cartesian3[]

An array of eight Cartesian3 instances onto which to store the corners.

返回

Cartesian3[]

The modified result parameter or a new array if none was provided.


computeTransformation()

computeTransformation(result: Matrix4): Matrix4

Computes a transformation matrix from an oriented bounding box.

参数

result

Matrix4

The object onto which to store the result.

返回

Matrix4

The modified result parameter or a new Matrix4 instance if none was provided.


isOccluded()

isOccluded(occluder: Occluder): boolean

Determines whether or not a bounding box is hidden from view by the occluder.

参数

occluder

Occluder

The occluder.

返回

boolean

true if the sphere is not visible; otherwise false.


clone()

clone(result?: OrientedBoundingBox): OrientedBoundingBox

Duplicates this OrientedBoundingBox instance.

参数

result?

OrientedBoundingBox

The object onto which to store the result.

返回

OrientedBoundingBox

The modified result parameter or a new OrientedBoundingBox instance if one was not provided.


equals()

equals(right?: OrientedBoundingBox): boolean

Compares this OrientedBoundingBox against the provided OrientedBoundingBox componentwise and returns <code>true</code> if they are equal, <code>false</code> otherwise.

参数

right?

OrientedBoundingBox

The right hand side OrientedBoundingBox.

返回

boolean

true if they are equal, false otherwise.

构造函数

构造函数

new OrientedBoundingBox(center?: Cartesian3, halfAxes?: Matrix3): OrientedBoundingBox

参数

center?

Cartesian3

halfAxes?

Matrix3

返回

OrientedBoundingBox

KBE3D @3.0.0 Copyright © 2024-present KBE3D