UNPKG

@itwin/core-common

Version:

iTwin.js components common to frontend and backend

84 lines 5.17 kB
/** @packageDocumentation * @module Geometry */ import { ClipPlane, Point3d, Vector3d } from "@itwin/core-geometry"; import { Frustum } from "../Frustum"; import { BoundingSphere } from "./BoundingSphere"; /** Represents a the planes of a [[Frustum]] for testing containment and intersection. * A valid frustum produces six planes. A degenerate frustum produces zero planes. * @public * @extensions */ export declare class FrustumPlanes { private _planes; private constructor(); /** Compute the six planes of the specified frustum. * If the frustum is degenerate - that is, its points do not represent a truncated pyramid - then the returned `FrustumPlanes` will contain zero planes. * @note This method assumes that the front plane is parallel to the back plane. * @see [[isValid]] to test this condition. */ static fromFrustum(frustum: Frustum): FrustumPlanes; /** Create an empty set of frustum planes. [[isValid]] will be `true`. This can be useful when you want to create a `FrustumPlanes` object and initialize it later via [[init]] - * for example, if you intend to use the same object repeatedly with different [[Frustum]]s. */ static createEmpty(): FrustumPlanes; /** Returns true if [[planes]] consists of six planes. This may return `false` if a degenerate [[Frustum]] was supplied to [[fromFrustum]], or if this object was created * via [[createEmpty]] - in either case, [[planes]] will be an empty array. */ get isValid(): boolean; /** Obtain the list of planes defining the frustum. If [[isValid]] is `true`, it will have a length of six, with the planes ordered as * right, left, top, bottom, back, front. Otherwise, it will be empty. */ get planes(): ClipPlane[]; /** Recompute the planes from the specified frustum. * @returns true upon success, or false if the input frustum was degenerate, in which case [[isValid]] will be `false`. * @note This method assumes that the front plane is parallel to the back plane. */ init(frustum: Frustum): boolean; /** Compute to what degree a [[Frustum]] is contained with these frustum planes. * @param box The frustum to test for containment. * @param sphere An optional spherical bounding volume fully containing `box`. If supplied, this can reduce the amount of computation required. * @returns the degree to which `box` is contained within the clipping planes. */ computeFrustumContainment(box: Frustum, sphere?: BoundingSphere): FrustumPlanes.Containment; /** Determines whether a [[Frustum]] intersects with or is fully contained within these frustum planes. * @param box The frustum to test for containment. * @param sphere An optional spherical bounding volume fully containing `box`. If supplied, this can reduce the amount of computation required. * @returns true if `box` is not entirely outside of the clipping planes. */ intersectsFrustum(box: Frustum, sphere?: BoundingSphere): boolean; /** Determines whether a point is contained within these frustum planes. * @param point The point to test for containment. * @param tolerance The maximum distance from the interior of the frustum planes that will still be considered "contained". * @returns true if `point` is no further than `tolerance` meters outside of the clipping planes. */ containsPoint(point: Point3d, tolerance?: number): boolean; /** Compute the degree to which a set of points is contained within these frustum planes. * @param points The points to test for containment. * @param sphere An optional spherical bounding volume fully containing all of the points. If supplied, this can reduce the amount of computation required. * @param tolerance The maximum distance from the interior of the frustum planes a point must be to be considered "contained". * @returns the degree to which all of the points are contained within the clipping planes. */ computeContainment(points: Point3d[], sphere?: BoundingSphere, tolerance?: number): FrustumPlanes.Containment; /** Computes whether a ray intersects these clipping planes. * @param origin The origin of the ray. * @param direction The direction of the ray. * @returns true if the ray extending from `origin` in the specified `direction` intersects at least one of the clipping planes. */ intersectsRay(origin: Point3d, direction: Vector3d): boolean; } /** @public @extensions */ export declare namespace FrustumPlanes { /** Describes the degree to which an object is contained within the planes of a [[Frustum]]. * @see [[FrustumPlanes.computeContainment]], for example. */ enum Containment { /** The object is entirely outside of the frustum, intersecting none of its planes. */ Outside = 0, /** The object intersects at least one of the frustum planes. placing it partially inside of the frustum. */ Partial = 1, /** The object is entirely inside of the frustum, intersecting none of its planes. */ Inside = 2 } } //# sourceMappingURL=FrustumPlanes.d.ts.map