import { UINT16_MAX } from "../../../../../../core/binary/UINT16_MAX.js";
import { PARTICLE_ATTRIBUTE_UV } from "./PARTICLE_ATTRIBUTES.js";

/**
 *
 * @param {AtlasPatch} patch
 * @param {ParticlePool} particles
 * @param {number} ref
 */
export function write_particle_patch_uv(patch, particles, ref) {
    const uv = patch.uv;

    const uv_position = uv.position;

    const u0 = uv_position.x;
    const v0 = uv_position.y;

    const uv_size = uv.size;

    const u1 = uv_size.x;
    const v1 = uv_size.y;

    particles.writeAttributeVector4(
        ref,
        PARTICLE_ATTRIBUTE_UV,
        u0 * UINT16_MAX, v0 * UINT16_MAX, u1 * UINT16_MAX, v1 * UINT16_MAX
    );
}