Finds the next octant that intersects with the ray based on the exit plane of
the current one.

@private
@param {Number} currentOctant - The index of the current octant.
@param {Number} tx1 - Ray projection parameter.
@param {Number} ty1 - Ray projection parameter.
@param {Number} tz1 - Ray projection parameter.
@return {Number} The index of the next octant that the ray travels through.
function findNextOctant(currentOctant, tx1, ty1, tz1) {

	let min;
	let exit = 0;

	// Find the exit plane.
	if(tx1 < ty1) {

		min = tx1;
		exit = 0; // YZ-plane.

	} else {

		min = ty1;
		exit = 1; // XZ-plane.

	}

	if(tz1 < min) {

		exit = 2; // XY-plane.

	}

	return octantTable[currentOctant][exit];

}