UpdateCallback

typealias UpdateCallback = (particle: Particle, dt: Double) -> Unit(source)

A function used to modify attributes of the particle at each time step. This can include force modifications, color, sizing, etc.

function applyGravity(particle, dt) {
const position = particle.position;
const gravityVector = Cartesian3.normalize(position, new Cartesian3());
Cartesian3.multiplyByScalar(gravityVector, GRAVITATIONAL_CONSTANT * dt, gravityVector);
particle.velocity = Cartesian3.add(particle.velocity, gravityVector, particle.velocity);
}

Parameters

particle

The particle being updated.

dt

The time in seconds since the last update.

See also