@loaders.gl/math 3.0.12 → 3.0.13

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.
Files changed (32) hide show
  1. package/dist/es5/geometry/attributes/compute-bounding-box.js +17 -34
  2. package/dist/es5/geometry/attributes/compute-bounding-box.js.map +1 -1
  3. package/dist/es5/geometry/attributes/compute-vertex-normals.js +30 -45
  4. package/dist/es5/geometry/attributes/compute-vertex-normals.js.map +1 -1
  5. package/dist/es5/geometry/attributes/convert-to-non-indexed.js +14 -29
  6. package/dist/es5/geometry/attributes/convert-to-non-indexed.js.map +1 -1
  7. package/dist/es5/geometry/attributes/get-attribute-from-geometry.js +4 -2
  8. package/dist/es5/geometry/attributes/get-attribute-from-geometry.js.map +1 -1
  9. package/dist/es5/geometry/attributes/normalize.js +2 -4
  10. package/dist/es5/geometry/attributes/normalize.js.map +1 -1
  11. package/dist/es5/geometry/colors/rgb565.js +7 -8
  12. package/dist/es5/geometry/colors/rgb565.js.map +1 -1
  13. package/dist/es5/geometry/compression/attribute-compression.js +39 -41
  14. package/dist/es5/geometry/compression/attribute-compression.js.map +1 -1
  15. package/dist/es5/geometry/constants.js +6 -15
  16. package/dist/es5/geometry/constants.js.map +1 -1
  17. package/dist/es5/geometry/gl/gl-type.js +63 -79
  18. package/dist/es5/geometry/gl/gl-type.js.map +1 -1
  19. package/dist/es5/geometry/is-geometry.js +1 -5
  20. package/dist/es5/geometry/is-geometry.js.map +1 -1
  21. package/dist/es5/geometry/iterators/attribute-iterator.js +9 -38
  22. package/dist/es5/geometry/iterators/attribute-iterator.js.map +1 -1
  23. package/dist/es5/geometry/iterators/primitive-iterator.js +75 -116
  24. package/dist/es5/geometry/iterators/primitive-iterator.js.map +1 -1
  25. package/dist/es5/geometry/typed-arrays/typed-array-utils.js +8 -9
  26. package/dist/es5/geometry/typed-arrays/typed-array-utils.js.map +1 -1
  27. package/dist/es5/index.js +24 -24
  28. package/dist/esm/geometry/compression/attribute-compression.js +1 -1
  29. package/dist/esm/geometry/compression/attribute-compression.js.map +1 -1
  30. package/dist/esm/geometry/utils/assert.js +1 -1
  31. package/dist/esm/geometry/utils/assert.js.map +1 -1
  32. package/package.json +4 -4
@@ -1,133 +1,92 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
8
6
  exports.makePrimitiveIterator = makePrimitiveIterator;
9
7
 
10
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
-
12
8
  var _constants = require("../constants");
13
9
 
14
10
  var _modes = require("../primitives/modes");
15
11
 
16
12
  var _loaderUtils = require("@loaders.gl/loader-utils");
17
13
 
18
- var _marked = _regenerator.default.mark(makePrimitiveIterator);
19
-
20
- function makePrimitiveIterator(indices) {
21
- var attributes,
22
- mode,
23
- start,
24
- end,
25
- info,
26
- i,
27
- _args = arguments;
28
- return _regenerator.default.wrap(function makePrimitiveIterator$(_context) {
29
- while (1) {
30
- switch (_context.prev = _context.next) {
31
- case 0:
32
- attributes = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
33
- mode = _args.length > 2 ? _args[2] : undefined;
34
- start = _args.length > 3 && _args[3] !== undefined ? _args[3] : 0;
35
- end = _args.length > 4 ? _args[4] : undefined;
36
-
37
- if (indices) {
38
- indices = indices.values || indices.value || indices;
39
- }
40
-
41
- if (end === undefined) {
42
- end = indices ? indices.length : start;
43
- }
44
-
45
- info = {
46
- attributes: attributes,
47
- type: (0, _modes.getPrimitiveModeType)(mode),
48
- i1: 0,
49
- i2: 0,
50
- i3: 0
51
- };
52
- i = start;
53
-
54
- case 8:
55
- if (!(i < end)) {
56
- _context.next = 47;
57
- break;
58
- }
59
-
60
- _context.t0 = mode;
61
- _context.next = _context.t0 === _constants.GL.POINTS ? 12 : _context.t0 === _constants.GL.LINES ? 15 : _context.t0 === _constants.GL.LINE_STRIP ? 19 : _context.t0 === _constants.GL.LINE_LOOP ? 23 : _context.t0 === _constants.GL.TRIANGLES ? 27 : _context.t0 === _constants.GL.TRIANGLE_STRIP ? 32 : _context.t0 === _constants.GL.TRIANGLE_FAN ? 36 : 41;
62
- break;
63
-
64
- case 12:
65
- info.i1 = i;
66
- i += 1;
67
- return _context.abrupt("break", 42);
68
-
69
- case 15:
70
- info.i1 = i;
71
- info.i2 = i + 1;
72
- i += 2;
73
- return _context.abrupt("break", 42);
74
-
75
- case 19:
76
- info.i1 = i;
77
- info.i2 = i + 1;
78
- i += 1;
79
- return _context.abrupt("break", 42);
80
-
81
- case 23:
82
- info.i1 = i;
83
- info.i2 = i + 1;
84
- i += 1;
85
- return _context.abrupt("break", 42);
86
-
87
- case 27:
88
- info.i1 = i;
89
- info.i2 = i + 1;
90
- info.i3 = i + 2;
91
- i += 3;
92
- return _context.abrupt("break", 42);
93
-
94
- case 32:
95
- info.i1 = i;
96
- info.i2 = i + 1;
97
- i += 1;
98
- return _context.abrupt("break", 42);
99
-
100
- case 36:
101
- info.i1 = 1;
102
- info.i2 = i;
103
- info.i3 = i + 1;
104
- i += 1;
105
- return _context.abrupt("break", 42);
106
-
107
- case 41:
108
- (0, _loaderUtils.assert)(false);
109
-
110
- case 42:
111
- if (indices) {
112
- if ('i1' in info) {
113
- info.i1 = indices[info.i1];
114
- info.i2 = indices[info.i2];
115
- info.i3 = indices[info.i3];
116
- }
117
- }
118
-
119
- _context.next = 45;
120
- return info;
121
-
122
- case 45:
123
- _context.next = 8;
124
- break;
125
-
126
- case 47:
127
- case "end":
128
- return _context.stop();
14
+ function* makePrimitiveIterator(indices, attributes = {}, mode, start = 0, end) {
15
+ if (indices) {
16
+ indices = indices.values || indices.value || indices;
17
+ }
18
+
19
+ if (end === undefined) {
20
+ end = indices ? indices.length : start;
21
+ }
22
+
23
+ const info = {
24
+ attributes,
25
+ type: (0, _modes.getPrimitiveModeType)(mode),
26
+ i1: 0,
27
+ i2: 0,
28
+ i3: 0
29
+ };
30
+ let i = start;
31
+
32
+ while (i < end) {
33
+ switch (mode) {
34
+ case _constants.GL.POINTS:
35
+ info.i1 = i;
36
+ i += 1;
37
+ break;
38
+
39
+ case _constants.GL.LINES:
40
+ info.i1 = i;
41
+ info.i2 = i + 1;
42
+ i += 2;
43
+ break;
44
+
45
+ case _constants.GL.LINE_STRIP:
46
+ info.i1 = i;
47
+ info.i2 = i + 1;
48
+ i += 1;
49
+ break;
50
+
51
+ case _constants.GL.LINE_LOOP:
52
+ info.i1 = i;
53
+ info.i2 = i + 1;
54
+ i += 1;
55
+ break;
56
+
57
+ case _constants.GL.TRIANGLES:
58
+ info.i1 = i;
59
+ info.i2 = i + 1;
60
+ info.i3 = i + 2;
61
+ i += 3;
62
+ break;
63
+
64
+ case _constants.GL.TRIANGLE_STRIP:
65
+ info.i1 = i;
66
+ info.i2 = i + 1;
67
+ i += 1;
68
+ break;
69
+
70
+ case _constants.GL.TRIANGLE_FAN:
71
+ info.i1 = 1;
72
+ info.i2 = i;
73
+ info.i3 = i + 1;
74
+ i += 1;
75
+ break;
76
+
77
+ default:
78
+ (0, _loaderUtils.assert)(false);
79
+ }
80
+
81
+ if (indices) {
82
+ if ('i1' in info) {
83
+ info.i1 = indices[info.i1];
84
+ info.i2 = indices[info.i2];
85
+ info.i3 = indices[info.i3];
129
86
  }
130
87
  }
131
- }, _marked);
88
+
89
+ yield info;
90
+ }
132
91
  }
133
92
  //# sourceMappingURL=primitive-iterator.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/geometry/iterators/primitive-iterator.ts"],"names":["makePrimitiveIterator","indices","attributes","mode","start","end","values","value","undefined","length","info","type","i1","i2","i3","i","GL","POINTS","LINES","LINE_STRIP","LINE_LOOP","TRIANGLES","TRIANGLE_STRIP","TRIANGLE_FAN"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AACA;;wCAsBiBA,qB;;AAAV,SAAUA,qBAAV,CACLC,OADK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;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Type} from '../primitives/modes';\nimport {assert} from '@loaders.gl/loader-utils';\n\n/**\n * Iteration info for making primitive iterator\n */\ntype Information = {\n attributes: object;\n type: number | void;\n i1: number;\n i2: number;\n i3: number;\n primitiveIndex?: object;\n};\n/**\n * Will iterate over each primitive, expanding (dereferencing) indices\n * @param indices\n * @param attributes\n * @param mode\n * @param start\n * @param end\n */\n// eslint-disable-next-line complexity\nexport function* makePrimitiveIterator(\n indices?: any,\n attributes: object = {},\n mode?: number,\n start = 0,\n end?: number\n): Iterable<{attributes: object; type: number; i1: number; i2: number; i3: number}> {\n // support indices being an object with a values array\n if (indices) {\n indices = indices.values || indices.value || indices;\n }\n\n // Autodeduce length from indices\n if (end === undefined) {\n end = indices ? indices.length : start;\n }\n\n // iteration info\n const info: Information = {\n attributes,\n type: getPrimitiveModeType(mode),\n i1: 0,\n i2: 0,\n i3: 0\n };\n\n let i = start;\n // @ts-ignore\n while (i < end) {\n switch (mode) {\n case GL.POINTS: // draw single points.\n info.i1 = i;\n i += 1;\n break;\n case GL.LINES: // draw lines. Each set of two vertices is treated as a separate line segment.\n info.i1 = i;\n info.i2 = i + 1;\n i += 2;\n break;\n case GL.LINE_STRIP: // draw lines. Each vertex connects to the one after it.\n info.i1 = i;\n info.i2 = i + 1;\n i += 1;\n break;\n case GL.LINE_LOOP: // draw a connected group of line segments from the first vertex to the last\n info.i1 = i;\n info.i2 = i + 1;\n i += 1;\n break;\n case GL.TRIANGLES: // draw triangles. Each set of three vertices creates a separate triangle.\n info.i1 = i;\n info.i2 = i + 1;\n info.i3 = i + 2;\n i += 3;\n break;\n case GL.TRIANGLE_STRIP: // draw a connected group of triangles.\n info.i1 = i;\n info.i2 = i + 1;\n i += 1;\n break;\n case GL.TRIANGLE_FAN: // draw a connected group of triangles.\n info.i1 = 1;\n info.i2 = i;\n info.i3 = i + 1;\n i += 1;\n break;\n\n default:\n assert(false);\n }\n\n // if indices are present, lookup actual vertices in indices\n if (indices) {\n if ('i1' in info) {\n info.i1 = indices[info.i1];\n info.i2 = indices[info.i2];\n info.i3 = indices[info.i3];\n }\n }\n // @ts-ignore\n yield info;\n }\n}\n"],"file":"primitive-iterator.js"}
1
+ {"version":3,"sources":["../../../../src/geometry/iterators/primitive-iterator.ts"],"names":["makePrimitiveIterator","indices","attributes","mode","start","end","values","value","undefined","length","info","type","i1","i2","i3","i","GL","POINTS","LINES","LINE_STRIP","LINE_LOOP","TRIANGLES","TRIANGLE_STRIP","TRIANGLE_FAN"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAsBO,UAAUA,qBAAV,CACLC,OADK,EAELC,UAAkB,GAAG,EAFhB,EAGLC,IAHK,EAILC,KAAK,GAAG,CAJH,EAKLC,GALK,EAM6E;AAElF,MAAIJ,OAAJ,EAAa;AACXA,IAAAA,OAAO,GAAGA,OAAO,CAACK,MAAR,IAAkBL,OAAO,CAACM,KAA1B,IAAmCN,OAA7C;AACD;;AAGD,MAAII,GAAG,KAAKG,SAAZ,EAAuB;AACrBH,IAAAA,GAAG,GAAGJ,OAAO,GAAGA,OAAO,CAACQ,MAAX,GAAoBL,KAAjC;AACD;;AAGD,QAAMM,IAAiB,GAAG;AACxBR,IAAAA,UADwB;AAExBS,IAAAA,IAAI,EAAE,iCAAqBR,IAArB,CAFkB;AAGxBS,IAAAA,EAAE,EAAE,CAHoB;AAIxBC,IAAAA,EAAE,EAAE,CAJoB;AAKxBC,IAAAA,EAAE,EAAE;AALoB,GAA1B;AAQA,MAAIC,CAAC,GAAGX,KAAR;;AAEA,SAAOW,CAAC,GAAGV,GAAX,EAAgB;AACd,YAAQF,IAAR;AACE,WAAKa,cAAGC,MAAR;AACEP,QAAAA,IAAI,CAACE,EAAL,GAAUG,CAAV;AACAA,QAAAA,CAAC,IAAI,CAAL;AACA;;AACF,WAAKC,cAAGE,KAAR;AACER,QAAAA,IAAI,CAACE,EAAL,GAAUG,CAAV;AACAL,QAAAA,IAAI,CAACG,EAAL,GAAUE,CAAC,GAAG,CAAd;AACAA,QAAAA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O,CAACS,IAAI,CAACI,EAAN,CAAjB;AACD;AACF;;AAED,UAAMJ,IAAN;AACD;AACF","sourcesContent":["import {GL} from '../constants';\nimport {getPrimitiveModeType} from '../primitives/modes';\nimport {assert} from '@loaders.gl/loader-utils';\n\n/**\n * Iteration info for making primitive iterator\n */\ntype Information = {\n attributes: object;\n type: number | void;\n i1: number;\n i2: number;\n i3: number;\n primitiveIndex?: object;\n};\n/**\n * Will iterate over each primitive, expanding (dereferencing) indices\n * @param indices\n * @param attributes\n * @param mode\n * @param start\n * @param end\n */\n// eslint-disable-next-line complexity\nexport function* makePrimitiveIterator(\n indices?: any,\n attributes: object = {},\n mode?: number,\n start = 0,\n end?: number\n): Iterable<{attributes: object; type: number; i1: number; i2: number; i3: number}> {\n // support indices being an object with a values array\n if (indices) {\n indices = indices.values || indices.value || indices;\n }\n\n // Autodeduce length from indices\n if (end === undefined) {\n end = indices ? indices.length : start;\n }\n\n // iteration info\n const info: Information = {\n attributes,\n type: getPrimitiveModeType(mode),\n i1: 0,\n i2: 0,\n i3: 0\n };\n\n let i = start;\n // @ts-ignore\n while (i < end) {\n switch (mode) {\n case GL.POINTS: // draw single points.\n info.i1 = i;\n i += 1;\n break;\n case GL.LINES: // draw lines. Each set of two vertices is treated as a separate line segment.\n info.i1 = i;\n info.i2 = i + 1;\n i += 2;\n break;\n case GL.LINE_STRIP: // draw lines. Each vertex connects to the one after it.\n info.i1 = i;\n info.i2 = i + 1;\n i += 1;\n break;\n case GL.LINE_LOOP: // draw a connected group of line segments from the first vertex to the last\n info.i1 = i;\n info.i2 = i + 1;\n i += 1;\n break;\n case GL.TRIANGLES: // draw triangles. Each set of three vertices creates a separate triangle.\n info.i1 = i;\n info.i2 = i + 1;\n info.i3 = i + 2;\n i += 3;\n break;\n case GL.TRIANGLE_STRIP: // draw a connected group of triangles.\n info.i1 = i;\n info.i2 = i + 1;\n i += 1;\n break;\n case GL.TRIANGLE_FAN: // draw a connected group of triangles.\n info.i1 = 1;\n info.i2 = i;\n info.i3 = i + 1;\n i += 1;\n break;\n\n default:\n assert(false);\n }\n\n // if indices are present, lookup actual vertices in indices\n if (indices) {\n if ('i1' in info) {\n info.i1 = indices[info.i1];\n info.i2 = indices[info.i2];\n info.i3 = indices[info.i3];\n }\n }\n // @ts-ignore\n yield info;\n }\n}\n"],"file":"primitive-iterator.js"}
@@ -5,22 +5,21 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.concatTypedArrays = concatTypedArrays;
7
7
 
8
- function concatTypedArrays() {
9
- var arrays = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
10
- var byteLength = 0;
8
+ function concatTypedArrays(arrays = []) {
9
+ let byteLength = 0;
11
10
 
12
- for (var i = 0; i < arrays.length; ++i) {
11
+ for (let i = 0; i < arrays.length; ++i) {
13
12
  byteLength += arrays[i].byteLength;
14
13
  }
15
14
 
16
- var buffer = new Uint8Array(byteLength);
17
- var byteOffset = 0;
15
+ const buffer = new Uint8Array(byteLength);
16
+ let byteOffset = 0;
18
17
 
19
- for (var _i = 0; _i < arrays.length; ++_i) {
20
- var data = new Uint8Array(arrays[_i].buffer);
18
+ for (let i = 0; i < arrays.length; ++i) {
19
+ const data = new Uint8Array(arrays[i].buffer);
21
20
  byteLength = data.length;
22
21
 
23
- for (var j = 0; j < byteLength; ++j) {
22
+ for (let j = 0; j < byteLength; ++j) {
24
23
  buffer[byteOffset++] = data[j];
25
24
  }
26
25
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/geometry/typed-arrays/typed-array-utils.ts"],"names":["concatTypedArrays","arrays","byteLength","i","length","buffer","Uint8Array","byteOffset","data","j"],"mappings":";;;;;;;AAKO,SAASA,iBAAT,GAAyD;AAAA,MAA9BC,MAA8B,uEAAhB,EAAgB;AAC9D,MAAIC,UAAU,GAAG,CAAjB;;AACA,OAAK,IAAIC,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGF,MAAM,CAACG,MAA3B,EAAmC,EAAED,CAArC,EAAwC;AACtCD,IAAAA,UAAU,IAAID,MAAM,CAACE,CAAD,CAAN,CAAUD,UAAxB;AACD;;AACD,MAAMG,MAAM,GAAG,IAAIC,UAAJ,CAAeJ,UAAf,CAAf;AAEA,MAAIK,UAAU,GAAG,CAAjB;;AACA,OAAK,IAAIJ,EAAC,GAAG,CAAb,EAAgBA,EAAC,GAAGF,MAAM,CAACG,MAA3B,EAAmC,EAAED,EAArC,EAAwC;AACtC,QAAMK,IAAI,GAAG,IAAIF,UAAJ,CAAeL,MAAM,CAACE,EAAD,CAAN,CAAUE,MAAzB,CAAb;AACAH,IAAAA,UAAU,GAAGM,IAAI,CAACJ,MAAlB;;AACA,SAAK,IAAIK,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGP,UAApB,EAAgC,EAAEO,CAAlC,EAAqC;AACnCJ,MAAAA,MAAM,CAACE,UAAU,EAAX,CAAN,GAAuBC,IAAI,CAACC,CAAD,CAA3B;AACD;AACF;;AACD,SAAOJ,MAAP;AACD","sourcesContent":["/**\n * Concats typed arrays\n * @param arrays\n * @returns new Uint8Array\n */\nexport function concatTypedArrays(arrays: any = []): Uint8Array {\n let byteLength = 0;\n for (let i = 0; i < arrays.length; ++i) {\n byteLength += arrays[i].byteLength;\n }\n const buffer = new Uint8Array(byteLength);\n\n let byteOffset = 0;\n for (let i = 0; i < arrays.length; ++i) {\n const data = new Uint8Array(arrays[i].buffer);\n byteLength = data.length;\n for (let j = 0; j < byteLength; ++j) {\n buffer[byteOffset++] = data[j];\n }\n }\n return buffer;\n}\n"],"file":"typed-array-utils.js"}
1
+ {"version":3,"sources":["../../../../src/geometry/typed-arrays/typed-array-utils.ts"],"names":["concatTypedArrays","arrays","byteLength","i","length","buffer","Uint8Array","byteOffset","data","j"],"mappings":";;;;;;;AAKO,SAASA,iBAAT,CAA2BC,MAAW,GAAG,EAAzC,EAAyD;AAC9D,MAAIC,UAAU,GAAG,CAAjB;;AACA,OAAK,IAAIC,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGF,MAAM,CAACG,MAA3B,EAAmC,EAAED,CAArC,EAAwC;AACtCD,IAAAA,UAAU,IAAID,MAAM,CAACE,CAAD,CAAN,CAAUD,UAAxB;AACD;;AACD,QAAMG,MAAM,GAAG,IAAIC,UAAJ,CAAeJ,UAAf,CAAf;AAEA,MAAIK,UAAU,GAAG,CAAjB;;AACA,OAAK,IAAIJ,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGF,MAAM,CAACG,MAA3B,EAAmC,EAAED,CAArC,EAAwC;AACtC,UAAMK,IAAI,GAAG,IAAIF,UAAJ,CAAeL,MAAM,CAACE,CAAD,CAAN,CAAUE,MAAzB,CAAb;AACAH,IAAAA,UAAU,GAAGM,IAAI,CAACJ,MAAlB;;AACA,SAAK,IAAIK,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGP,UAApB,EAAgC,EAAEO,CAAlC,EAAqC;AACnCJ,MAAAA,MAAM,CAACE,UAAU,EAAX,CAAN,GAAuBC,IAAI,CAACC,CAAD,CAA3B;AACD;AACF;;AACD,SAAOJ,MAAP;AACD","sourcesContent":["/**\n * Concats typed arrays\n * @param arrays\n * @returns new Uint8Array\n */\nexport function concatTypedArrays(arrays: any = []): Uint8Array {\n let byteLength = 0;\n for (let i = 0; i < arrays.length; ++i) {\n byteLength += arrays[i].byteLength;\n }\n const buffer = new Uint8Array(byteLength);\n\n let byteOffset = 0;\n for (let i = 0; i < arrays.length; ++i) {\n const data = new Uint8Array(arrays[i].buffer);\n byteLength = data.length;\n for (let j = 0; j < byteLength; ++j) {\n buffer[byteOffset++] = data[j];\n }\n }\n return buffer;\n}\n"],"file":"typed-array-utils.js"}
package/dist/es5/index.js CHANGED
@@ -7,145 +7,145 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  Object.defineProperty(exports, "GL", {
9
9
  enumerable: true,
10
- get: function get() {
10
+ get: function () {
11
11
  return _constants.GL;
12
12
  }
13
13
  });
14
14
  Object.defineProperty(exports, "GL_TYPE", {
15
15
  enumerable: true,
16
- get: function get() {
16
+ get: function () {
17
17
  return _constants.GL_TYPE;
18
18
  }
19
19
  });
20
20
  Object.defineProperty(exports, "GLType", {
21
21
  enumerable: true,
22
- get: function get() {
22
+ get: function () {
23
23
  return _glType.default;
24
24
  }
25
25
  });
26
26
  Object.defineProperty(exports, "isGeometry", {
27
27
  enumerable: true,
28
- get: function get() {
28
+ get: function () {
29
29
  return _isGeometry.default;
30
30
  }
31
31
  });
32
32
  Object.defineProperty(exports, "makeAttributeIterator", {
33
33
  enumerable: true,
34
- get: function get() {
34
+ get: function () {
35
35
  return _attributeIterator.makeAttributeIterator;
36
36
  }
37
37
  });
38
38
  Object.defineProperty(exports, "makePrimitiveIterator", {
39
39
  enumerable: true,
40
- get: function get() {
40
+ get: function () {
41
41
  return _primitiveIterator.makePrimitiveIterator;
42
42
  }
43
43
  });
44
44
  Object.defineProperty(exports, "computeVertexNormals", {
45
45
  enumerable: true,
46
- get: function get() {
46
+ get: function () {
47
47
  return _computeVertexNormals.computeVertexNormals;
48
48
  }
49
49
  });
50
50
  Object.defineProperty(exports, "encodeRGB565", {
51
51
  enumerable: true,
52
- get: function get() {
52
+ get: function () {
53
53
  return _rgb.encodeRGB565;
54
54
  }
55
55
  });
56
56
  Object.defineProperty(exports, "decodeRGB565", {
57
57
  enumerable: true,
58
- get: function get() {
58
+ get: function () {
59
59
  return _rgb.decodeRGB565;
60
60
  }
61
61
  });
62
62
  Object.defineProperty(exports, "concatTypedArrays", {
63
63
  enumerable: true,
64
- get: function get() {
64
+ get: function () {
65
65
  return _typedArrayUtils.concatTypedArrays;
66
66
  }
67
67
  });
68
68
  Object.defineProperty(exports, "octEncodeInRange", {
69
69
  enumerable: true,
70
- get: function get() {
70
+ get: function () {
71
71
  return _attributeCompression.octEncodeInRange;
72
72
  }
73
73
  });
74
74
  Object.defineProperty(exports, "octEncode", {
75
75
  enumerable: true,
76
- get: function get() {
76
+ get: function () {
77
77
  return _attributeCompression.octEncode;
78
78
  }
79
79
  });
80
80
  Object.defineProperty(exports, "octEncodeToVector4", {
81
81
  enumerable: true,
82
- get: function get() {
82
+ get: function () {
83
83
  return _attributeCompression.octEncodeToVector4;
84
84
  }
85
85
  });
86
86
  Object.defineProperty(exports, "octDecodeInRange", {
87
87
  enumerable: true,
88
- get: function get() {
88
+ get: function () {
89
89
  return _attributeCompression.octDecodeInRange;
90
90
  }
91
91
  });
92
92
  Object.defineProperty(exports, "octDecode", {
93
93
  enumerable: true,
94
- get: function get() {
94
+ get: function () {
95
95
  return _attributeCompression.octDecode;
96
96
  }
97
97
  });
98
98
  Object.defineProperty(exports, "octDecodeFromVector4", {
99
99
  enumerable: true,
100
- get: function get() {
100
+ get: function () {
101
101
  return _attributeCompression.octDecodeFromVector4;
102
102
  }
103
103
  });
104
104
  Object.defineProperty(exports, "octPackFloat", {
105
105
  enumerable: true,
106
- get: function get() {
106
+ get: function () {
107
107
  return _attributeCompression.octPackFloat;
108
108
  }
109
109
  });
110
110
  Object.defineProperty(exports, "octEncodeFloat", {
111
111
  enumerable: true,
112
- get: function get() {
112
+ get: function () {
113
113
  return _attributeCompression.octEncodeFloat;
114
114
  }
115
115
  });
116
116
  Object.defineProperty(exports, "octDecodeFloat", {
117
117
  enumerable: true,
118
- get: function get() {
118
+ get: function () {
119
119
  return _attributeCompression.octDecodeFloat;
120
120
  }
121
121
  });
122
122
  Object.defineProperty(exports, "octPack", {
123
123
  enumerable: true,
124
- get: function get() {
124
+ get: function () {
125
125
  return _attributeCompression.octPack;
126
126
  }
127
127
  });
128
128
  Object.defineProperty(exports, "octUnpack", {
129
129
  enumerable: true,
130
- get: function get() {
130
+ get: function () {
131
131
  return _attributeCompression.octUnpack;
132
132
  }
133
133
  });
134
134
  Object.defineProperty(exports, "compressTextureCoordinates", {
135
135
  enumerable: true,
136
- get: function get() {
136
+ get: function () {
137
137
  return _attributeCompression.compressTextureCoordinates;
138
138
  }
139
139
  });
140
140
  Object.defineProperty(exports, "decompressTextureCoordinates", {
141
141
  enumerable: true,
142
- get: function get() {
142
+ get: function () {
143
143
  return _attributeCompression.decompressTextureCoordinates;
144
144
  }
145
145
  });
146
146
  Object.defineProperty(exports, "zigZagDeltaDecode", {
147
147
  enumerable: true,
148
- get: function get() {
148
+ get: function () {
149
149
  return _attributeCompression.zigZagDeltaDecode;
150
150
  }
151
151
  });
@@ -59,7 +59,7 @@ export function octDecodeInRange(x, y, rangeMax, result) {
59
59
  assert(result);
60
60
 
61
61
  if (x < 0 || x > rangeMax || y < 0 || y > rangeMax) {
62
- throw new Error(`x and y must be unsigned normalized integers between 0 and ${rangeMax}`);
62
+ throw new Error("x and y must be unsigned normalized integers between 0 and ".concat(rangeMax));
63
63
  }
64
64
 
65
65
  result.x = fromSNorm(x, rangeMax);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/geometry/compression/attribute-compression.ts"],"names":["Vector2","Vector3","clamp","_MathUtils","assert","RIGHT_SHIFT","LEFT_SHIFT","scratchVector2","scratchVector3","scratchEncodeVector2","octEncodeScratch","uint8ForceArray","Uint8Array","forceUint8","value","fromSNorm","rangeMaximum","toSNorm","Math","round","signNotZero","octEncodeInRange","vector","rangeMax","result","vector3","from","abs","magnitudeSquared","EPSILON6","x","y","z","octEncode","octEncodeToVector4","w","octDecodeInRange","Error","oldVX","normalize","octDecode","octDecodeFromVector4","encoded","xOct16","yOct16","octPackFloat","vector2","octEncodeFloat","octDecodeFloat","Number","isFinite","temp","floor","octPack","v1","v2","v3","encoded1","encoded2","encoded3","octUnpack","packed","encodedFloat1","encodedFloat2","compressTextureCoordinates","textureCoordinates","decompressTextureCoordinates","compressed","xZeroTo4095","zigZagDeltaDecode","uBuffer","vBuffer","heightBuffer","length","zigZagDecode","u","v","height","i"],"mappings":"AAKA,SAAQA,OAAR,EAAiBC,OAAjB,EAA0BC,KAA1B,EAAiCC,UAAjC,QAAkD,eAAlD;AAEA,SAAQC,MAAR,QAAqB,iBAArB;AAEA,MAAMC,WAAW,GAAG,MAA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A,MAAM,IAAIH,YAAY,CAACF,YAAY,CAACM,CAAD,CAAb,CAAtB;AACAN,MAAAA,YAAY,CAACM,CAAD,CAAZ,GAAkBD,MAAlB;AACD;AACF;AACF","sourcesContent":["// This file is derived from the Cesium code base under Apache 2 license\n// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md\n\n// Attribute compression and decompression functions.\n\nimport {Vector2, Vector3, clamp, _MathUtils} from '@math.gl/core';\nimport {Vector4} from '../types';\nimport {assert} from '../utils/assert';\n\nconst RIGHT_SHIFT = 1.0 / 256.0;\nconst LEFT_SHIFT = 256.0;\n\nconst scratchVector2 = new Vector2();\nconst scratchVector3 = new Vector3();\nconst scratchEncodeVector2 = new Vector2();\nconst octEncodeScratch = new Vector2();\n\nconst uint8ForceArray = new Uint8Array(1);\n\n/**\n * Force a value to Uint8\n *\n * @param value\n * @returns\n */\nfunction forceUint8(value: number): number {\n uint8ForceArray[0] = value;\n return uint8ForceArray[0];\n}\n\n/**\n * Converts a SNORM value in the range [0, rangeMaximum] to a scalar in the range [-1.0, 1.0].\n *\n * @param value SNORM value in the range [0, rangeMaximum]\n * @param [rangeMaximum=255] The maximum value in the SNORM range, 255 by default.\n * @returns Scalar in the range [-1.0, 1.0].\n *\n * @see CesiumMath.toSNorm\n */\nfunction fromSNorm(value: number, rangeMaximum = 255): number {\n return (clamp(value, 0.0, rangeMaximum) / rangeMaximum) * 2.0 - 1.0;\n}\n\n/**\n * Converts a scalar value in the range [-1.0, 1.0] to a SNORM in the range [0, rangeMaximum].\n *\n * @param value The scalar value in the range [-1.0, 1.0]\n * @param [rangeMaximum=255] The maximum value in the mapped range, 255 by default.\n * @returns A SNORM value, where 0 maps to -1.0 and rangeMaximum maps to 1.0.\n *\n * @see CesiumMath.fromSNorm\n */\nfunction toSNorm(value: number, rangeMaximum = 255): number {\n return Math.round((clamp(value, -1.0, 1.0) * 0.5 + 0.5) * rangeMaximum);\n}\n\n/**\n * Returns 1.0 if the given value is positive or zero, and -1.0 if it is negative.\n * This is similar to `Math.sign` except that returns 1.0 instead of\n * 0.0 when the input value is 0.0.\n *\n * @param value The value to return the sign of.\n * @returns The sign of value.\n */\nfunction signNotZero(value: number): number {\n return value < 0.0 ? -1.0 : 1.0;\n}\n\n/**\n * Encodes a normalized vector into 2 SNORM values in the range of [0-rangeMax] following the 'oct' encoding.\n *\n * Oct encoding is a compact representation of unit length vectors.\n * The 'oct' encoding is described in \"A Survey of Efficient Representations of Independent Unit Vectors\",\n * Cigolle et al 2014: {@link http://jcgt.org/published/0003/02/01/}\n *\n * @param vector The normalized vector to be compressed into 2 component 'oct' encoding.\n * @param result The 2 component oct-encoded unit length vector.\n * @param rangeMax The maximum value of the SNORM range. The encoded vector is stored in log2(rangeMax+1) bits.\n * @returns The 2 component oct-encoded unit length vector.\n *\n * @exception vector must be normalized.\n *\n * @see octDecodeInRange\n */\nexport function octEncodeInRange(vector: Vector3, rangeMax: number, result: Vector2): Vector2 {\n assert(vector);\n assert(result);\n\n const vector3 = scratchVector3.from(vector);\n\n assert(Math.abs(vector3.magnitudeSquared() - 1.0) <= _MathUtils.EPSILON6);\n\n result.x = vector.x / (Math.abs(vector.x) + Math.abs(vector.y) + Math.abs(vector.z));\n result.y = vector.y / (Math.abs(vector.x) + Math.abs(vector.y) + Math.abs(vector.z));\n\n if (vector.z < 0) {\n const x = result.x;\n const y = result.y;\n result.x = (1.0 - Math.abs(y)) * signNotZero(x);\n result.y = (1.0 - Math.abs(x)) * signNotZero(y);\n }\n\n result.x = toSNorm(result.x, rangeMax);\n result.y = toSNorm(result.y, rangeMax);\n\n return result;\n}\n\n/**\n * Encodes a normalized vector into 2 SNORM values in the range of [0-255] following the 'oct' encoding.\n *\n * @param vector The normalized vector to be compressed into 2 byte 'oct' encoding.\n * @param result The 2 byte oct-encoded unit length vector.\n * @returns he 2 byte oct-encoded unit length vector.\n *\n * @exception vector must be normalized.\n *\n * @see octEncodeInRange\n * @see octDecode\n */\nexport function octEncode(vector: Vector3, result: Vector2): Vector2 {\n return octEncodeInRange(vector, 255, result);\n}\n\n/**\n * Encodes a normalized vector into 4-byte vector\n * @param vector The normalized vector to be compressed into 4 byte 'oct' encoding.\n * @param result The 4 byte oct-encoded unit length vector.\n * @returns The 4 byte oct-encoded unit length vector.\n *\n * @exception vector must be normalized.\n *\n * @see octEncodeInRange\n * @see octDecodeFromVector4\n */\nexport function octEncodeToVector4(vector: Vector3, result: Vector4): Vector4 {\n octEncodeInRange(vector, 65535, octEncodeScratch);\n result.x = forceUint8(octEncodeScratch.x * RIGHT_SHIFT);\n result.y = forceUint8(octEncodeScratch.x);\n result.z = forceUint8(octEncodeScratch.y * RIGHT_SHIFT);\n result.w = forceUint8(octEncodeScratch.y);\n return result;\n}\n\n/**\n * Decodes a unit-length vector in 'oct' encoding to a normalized 3-component vector.\n *\n * @param x The x component of the oct-encoded unit length vector.\n * @param y The y component of the oct-encoded unit length vector.\n * @param rangeMax The maximum value of the SNORM range. The encoded vector is stored in log2(rangeMax+1) bits.\n * @param result The decoded and normalized vector\n * @returns The decoded and normalized vector.\n *\n * @exception x and y must be unsigned normalized integers between 0 and rangeMax.\n *\n * @see octEncodeInRange\n */\nexport function octDecodeInRange(x: number, y: number, rangeMax: number, result: Vector3): Vector3 {\n assert(result);\n if (x < 0 || x > rangeMax || y < 0 || y > rangeMax) {\n throw new Error(`x and y must be unsigned normalized integers between 0 and ${rangeMax}`);\n }\n\n result.x = fromSNorm(x, rangeMax);\n result.y = fromSNorm(y, rangeMax);\n result.z = 1.0 - (Math.abs(result.x) + Math.abs(result.y));\n\n if (result.z < 0.0) {\n const oldVX = result.x;\n result.x = (1.0 - Math.abs(result.y)) * signNotZero(oldVX);\n result.y = (1.0 - Math.abs(oldVX)) * signNotZero(result.y);\n }\n\n return result.normalize();\n}\n\n/**\n * Decodes a unit-length vector in 2 byte 'oct' encoding to a normalized 3-component vector.\n *\n * @param x The x component of the oct-encoded unit length vector.\n * @param y The y component of the oct-encoded unit length vector.\n * @param result The decoded and normalized vector.\n * @returns he decoded and normalized vector.\n *\n * @exception x and y must be an unsigned normalized integer between 0 and 255.\n *\n * @see octDecodeInRange\n */\nexport function octDecode(x: number, y: number, result: Vector3): Vector3 {\n return octDecodeInRange(x, y, 255, result);\n}\n\n/**\n * Decodes a unit-length vector in 4 byte 'oct' encoding to a normalized 3-component vector.\n *\n * @param encoded The oct-encoded unit length vector.\n * @param esult The decoded and normalized vector.\n * @returns The decoded and normalized vector.\n *\n * @exception x, y, z, and w must be unsigned normalized integers between 0 and 255.\n *\n * @see octDecodeInRange\n * @see octEncodeToVector4\n */\nexport function octDecodeFromVector4(encoded: Vector4, result: Vector3): Vector3 {\n assert(encoded);\n assert(result);\n const x = encoded.x;\n const y = encoded.y;\n const z = encoded.z;\n const w = encoded.w;\n\n if (x < 0 || x > 255 || y < 0 || y > 255 || z < 0 || z > 255 || w < 0 || w > 255) {\n throw new Error('x, y, z, and w must be unsigned normalized integers between 0 and 255');\n }\n\n const xOct16 = x * LEFT_SHIFT + y;\n const yOct16 = z * LEFT_SHIFT + w;\n return octDecodeInRange(xOct16, yOct16, 65535, result);\n}\n\n/**\n * Packs an oct encoded vector into a single floating-point number.\n *\n * @param encoded The oct encoded vector.\n * @returns The oct encoded vector packed into a single float.\n *\n */\nexport function octPackFloat(encoded: Vector2): number {\n const vector2 = scratchVector2.from(encoded);\n return 256.0 * vector2.x + vector2.y;\n}\n\n/**\n * Encodes a normalized vector into 2 SNORM values in the range of [0-255] following the 'oct' encoding and\n * stores those values in a single float-point number.\n *\n * @param vector The normalized vector to be compressed into 2 byte 'oct' encoding.\n * @returns The 2 byte oct-encoded unit length vector.\n *\n * @exception vector must be normalized.\n */\nexport function octEncodeFloat(vector: Vector3): number {\n octEncode(vector, scratchEncodeVector2);\n return octPackFloat(scratchEncodeVector2);\n}\n\n/**\n * Decodes a unit-length vector in 'oct' encoding packed in a floating-point number to a normalized 3-component vector.\n *\n * @param value The oct-encoded unit length vector stored as a single floating-point number.\n * @param result The decoded and normalized vector\n * @returns The decoded and normalized vector.\n *\n */\nexport function octDecodeFloat(value: number, result: Vector3): Vector3 {\n assert(Number.isFinite(value));\n\n const temp = value / 256.0;\n const x = Math.floor(temp);\n const y = (temp - x) * 256.0;\n\n return octDecode(x, y, result);\n}\n\n/**\n * Encodes three normalized vectors into 6 SNORM values in the range of [0-255] following the 'oct' encoding and\n * packs those into two floating-point numbers.\n *\n * @param v1 A normalized vector to be compressed.\n * @param v2 A normalized vector to be compressed.\n * @param v3 A normalized vector to be compressed.\n * @param result The 'oct' encoded vectors packed into two floating-point numbers.\n * @returns The 'oct' encoded vectors packed into two floating-point numbers.\n *\n */\nexport function octPack(v1: Vector3, v2: Vector3, v3: Vector3, result: Vector2): Vector2 {\n assert(v1);\n assert(v2);\n assert(v3);\n assert(result);\n\n const encoded1 = octEncodeFloat(v1);\n const encoded2 = octEncodeFloat(v2);\n\n const encoded3 = octEncode(v3, scratchEncodeVector2);\n result.x = 65536.0 * encoded3.x + encoded1;\n result.y = 65536.0 * encoded3.y + encoded2;\n return result;\n}\n\n/**\n * Decodes three unit-length vectors in 'oct' encoding packed into a floating-point number to a normalized 3-component vector.\n *\n * @param packed The three oct-encoded unit length vectors stored as two floating-point number.\n * @param v1 One decoded and normalized vector.\n * @param v2 One decoded and normalized vector.\n * @param v3 One decoded and normalized vector.\n */\nexport function octUnpack(packed: Vector2, v1: Vector3, v2: Vector3, v3: Vector3): void {\n let temp = packed.x / 65536.0;\n const x = Math.floor(temp);\n const encodedFloat1 = (temp - x) * 65536.0;\n\n temp = packed.y / 65536.0;\n const y = Math.floor(temp);\n const encodedFloat2 = (temp - y) * 65536.0;\n\n octDecodeFloat(encodedFloat1, v1);\n octDecodeFloat(encodedFloat2, v2);\n octDecode(x, y, v3);\n}\n\n/**\n * Pack texture coordinates into a single float. The texture coordinates will only preserve 12 bits of precision.\n *\n * @param textureCoordinates The texture coordinates to compress. Both coordinates must be in the range 0.0-1.0.\n * @returns The packed texture coordinates.\n *\n */\nexport function compressTextureCoordinates(textureCoordinates: Vector2): number {\n // Move x and y to the range 0-4095;\n const x = (textureCoordinates.x * 4095.0) | 0;\n const y = (textureCoordinates.y * 4095.0) | 0;\n return 4096.0 * x + y;\n}\n\n/**\n * Decompresses texture coordinates that were packed into a single float.\n *\n * @param compressed The compressed texture coordinates.\n * @param result The decompressed texture coordinates.\n * @returns The modified result parameter.\n *\n */\nexport function decompressTextureCoordinates(compressed: number, result: Vector2): Vector2 {\n const temp = compressed / 4096.0;\n const xZeroTo4095 = Math.floor(temp);\n result.x = xZeroTo4095 / 4095.0;\n result.y = (compressed - xZeroTo4095 * 4096) / 4095;\n return result;\n}\n\n/**\n * Decodes delta and ZigZag encoded vertices. This modifies the buffers in place.\n *\n * @param uBuffer The buffer view of u values.\n * @param vBuffer The buffer view of v values.\n * @param [heightBuffer] The buffer view of height values.\n *\n * @link https://github.com/AnalyticalGraphicsInc/quantized-mesh|quantized-mesh-1.0 terrain format\n */\nexport function zigZagDeltaDecode(\n uBuffer: Uint16Array,\n vBuffer: Uint16Array,\n heightBuffer?: Uint16Array | number[]\n) {\n assert(uBuffer);\n assert(vBuffer);\n assert(uBuffer.length === vBuffer.length);\n if (heightBuffer) {\n assert(uBuffer.length === heightBuffer.length);\n }\n\n function zigZagDecode(value: number) {\n return (value >> 1) ^ -(value & 1);\n }\n\n let u = 0;\n let v = 0;\n let height = 0;\n\n for (let i = 0; i < uBuffer.length; ++i) {\n u += zigZagDecode(uBuffer[i]);\n v += zigZagDecode(vBuffer[i]);\n\n uBuffer[i] = u;\n vBuffer[i] = v;\n\n if (heightBuffer) {\n height += zigZagDecode(heightBuffer[i]);\n heightBuffer[i] = height;\n }\n }\n}\n"],"file":"attribute-compression.js"}
1
+ {"version":3,"sources":["../../../../src/geometry/compression/attribute-compression.ts"],"names":["Vector2","Vector3","clamp","_MathUtils","assert","RIGHT_SHIFT","LEFT_SHIFT","scratchVector2","scratchVector3","scratchEncodeVector2","octEncodeScratch","uint8ForceArray","Uint8Array","forceUint8","value","fromSNorm","rangeMaximum","toSNorm","Math","round","signNotZero","octEncodeInRange","vector","rangeMax","result","vector3","from","abs","magnitudeSquared","EPSILON6","x","y","z","octEncode","octEncodeToVector4","w","octDecodeInRange","Error","oldVX","normalize","octDecode","octDecodeFromVector4","encoded","xOct16","yOct16","octPackFloat","vector2","octEncodeFloat","octDecodeFloat","Number","isFinite","temp","floor","octPack","v1","v2","v3","encoded1","encoded2","encoded3","octUnpack","packed","encodedFloat1","encodedFloat2","compressTextureCoordinates","textureCoordinates","decompressTextureCoordinates","compressed","xZeroTo4095","zigZagDeltaDecode","uBuffer","vBuffer","heightBuffer","length","zigZagDecode","u","v","height","i"],"mappings":"AAKA,SAAQA,OAAR,EAAiBC,OAAjB,EAA0BC,KAA1B,EAAiCC,UAAjC,QAAkD,eAAlD;AAEA,SAAQC,MAAR,QAAqB,iBAArB;AAEA,MAAMC,WAAW,GAAG,MAAM,KAA1B;AACA,MAAMC,UAAU,GAAG,KAAnB;AAEA,MAAMC,cAAc,GAAG,IAAIP,OAAJ,EAAvB;AACA,MAAMQ,cAAc,GAAG,IAAIP,OAAJ,EAAvB;AACA,MAAMQ,oBAAoB,GAAG,IAAIT,OAAJ,EAA7B;AACA,MAAMU,gBAAgB,GAAG,IAAIV,OAAJ,EAAzB;AAEA,MAAMW,eAAe,GAAG,IAAIC,UAAJ,CAAe,CAAf,CAAxB;;AAQA,SAASC,UAAT,CAAoBC,KAApB,EAA2C;AACzCH,EAAAA,eAAe,CAAC,CAAD,CAAf,GAAqBG,KAArB;AACA,SAAOH,eAAe,CAAC,CAAD,CAAtB;AACD;;AAWD,SAASI,SAAT,CAAmBD,KAAnB,EAAkCE,YAAY,GAAG,GAAjD,EAA8D;AAC5D,SAAQd,KAAK,CAACY,KAAD,EAAQ,GAAR,EAAaE,YAAb,CAAL,GAAkCA,YAAnC,GAAmD,GAAnD,GAAyD,GAAhE;AACD;;AAWD,SAASC,OAAT,CAAiBH,KAAjB,EA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AAqC;AACnC,WAAQA,KAAK,IAAI,CAAV,GAAe,EAAEA,KAAK,GAAG,CAAV,CAAtB;AACD;;AAED,MAAI6D,CAAC,GAAG,CAAR;AACA,MAAIC,CAAC,GAAG,CAAR;AACA,MAAIC,MAAM,GAAG,CAAb;;AAEA,OAAK,IAAIC,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGR,OAAO,CAACG,MAA5B,EAAoC,EAAEK,CAAtC,EAAyC;AACvCH,IAAAA,CAAC,IAAID,YAAY,CAACJ,OAAO,CAACQ,CAAD,CAAR,CAAjB;AACAF,IAAAA,CAAC,IAAIF,YAAY,CAACH,OAAO,CAACO,CAAD,CAAR,CAAjB;AAEAR,IAAAA,OAAO,CAACQ,CAAD,CAAP,GAAaH,CAAb;AACAJ,IAAAA,OAAO,CAACO,CAAD,CAAP,GAAaF,CAAb;;AAEA,QAAIJ,YAAJ,EAAkB;AAChBK,MAAAA,MAAM,IAAIH,YAAY,CAACF,YAAY,CAACM,CAAD,CAAb,CAAtB;AACAN,MAAAA,YAAY,CAACM,CAAD,CAAZ,GAAkBD,MAAlB;AACD;AACF;AACF","sourcesContent":["// This file is derived from the Cesium code base under Apache 2 license\n// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md\n\n// Attribute compression and decompression functions.\n\nimport {Vector2, Vector3, clamp, _MathUtils} from '@math.gl/core';\nimport {Vector4} from '../types';\nimport {assert} from '../utils/assert';\n\nconst RIGHT_SHIFT = 1.0 / 256.0;\nconst LEFT_SHIFT = 256.0;\n\nconst scratchVector2 = new Vector2();\nconst scratchVector3 = new Vector3();\nconst scratchEncodeVector2 = new Vector2();\nconst octEncodeScratch = new Vector2();\n\nconst uint8ForceArray = new Uint8Array(1);\n\n/**\n * Force a value to Uint8\n *\n * @param value\n * @returns\n */\nfunction forceUint8(value: number): number {\n uint8ForceArray[0] = value;\n return uint8ForceArray[0];\n}\n\n/**\n * Converts a SNORM value in the range [0, rangeMaximum] to a scalar in the range [-1.0, 1.0].\n *\n * @param value SNORM value in the range [0, rangeMaximum]\n * @param [rangeMaximum=255] The maximum value in the SNORM range, 255 by default.\n * @returns Scalar in the range [-1.0, 1.0].\n *\n * @see CesiumMath.toSNorm\n */\nfunction fromSNorm(value: number, rangeMaximum = 255): number {\n return (clamp(value, 0.0, rangeMaximum) / rangeMaximum) * 2.0 - 1.0;\n}\n\n/**\n * Converts a scalar value in the range [-1.0, 1.0] to a SNORM in the range [0, rangeMaximum].\n *\n * @param value The scalar value in the range [-1.0, 1.0]\n * @param [rangeMaximum=255] The maximum value in the mapped range, 255 by default.\n * @returns A SNORM value, where 0 maps to -1.0 and rangeMaximum maps to 1.0.\n *\n * @see CesiumMath.fromSNorm\n */\nfunction toSNorm(value: number, rangeMaximum = 255): number {\n return Math.round((clamp(value, -1.0, 1.0) * 0.5 + 0.5) * rangeMaximum);\n}\n\n/**\n * Returns 1.0 if the given value is positive or zero, and -1.0 if it is negative.\n * This is similar to `Math.sign` except that returns 1.0 instead of\n * 0.0 when the input value is 0.0.\n *\n * @param value The value to return the sign of.\n * @returns The sign of value.\n */\nfunction signNotZero(value: number): number {\n return value < 0.0 ? -1.0 : 1.0;\n}\n\n/**\n * Encodes a normalized vector into 2 SNORM values in the range of [0-rangeMax] following the 'oct' encoding.\n *\n * Oct encoding is a compact representation of unit length vectors.\n * The 'oct' encoding is described in \"A Survey of Efficient Representations of Independent Unit Vectors\",\n * Cigolle et al 2014: {@link http://jcgt.org/published/0003/02/01/}\n *\n * @param vector The normalized vector to be compressed into 2 component 'oct' encoding.\n * @param result The 2 component oct-encoded unit length vector.\n * @param rangeMax The maximum value of the SNORM range. The encoded vector is stored in log2(rangeMax+1) bits.\n * @returns The 2 component oct-encoded unit length vector.\n *\n * @exception vector must be normalized.\n *\n * @see octDecodeInRange\n */\nexport function octEncodeInRange(vector: Vector3, rangeMax: number, result: Vector2): Vector2 {\n assert(vector);\n assert(result);\n\n const vector3 = scratchVector3.from(vector);\n\n assert(Math.abs(vector3.magnitudeSquared() - 1.0) <= _MathUtils.EPSILON6);\n\n result.x = vector.x / (Math.abs(vector.x) + Math.abs(vector.y) + Math.abs(vector.z));\n result.y = vector.y / (Math.abs(vector.x) + Math.abs(vector.y) + Math.abs(vector.z));\n\n if (vector.z < 0) {\n const x = result.x;\n const y = result.y;\n result.x = (1.0 - Math.abs(y)) * signNotZero(x);\n result.y = (1.0 - Math.abs(x)) * signNotZero(y);\n }\n\n result.x = toSNorm(result.x, rangeMax);\n result.y = toSNorm(result.y, rangeMax);\n\n return result;\n}\n\n/**\n * Encodes a normalized vector into 2 SNORM values in the range of [0-255] following the 'oct' encoding.\n *\n * @param vector The normalized vector to be compressed into 2 byte 'oct' encoding.\n * @param result The 2 byte oct-encoded unit length vector.\n * @returns he 2 byte oct-encoded unit length vector.\n *\n * @exception vector must be normalized.\n *\n * @see octEncodeInRange\n * @see octDecode\n */\nexport function octEncode(vector: Vector3, result: Vector2): Vector2 {\n return octEncodeInRange(vector, 255, result);\n}\n\n/**\n * Encodes a normalized vector into 4-byte vector\n * @param vector The normalized vector to be compressed into 4 byte 'oct' encoding.\n * @param result The 4 byte oct-encoded unit length vector.\n * @returns The 4 byte oct-encoded unit length vector.\n *\n * @exception vector must be normalized.\n *\n * @see octEncodeInRange\n * @see octDecodeFromVector4\n */\nexport function octEncodeToVector4(vector: Vector3, result: Vector4): Vector4 {\n octEncodeInRange(vector, 65535, octEncodeScratch);\n result.x = forceUint8(octEncodeScratch.x * RIGHT_SHIFT);\n result.y = forceUint8(octEncodeScratch.x);\n result.z = forceUint8(octEncodeScratch.y * RIGHT_SHIFT);\n result.w = forceUint8(octEncodeScratch.y);\n return result;\n}\n\n/**\n * Decodes a unit-length vector in 'oct' encoding to a normalized 3-component vector.\n *\n * @param x The x component of the oct-encoded unit length vector.\n * @param y The y component of the oct-encoded unit length vector.\n * @param rangeMax The maximum value of the SNORM range. The encoded vector is stored in log2(rangeMax+1) bits.\n * @param result The decoded and normalized vector\n * @returns The decoded and normalized vector.\n *\n * @exception x and y must be unsigned normalized integers between 0 and rangeMax.\n *\n * @see octEncodeInRange\n */\nexport function octDecodeInRange(x: number, y: number, rangeMax: number, result: Vector3): Vector3 {\n assert(result);\n if (x < 0 || x > rangeMax || y < 0 || y > rangeMax) {\n throw new Error(`x and y must be unsigned normalized integers between 0 and ${rangeMax}`);\n }\n\n result.x = fromSNorm(x, rangeMax);\n result.y = fromSNorm(y, rangeMax);\n result.z = 1.0 - (Math.abs(result.x) + Math.abs(result.y));\n\n if (result.z < 0.0) {\n const oldVX = result.x;\n result.x = (1.0 - Math.abs(result.y)) * signNotZero(oldVX);\n result.y = (1.0 - Math.abs(oldVX)) * signNotZero(result.y);\n }\n\n return result.normalize();\n}\n\n/**\n * Decodes a unit-length vector in 2 byte 'oct' encoding to a normalized 3-component vector.\n *\n * @param x The x component of the oct-encoded unit length vector.\n * @param y The y component of the oct-encoded unit length vector.\n * @param result The decoded and normalized vector.\n * @returns he decoded and normalized vector.\n *\n * @exception x and y must be an unsigned normalized integer between 0 and 255.\n *\n * @see octDecodeInRange\n */\nexport function octDecode(x: number, y: number, result: Vector3): Vector3 {\n return octDecodeInRange(x, y, 255, result);\n}\n\n/**\n * Decodes a unit-length vector in 4 byte 'oct' encoding to a normalized 3-component vector.\n *\n * @param encoded The oct-encoded unit length vector.\n * @param esult The decoded and normalized vector.\n * @returns The decoded and normalized vector.\n *\n * @exception x, y, z, and w must be unsigned normalized integers between 0 and 255.\n *\n * @see octDecodeInRange\n * @see octEncodeToVector4\n */\nexport function octDecodeFromVector4(encoded: Vector4, result: Vector3): Vector3 {\n assert(encoded);\n assert(result);\n const x = encoded.x;\n const y = encoded.y;\n const z = encoded.z;\n const w = encoded.w;\n\n if (x < 0 || x > 255 || y < 0 || y > 255 || z < 0 || z > 255 || w < 0 || w > 255) {\n throw new Error('x, y, z, and w must be unsigned normalized integers between 0 and 255');\n }\n\n const xOct16 = x * LEFT_SHIFT + y;\n const yOct16 = z * LEFT_SHIFT + w;\n return octDecodeInRange(xOct16, yOct16, 65535, result);\n}\n\n/**\n * Packs an oct encoded vector into a single floating-point number.\n *\n * @param encoded The oct encoded vector.\n * @returns The oct encoded vector packed into a single float.\n *\n */\nexport function octPackFloat(encoded: Vector2): number {\n const vector2 = scratchVector2.from(encoded);\n return 256.0 * vector2.x + vector2.y;\n}\n\n/**\n * Encodes a normalized vector into 2 SNORM values in the range of [0-255] following the 'oct' encoding and\n * stores those values in a single float-point number.\n *\n * @param vector The normalized vector to be compressed into 2 byte 'oct' encoding.\n * @returns The 2 byte oct-encoded unit length vector.\n *\n * @exception vector must be normalized.\n */\nexport function octEncodeFloat(vector: Vector3): number {\n octEncode(vector, scratchEncodeVector2);\n return octPackFloat(scratchEncodeVector2);\n}\n\n/**\n * Decodes a unit-length vector in 'oct' encoding packed in a floating-point number to a normalized 3-component vector.\n *\n * @param value The oct-encoded unit length vector stored as a single floating-point number.\n * @param result The decoded and normalized vector\n * @returns The decoded and normalized vector.\n *\n */\nexport function octDecodeFloat(value: number, result: Vector3): Vector3 {\n assert(Number.isFinite(value));\n\n const temp = value / 256.0;\n const x = Math.floor(temp);\n const y = (temp - x) * 256.0;\n\n return octDecode(x, y, result);\n}\n\n/**\n * Encodes three normalized vectors into 6 SNORM values in the range of [0-255] following the 'oct' encoding and\n * packs those into two floating-point numbers.\n *\n * @param v1 A normalized vector to be compressed.\n * @param v2 A normalized vector to be compressed.\n * @param v3 A normalized vector to be compressed.\n * @param result The 'oct' encoded vectors packed into two floating-point numbers.\n * @returns The 'oct' encoded vectors packed into two floating-point numbers.\n *\n */\nexport function octPack(v1: Vector3, v2: Vector3, v3: Vector3, result: Vector2): Vector2 {\n assert(v1);\n assert(v2);\n assert(v3);\n assert(result);\n\n const encoded1 = octEncodeFloat(v1);\n const encoded2 = octEncodeFloat(v2);\n\n const encoded3 = octEncode(v3, scratchEncodeVector2);\n result.x = 65536.0 * encoded3.x + encoded1;\n result.y = 65536.0 * encoded3.y + encoded2;\n return result;\n}\n\n/**\n * Decodes three unit-length vectors in 'oct' encoding packed into a floating-point number to a normalized 3-component vector.\n *\n * @param packed The three oct-encoded unit length vectors stored as two floating-point number.\n * @param v1 One decoded and normalized vector.\n * @param v2 One decoded and normalized vector.\n * @param v3 One decoded and normalized vector.\n */\nexport function octUnpack(packed: Vector2, v1: Vector3, v2: Vector3, v3: Vector3): void {\n let temp = packed.x / 65536.0;\n const x = Math.floor(temp);\n const encodedFloat1 = (temp - x) * 65536.0;\n\n temp = packed.y / 65536.0;\n const y = Math.floor(temp);\n const encodedFloat2 = (temp - y) * 65536.0;\n\n octDecodeFloat(encodedFloat1, v1);\n octDecodeFloat(encodedFloat2, v2);\n octDecode(x, y, v3);\n}\n\n/**\n * Pack texture coordinates into a single float. The texture coordinates will only preserve 12 bits of precision.\n *\n * @param textureCoordinates The texture coordinates to compress. Both coordinates must be in the range 0.0-1.0.\n * @returns The packed texture coordinates.\n *\n */\nexport function compressTextureCoordinates(textureCoordinates: Vector2): number {\n // Move x and y to the range 0-4095;\n const x = (textureCoordinates.x * 4095.0) | 0;\n const y = (textureCoordinates.y * 4095.0) | 0;\n return 4096.0 * x + y;\n}\n\n/**\n * Decompresses texture coordinates that were packed into a single float.\n *\n * @param compressed The compressed texture coordinates.\n * @param result The decompressed texture coordinates.\n * @returns The modified result parameter.\n *\n */\nexport function decompressTextureCoordinates(compressed: number, result: Vector2): Vector2 {\n const temp = compressed / 4096.0;\n const xZeroTo4095 = Math.floor(temp);\n result.x = xZeroTo4095 / 4095.0;\n result.y = (compressed - xZeroTo4095 * 4096) / 4095;\n return result;\n}\n\n/**\n * Decodes delta and ZigZag encoded vertices. This modifies the buffers in place.\n *\n * @param uBuffer The buffer view of u values.\n * @param vBuffer The buffer view of v values.\n * @param [heightBuffer] The buffer view of height values.\n *\n * @link https://github.com/AnalyticalGraphicsInc/quantized-mesh|quantized-mesh-1.0 terrain format\n */\nexport function zigZagDeltaDecode(\n uBuffer: Uint16Array,\n vBuffer: Uint16Array,\n heightBuffer?: Uint16Array | number[]\n) {\n assert(uBuffer);\n assert(vBuffer);\n assert(uBuffer.length === vBuffer.length);\n if (heightBuffer) {\n assert(uBuffer.length === heightBuffer.length);\n }\n\n function zigZagDecode(value: number) {\n return (value >> 1) ^ -(value & 1);\n }\n\n let u = 0;\n let v = 0;\n let height = 0;\n\n for (let i = 0; i < uBuffer.length; ++i) {\n u += zigZagDecode(uBuffer[i]);\n v += zigZagDecode(vBuffer[i]);\n\n uBuffer[i] = u;\n vBuffer[i] = v;\n\n if (heightBuffer) {\n height += zigZagDecode(heightBuffer[i]);\n heightBuffer[i] = height;\n }\n }\n}\n"],"file":"attribute-compression.js"}
@@ -1,6 +1,6 @@
1
1
  export function assert(condition, message) {
2
2
  if (!condition) {
3
- throw new Error(`math.gl assertion failed. ${message}`);
3
+ throw new Error("math.gl assertion failed. ".concat(message));
4
4
  }
5
5
  }
6
6
  //# sourceMappingURL=assert.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/geometry/utils/assert.ts"],"names":["assert","condition","message","Error"],"mappings":"AAKA,OAAO,SAASA,MAAT,CAAgBC,SAAhB,EAAgCC,OAAhC,EAAqD;AAC1D,MAAI,CAACD,SAAL,EAAgB;AACd,UAAM,IAAIE,KAAJ,CAAW,6BAA4BD,OAAQ,EAA/C,CAAN;AACD;AACF","sourcesContent":["/**\n * Throws error message\n * @param condition checks if an attribute equal to condition\n * @param message error message\n */\nexport function assert(condition: any, message?: any): void {\n if (!condition) {\n throw new Error(`math.gl assertion failed. ${message}`);\n }\n}\n"],"file":"assert.js"}
1
+ {"version":3,"sources":["../../../../src/geometry/utils/assert.ts"],"names":["assert","condition","message","Error"],"mappings":"AAKA,OAAO,SAASA,MAAT,CAAgBC,SAAhB,EAAgCC,OAAhC,EAAqD;AAC1D,MAAI,CAACD,SAAL,EAAgB;AACd,UAAM,IAAIE,KAAJ,qCAAuCD,OAAvC,EAAN;AACD;AACF","sourcesContent":["/**\n * Throws error message\n * @param condition checks if an attribute equal to condition\n * @param message error message\n */\nexport function assert(condition: any, message?: any): void {\n if (!condition) {\n throw new Error(`math.gl assertion failed. ${message}`);\n }\n}\n"],"file":"assert.js"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loaders.gl/math",
3
- "version": "3.0.12",
3
+ "version": "3.0.13",
4
4
  "description": "Experimental math classes for loaders.gl",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -31,9 +31,9 @@
31
31
  "pre-build": "echo \"Nothing to build in @loaders.gl/math\""
32
32
  },
33
33
  "dependencies": {
34
- "@loaders.gl/images": "3.0.12",
35
- "@loaders.gl/loader-utils": "3.0.12",
34
+ "@loaders.gl/images": "3.0.13",
35
+ "@loaders.gl/loader-utils": "3.0.13",
36
36
  "@math.gl/core": "^3.5.1"
37
37
  },
38
- "gitHead": "47cac9b0d4e6c1953bcfa6af5cadf1d42c25401a"
38
+ "gitHead": "acb7e5ecb4fc82e3628a2cf47a5345e8d28c0c2a"
39
39
  }