yzt
2023-05-05 4c558c77a6a9d23f057f094c4dc3e315eabef497
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
import Cartesian2 from "../Core/Cartesian2.js";
import Cartesian3 from "../Core/Cartesian3.js";
import Cartesian4 from "../Core/Cartesian4.js";
import Check from "../Core/Check.js";
import DeveloperError from "../Core/DeveloperError.js";
import Matrix2 from "../Core/Matrix2.js";
import Matrix3 from "../Core/Matrix3.js";
import Matrix4 from "../Core/Matrix4.js";
 
/**
 * An enum describing the attribute type for glTF and 3D Tiles.
 *
 * @enum {String}
 *
 * @private
 */
var AttributeType = {
  /**
   * The attribute is a single component.
   *
   * @type {String}
   * @constant
   */
  SCALAR: "SCALAR",
 
  /**
   * The attribute is a two-component vector.
   *
   * @type {String}
   * @constant
   */
  VEC2: "VEC2",
 
  /**
   * The attribute is a three-component vector.
   *
   * @type {String}
   * @constant
   */
  VEC3: "VEC3",
 
  /**
   * The attribute is a four-component vector.
   *
   * @type {String}
   * @constant
   */
  VEC4: "VEC4",
 
  /**
   * The attribute is a 2x2 matrix.
   *
   * @type {String}
   * @constant
   */
  MAT2: "MAT2",
 
  /**
   * The attribute is a 3x3 matrix.
   *
   * @type {String}
   * @constant
   */
  MAT3: "MAT3",
 
  /**
   * The attribute is a 4x4 matrix.
   *
   * @type {String}
   * @constant
   */
  MAT4: "MAT4",
};
 
/**
 * Gets the scalar, vector, or matrix type for the attribute type.
 *
 * @param {AttributeType} attributeType The attribute type.
 * @returns {*} The math type.
 *
 * @private
 */
AttributeType.getMathType = function (attributeType) {
  switch (attributeType) {
    case AttributeType.SCALAR:
      return Number;
    case AttributeType.VEC2:
      return Cartesian2;
    case AttributeType.VEC3:
      return Cartesian3;
    case AttributeType.VEC4:
      return Cartesian4;
    case AttributeType.MAT2:
      return Matrix2;
    case AttributeType.MAT3:
      return Matrix3;
    case AttributeType.MAT4:
      return Matrix4;
    //>>includeStart('debug', pragmas.debug);
    default:
      throw new DeveloperError("attributeType is not a valid value.");
    //>>includeEnd('debug');
  }
};
 
/**
 * Gets the number of components per attribute.
 *
 * @param {AttributeType} attributeType The attribute type.
 * @returns {Number} The number of components.
 *
 * @private
 */
AttributeType.getNumberOfComponents = function (attributeType) {
  switch (attributeType) {
    case AttributeType.SCALAR:
      return 1;
    case AttributeType.VEC2:
      return 2;
    case AttributeType.VEC3:
      return 3;
    case AttributeType.VEC4:
    case AttributeType.MAT2:
      return 4;
    case AttributeType.MAT3:
      return 9;
    case AttributeType.MAT4:
      return 16;
    //>>includeStart('debug', pragmas.debug);
    default:
      throw new DeveloperError("attributeType is not a valid value.");
    //>>includeEnd('debug');
  }
};
 
/**
 * Gets the GLSL type for the attribute type.
 *
 * @param {AttributeType} attributeType The attribute type.
 * @returns {String} The GLSL type for the attribute type.
 *
 * @private
 */
AttributeType.getGlslType = function (attributeType) {
  //>>includeStart('debug', pragmas.debug);
  Check.typeOf.string("attributeType", attributeType);
  //>>includeEnd('debug');
 
  switch (attributeType) {
    case AttributeType.SCALAR:
      return "float";
    case AttributeType.VEC2:
      return "vec2";
    case AttributeType.VEC3:
      return "vec3";
    case AttributeType.VEC4:
      return "vec4";
    case AttributeType.MAT2:
      return "mat2";
    case AttributeType.MAT3:
      return "mat3";
    case AttributeType.MAT4:
      return "mat4";
    //>>includeStart('debug', pragmas.debug);
    default:
      throw new DeveloperError("attributeType is not a valid value.");
    //>>includeEnd('debug');
  }
};
 
export default Object.freeze(AttributeType);