UpdateCallback
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);
}
Content copied to clipboard
Parameters
particle
The particle being updated.
dt
The time in seconds since the last update.