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
| import Cartesian2 from "../Core/Cartesian2.js";
| import Cartesian3 from "../Core/Cartesian3.js";
| import Cartesian4 from "../Core/Cartesian4.js";
| import ComponentDatatype from "../Core/ComponentDatatype.js";
| import Matrix2 from "../Core/Matrix2.js";
| import Matrix3 from "../Core/Matrix3.js";
| import Matrix4 from "../Core/Matrix4.js";
|
| var ComponentsPerAttribute = {
| SCALAR: 1,
| VEC2: 2,
| VEC3: 3,
| VEC4: 4,
| MAT2: 4,
| MAT3: 9,
| MAT4: 16,
| };
|
| var ClassPerType = {
| SCALAR: undefined,
| VEC2: Cartesian2,
| VEC3: Cartesian3,
| VEC4: Cartesian4,
| MAT2: Matrix2,
| MAT3: Matrix3,
| MAT4: Matrix4,
| };
|
| /**
| * @private
| */
| function getBinaryAccessor(accessor) {
| var componentType = accessor.componentType;
| var componentDatatype;
| if (typeof componentType === "string") {
| componentDatatype = ComponentDatatype.fromName(componentType);
| } else {
| componentDatatype = componentType;
| }
|
| var componentsPerAttribute = ComponentsPerAttribute[accessor.type];
| var classType = ClassPerType[accessor.type];
| return {
| componentsPerAttribute: componentsPerAttribute,
| classType: classType,
| createArrayBufferView: function (buffer, byteOffset, length) {
| return ComponentDatatype.createArrayBufferView(
| componentDatatype,
| buffer,
| byteOffset,
| componentsPerAttribute * length
| );
| },
| };
| }
| export default getBinaryAccessor;
|
|