@loaders.gl/math 3.1.0-alpha.5 → 3.1.0-beta.1

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 (61) hide show
  1. package/dist/geometry/attributes/compute-bounding-box.d.ts +1 -0
  2. package/dist/geometry/attributes/compute-bounding-box.d.ts.map +1 -0
  3. package/dist/geometry/attributes/compute-bounding-box.js +44 -0
  4. package/dist/geometry/attributes/compute-bounding-sphere.d.ts +1 -0
  5. package/dist/geometry/attributes/compute-bounding-sphere.d.ts.map +1 -0
  6. package/dist/geometry/attributes/compute-bounding-sphere.js +30 -0
  7. package/dist/geometry/attributes/compute-tangents.d.ts +1 -0
  8. package/dist/geometry/attributes/compute-tangents.d.ts.map +1 -0
  9. package/dist/geometry/attributes/compute-tangents.js +146 -0
  10. package/dist/geometry/attributes/compute-vertex-normals.d.ts +1 -0
  11. package/dist/geometry/attributes/compute-vertex-normals.d.ts.map +1 -0
  12. package/dist/geometry/attributes/compute-vertex-normals.js +48 -0
  13. package/dist/geometry/attributes/convert-to-non-indexed.d.ts +1 -0
  14. package/dist/geometry/attributes/convert-to-non-indexed.d.ts.map +1 -0
  15. package/dist/geometry/attributes/convert-to-non-indexed.js +33 -0
  16. package/dist/geometry/attributes/get-attribute-from-geometry.d.ts +1 -0
  17. package/dist/geometry/attributes/get-attribute-from-geometry.d.ts.map +1 -0
  18. package/dist/geometry/attributes/get-attribute-from-geometry.js +34 -0
  19. package/dist/geometry/attributes/normalize.d.ts +1 -0
  20. package/dist/geometry/attributes/normalize.d.ts.map +1 -0
  21. package/dist/geometry/attributes/normalize.js +20 -0
  22. package/dist/geometry/colors/rgb565.d.ts +1 -0
  23. package/dist/geometry/colors/rgb565.d.ts.map +1 -0
  24. package/dist/geometry/colors/rgb565.js +31 -0
  25. package/dist/geometry/compression/attribute-compression.d.ts +1 -0
  26. package/dist/geometry/compression/attribute-compression.d.ts.map +1 -0
  27. package/dist/geometry/compression/attribute-compression.js +352 -0
  28. package/dist/geometry/constants.d.ts +1 -0
  29. package/dist/geometry/constants.d.ts.map +1 -0
  30. package/dist/geometry/constants.js +34 -0
  31. package/dist/geometry/gl/gl-type.d.ts +1 -0
  32. package/dist/geometry/gl/gl-type.d.ts.map +1 -0
  33. package/dist/geometry/gl/gl-type.js +112 -0
  34. package/dist/geometry/is-geometry.d.ts +1 -0
  35. package/dist/geometry/is-geometry.d.ts.map +1 -0
  36. package/dist/geometry/is-geometry.js +14 -0
  37. package/dist/geometry/iterators/attribute-iterator.d.ts +1 -0
  38. package/dist/geometry/iterators/attribute-iterator.d.ts.map +1 -0
  39. package/dist/geometry/iterators/attribute-iterator.js +19 -0
  40. package/dist/geometry/iterators/primitive-iterator.d.ts +1 -0
  41. package/dist/geometry/iterators/primitive-iterator.d.ts.map +1 -0
  42. package/dist/geometry/iterators/primitive-iterator.js +88 -0
  43. package/dist/geometry/primitives/modes.d.ts +1 -0
  44. package/dist/geometry/primitives/modes.d.ts.map +1 -0
  45. package/dist/geometry/primitives/modes.js +71 -0
  46. package/dist/geometry/typed-arrays/typed-array-utils.d.ts +1 -0
  47. package/dist/geometry/typed-arrays/typed-array-utils.d.ts.map +1 -0
  48. package/dist/geometry/typed-arrays/typed-array-utils.js +25 -0
  49. package/dist/geometry/types.d.ts +1 -0
  50. package/dist/geometry/types.d.ts.map +1 -0
  51. package/dist/geometry/types.js +2 -0
  52. package/dist/geometry/utils/assert.d.ts +1 -0
  53. package/dist/geometry/utils/assert.d.ts.map +1 -0
  54. package/dist/geometry/utils/assert.js +14 -0
  55. package/dist/index.d.ts +1 -0
  56. package/dist/index.d.ts.map +1 -0
  57. package/dist/index.js +46 -0
  58. package/dist/utils/assert.d.ts +1 -0
  59. package/dist/utils/assert.d.ts.map +1 -0
  60. package/dist/utils/assert.js +12 -0
  61. package/package.json +5 -6
@@ -7,3 +7,4 @@ export declare function computeBoundingBox(positions?: any): {
7
7
  min: number[];
8
8
  max: number[];
9
9
  };
10
+ //# sourceMappingURL=compute-bounding-box.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compute-bounding-box.d.ts","sourceRoot":"","sources":["../../../src/geometry/attributes/compute-bounding-box.ts"],"names":[],"mappings":"AAUA;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,GAAE,GAAQ;;;EAqBrD"}
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.computeBoundingBox = void 0;
4
+ const attribute_iterator_1 = require("../iterators/attribute-iterator");
5
+ const assert_1 = require("../utils/assert");
6
+ /**
7
+ * Getting bounding box geometry according to positions parameters
8
+ * @param positions
9
+ * @returns Bounding Box
10
+ */
11
+ function computeBoundingBox(positions = []) {
12
+ const min = [Number(Infinity), Number(Infinity), Number(Infinity)];
13
+ const max = [-Infinity, -Infinity, -Infinity];
14
+ // @ts-ignore
15
+ for (const position of (0, attribute_iterator_1.makeAttributeIterator)(positions)) {
16
+ const x = position[0];
17
+ const y = position[1];
18
+ const z = position[2];
19
+ if (x < min[0])
20
+ min[0] = x;
21
+ if (y < min[1])
22
+ min[1] = y;
23
+ if (z < min[2])
24
+ min[2] = z;
25
+ if (x > max[0])
26
+ max[0] = x;
27
+ if (y > max[1])
28
+ max[1] = y;
29
+ if (z > max[2])
30
+ max[2] = z;
31
+ }
32
+ const boundingBox = { min, max };
33
+ validateBoundingBox(boundingBox);
34
+ return boundingBox;
35
+ }
36
+ exports.computeBoundingBox = computeBoundingBox;
37
+ function validateBoundingBox(boundingBox) {
38
+ (0, assert_1.assert)(Number.isFinite(boundingBox.min[0]) &&
39
+ Number.isFinite(boundingBox.min[1]) &&
40
+ Number.isFinite(boundingBox.min[2]) &&
41
+ Number.isFinite(boundingBox.max[0]) &&
42
+ Number.isFinite(boundingBox.max[1]) &&
43
+ Number.isFinite(boundingBox.max[2]));
44
+ }
@@ -26,3 +26,4 @@ export function computeBoundingSphere(geometry: any, boundingBox: object, vector
26
26
  return {center, radius};
27
27
  }
28
28
  */
29
+ //# sourceMappingURL=compute-bounding-sphere.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compute-bounding-sphere.d.ts","sourceRoot":"","sources":["../../../src/geometry/attributes/compute-bounding-sphere.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2BE"}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ /* eslint-disable */
3
+ /**
4
+ import {getPositions} from './get-attribute-from-geometry.js';
5
+
6
+ export function computeBoundingSphere(geometry: any, boundingBox: object, vector: Vector3 ) {
7
+ const positions = getPositions(geometry);
8
+
9
+ const center = getBoundingBox(center);
10
+ box.setFromBufferAttribute(position);
11
+ box.getCenter(center);
12
+
13
+ // hoping to find a boundingSphere with a radius smaller than the
14
+ // boundingSphere of the boundingBox: sqrt(3) smaller in the best case
15
+
16
+ var maxRadiusSq = 0;
17
+
18
+ for (const position of makeAttributeIterator(positions)) {
19
+ vector.x = position[0];
20
+ vector.y = position[1];
21
+ vector.z = position[2];
22
+ maxRadiusSq = Math.max(maxRadiusSq, center.distanceToSquared(vector));
23
+ }
24
+
25
+ const radius = Math.sqrt(maxRadiusSq);
26
+ assert(Number.isFinite(radius));
27
+
28
+ return {center, radius};
29
+ }
30
+ */
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=compute-tangents.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compute-tangents.d.ts","sourceRoot":"","sources":["../../../src/geometry/attributes/compute-tangents.ts"],"names":[],"mappings":""}
@@ -0,0 +1,146 @@
1
+ "use strict";
2
+ /*
3
+ export function computeTangents({indices, positions, normals, uvs}) {
4
+ var index = geometry.index;
5
+ var attributes = geometry.attributes;
6
+
7
+ // based on http://www.terathon.com/code/tangent.html
8
+ // (per vertex tangents)
9
+
10
+ if (
11
+ index === null ||
12
+ attributes.position === undefined ||
13
+ attributes.normal === undefined ||
14
+ attributes.uv === undefined
15
+ ) {
16
+ console.warn(
17
+ 'THREE.BufferGeometry: Missing required attributes (index, position, normal or uv) in BufferGeometry.computeTangents()'
18
+ );
19
+ return;
20
+ }
21
+
22
+ var nVertices = positions.length / 3;
23
+
24
+ var tangents = new Float32Array(4 * nVertices); // size: 4
25
+
26
+ var tan1 = [],
27
+ tan2 = [];
28
+
29
+ for (var k = 0; k < nVertices; k++) {
30
+ tan1[k] = new THREE.Vector3();
31
+ tan2[k] = new THREE.Vector3();
32
+ }
33
+
34
+ var vA = new THREE.Vector3(),
35
+ vB = new THREE.Vector3(),
36
+ vC = new THREE.Vector3(),
37
+ uvA = new THREE.Vector2(),
38
+ uvB = new THREE.Vector2(),
39
+ uvC = new THREE.Vector2(),
40
+ sdir = new THREE.Vector3(),
41
+ tdir = new THREE.Vector3();
42
+
43
+ function handleTriangle(a, b, c) {
44
+ vA.fromArray(positions, a * 3);
45
+ vB.fromArray(positions, b * 3);
46
+ vC.fromArray(positions, c * 3);
47
+
48
+ uvA.fromArray(uvs, a * 2);
49
+ uvB.fromArray(uvs, b * 2);
50
+ uvC.fromArray(uvs, c * 2);
51
+
52
+ var x1 = vB.x - vA.x;
53
+ var x2 = vC.x - vA.x;
54
+
55
+ var y1 = vB.y - vA.y;
56
+ var y2 = vC.y - vA.y;
57
+
58
+ var z1 = vB.z - vA.z;
59
+ var z2 = vC.z - vA.z;
60
+
61
+ var s1 = uvB.x - uvA.x;
62
+ var s2 = uvC.x - uvA.x;
63
+
64
+ var t1 = uvB.y - uvA.y;
65
+ var t2 = uvC.y - uvA.y;
66
+
67
+ var r = 1.0 / (s1 * t2 - s2 * t1);
68
+
69
+ sdir.set((t2 * x1 - t1 * x2) * r, (t2 * y1 - t1 * y2) * r, (t2 * z1 - t1 * z2) * r);
70
+
71
+ tdir.set((s1 * x2 - s2 * x1) * r, (s1 * y2 - s2 * y1) * r, (s1 * z2 - s2 * z1) * r);
72
+
73
+ tan1[a].add(sdir);
74
+ tan1[b].add(sdir);
75
+ tan1[c].add(sdir);
76
+
77
+ tan2[a].add(tdir);
78
+ tan2[b].add(tdir);
79
+ tan2[c].add(tdir);
80
+ }
81
+
82
+ var groups = geometry.groups;
83
+
84
+ if (groups.length === 0) {
85
+ groups = [
86
+ {
87
+ start: 0,
88
+ count: indices.length
89
+ }
90
+ ];
91
+ }
92
+
93
+ for (var j = 0, jl = groups.length; j < jl; ++j) {
94
+ var group = groups[j];
95
+
96
+ var start = group.start;
97
+ var count = group.count;
98
+
99
+ for (var i = start, il = start + count; i < il; i += 3) {
100
+ handleTriangle(indices[i + 0], indices[i + 1], indices[i + 2]);
101
+ }
102
+ }
103
+
104
+ var tmp = new THREE.Vector3(),
105
+ tmp2 = new THREE.Vector3();
106
+ var n = new THREE.Vector3(),
107
+ n2 = new THREE.Vector3();
108
+ var w, t, test;
109
+
110
+ function handleVertex(v) {
111
+ n.fromArray(normals, v * 3);
112
+ n2.copy(n);
113
+
114
+ t = tan1[v];
115
+
116
+ // Gram-Schmidt orthogonalize
117
+
118
+ tmp.copy(t);
119
+ tmp.sub(n.multiplyScalar(n.dot(t))).normalize();
120
+
121
+ // Calculate handedness
122
+
123
+ tmp2.crossVectors(n2, t);
124
+ test = tmp2.dot(tan2[v]);
125
+ w = test < 0.0 ? -1.0 : 1.0;
126
+
127
+ tangents[v * 4] = tmp.x;
128
+ tangents[v * 4 + 1] = tmp.y;
129
+ tangents[v * 4 + 2] = tmp.z;
130
+ tangents[v * 4 + 3] = w;
131
+ }
132
+
133
+ for (var j = 0, jl = groups.length; j < jl; ++j) {
134
+ var group = groups[j];
135
+
136
+ var start = group.start;
137
+ var count = group.count;
138
+
139
+ for (var i = start, il = start + count; i < il; i += 3) {
140
+ handleVertex(indices[i + 0]);
141
+ handleVertex(indices[i + 1]);
142
+ handleVertex(indices[i + 2]);
143
+ }
144
+ }
145
+ }
146
+ */
@@ -14,3 +14,4 @@ declare type Geometry = {
14
14
  */
15
15
  export declare function computeVertexNormals(geometry: Geometry): Float32Array;
16
16
  export {};
17
+ //# sourceMappingURL=compute-vertex-normals.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compute-vertex-normals.d.ts","sourceRoot":"","sources":["../../../src/geometry/attributes/compute-vertex-normals.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AAQzC,aAAK,QAAQ,GAAG;IACd,IAAI,EAAE,GAAG,CAAC;IACV,OAAO,CAAC,EAAE;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,UAAU,CAAA;KAAC,CAAC;IAC7C,UAAU,CAAC,EAAE,EAAE,CAAC;CACjB,CAAC;AACF;;;;GAIG;AAEH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,QAAQ,GAAG,YAAY,CAyCrE"}
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.computeVertexNormals = void 0;
4
+ const core_1 = require("@math.gl/core");
5
+ const constants_1 = require("../constants");
6
+ const assert_1 = require("../utils/assert");
7
+ const primitive_iterator_1 = require("../iterators/primitive-iterator");
8
+ const modes_1 = require("../primitives/modes");
9
+ const get_attribute_from_geometry_1 = require("./get-attribute-from-geometry");
10
+ /**
11
+ * Computes vertex normals for a geometry
12
+ * @param param0
13
+ * @returns
14
+ */
15
+ // eslint-disable-next-line max-statements
16
+ function computeVertexNormals(geometry) {
17
+ // Only support GL.TRIANGLES, GL.TRIANGLE_STRIP, GL.TRIANGLE_FAN
18
+ (0, assert_1.assert)((0, modes_1.getPrimitiveModeType)(geometry.mode) === constants_1.GL.TRIANGLES, 'TRIANGLES required');
19
+ const { values: positions } = (0, get_attribute_from_geometry_1.getPositions)(geometry);
20
+ const normals = new Float32Array(positions.length);
21
+ const vectorA = new core_1.Vector3();
22
+ const vectorB = new core_1.Vector3();
23
+ const vectorC = new core_1.Vector3();
24
+ const vectorCB = new core_1.Vector3();
25
+ const vectorAB = new core_1.Vector3();
26
+ for (const primitive of (0, primitive_iterator_1.makePrimitiveIterator)(geometry)) {
27
+ vectorA.fromArray(positions, primitive.i1 * 3);
28
+ vectorB.fromArray(positions, primitive.i2 * 3 + 3);
29
+ vectorC.fromArray(positions, primitive.i3 * 3 + 6);
30
+ vectorCB.subVectors(vectorC, vectorB);
31
+ vectorAB.subVectors(vectorA, vectorB);
32
+ const normal = vectorCB.cross(vectorAB);
33
+ normal.normalize();
34
+ // @ts-ignore
35
+ const { primitiveIndex } = primitive;
36
+ normals[primitiveIndex * 9 + 0] = normal.x;
37
+ normals[primitiveIndex * 9 + 1] = normal.y;
38
+ normals[primitiveIndex * 9 + 2] = normal.z;
39
+ normals[primitiveIndex * 9 + 3] = normal.x;
40
+ normals[primitiveIndex * 9 + 4] = normal.y;
41
+ normals[primitiveIndex * 9 + 5] = normal.z;
42
+ normals[primitiveIndex * 9 + 6] = normal.x;
43
+ normals[primitiveIndex * 9 + 7] = normal.y;
44
+ normals[primitiveIndex * 9 + 8] = normal.z;
45
+ }
46
+ return normals;
47
+ }
48
+ exports.computeVertexNormals = computeVertexNormals;
@@ -8,3 +8,4 @@ export declare function convertBuffersToNonIndexed({ indices, attributes }: {
8
8
  indices: any;
9
9
  attributes: any;
10
10
  }): any;
11
+ //# sourceMappingURL=convert-to-non-indexed.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convert-to-non-indexed.d.ts","sourceRoot":"","sources":["../../../src/geometry/attributes/convert-to-non-indexed.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,EAAC,OAAO,EAAE,UAAU,EAAC;;;CAAA,GAAG,GAAG,CA2BrE"}
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.convertBuffersToNonIndexed = void 0;
4
+ /* eslint-disable */
5
+ // @ts-nocheck
6
+ /**
7
+ * Converts indices of geometry.
8
+ *
9
+ * @param param0
10
+ * @returns no indexed geometry
11
+ */
12
+ function convertBuffersToNonIndexed({ indices, attributes }) {
13
+ const geometry2 = new BufferGeometry();
14
+ for (const name in attributes) {
15
+ const attribute = attributes[name];
16
+ const array = attribute.array;
17
+ const itemSize = attribute.itemSize;
18
+ const array2 = new array.constructor(indices.length * itemSize);
19
+ let index = 0, index2 = 0;
20
+ for (var i = 0, l = indices.length; i < l; i++) {
21
+ index = indices[i] * itemSize;
22
+ for (var j = 0; j < itemSize; j++) {
23
+ array2[index2++] = array[index++];
24
+ }
25
+ }
26
+ geometry2.addAttribute(name, new BufferAttribute(array2, itemSize));
27
+ }
28
+ for (const group of this.groups) {
29
+ geometry2.addGroup(group.start, group.count, group.materialIndex);
30
+ }
31
+ return geometry2;
32
+ }
33
+ exports.convertBuffersToNonIndexed = convertBuffersToNonIndexed;
@@ -5,3 +5,4 @@
5
5
  * @returns Position| New geometry |assert
6
6
  */
7
7
  export declare function getPositions(geometry: any): any;
8
+ //# sourceMappingURL=get-attribute-from-geometry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-attribute-from-geometry.d.ts","sourceRoot":"","sources":["../../../src/geometry/attributes/get-attribute-from-geometry.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AAEH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,GAAG,OAqBzC"}
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getPositions = void 0;
7
+ const is_geometry_1 = __importDefault(require("../is-geometry"));
8
+ const assert_1 = require("../utils/assert");
9
+ /**
10
+ * analyze positions of geometry
11
+ *
12
+ * @param geometry
13
+ * @returns Position| New geometry |assert
14
+ */
15
+ function getPositions(geometry) {
16
+ // If geometry, extract positions
17
+ if ((0, is_geometry_1.default)(geometry)) {
18
+ const { attributes } = geometry;
19
+ const position = attributes.POSITION || attributes.positions;
20
+ (0, assert_1.assert)(position);
21
+ return position;
22
+ }
23
+ // If arraybuffer, assume 3 components
24
+ if (ArrayBuffer.isView(geometry)) {
25
+ return { values: geometry, size: 3 };
26
+ }
27
+ // Else assume accessor object
28
+ if (geometry) {
29
+ (0, assert_1.assert)(geometry.values);
30
+ return geometry;
31
+ }
32
+ return (0, assert_1.assert)(false);
33
+ }
34
+ exports.getPositions = getPositions;
@@ -5,3 +5,4 @@ import { Vector3 } from '@math.gl/core';
5
5
  * @param vector
6
6
  */
7
7
  export declare function normalize(normals: any, vector: Vector3): void;
8
+ //# sourceMappingURL=normalize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../../../src/geometry/attributes/normalize.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,OAAO,EAAC,MAAM,eAAe,CAAC;AAEtC;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,OAAO,KAAU,EAAE,MAAM,EAAE,OAAO,QAU3D"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.normalize = void 0;
4
+ /**
5
+ * Setting X, Y, Z for Vector
6
+ * @param normals
7
+ * @param vector
8
+ */
9
+ function normalize(normals = {}, vector) {
10
+ //@ts-ignore
11
+ normals = this.attributes.normal;
12
+ for (let i = 0, il = normals.count; i < il; i++) {
13
+ vector.x = normals.getX(i);
14
+ vector.y = normals.getY(i);
15
+ vector.z = normals.getZ(i);
16
+ vector.normalize();
17
+ normals.setXYZ(i, vector.x, vector.y, vector.z);
18
+ }
19
+ }
20
+ exports.normalize = normalize;
@@ -11,3 +11,4 @@ export declare function decodeRGB565(rgb565: number, target?: number[]): number[
11
11
  * @returns color
12
12
  */
13
13
  export declare function encodeRGB565(rgb: number[]): number;
14
+ //# sourceMappingURL=rgb565.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rgb565.d.ts","sourceRoot":"","sources":["../../../src/geometry/colors/rgb565.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,GAAE,MAAM,EAAc,GAAG,MAAM,EAAE,CAUnF;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,MAAM,CAKlD"}
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.encodeRGB565 = exports.decodeRGB565 = void 0;
4
+ /**
5
+ * Decode color values
6
+ * @param rgb565
7
+ * @param target
8
+ * @returns target
9
+ */
10
+ function decodeRGB565(rgb565, target = [0, 0, 0]) {
11
+ const r5 = (rgb565 >> 11) & 31;
12
+ const g6 = (rgb565 >> 5) & 63;
13
+ const b5 = rgb565 & 31;
14
+ target[0] = r5 << 3;
15
+ target[1] = g6 << 2;
16
+ target[2] = b5 << 3;
17
+ return target;
18
+ }
19
+ exports.decodeRGB565 = decodeRGB565;
20
+ /**
21
+ * Encode color values
22
+ * @param rgb
23
+ * @returns color
24
+ */
25
+ function encodeRGB565(rgb) {
26
+ const r5 = Math.floor(rgb[0] / 8) + 4;
27
+ const g6 = Math.floor(rgb[1] / 4) + 2;
28
+ const b5 = Math.floor(rgb[2] / 8) + 4;
29
+ return r5 + (g6 << 5) + (b5 << 11);
30
+ }
31
+ exports.encodeRGB565 = encodeRGB565;
@@ -157,3 +157,4 @@ export declare function decompressTextureCoordinates(compressed: number, result:
157
157
  * @link https://github.com/AnalyticalGraphicsInc/quantized-mesh|quantized-mesh-1.0 terrain format
158
158
  */
159
159
  export declare function zigZagDeltaDecode(uBuffer: Uint16Array, vBuffer: Uint16Array, heightBuffer?: Uint16Array | number[]): void;
160
+ //# sourceMappingURL=attribute-compression.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attribute-compression.d.ts","sourceRoot":"","sources":["../../../src/geometry/compression/attribute-compression.ts"],"names":[],"mappings":"AAKA,OAAO,EAAC,OAAO,EAAE,OAAO,EAAoB,MAAM,e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