GitHub repository

Body

Bodies are very simple. They are just the AraraJS way of outputting animated signals. In case you are interested in the speed in which your signal is changing, for example, you can access the velocity and acceleration properties of the Body object.

type Body = {
  position: number
  velocity: number
  acceleration: number
}

2D and 3D variants Section titled 2D and 3D variants

For your convenience, AraraJS provides primitives for 2D and 3D animations as well. For example createSpring2D will return an accessor for a Body2D

const [body2d] = createSineWave2D({
  phase: [Math.PI / 2, 0],
})

The 2D and 3D variants use vectors from the gl-matrix library.

These types vec2 and vec3 are exposed to you by directly importing from AraraJS.

import { vec2, vec3 } from 'ararajs'
// Equilalent to
import { vec2, vec3 } from 'gl-matrix'


type Body2D = {
  position: vec2
  velocity: vec2
  acceleration: vec2
}

type Body3D = {
  position: vec3
  velocity: vec3
  acceleration: vec3
}