VoxelRayTrace
in package
Table of Contents
- betweenPoints() : Generator|array<string|int, Vector3>
- Performs a ray trace between the start and end coordinates. This returns a Generator which yields Vector3s containing the coordinates of voxels it passes through.
- inDirection() : Generator|array<string|int, Vector3>
- Performs a ray trace from the start position in the given direction, for a distance of $maxDistance. This returns a Generator which yields Vector3s containing the coordinates of voxels it passes through.
- __construct() : mixed
- rayTraceDistanceToBoundary() : float
- Returns the distance that must be travelled on an axis from the start point with the direction vector component to cross a block boundary.
Methods
betweenPoints()
Performs a ray trace between the start and end coordinates. This returns a Generator which yields Vector3s containing the coordinates of voxels it passes through.
public
static betweenPoints(Vector3 $start, Vector3 $end) : Generator|array<string|int, Vector3>
This is an implementation of the algorithm described in the link below.
Parameters
Tags
Return values
Generator|array<string|int, Vector3> —inDirection()
Performs a ray trace from the start position in the given direction, for a distance of $maxDistance. This returns a Generator which yields Vector3s containing the coordinates of voxels it passes through.
public
static inDirection(Vector3 $start, Vector3 $directionVector, float $maxDistance) : Generator|array<string|int, Vector3>
Parameters
Tags
Return values
Generator|array<string|int, Vector3> —__construct()
private
__construct() : mixed
Return values
mixed —rayTraceDistanceToBoundary()
Returns the distance that must be travelled on an axis from the start point with the direction vector component to cross a block boundary.
private
static rayTraceDistanceToBoundary(float $s, float $ds) : float
For example, given an X coordinate inside a block and the X component of a direction vector, will return the distance travelled by that direction component to reach a block with a different X coordinate.
Find the smallest positive t such that s+t*ds is an integer.
Parameters
- $s : float
-
Starting coordinate
- $ds : float
-
Direction vector component of the relevant axis
Return values
float —Distance along the ray trace that must be travelled to cross a boundary.