#
luxiaotao1123
2024-04-23 9fce7ce7b76b859c5b70cc622d885cd9d6c1579f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import * as THREE from 'three';
 
export const isNullOfUndefined = (param) => {
    if (null === param || undefined === param) {
        return true;
    } else {
        return false;
    }
}
 
export const rotationToNum = (rotation) => {
    let res = rotation * 180 / Math.PI;
    if (res < 0) {
        res += 360;
    } else if (res > 360) {
        res -= 360;
    }
    return res;
}
 
export const rotationParseNum = (num) => {
    return num * Math.PI / 180;
}
 
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;
}