import { threeUpdateTransform } from "../../../../util/threeUpdateTransform.js";

/**
 *
 * @param {Light} component
 * @param {Quaternion} r
 */
export function applyRotation(component, r) {
    const l = component.__threeObject;

    r.toEulerAnglesXYZ(l.rotation);

    if (l.target !== undefined) {

        const targetPosition = l.target.position;

        targetPosition.set(0, 0, 1).applyQuaternion(r);
        targetPosition.set(l.position.x + targetPosition.x, l.position.y + targetPosition.y, l.position.z + targetPosition.z);

        l.target.updateMatrixWorld(true);
    }

    threeUpdateTransform(component.__threeObject);
}
