export function createVector3(value = {}) {
    return {
        x: value.x ?? 0,
        y: value.y ?? 0,
        z: value.z ?? 0,
    };
}
export function cloneVector3(value) {
    return { x: value.x, y: value.y, z: value.z };
}
export function addScaledVector3(target, source, scale) {
    target.x += source.x * scale;
    target.y += source.y * scale;
    target.z += source.z * scale;
}
export function setVector3(target, source) {
    target.x = source.x;
    target.y = source.y;
    target.z = source.z;
}
export function createColor(value = {}) {
    return {
        r: value.r ?? 1,
        g: value.g ?? 1,
        b: value.b ?? 1,
        a: value.a ?? 1,
    };
}
export function cloneColor(value) {
    return { r: value.r, g: value.g, b: value.b, a: value.a };
}
export function createParticle(initial = {}) {
    if ((initial.lifetime ?? 1) <= 0) {
        throw new RangeError("Particle lifetime must be greater than zero.");
    }
    const position = createVector3(initial.position);
    return {
        id: initial.id ?? 0,
        age: initial.age ?? 0,
        lifetime: initial.lifetime ?? 1,
        position,
        previousPosition: cloneVector3(position),
        velocity: createVector3(initial.velocity),
        acceleration: createVector3(initial.acceleration),
        color: createColor(initial.color),
        size: initial.size ?? 1,
        rotation: initial.rotation ?? 0,
        angularVelocity: initial.angularVelocity ?? 0,
        alive: initial.alive ?? true,
        userData: { ...(initial.userData ?? {}) },
    };
}
export function normalizedParticleAge(particle) {
    return particle.lifetime <= 0 ? 1 : Math.min(Math.max(particle.age / particle.lifetime, 0), 1);
}
//# sourceMappingURL=Particle.js.map