@loaders.gl/math 4.0.0-alpha.5 → 4.0.0-alpha.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es5/geometry/attributes/compute-bounding-box.js +46 -0
- package/dist/es5/geometry/attributes/compute-bounding-box.js.map +1 -0
- package/dist/es5/geometry/attributes/compute-bounding-sphere.js +2 -0
- package/dist/es5/geometry/attributes/compute-bounding-sphere.js.map +1 -0
- package/dist/es5/geometry/attributes/compute-tangents.js +2 -0
- package/dist/es5/geometry/attributes/compute-tangents.js.map +1 -0
- package/dist/es5/geometry/attributes/compute-vertex-normals.js +56 -0
- package/dist/es5/geometry/attributes/compute-vertex-normals.js.map +1 -0
- package/dist/es5/geometry/attributes/convert-to-non-indexed.js +43 -0
- package/dist/es5/geometry/attributes/convert-to-non-indexed.js.map +1 -0
- package/dist/es5/geometry/attributes/get-attribute-from-geometry.js +29 -0
- package/dist/es5/geometry/attributes/get-attribute-from-geometry.js.map +1 -0
- package/dist/es5/geometry/attributes/normalize.js +19 -0
- package/dist/es5/geometry/attributes/normalize.js.map +1 -0
- package/dist/es5/geometry/colors/rgb565.js +24 -0
- package/dist/es5/geometry/colors/rgb565.js.map +1 -0
- package/dist/es5/geometry/compression/attribute-compression.js +178 -0
- package/dist/es5/geometry/compression/attribute-compression.js.map +1 -0
- package/dist/es5/geometry/constants.js +40 -0
- package/dist/es5/geometry/constants.js.map +1 -0
- package/dist/es5/geometry/gl/gl-type.js +92 -0
- package/dist/es5/geometry/gl/gl-type.js.map +1 -0
- package/dist/es5/geometry/is-geometry.js +12 -0
- package/dist/es5/geometry/is-geometry.js.map +1 -0
- package/dist/es5/geometry/iterators/attribute-iterator.js +38 -0
- package/dist/es5/geometry/iterators/attribute-iterator.js.map +1 -0
- package/dist/es5/geometry/iterators/primitive-iterator.js +102 -0
- package/dist/es5/geometry/iterators/primitive-iterator.js.map +1 -0
- package/dist/es5/geometry/primitives/modes.js +56 -0
- package/dist/es5/geometry/primitives/modes.js.map +1 -0
- package/dist/es5/geometry/typed-arrays/typed-array-utils.js +24 -0
- package/dist/es5/geometry/typed-arrays/typed-array-utils.js.map +1 -0
- package/dist/es5/geometry/utils/assert.js +12 -0
- package/dist/es5/geometry/utils/assert.js.map +1 -0
- package/dist/es5/index.js +160 -0
- package/dist/es5/index.js.map +1 -0
- package/dist/es5/utils/assert.js +12 -0
- package/dist/es5/utils/assert.js.map +1 -0
- package/dist/esm/geometry/attributes/compute-bounding-box.js +28 -0
- package/dist/esm/geometry/attributes/compute-bounding-box.js.map +1 -0
- package/dist/esm/geometry/attributes/compute-bounding-sphere.js +2 -0
- package/dist/esm/geometry/attributes/compute-bounding-sphere.js.map +1 -0
- package/dist/esm/geometry/attributes/compute-tangents.js +2 -0
- package/dist/esm/geometry/attributes/compute-tangents.js.map +1 -0
- package/dist/esm/geometry/attributes/compute-vertex-normals.js +41 -0
- package/dist/esm/geometry/attributes/compute-vertex-normals.js.map +1 -0
- package/dist/esm/geometry/attributes/convert-to-non-indexed.js +27 -0
- package/dist/esm/geometry/attributes/convert-to-non-indexed.js.map +1 -0
- package/dist/esm/geometry/attributes/get-attribute-from-geometry.js +24 -0
- package/dist/esm/geometry/attributes/get-attribute-from-geometry.js.map +1 -0
- package/dist/esm/geometry/attributes/normalize.js +13 -0
- package/dist/esm/geometry/attributes/normalize.js.map +1 -0
- package/dist/esm/geometry/colors/rgb565.js +17 -0
- package/dist/esm/geometry/colors/rgb565.js.map +1 -0
- package/dist/esm/geometry/compression/attribute-compression.js +159 -0
- package/dist/esm/geometry/compression/attribute-compression.js.map +1 -0
- package/dist/esm/geometry/constants.js +29 -0
- package/dist/esm/geometry/constants.js.map +1 -0
- package/dist/esm/geometry/gl/gl-type.js +72 -0
- package/dist/esm/geometry/gl/gl-type.js.map +1 -0
- package/dist/esm/geometry/is-geometry.js +4 -0
- package/dist/esm/geometry/is-geometry.js.map +1 -0
- package/dist/esm/geometry/iterators/attribute-iterator.js +11 -0
- package/dist/esm/geometry/iterators/attribute-iterator.js.map +1 -0
- package/dist/esm/geometry/iterators/primitive-iterator.js +76 -0
- package/dist/esm/geometry/iterators/primitive-iterator.js.map +1 -0
- package/dist/esm/geometry/primitives/modes.js +48 -0
- package/dist/esm/geometry/primitives/modes.js.map +1 -0
- package/dist/esm/geometry/typed-arrays/typed-array-utils.js +18 -0
- package/dist/esm/geometry/typed-arrays/typed-array-utils.js.map +1 -0
- package/dist/esm/geometry/utils/assert.js +6 -0
- package/dist/esm/geometry/utils/assert.js.map +1 -0
- package/dist/esm/index.js +11 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/utils/assert.js +6 -0
- package/dist/esm/utils/assert.js.map +1 -0
- package/dist/geometry/attributes/compute-bounding-box.js +41 -27
- package/dist/geometry/attributes/compute-bounding-sphere.js +29 -1
- package/dist/geometry/attributes/compute-tangents.js +145 -1
- package/dist/geometry/attributes/compute-vertex-normals.d.ts +2 -2
- package/dist/geometry/attributes/compute-vertex-normals.d.ts.map +1 -1
- package/dist/geometry/attributes/compute-vertex-normals.js +47 -42
- package/dist/geometry/attributes/convert-to-non-indexed.js +31 -30
- package/dist/geometry/attributes/get-attribute-from-geometry.js +33 -26
- package/dist/geometry/attributes/normalize.js +19 -11
- package/dist/geometry/colors/rgb565.js +29 -14
- package/dist/geometry/compression/attribute-compression.d.ts +7 -1
- package/dist/geometry/compression/attribute-compression.d.ts.map +1 -1
- package/dist/geometry/compression/attribute-compression.js +339 -162
- package/dist/geometry/constants.d.ts +1 -1
- package/dist/geometry/constants.d.ts.map +1 -1
- package/dist/geometry/constants.js +30 -24
- package/dist/geometry/gl/gl-type.d.ts +1 -1
- package/dist/geometry/gl/gl-type.d.ts.map +1 -1
- package/dist/geometry/gl/gl-type.js +101 -74
- package/dist/geometry/is-geometry.js +13 -3
- package/dist/geometry/iterators/attribute-iterator.js +17 -11
- package/dist/geometry/iterators/primitive-iterator.js +85 -79
- package/dist/geometry/primitives/modes.js +67 -54
- package/dist/geometry/typed-arrays/typed-array-utils.js +23 -20
- package/dist/geometry/utils/assert.js +13 -5
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +46 -11
- package/dist/utils/assert.js +11 -5
- package/package.json +6 -6
- package/src/geometry/attributes/compute-vertex-normals.ts +1 -1
- package/src/geometry/compression/attribute-compression.ts +7 -1
- package/src/geometry/gl/gl-type.ts +1 -1
- package/src/index.ts +12 -0
- package/dist/geometry/attributes/compute-bounding-box.js.map +0 -1
- package/dist/geometry/attributes/compute-bounding-sphere.js.map +0 -1
- package/dist/geometry/attributes/compute-tangents.js.map +0 -1
- package/dist/geometry/attributes/compute-vertex-normals.js.map +0 -1
- package/dist/geometry/attributes/convert-to-non-indexed.js.map +0 -1
- package/dist/geometry/attributes/get-attribute-from-geometry.js.map +0 -1
- package/dist/geometry/attributes/normalize.js.map +0 -1
- package/dist/geometry/colors/rgb565.js.map +0 -1
- package/dist/geometry/compression/attribute-compression.js.map +0 -1
- package/dist/geometry/constants.js.map +0 -1
- package/dist/geometry/gl/gl-type.js.map +0 -1
- package/dist/geometry/is-geometry.js.map +0 -1
- package/dist/geometry/iterators/attribute-iterator.js.map +0 -1
- package/dist/geometry/iterators/primitive-iterator.js.map +0 -1
- package/dist/geometry/primitives/modes.js.map +0 -1
- package/dist/geometry/typed-arrays/typed-array-utils.js.map +0 -1
- package/dist/geometry/types.d.ts +0 -13
- package/dist/geometry/types.d.ts.map +0 -1
- package/dist/geometry/types.js +0 -2
- package/dist/geometry/types.js.map +0 -1
- package/dist/geometry/utils/assert.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/utils/assert.js.map +0 -1
- package/src/geometry/types.ts +0 -25
|
@@ -1,28 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
// Subset of WebGL constants
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.GL = exports.GL_TYPE = exports.GL_PRIMITIVE_MODE = exports.GL_PRIMITIVE = void 0;
|
|
5
|
+
exports.GL_PRIMITIVE = {
|
|
6
|
+
POINTS: 0x0000,
|
|
7
|
+
LINES: 0x0001,
|
|
8
|
+
TRIANGLES: 0x0004 // Triangles. Each set of three vertices creates a separate triangle.
|
|
5
9
|
};
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
// Primitive modes
|
|
11
|
+
exports.GL_PRIMITIVE_MODE = {
|
|
12
|
+
POINTS: 0x0000,
|
|
13
|
+
LINES: 0x0001,
|
|
14
|
+
LINE_LOOP: 0x0002,
|
|
15
|
+
LINE_STRIP: 0x0003,
|
|
16
|
+
TRIANGLES: 0x0004,
|
|
17
|
+
TRIANGLE_STRIP: 0x0005,
|
|
18
|
+
TRIANGLE_FAN: 0x0006 // Triangles. A connected group of triangles.
|
|
19
|
+
// Each vertex connects to the previous and the first vertex in the fan.
|
|
14
20
|
};
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
exports.GL_TYPE = {
|
|
22
|
+
BYTE: 5120,
|
|
23
|
+
UNSIGNED_BYTE: 5121,
|
|
24
|
+
SHORT: 5122,
|
|
25
|
+
UNSIGNED_SHORT: 5123,
|
|
26
|
+
INT: 5124,
|
|
27
|
+
UNSIGNED_INT: 5125,
|
|
28
|
+
FLOAT: 5126,
|
|
29
|
+
DOUBLE: 5130
|
|
24
30
|
};
|
|
25
|
-
|
|
26
|
-
|
|
31
|
+
exports.GL = {
|
|
32
|
+
...exports.GL_PRIMITIVE_MODE,
|
|
33
|
+
...exports.GL_TYPE
|
|
27
34
|
};
|
|
28
|
-
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gl-type.d.ts","sourceRoot":"","sources":["../../../src/geometry/gl/gl-type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"gl-type.d.ts","sourceRoot":"","sources":["../../../src/geometry/gl/gl-type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AA6B9C,MAAM,CAAC,OAAO,OAAO,MAAM;IAGzB;;;;OAIG;IACH,MAAM,CAAC,cAAc,CAAC,WAAW,EAAE,UAAU,GAAG,QAAQ,GAAG,MAAM;IAWjE;;;;OAIG;IACH,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IASrC,MAAM,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM;IAmBlC;;;;OAIG;IACH,MAAM,CAAC,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IAI1C;;;;OAIG;IACH,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IAGxC;;;;;;;OAOG;IACH,MAAM,CAAC,gBAAgB,CACrB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,UAAU,EAClB,UAAU,GAAE,MAAU,EACtB,MAAM,CAAC,EAAE,MAAM,GACd,UAAU;CAOd"}
|
|
@@ -1,85 +1,112 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const constants_1 = require("../constants");
|
|
2
4
|
const GL_TYPE_TO_ARRAY_TYPE = {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
[constants_1.GL_TYPE.DOUBLE]: Float64Array,
|
|
6
|
+
[constants_1.GL_TYPE.FLOAT]: Float32Array,
|
|
7
|
+
[constants_1.GL_TYPE.UNSIGNED_SHORT]: Uint16Array,
|
|
8
|
+
[constants_1.GL_TYPE.UNSIGNED_INT]: Uint32Array,
|
|
9
|
+
[constants_1.GL_TYPE.UNSIGNED_BYTE]: Uint8Array,
|
|
10
|
+
[constants_1.GL_TYPE.BYTE]: Int8Array,
|
|
11
|
+
[constants_1.GL_TYPE.SHORT]: Int16Array,
|
|
12
|
+
[constants_1.GL_TYPE.INT]: Int32Array
|
|
11
13
|
};
|
|
12
14
|
const NAME_TO_GL_TYPE = {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
DOUBLE: constants_1.GL_TYPE.DOUBLE,
|
|
16
|
+
FLOAT: constants_1.GL_TYPE.FLOAT,
|
|
17
|
+
UNSIGNED_SHORT: constants_1.GL_TYPE.UNSIGNED_SHORT,
|
|
18
|
+
UNSIGNED_INT: constants_1.GL_TYPE.UNSIGNED_INT,
|
|
19
|
+
UNSIGNED_BYTE: constants_1.GL_TYPE.UNSIGNED_BYTE,
|
|
20
|
+
BYTE: constants_1.GL_TYPE.BYTE,
|
|
21
|
+
SHORT: constants_1.GL_TYPE.SHORT,
|
|
22
|
+
INT: constants_1.GL_TYPE.INT
|
|
21
23
|
};
|
|
22
24
|
const ERR_TYPE_CONVERSION = 'Failed to convert GL type';
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
25
|
+
// Converts TYPED ARRAYS to corresponding GL constant
|
|
26
|
+
// Used to auto deduce gl parameter types
|
|
27
|
+
class GLType {
|
|
28
|
+
// Signature: fromTypedArray(new Uint8Array())
|
|
29
|
+
// Signature: fromTypedArray(Uint8Array)
|
|
30
|
+
/**
|
|
31
|
+
* Returns the size, in bytes, of the corresponding datatype
|
|
32
|
+
* @param arrayOrType
|
|
33
|
+
* @returns glType a a string
|
|
34
|
+
*/
|
|
35
|
+
static fromTypedArray(arrayOrType) {
|
|
36
|
+
// If typed array, look up constructor
|
|
37
|
+
arrayOrType = ArrayBuffer.isView(arrayOrType) ? arrayOrType.constructor : arrayOrType;
|
|
38
|
+
for (const glType in GL_TYPE_TO_ARRAY_TYPE) {
|
|
39
|
+
const ArrayType = GL_TYPE_TO_ARRAY_TYPE[glType];
|
|
40
|
+
if (ArrayType === arrayOrType) {
|
|
41
|
+
return glType;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
throw new Error(ERR_TYPE_CONVERSION);
|
|
33
45
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
46
|
+
/**
|
|
47
|
+
* Extracts name for glType from array NAME_TO_GL_TYPE
|
|
48
|
+
* @param name
|
|
49
|
+
* @returns glType as a number
|
|
50
|
+
*/
|
|
51
|
+
static fromName(name) {
|
|
52
|
+
const glType = NAME_TO_GL_TYPE[name];
|
|
53
|
+
if (!glType) {
|
|
54
|
+
throw new Error(ERR_TYPE_CONVERSION);
|
|
55
|
+
}
|
|
56
|
+
return glType;
|
|
43
57
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
// Converts GL constant to corresponding typed array type
|
|
59
|
+
// eslint-disable-next-line complexity
|
|
60
|
+
static getArrayType(glType) {
|
|
61
|
+
switch (glType) {
|
|
62
|
+
/*eslint-disable*/
|
|
63
|
+
// @ts-ignore
|
|
64
|
+
case constants_1.GL_TYPE.UNSIGNED_SHORT_5_6_5:
|
|
65
|
+
// @ts-ignore
|
|
66
|
+
case constants_1.GL_TYPE.UNSIGNED_SHORT_4_4_4_4:
|
|
67
|
+
// @ts-ignore
|
|
68
|
+
case constants_1.GL_TYPE.UNSIGNED_SHORT_5_5_5_1:
|
|
69
|
+
/* eslint-enable*/
|
|
70
|
+
return Uint16Array;
|
|
71
|
+
default:
|
|
72
|
+
const ArrayType = GL_TYPE_TO_ARRAY_TYPE[glType];
|
|
73
|
+
if (!ArrayType) {
|
|
74
|
+
throw new Error(ERR_TYPE_CONVERSION);
|
|
75
|
+
}
|
|
76
|
+
return ArrayType;
|
|
60
77
|
}
|
|
61
|
-
|
|
62
|
-
return ArrayType;
|
|
63
78
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
79
|
+
/**
|
|
80
|
+
* Returns the size in bytes of one element of the provided WebGL type
|
|
81
|
+
* @param glType
|
|
82
|
+
* @returns size of glType
|
|
83
|
+
*/
|
|
84
|
+
static getByteSize(glType) {
|
|
85
|
+
const ArrayType = GLType.getArrayType(glType);
|
|
86
|
+
return ArrayType.BYTES_PER_ELEMENT;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Returns `true` if `glType` is a valid WebGL data type.
|
|
90
|
+
* @param glType
|
|
91
|
+
* @returns boolean
|
|
92
|
+
*/
|
|
93
|
+
static validate(glType) {
|
|
94
|
+
return Boolean(GLType.getArrayType(glType));
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Creates a typed view of an array of bytes
|
|
98
|
+
* @param glType The type of typed array (ArrayBuffer view) to create
|
|
99
|
+
* @param buffer The buffer storage to use for the view.
|
|
100
|
+
* @param byteOffset The offset, in bytes, to the first element in the view
|
|
101
|
+
* @param length The number of elements in the view. Defaults to buffer length
|
|
102
|
+
* @returns A typed array view of the buffer
|
|
103
|
+
*/
|
|
104
|
+
static createTypedArray(glType, buffer, byteOffset = 0, length) {
|
|
105
|
+
if (length === undefined) {
|
|
106
|
+
length = (buffer.byteLength - byteOffset) / GLType.getByteSize(glType);
|
|
107
|
+
}
|
|
108
|
+
const ArrayType = GLType.getArrayType(glType);
|
|
109
|
+
return new ArrayType(buffer, byteOffset, length);
|
|
78
110
|
}
|
|
79
|
-
|
|
80
|
-
const ArrayType = GLType.getArrayType(glType);
|
|
81
|
-
return new ArrayType(buffer, byteOffset, length);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
111
|
}
|
|
85
|
-
|
|
112
|
+
exports.default = GLType;
|
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* Checking if it is geometry
|
|
5
|
+
* @param geometry
|
|
6
|
+
*/
|
|
7
|
+
function isGeometry(geometry) {
|
|
8
|
+
return (geometry &&
|
|
9
|
+
typeof geometry === 'object' &&
|
|
10
|
+
geometry.mode &&
|
|
11
|
+
geometry.attributes &&
|
|
12
|
+
typeof geometry.attributes === 'object');
|
|
3
13
|
}
|
|
4
|
-
|
|
14
|
+
exports.default = isGeometry;
|
|
@@ -1,13 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeAttributeIterator = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Iterates over a single attribute
|
|
6
|
+
* NOTE: For performance, re-yields the same modified element
|
|
7
|
+
* @param param0
|
|
8
|
+
*/
|
|
9
|
+
function* makeAttributeIterator(values, size) {
|
|
10
|
+
const ArrayType = values.constructor;
|
|
11
|
+
const element = new ArrayType(size);
|
|
12
|
+
for (let i = 0; i < values.length; i += size) {
|
|
13
|
+
for (let j = 0; j < size; j++) {
|
|
14
|
+
element[j] = element[i + j];
|
|
15
|
+
}
|
|
16
|
+
yield element;
|
|
8
17
|
}
|
|
9
|
-
|
|
10
|
-
yield element;
|
|
11
|
-
}
|
|
12
18
|
}
|
|
13
|
-
|
|
19
|
+
exports.makeAttributeIterator = makeAttributeIterator;
|
|
@@ -1,82 +1,88 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
i3: 0
|
|
19
|
-
};
|
|
20
|
-
let i = start;
|
|
21
|
-
|
|
22
|
-
while (i < end) {
|
|
23
|
-
switch (mode) {
|
|
24
|
-
case GL.POINTS:
|
|
25
|
-
info.i1 = i;
|
|
26
|
-
i += 1;
|
|
27
|
-
break;
|
|
28
|
-
|
|
29
|
-
case GL.LINES:
|
|
30
|
-
info.i1 = i;
|
|
31
|
-
info.i2 = i + 1;
|
|
32
|
-
i += 2;
|
|
33
|
-
break;
|
|
34
|
-
|
|
35
|
-
case GL.LINE_STRIP:
|
|
36
|
-
info.i1 = i;
|
|
37
|
-
info.i2 = i + 1;
|
|
38
|
-
i += 1;
|
|
39
|
-
break;
|
|
40
|
-
|
|
41
|
-
case GL.LINE_LOOP:
|
|
42
|
-
info.i1 = i;
|
|
43
|
-
info.i2 = i + 1;
|
|
44
|
-
i += 1;
|
|
45
|
-
break;
|
|
46
|
-
|
|
47
|
-
case GL.TRIANGLES:
|
|
48
|
-
info.i1 = i;
|
|
49
|
-
info.i2 = i + 1;
|
|
50
|
-
info.i3 = i + 2;
|
|
51
|
-
i += 3;
|
|
52
|
-
break;
|
|
53
|
-
|
|
54
|
-
case GL.TRIANGLE_STRIP:
|
|
55
|
-
info.i1 = i;
|
|
56
|
-
info.i2 = i + 1;
|
|
57
|
-
i += 1;
|
|
58
|
-
break;
|
|
59
|
-
|
|
60
|
-
case GL.TRIANGLE_FAN:
|
|
61
|
-
info.i1 = 1;
|
|
62
|
-
info.i2 = i;
|
|
63
|
-
info.i3 = i + 1;
|
|
64
|
-
i += 1;
|
|
65
|
-
break;
|
|
66
|
-
|
|
67
|
-
default:
|
|
68
|
-
assert(false);
|
|
69
|
-
}
|
|
70
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makePrimitiveIterator = void 0;
|
|
4
|
+
const constants_1 = require("../constants");
|
|
5
|
+
const modes_1 = require("../primitives/modes");
|
|
6
|
+
const loader_utils_1 = require("@loaders.gl/loader-utils");
|
|
7
|
+
/**
|
|
8
|
+
* Will iterate over each primitive, expanding (dereferencing) indices
|
|
9
|
+
* @param indices
|
|
10
|
+
* @param attributes
|
|
11
|
+
* @param mode
|
|
12
|
+
* @param start
|
|
13
|
+
* @param end
|
|
14
|
+
*/
|
|
15
|
+
// eslint-disable-next-line complexity
|
|
16
|
+
function* makePrimitiveIterator(indices, attributes = {}, mode, start = 0, end) {
|
|
17
|
+
// support indices being an object with a values array
|
|
71
18
|
if (indices) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
19
|
+
indices = indices.values || indices.value || indices;
|
|
20
|
+
}
|
|
21
|
+
// Autodeduce length from indices
|
|
22
|
+
if (end === undefined) {
|
|
23
|
+
end = indices ? indices.length : start;
|
|
24
|
+
}
|
|
25
|
+
// iteration info
|
|
26
|
+
const info = {
|
|
27
|
+
attributes,
|
|
28
|
+
type: (0, modes_1.getPrimitiveModeType)(mode),
|
|
29
|
+
i1: 0,
|
|
30
|
+
i2: 0,
|
|
31
|
+
i3: 0
|
|
32
|
+
};
|
|
33
|
+
let i = start;
|
|
34
|
+
// @ts-ignore
|
|
35
|
+
while (i < end) {
|
|
36
|
+
switch (mode) {
|
|
37
|
+
case constants_1.GL.POINTS: // draw single points.
|
|
38
|
+
info.i1 = i;
|
|
39
|
+
i += 1;
|
|
40
|
+
break;
|
|
41
|
+
case constants_1.GL.LINES: // draw lines. Each set of two vertices is treated as a separate line segment.
|
|
42
|
+
info.i1 = i;
|
|
43
|
+
info.i2 = i + 1;
|
|
44
|
+
i += 2;
|
|
45
|
+
break;
|
|
46
|
+
case constants_1.GL.LINE_STRIP: // draw lines. Each vertex connects to the one after it.
|
|
47
|
+
info.i1 = i;
|
|
48
|
+
info.i2 = i + 1;
|
|
49
|
+
i += 1;
|
|
50
|
+
break;
|
|
51
|
+
case constants_1.GL.LINE_LOOP: // draw a connected group of line segments from the first vertex to the last
|
|
52
|
+
info.i1 = i;
|
|
53
|
+
info.i2 = i + 1;
|
|
54
|
+
i += 1;
|
|
55
|
+
break;
|
|
56
|
+
case constants_1.GL.TRIANGLES: // draw triangles. Each set of three vertices creates a separate triangle.
|
|
57
|
+
info.i1 = i;
|
|
58
|
+
info.i2 = i + 1;
|
|
59
|
+
info.i3 = i + 2;
|
|
60
|
+
i += 3;
|
|
61
|
+
break;
|
|
62
|
+
case constants_1.GL.TRIANGLE_STRIP: // draw a connected group of triangles.
|
|
63
|
+
info.i1 = i;
|
|
64
|
+
info.i2 = i + 1;
|
|
65
|
+
i += 1;
|
|
66
|
+
break;
|
|
67
|
+
case constants_1.GL.TRIANGLE_FAN: // draw a connected group of triangles.
|
|
68
|
+
info.i1 = 1;
|
|
69
|
+
info.i2 = i;
|
|
70
|
+
info.i3 = i + 1;
|
|
71
|
+
i += 1;
|
|
72
|
+
break;
|
|
73
|
+
default:
|
|
74
|
+
(0, loader_utils_1.assert)(false);
|
|
75
|
+
}
|
|
76
|
+
// if indices are present, lookup actual vertices in indices
|
|
77
|
+
if (indices) {
|
|
78
|
+
if ('i1' in info) {
|
|
79
|
+
info.i1 = indices[info.i1];
|
|
80
|
+
info.i2 = indices[info.i2];
|
|
81
|
+
info.i3 = indices[info.i3];
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
// @ts-ignore
|
|
85
|
+
yield info;
|
|
77
86
|
}
|
|
78
|
-
|
|
79
|
-
yield info;
|
|
80
|
-
}
|
|
81
87
|
}
|
|
82
|
-
|
|
88
|
+
exports.makePrimitiveIterator = makePrimitiveIterator;
|
|
@@ -1,58 +1,71 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPrimitiveModeExpandedLength = exports.isPrimitiveModeExpandable = exports.getPrimitiveModeType = void 0;
|
|
4
|
+
const constants_1 = require("../constants");
|
|
5
|
+
/**
|
|
6
|
+
* Different methods of working with geometries depending on glType
|
|
7
|
+
/**
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
9
|
+
/**
|
|
10
|
+
* @param mode
|
|
11
|
+
* @returns draw points | lines | triangles
|
|
12
|
+
*/
|
|
13
|
+
function getPrimitiveModeType(mode) {
|
|
14
|
+
switch (mode) {
|
|
15
|
+
case constants_1.GL.POINTS: // draw single points.
|
|
16
|
+
return constants_1.GL.POINTS;
|
|
17
|
+
case constants_1.GL.LINES: // draw lines. Each set of two vertices is treated as a separate line segment.
|
|
18
|
+
case constants_1.GL.LINE_STRIP: // draw lines. Each vertex connects to the one after it.
|
|
19
|
+
case constants_1.GL.LINE_LOOP: // draw a connected group of line segments from the first vertex to the last
|
|
20
|
+
return constants_1.GL.LINES;
|
|
21
|
+
case constants_1.GL.TRIANGLES:
|
|
22
|
+
case constants_1.GL.TRIANGLE_STRIP:
|
|
23
|
+
case constants_1.GL.TRIANGLE_FAN: // draw a connected group of triangles.
|
|
24
|
+
return constants_1.GL.TRIANGLES;
|
|
25
|
+
default:
|
|
26
|
+
throw new Error('Unknown primitive mode');
|
|
27
|
+
}
|
|
20
28
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
exports.getPrimitiveModeType = getPrimitiveModeType;
|
|
30
|
+
/**
|
|
31
|
+
* @param mode
|
|
32
|
+
* @returns true | false
|
|
33
|
+
*/
|
|
34
|
+
function isPrimitiveModeExpandable(mode) {
|
|
35
|
+
switch (mode) {
|
|
36
|
+
case constants_1.GL.LINE_STRIP: // draw lines. Each vertex connects to the one after it.
|
|
37
|
+
case constants_1.GL.LINE_LOOP: // draw a connected group of line segments from the first vertex to the last
|
|
38
|
+
case constants_1.GL.TRIANGLE_STRIP: // draw a connected group of triangles.
|
|
39
|
+
case constants_1.GL.TRIANGLE_FAN: // draw a connected group of triangles.
|
|
40
|
+
return true;
|
|
41
|
+
default:
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
32
44
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
45
|
+
exports.isPrimitiveModeExpandable = isPrimitiveModeExpandable;
|
|
46
|
+
/**
|
|
47
|
+
* Returns new length depends on glType
|
|
48
|
+
* @param mode
|
|
49
|
+
* @param length
|
|
50
|
+
* @returns new length
|
|
51
|
+
*/
|
|
52
|
+
function getPrimitiveModeExpandedLength(mode, length) {
|
|
53
|
+
switch (mode) {
|
|
54
|
+
case constants_1.GL.POINTS: // draw single points.
|
|
55
|
+
return length;
|
|
56
|
+
case constants_1.GL.LINES: // draw lines. Each set of two vertices is treated as a separate line segment.
|
|
57
|
+
return length;
|
|
58
|
+
case constants_1.GL.LINE_STRIP: // draw lines. Each vertex connects to the one after it.
|
|
59
|
+
return length;
|
|
60
|
+
case constants_1.GL.LINE_LOOP: // draw a connected group of line segments from the first vertex to the last
|
|
61
|
+
return length + 1;
|
|
62
|
+
case constants_1.GL.TRIANGLES: // draw triangles. Each set of three vertices creates a separate triangle.
|
|
63
|
+
return length;
|
|
64
|
+
case constants_1.GL.TRIANGLE_STRIP: // draw a connected group of triangles.
|
|
65
|
+
case constants_1.GL.TRIANGLE_FAN: // draw a connected group of triangles.
|
|
66
|
+
return (length - 2) * 3;
|
|
67
|
+
default:
|
|
68
|
+
throw new Error('Unknown length');
|
|
69
|
+
}
|
|
57
70
|
}
|
|
58
|
-
|
|
71
|
+
exports.getPrimitiveModeExpandedLength = getPrimitiveModeExpandedLength;
|
|
@@ -1,22 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
byteLength = data.length;
|
|
14
|
-
|
|
15
|
-
for (let j = 0; j < byteLength; ++j) {
|
|
16
|
-
buffer[byteOffset++] = data[j];
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.concatTypedArrays = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Concats typed arrays
|
|
6
|
+
* @param arrays
|
|
7
|
+
* @returns new Uint8Array
|
|
8
|
+
*/
|
|
9
|
+
function concatTypedArrays(arrays = []) {
|
|
10
|
+
let byteLength = 0;
|
|
11
|
+
for (let i = 0; i < arrays.length; ++i) {
|
|
12
|
+
byteLength += arrays[i].byteLength;
|
|
17
13
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
const buffer = new Uint8Array(byteLength);
|
|
15
|
+
let byteOffset = 0;
|
|
16
|
+
for (let i = 0; i < arrays.length; ++i) {
|
|
17
|
+
const data = new Uint8Array(arrays[i].buffer);
|
|
18
|
+
byteLength = data.length;
|
|
19
|
+
for (let j = 0; j < byteLength; ++j) {
|
|
20
|
+
buffer[byteOffset++] = data[j];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return buffer;
|
|
21
24
|
}
|
|
22
|
-
|
|
25
|
+
exports.concatTypedArrays = concatTypedArrays;
|