#
luxiaotao1123
2024-04-24 ef1c6cacf5aa4b2bcce35eb3b7bae2db95692edd
src/utils/common.js
@@ -19,5 +19,52 @@
}
export const rotationParseNum = (num) => {
    return num * Math.PI / 180;
    const normalizedDegrees = num % 360;
    return normalizedDegrees * Math.PI / 180;
}
export const minDiffTheta = (originTheta, targetTheta) => {
    return (targetTheta - originTheta > 180) ? targetTheta - 360 : targetTheta;
}
export const setShadow = (obj) => {
    obj.castShadow = true;
    obj.receiveShadow = true;
    if (obj.children) {
        obj.children.forEach((child) => {
            setShadow(child);
        });
    }
};
export const setColor = (obj) => {
    if (obj.material) {
        obj.material.color.set(0x4680BF);
    }
    if (obj.children) {
        obj.children.forEach((child) => {
            setColor(child);
        });
    }
};
export const deepEqual = (obj1, obj2) => {
    if (obj1 === obj2) {
        return true;
    }
    if (typeof obj1 !== "object" || obj1 === null || typeof obj2 !== "object" || obj2 === null) {
        return false;
    }
    var keys1 = Object.keys(obj1);
    var keys2 = Object.keys(obj2);
    if (keys1.length !== keys2.length) {
        return false;
    }
    for (var key of keys1) {
        if (!keys2.includes(key) || !deepEqual(obj1[key], obj2[key])) {
            return false;
        }
    }
    return true;
}