AURA

JSGG

AuraJS
DOCSEXAMPLESGITHUB
06 Math, Colors, Vectors, Timers, Collision, Collision3D, and ECS
Math helpers, colors, vector types, timers, collision, collision3d, and ECS surfaces.
docs/external/game-dev-api/06-math-colors-vectors-timers-collision-and-ecs.md

Math, Colors, Vectors, Timers, Collision, Collision3D, and ECS

These are the small, high-frequency helpers most games and agents use constantly.

`aura.math`

Methods and constants:

  • lerp(a, b, t)
  • clamp(value, min, max)
  • random()
  • random(max)
  • random(min, max)
  • distance(x1, y1, x2, y2)
  • angle(x1, y1, x2, y2)
  • PI
  • TAU

Alias helpers:

  • aura.math.vec2 === aura.vec2
  • aura.math.vec3 === aura.vec3

Color constructors and constants

Canonical color helpers:

  • aura.rgb(r, g, b)
  • aura.rgba(r, g, b, a)
  • aura.Color.RED
  • aura.Color.GREEN
  • aura.Color.BLUE
  • aura.Color.WHITE
  • aura.Color.BLACK
  • aura.Color.YELLOW
  • aura.Color.CYAN
  • aura.Color.MAGENTA
  • aura.Color.TRANSPARENT

Compatibility aliases still seen in older code/docs:

  • aura.color(...)
  • aura.colors.*

New code should prefer rgb, rgba, and Color.*.

`aura.vec2`

Constructor and pure helpers:

  • aura.vec2(x, y)
  • aura.vec2.add(a, b)
  • aura.vec2.sub(a, b)
  • aura.vec2.scale(v, s)
  • aura.vec2.dot(a, b)
  • aura.vec2.length(v)
  • aura.vec2.normalize(v)
  • aura.vec2.distance(a, b)
  • aura.vec2.lerp(a, b, t)

`aura.vec3`

Constructor and pure helpers:

  • aura.vec3(x, y, z)
  • aura.vec3.add(a, b)
  • aura.vec3.sub(a, b)
  • aura.vec3.scale(v, s)
  • aura.vec3.dot(a, b)
  • aura.vec3.cross(a, b)
  • aura.vec3.length(v)
  • aura.vec3.normalize(v)
  • aura.vec3.distance(a, b)
  • aura.vec3.lerp(a, b, t)

`aura.timer`

Timer/time helpers:

  • after(delay, callback)
  • every(interval, callback)
  • cancel(timerId)
  • getDelta()
  • getTime()

Use cases:

  • delayed actions
  • repeated gameplay timers
  • time sampling inside update logic

`aura.collision`

Primitive collision checks:

  • rectRect(a, b)
  • rectPoint(rect, point)
  • circleCircle(a, b)
  • circlePoint(circle, point)
  • circleRect(circle, rect)

Batch helpers:

  • rectRectBatch(...)
  • rectPointBatch(...)
  • circleCircleBatch(...)
  • circlePointBatch(...)
  • circleRectBatch(...)

Use cases:

  • arcade hit checks
  • deterministic batch overlap probes
  • quick gameplay collision without a full physics world

`aura.collision3d`

3D collision helpers:

  • boxBox(a, b)
  • boxBoxContact(a, b)
  • sphereSphere(a, b)
  • sphereBox(sphere, box)
  • sphereBoxContact(sphere, box)
  • raySphere(ray, sphere)
  • raySphereHit(ray, sphere)
  • rayBox(ray, box)
  • rayBoxHit(ray, box)
  • pointBox(point, box)
  • pointSphere(point, sphere)
  • spherePlane(sphere, plane)
  • rayPlane(ray, plane)
  • rayPlaneHit(ray, plane)
  • rayTriangle(ray, v0, v1, v2)
  • capsuleCapsule(aStart, aEnd, aRadius, bStart, bEnd, bRadius)
  • closestPoint(shape, point)
  • sphereCast(start, end, radius, target)
  • movingBoxBox(a, velocityA, b, velocityB, dt)

Return-shape notes:

  • overlap checks return boolean
  • the older boolean probes remain raySphere(...), rayBox(...), rayPlane(...), sphereBox(...), and boxBox(...)
  • raySphereHit(...), rayBoxHit(...), rayPlaneHit(...), and rayTriangle(...) return false on miss or invalid input, or { hit: true, t, point, normal } on hit
  • sphereBoxContact(...) and boxBoxContact(...) return false on miss or invalid input, or { hit: true, depth, point, normal } on hit
  • capsuleCapsule(...), sphereCast(...), and movingBoxBox(...) return false on miss or invalid input
  • successful sweep-style hits return { hit: true, toi, point, normal } where toi is the normalized hit fraction in [0, 1] over the authored sweep interval

Use cases:

  • simple 3D overlap checks without spinning up a full aura.physics3d world
  • editor/tooling probes
  • deterministic geometry intersection helpers
  • common gameplay sweeps such as projectile volumes, soft camera probes, and moving AABB checks without requiring physics bodies

`aura.ecs`

ECS-lite helper namespace:

  • createEntity()
  • removeEntity(entityId)
  • addComponent(entityId, componentName, value)
  • getComponent(entityId, componentName)
  • system(name, fn, order?)
  • run(dt)

Notes:

  • This is an opt-in deterministic helper, not a replacement for the host loop.
  • A common pattern is calling aura.ecs.run(dt) from aura.update(dt).
DOCUMENT REFERENCE
docs/external/game-dev-api/06-math-colors-vectors-timers-collision-and-ecs.md
AURAJS
Cmd/Ctrl+K
aurajsgg