Class Raycaster

Hierarchy

  • Raycaster

Constructors

  • This creates a new raycaster object.

    Parameters

    • Optional origin: THREE.Vector3

      The origin vector where the ray casts from.

    • Optional direction: THREE.Vector3

      The direction vector that gives direction to the ray. Should be normalized.

    • Optional near: number

      All results returned are further away than near. Near can't be negative. Default value is 0.

    • Optional far: number

      All results returned are closer then far. Far can't be lower then near . Default value is Infinity.

    Returns THREE.Raycaster

Properties

camera: THREE.Camera

The camera to use when raycasting against view-dependent objects such as billboarded objects like Sprites. This field can be set manually or is set when calling "setFromCamera".

far: number

The far factor of the raycaster. This value indicates which objects can be discarded based on the distance. This value shouldn't be negative and should be larger than the near property.

Default

Infinity

layers: Layers

Used by Raycaster to selectively ignore 3D objects when performing intersection tests.

Default

new THREE.Layers()

near: number

The near factor of the raycaster. This value indicates which objects can be discarded based on the distance. This value shouldn't be negative and should be smaller than the far property.

Default

0

Default

ray: Ray

The Ray used for the raycasting.

Methods

  • Checks all intersection between the ray and the object with or without the descendants. Intersections are returned sorted by distance, closest first.

    Type Parameters

    Parameters

    • object: Object3D<Event>

      The object to check for intersection with the ray.

    • Optional recursive: boolean

      If true, it also checks all descendants. Otherwise it only checks intersecton with the object. Default is true.

    • Optional optionalTarget: Intersection<TIntersected>[]

      (optional) target to set the result. Otherwise a new Array is instantiated. If set, you must clear this array prior to each call (i.e., array.length = 0;).

    Returns Intersection<TIntersected>[]

  • Checks all intersection between the ray and the objects with or without the descendants. Intersections are returned sorted by distance, closest first. Intersections are of the same form as those returned by .intersectObject.

    Type Parameters

    Parameters

    • objects: Object3D<Event>[]

      The objects to check for intersection with the ray.

    • Optional recursive: boolean

      If true, it also checks all descendants of the objects. Otherwise it only checks intersecton with the objects. Default is true.

    • Optional optionalTarget: Intersection<TIntersected>[]

      (optional) target to set the result. Otherwise a new Array is instantiated. If set, you must clear this array prior to each call (i.e., array.length = 0;).

    Returns Intersection<TIntersected>[]

  • Updates the ray with a new origin and direction.

    Parameters

    • origin: THREE.Vector3

      The origin vector where the ray casts from.

    • direction: THREE.Vector3

      The normalized direction vector that gives direction to the ray.

    Returns void

  • Updates the ray with a new origin and direction.

    Parameters

    • coords: {
          x: number;
          y: number;
      }

      2D coordinates of the mouse, in normalized device coordinates (NDC)---X and Y components should be between -1 and 1.

      • x: number
      • y: number
    • camera: THREE.Camera

      camera from which the ray should originate

    Returns void

Generated using TypeDoc