RSX Code Reference
    Preparing search index...

    Class Sphere

    The Sphere implements a sphere represented by a center point and a radius. The class follows the 'copy-on-write' pattern, which means that every operation returns a copy of the sphere with updates values. It also implies that the values of the sphere cannot be directly modified.

    The concept of immutability improves sharing of objects as all types in TypeScript are assigned by identity, instead of by-value (e.g. a copy) as in other programming languages like C.

    Index
    _center: Vector3
    _radius: number
    • get radius(): number

      Returns number

    • set radius(value: number): void

      Parameters

      • value: number

      Returns void

    • Copies all properties defined by the prototype of Sphere from other to this instance.

      Parameters

      Returns Sphere

    • Clones this instance and returns a new Sphere with identical values.

      Returns Sphere

    • Test for intersection with a ray.

      Parameters

      • ray: Immutable<Ray>

        The ray to test for intersection.

      • discardInside: boolean

        Whether the ray should immediately return with a value of 0 if inside.

      Returns number

      The first positive intersection time along the ray, if any intersection. -1 otherwise.

    • Transforms the sphere by the given affine matrix. The center is transformed by the matrix and the radius is scaled by the maximum axis scale.

      Parameters

      • transformMatrix: Immutable<Matrix4>

        Affine matrix to transform the sphere with.

      Returns Sphere

      A new sphere with the transformed center and radius.

    • Creates a new sphere with the given parameters.

      Parameters

      • position: Vector3

        The center of the sphere.

      • radius: number

        The radius of the sphere.

      Returns Sphere

      The newly constructed sphere.