/*!
 * Copyright (c) 2026 Vertex Software LLC. All rights reserved.
 */
import { v as vector3, a as angle, q as quaternion, h as euler, m as matrix4 } from './bundle-DfdVaPrt.js';

/**
 * Converts an array of points to an array of numbers
 * @param arr The array to convert
 * @returns The given array as an array of numbers
 */
function flattenPointArray(arr) {
    return arr.reduce((res, pt) => [...res, pt.x, pt.y], []);
}
/**
 * Converts the rotation vector of a Transform from degrees to radians
 * @param transform The Transform to convert
 * @returns The Transform where the rotation matrix is in terms of radians
 */
function toRadiansTransform(transform) {
    const { position, rotation: r, scale } = transform;
    const rotation = vector3.create(angle.toRadians(r.x), angle.toRadians(r.y), angle.toRadians(r.z));
    return { position, rotation, scale };
}
/**
 * Converts the rotation vector of a Transform from radians to degrees
 * @param transform The Transform to convert
 * @returns The Transform where the rotation matrix is in terms of degrees
 */
function toDegreesTransform(transform) {
    const { position, rotation: r, scale } = transform;
    const rotation = vector3.create(angle.toDegrees(r.x), angle.toDegrees(r.y), angle.toDegrees(r.z));
    return { position, rotation, scale };
}
/**
 * Converts a Transform to a Matrix4 transform
 * @param transform The Transform to convert
 * @returns The transform as a Matrix4
 */
function toMatrix(transform) {
    const { position: t, rotation, scale } = transform;
    const r = quaternion.fromEuler(euler.create(rotation));
    const s = vector3.create(scale, scale, scale);
    return matrix4.makeTRS(t, r, s);
}
/**
 * Converts a Matrix4 transform to a Transform
 * @param matrix The Matrix4 transform to convert
 * @returns The transform as a Transform
 */
function toTransform(matrix) {
    const position = vector3.fromMatrixPosition(matrix);
    const rotation = euler.fromRotationMatrix(matrix);
    const { x: scale } = vector3.fromMatrixScale(matrix);
    return { position, rotation, scale };
}
/**
 * Converts a local transform to a world transform relative to the given parent world matrix.
 * @param localT The local transform to convert
 * @param parentWM The world matrix of the item's parent
 * @returns The world transform of the item
 */
function toWorldTransform(localT, parentWM) {
    const localM = toMatrix(toRadiansTransform(localT));
    const worldM = matrix4.multiply(parentWM, localM);
    return toDegreesTransform(toTransform(worldM));
}
/**
 * Converts a world transform to a local transform relative to the given parent world matrix.
 * @param worldT The world transform to convert
 * @param parentWM The world matrix of the item's parent
 * @returns The local transform of the item
 */
function toLocalTransform(worldT, parentWM) {
    const worldM = toMatrix(toRadiansTransform(worldT));
    const localM = matrix4.multiply(matrix4.invert(parentWM), worldM);
    return toDegreesTransform(toTransform(localM));
}

export { toDegreesTransform as a, toMatrix as b, toTransform as c, toWorldTransform as d, toLocalTransform as e, flattenPointArray as f, toRadiansTransform as t };
//# sourceMappingURL=util-BrZtfp84.js.map

//# sourceMappingURL=util-BrZtfp84.js.map