API Docs for:
Show:

geo Class

Defined in: ../src/geo.js:11
Module: GL

Computational geometry algorithms, is a static class

Methods

createPlane

(
  • P
  • N
)
Vec4

Defined in ../src/geo.js:18

Returns a float4 containing the info about a plane with normal N and that passes through point P

Parameters:

  • P Vec3
  • N Vec3

Returns:

Vec4:

plane values

distance2PointToPlane

(
  • point
  • plane
)
Number

Defined in ../src/geo.js:42

Computes the square distance between the point and the plane

Parameters:

  • point Vec3
  • plane Vec4

Returns:

Number:

distance*distance

distancePointToPlane

(
  • point
  • plane
)
Number

Defined in ../src/geo.js:30

Computes the distance between the point and the plane

Parameters:

  • point Vec3
  • plane Vec4

Returns:

Number:

distance

extractPlanes

(
  • viewprojection
)
Float32Array

Defined in ../src/geo.js:512

extract frustum planes given a view-projection matrix

Parameters:

  • viewprojection Mat4

    matrix

Returns:

Float32Array:

returns all 6 planes in a float32array[24]

frustumTestBox

(
  • planes
  • boundindbox
)
Enum

Defined in ../src/geo.js:561

test a BBox against the frustum

Parameters:

  • planes Float32Array

    frustum planes

  • boundindbox BBox

    in BBox format

Returns:

Enum:

CLIP_INSIDE, CLIP_OVERLAP, CLIP_OUTSIDE

frustumTestSphere

(
  • center
  • radius
)
Enum

Defined in ../src/geo.js:588

test a Sphere against the frustum

Parameters:

  • center Vec3

    sphere center

  • radius Number

    sphere radius

Returns:

Enum:

CLIP_INSIDE, CLIP_OVERLAP, CLIP_OUTSIDE

projectPointOnPlane

(
  • point
  • P
  • N
  • result
)
Vec3

Defined in ../src/geo.js:54

Projects point on plane

Parameters:

  • point Vec3
  • P Vec3

    plane point

  • N Vec3

    plane normal

  • result Vec3

    to store result (optional)

Returns:

Vec3:

projectec point

reflectPointInPlane

(
  • point
  • P
  • N
)
Vec3

Defined in ../src/geo.js:71

Finds the reflected point over a plane (useful for reflecting camera position when rendering reflections)

Parameters:

  • point Vec3

    point to reflect

  • P Vec3

    point where the plane passes

  • N Vec3

    normal of the plane

Returns:

Vec3:

reflected point

testBBoxBBox

(
  • a
  • b
)
Boolean

Defined in ../src/geo.js:397

test if a BBox overlaps another BBox

Parameters:

Returns:

Boolean:

true if it overlaps

testPoint2DInPolygon

(
  • poly
  • point
)
Boolean

Defined in ../src/geo.js:623

test if a 2d point is inside a 2d polygon

Parameters:

  • poly Array

    array of 2d points

  • point Vec2

Returns:

Boolean:

true if it is inside

testPointBBox

(
  • point
  • bbox
)
Boolean

Defined in ../src/geo.js:382

test if a 3d point is inside a BBox

Parameters:

  • point Vec3
  • bbox BBox

Returns:

Boolean:

true if it is inside

testRayBBox

(
  • start
  • direction
  • box
  • model
  • result
)
Boolean

Defined in ../src/geo.js:354

test a ray bounding-box collision, it uses the BBox class and allows to use non-axis aligned bbox

Parameters:

  • start Vec3

    ray start

  • direction Vec3

    ray direction

  • box BBox

    in BBox format

  • model Mat4

    transformation of the BBox

  • result Vec3

    collision position

Returns:

Boolean:

returns if the ray collides the box

testRayBox

(
  • start
  • direction
  • minB
  • maxB
  • result
)
Boolean

Defined in ../src/geo.js:277

test a ray bounding-box collision and retrieves the collision point, the BB must be Axis Aligned

Parameters:

  • start Vec3

    ray start

  • direction Vec3

    ray direction

  • minB Vec3

    minimum position of the bounding box

  • maxB Vec3

    maximim position of the bounding box

  • result Vec3

    collision position

Returns:

Boolean:

returns if the ray collides the box

testRayPlane

(
  • start
  • direction
  • P
  • N
  • result
)
Boolean

Defined in ../src/geo.js:89

test a ray plane collision and retrieves the collision point

Parameters:

  • start Vec3

    ray start

  • direction Vec3

    ray direction

  • P Vec3

    point where the plane passes

  • N Vec3

    normal of the plane

  • result Vec3

    collision position

Returns:

Boolean:

returns if the ray collides the plane or the ray is parallel to the plane

testRaySphere

(
  • start
  • direction
  • p
  • q
  • r
  • result
)
Boolean

Defined in ../src/geo.js:191

test a ray cylinder collision and retrieves the collision point

Parameters:

  • start Vec3

    ray start

  • direction Vec3

    ray direction

  • p Vec3

    center of the cylinder

  • q Number

    height of the cylinder

  • r Number

    radius of the cylinder

  • result Vec3

    collision position

Returns:

Boolean:

returns if the ray collides the cylinder

testRaySphere

(
  • start
  • direction
  • center
  • radius
  • result
  • max_dist
)
Boolean

Defined in ../src/geo.js:144

test a ray sphere collision and retrieves the collision point

Parameters:

  • start Vec3

    ray start

  • direction Vec3

    ray direction (normalized)

  • center Vec3

    center of the sphere

  • radius Number

    radius of the sphere

  • result Vec3

    collision position

  • max_dist Number

    not fully tested

Returns:

Boolean:

returns if the ray collides the sphere

testSegmentPlane

(
  • start
  • end
  • P
  • N
  • result
)
Boolean

Defined in ../src/geo.js:113

test collision between segment and plane and retrieves the collision point

Parameters:

  • start Vec3

    segment start

  • end Vec3

    segment end

  • P Vec3

    point where the plane passes

  • N Vec3

    normal of the plane

  • result Vec3

    collision position

Returns:

Boolean:

returns if the segment collides the plane or it is parallel to the plane

testSphereBBox

(
  • point
  • radius
  • bounding_box
)
Boolean

Defined in ../src/geo.js:429

test if a sphere overlaps a BBox

Parameters:

  • point Vec3
  • radius Float
  • bounding_box BBox

Returns:

Boolean:

true if it overlaps