API Docs for:
Show:

geo Class

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

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:570

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:619

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:646

test a Sphere against the frustum

Parameters:

  • center Vec3

    sphere center

  • radius Number

    sphere radius

Returns:

Enum:

CLIP_INSIDE, CLIP_OVERLAP, CLIP_OUTSIDE

project2DPointOnLine

(
  • P
  • A
  • B
  • result
)
Vec2

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

Projects a 2D point on a 2D line

Parameters:

  • P Vec2
  • A Vec2

    line start

  • B Vec2

    line end

  • result Vec2

    to store result (optional)

Returns:

Vec2:

projectec point

projectPointOnLine

(
  • P
  • A
  • B
  • result
)
Vec3

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

Projects a 3D point on a 3D line

Parameters:

  • P Vec3
  • A Vec3

    line start

  • B Vec3

    line end

  • result Vec3

    to store result (optional)

Returns:

Vec3:

projectec point

projectPointOnPlane

(
  • point
  • P
  • N
  • result
)
Vec3

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

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:114

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:455

test if a BBox overlaps another BBox

Parameters:

Returns:

Boolean:

true if it overlaps

testPoint2DInPolygon

(
  • poly
  • point
)
Boolean

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

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:440

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:408

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 in world space unless in_local is true

Returns:

Boolean:

returns if the ray collides the box

testRayBox

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

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

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:132

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
  • center
  • radius
  • result
  • max_dist
)
Boolean

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

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

testRaySphere

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

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

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

testSegmentPlane

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

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

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:487

test if a sphere overlaps a BBox

Parameters:

  • point Vec3
  • radius Float
  • bounding_box BBox

Returns:

Boolean:

true if it overlaps