import { EmissionShapeType } from "./EmissionShapeType.js";
import { randomPointInPoint } from "../../../../../../core/geom/random/randomPointInPoint.js";
import { EmissionFromType } from "./EmissionFromType.js";
import { randomPointInSphere } from "../../../../../../core/geom/random/randomPointInSphere.js";
import { randomPointOnSphere } from "../../../../../../core/geom/random/randomPointOnSphere.js";
import { randomPointInBox } from "../../../../../../core/geom/random/randomPointInBox.js";
import { randomPointOnBox } from "../../../../../../core/geom/random/randomPointOnBox.js";

/**
 *
 * @param {EmissionFromType} emissionType
 * @param {EmissionShapeType} emissionShape
 * @returns {function(random: function, result:(number[]|Float32Array|Float64Array), result_offset:number):void}
 */
export function computeEmissionFunction(emissionType, emissionShape) {
    if (emissionShape === EmissionShapeType.Point) {
        return randomPointInPoint;
    } else if (emissionShape === EmissionShapeType.Sphere) {
        if (emissionType === EmissionFromType.Volume) {
            return randomPointInSphere;
        } else if (emissionType === EmissionFromType.Shell) {
            return randomPointOnSphere;
        } else {
            throw new TypeError('Unsupported EmissionFrom Type');
        }
    } else if (emissionShape === EmissionShapeType.Box) {
        if (emissionType === EmissionFromType.Volume) {
            return randomPointInBox;
        } else if (emissionType === EmissionFromType.Shell) {
            return randomPointOnBox;
        } else {
            throw new TypeError('Unsupported EmissionFrom Type');
        }
    } else {
        throw new TypeError('Unsupported emission shape');
    }
}
