pub struct Raycaster {
pub ray: Ray,
pub near: f64,
pub far: f64,
pub camera: Option<RaycasterCamera>,
pub layers: Layers,
pub params: RaycasterParams,
}Expand description
Raycaster — picks the objects a ray passes through.
Fields§
§ray: Rayraycaster.ray — its direction is assumed normalised.
near: f64raycaster.near — hits closer than this are dropped. Default 0.
far: f64raycaster.far — hits farther than this are dropped. Default ∞.
camera: Option<RaycasterCamera>raycaster.camera, set by set_from_camera:
null until then. See RaycasterCamera for why it is a copy.
layers: Layersraycaster.layers — an object is only tested when its layers share one
with these, though its children are still visited.
params: RaycasterParamsraycaster.params.
Implementations§
Source§impl Raycaster
impl Raycaster
Sourcepub fn new(origin: Vector3, direction: Vector3, near: f64, far: f64) -> Self
pub fn new(origin: Vector3, direction: Vector3, near: f64, far: f64) -> Self
new Raycaster( origin, direction, near, far ).
Sourcepub fn set(&mut self, origin: &Vector3, direction: &Vector3)
pub fn set(&mut self, origin: &Vector3, direction: &Vector3)
raycaster.set( origin, direction ) — direction is assumed
normalised, for accurate distances.
Sourcepub fn set_from_camera(&mut self, coords: &Vector2, camera: &impl RenderCamera)
pub fn set_from_camera(&mut self, coords: &Vector2, camera: &impl RenderCamera)
raycaster.setFromCamera( coords, camera ) — a ray from the camera
through coords, in normalised device coordinates (-1 … 1 on both
axes, y up).
Sourcepub fn intersect_object(
&self,
object: &ObjectRef,
recursive: bool,
) -> Vec<Intersection>
pub fn intersect_object( &self, object: &ObjectRef, recursive: bool, ) -> Vec<Intersection>
raycaster.intersectObject( object, recursive ) — every hit on
object, and on its descendants when recursive (three’s default),
nearest first.
Sourcepub fn intersect_objects(
&self,
objects: &[ObjectRef],
recursive: bool,
) -> Vec<Intersection>
pub fn intersect_objects( &self, objects: &[ObjectRef], recursive: bool, ) -> Vec<Intersection>
raycaster.intersectObjects( objects, recursive ).