Vertex Viewer SDK
    Preparing search index...

    Class DepthBuffer

    A DepthBuffer represents the depth information for a rendered frame. This depth information can be used for checking if a world point is occluded by geometry or getting a world position from a 2D viewport point without having to do a server call.

    A depth buffer is represented by a 16-bit typed array, where each value is a relative distance between the camera's near and far planes.

    Implements

    • FrameImageLike
    Index

    Constructors

    Properties

    The camera data that generated this depth buffer.

    imageAttr: ImageAttributesLike

    The attributes of the depth buffer image.

    pixels: Uint16Array

    A 16-bit typed array of depth values.

    MAX_DEPTH_VALUE: number = ...

    A constant that specifies the maximum depth value that can be represented by a depth buffer.

    Methods

    • Computes the depth from a 2D point within the coordinate space of the depth buffer.

      For perspective cameras, the returned depth is a value that's between the near and far planes of the camera.

      For orthographic cameras, the returned depth is a value that's between 0 and the distance between the near and far planes of the camera.

      Parameters

      • point: Point.Point

        A 2D point within the viewport.

      • OptionalfallbackNormalizedDepth: number

        A fallback value if the depth is the max depth value, or cannot be determined.

      Returns number

      The depth at the point.

    • Computes the maximum depth of visible geometry within the coordinate space of the depth buffer.

      For perspective cameras, the maximum depth is the magnitude of the far plane of the camera.

      For orthographic cameras, the maximum depth is the distance between the near and far planes of the camera.

      Returns number

      The maximum depth of visible geometry.

    • Computes a depth from a 2D point within the coordinate space of the frame. The returned depth is a normalized value ([0, 1]) between the near and far plane.

      Parameters

      • point: Point.Point

        A 2D point within the frame.

      • OptionalfallbackNormalizedDepth: number

        A fallback value if the depth is the max depth value, or cannot be determined.

      Returns number

      A depth between 0 and 1.

    • Computes a 3D point in world space coordinates from the depth value at the given pixel and ray.

      Parameters

      • point: Point.Point

        A pixel to use for reading a depth value.

      • ray: Ray

        A ray that specifies the origin and direction.

      • OptionalfallbackNormalizedDepth: number

        A fallback value if the depth is the max depth value, or cannot be determined.

      Returns Vector3.Vector3

      A point in world space coordinates.

    • Returns true if the point is in front of the far plane and the point is inside the frame. This method is useful for checking if geometry exists at a given 2D coordinate.

      Parameters

      Returns boolean

      true if point is in front of far plane.

    • Creates a DepthBuffer from a decoded PNG.

      Parameters

      • png: Pick<DecodedPng, "data">

        An object containing the width, height and raw PNG data.

      • camera: FrameCameraBase

        The camera that generated the depth buffer image.

      • imageAttr: ImageAttributesLike

        The attributes of the depth buffer image.

      Returns DepthBuffer

      A depth buffer.

      If the PNG is not a single channel, 16-bit image.