@loaders.gl/math 3.1.3 → 4.0.0-alpha.5
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/geometry/attributes/compute-bounding-box.js +27 -41
- package/dist/geometry/attributes/compute-bounding-box.js.map +1 -0
- package/dist/geometry/attributes/compute-bounding-sphere.js +1 -29
- package/dist/{es5/geometry → geometry}/attributes/compute-bounding-sphere.js.map +0 -0
- package/dist/geometry/attributes/compute-tangents.js +1 -145
- package/dist/{es5/geometry → geometry}/attributes/compute-tangents.js.map +0 -0
- package/dist/geometry/attributes/compute-vertex-normals.js +42 -47
- package/dist/geometry/attributes/compute-vertex-normals.js.map +1 -0
- package/dist/geometry/attributes/convert-to-non-indexed.js +30 -31
- package/dist/geometry/attributes/convert-to-non-indexed.js.map +1 -0
- package/dist/geometry/attributes/get-attribute-from-geometry.js +26 -33
- package/dist/geometry/attributes/get-attribute-from-geometry.js.map +1 -0
- package/dist/geometry/attributes/normalize.js +11 -19
- package/dist/geometry/attributes/normalize.js.map +1 -0
- package/dist/geometry/colors/rgb565.js +14 -29
- package/dist/geometry/colors/rgb565.js.map +1 -0
- package/dist/geometry/compression/attribute-compression.js +162 -339
- package/dist/geometry/compression/attribute-compression.js.map +1 -0
- package/dist/geometry/constants.js +24 -30
- package/dist/geometry/constants.js.map +1 -0
- package/dist/geometry/gl/gl-type.js +74 -101
- package/dist/geometry/gl/gl-type.js.map +1 -0
- package/dist/geometry/is-geometry.js +3 -13
- package/dist/geometry/is-geometry.js.map +1 -0
- package/dist/geometry/iterators/attribute-iterator.js +11 -17
- package/dist/geometry/iterators/attribute-iterator.js.map +1 -0
- package/dist/geometry/iterators/primitive-iterator.js +79 -85
- package/dist/geometry/iterators/primitive-iterator.js.map +1 -0
- package/dist/geometry/primitives/modes.js +54 -67
- package/dist/{es5/geometry → geometry}/primitives/modes.js.map +1 -1
- package/dist/geometry/typed-arrays/typed-array-utils.js +20 -23
- package/dist/geometry/typed-arrays/typed-array-utils.js.map +1 -0
- package/dist/geometry/types.js +2 -2
- package/dist/{es5/geometry → geometry}/types.js.map +0 -0
- package/dist/geometry/utils/assert.js +5 -13
- package/dist/geometry/utils/assert.js.map +1 -0
- package/dist/index.js +11 -46
- package/dist/index.js.map +1 -0
- package/dist/utils/assert.js +5 -11
- package/dist/utils/assert.js.map +1 -0
- package/package.json +6 -6
- package/dist/es5/geometry/attributes/compute-bounding-box.js +0 -56
- package/dist/es5/geometry/attributes/compute-bounding-box.js.map +0 -1
- package/dist/es5/geometry/attributes/compute-bounding-sphere.js +0 -2
- package/dist/es5/geometry/attributes/compute-tangents.js +0 -2
- package/dist/es5/geometry/attributes/compute-vertex-normals.js +0 -71
- package/dist/es5/geometry/attributes/compute-vertex-normals.js.map +0 -1
- package/dist/es5/geometry/attributes/convert-to-non-indexed.js +0 -54
- package/dist/es5/geometry/attributes/convert-to-non-indexed.js.map +0 -1
- package/dist/es5/geometry/attributes/get-attribute-from-geometry.js +0 -36
- package/dist/es5/geometry/attributes/get-attribute-from-geometry.js.map +0 -1
- package/dist/es5/geometry/attributes/normalize.js +0 -21
- package/dist/es5/geometry/attributes/normalize.js.map +0 -1
- package/dist/es5/geometry/colors/rgb565.js +0 -26
- package/dist/es5/geometry/colors/rgb565.js.map +0 -1
- package/dist/es5/geometry/compression/attribute-compression.js +0 -212
- package/dist/es5/geometry/compression/attribute-compression.js.map +0 -1
- package/dist/es5/geometry/constants.js +0 -47
- package/dist/es5/geometry/constants.js.map +0 -1
- package/dist/es5/geometry/gl/gl-type.js +0 -112
- package/dist/es5/geometry/gl/gl-type.js.map +0 -1
- package/dist/es5/geometry/is-geometry.js +0 -15
- package/dist/es5/geometry/is-geometry.js.map +0 -1
- package/dist/es5/geometry/iterators/attribute-iterator.js +0 -49
- package/dist/es5/geometry/iterators/attribute-iterator.js.map +0 -1
- package/dist/es5/geometry/iterators/primitive-iterator.js +0 -133
- package/dist/es5/geometry/iterators/primitive-iterator.js.map +0 -1
- package/dist/es5/geometry/primitives/modes.js +0 -70
- package/dist/es5/geometry/typed-arrays/typed-array-utils.js +0 -30
- package/dist/es5/geometry/typed-arrays/typed-array-utils.js.map +0 -1
- package/dist/es5/geometry/types.js +0 -2
- package/dist/es5/geometry/utils/assert.js +0 -13
- package/dist/es5/geometry/utils/assert.js.map +0 -1
- package/dist/es5/index.js +0 -170
- package/dist/es5/index.js.map +0 -1
- package/dist/es5/utils/assert.js +0 -13
- package/dist/es5/utils/assert.js.map +0 -1
- package/dist/esm/geometry/attributes/compute-bounding-box.js +0 -30
- package/dist/esm/geometry/attributes/compute-bounding-box.js.map +0 -1
- package/dist/esm/geometry/attributes/compute-bounding-sphere.js +0 -2
- package/dist/esm/geometry/attributes/compute-bounding-sphere.js.map +0 -1
- package/dist/esm/geometry/attributes/compute-tangents.js +0 -2
- package/dist/esm/geometry/attributes/compute-tangents.js.map +0 -1
- package/dist/esm/geometry/attributes/compute-vertex-normals.js +0 -43
- package/dist/esm/geometry/attributes/compute-vertex-normals.js.map +0 -1
- package/dist/esm/geometry/attributes/convert-to-non-indexed.js +0 -32
- package/dist/esm/geometry/attributes/convert-to-non-indexed.js.map +0 -1
- package/dist/esm/geometry/attributes/get-attribute-from-geometry.js +0 -27
- package/dist/esm/geometry/attributes/get-attribute-from-geometry.js.map +0 -1
- package/dist/esm/geometry/attributes/normalize.js +0 -12
- package/dist/esm/geometry/attributes/normalize.js.map +0 -1
- package/dist/esm/geometry/colors/rgb565.js +0 -16
- package/dist/esm/geometry/colors/rgb565.js.map +0 -1
- package/dist/esm/geometry/compression/attribute-compression.js +0 -175
- package/dist/esm/geometry/compression/attribute-compression.js.map +0 -1
- package/dist/esm/geometry/constants.js +0 -28
- package/dist/esm/geometry/constants.js.map +0 -1
- package/dist/esm/geometry/gl/gl-type.js +0 -85
- package/dist/esm/geometry/gl/gl-type.js.map +0 -1
- package/dist/esm/geometry/is-geometry.js +0 -4
- package/dist/esm/geometry/is-geometry.js.map +0 -1
- package/dist/esm/geometry/iterators/attribute-iterator.js +0 -13
- package/dist/esm/geometry/iterators/attribute-iterator.js.map +0 -1
- package/dist/esm/geometry/iterators/primitive-iterator.js +0 -82
- package/dist/esm/geometry/iterators/primitive-iterator.js.map +0 -1
- package/dist/esm/geometry/primitives/modes.js +0 -58
- package/dist/esm/geometry/primitives/modes.js.map +0 -1
- package/dist/esm/geometry/typed-arrays/typed-array-utils.js +0 -22
- package/dist/esm/geometry/typed-arrays/typed-array-utils.js.map +0 -1
- package/dist/esm/geometry/types.js +0 -2
- package/dist/esm/geometry/types.js.map +0 -1
- package/dist/esm/geometry/utils/assert.js +0 -6
- package/dist/esm/geometry/utils/assert.js.map +0 -1
- package/dist/esm/index.js +0 -11
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/utils/assert.js +0 -6
- package/dist/esm/utils/assert.js.map +0 -1
|
@@ -1,44 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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;
|
|
1
|
+
import { makeAttributeIterator } from '../iterators/attribute-iterator';
|
|
2
|
+
import { assert } from '../utils/assert';
|
|
3
|
+
export function computeBoundingBox(positions = []) {
|
|
4
|
+
const min = [Number(Infinity), Number(Infinity), Number(Infinity)];
|
|
5
|
+
const max = [-Infinity, -Infinity, -Infinity];
|
|
6
|
+
|
|
7
|
+
for (const position of makeAttributeIterator(positions)) {
|
|
8
|
+
const x = position[0];
|
|
9
|
+
const y = position[1];
|
|
10
|
+
const z = position[2];
|
|
11
|
+
if (x < min[0]) min[0] = x;
|
|
12
|
+
if (y < min[1]) min[1] = y;
|
|
13
|
+
if (z < min[2]) min[2] = z;
|
|
14
|
+
if (x > max[0]) max[0] = x;
|
|
15
|
+
if (y > max[1]) max[1] = y;
|
|
16
|
+
if (z > max[2]) max[2] = z;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const boundingBox = {
|
|
20
|
+
min,
|
|
21
|
+
max
|
|
22
|
+
};
|
|
23
|
+
validateBoundingBox(boundingBox);
|
|
24
|
+
return boundingBox;
|
|
35
25
|
}
|
|
36
|
-
|
|
26
|
+
|
|
37
27
|
function validateBoundingBox(boundingBox) {
|
|
38
|
-
|
|
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]));
|
|
28
|
+
assert(Number.isFinite(boundingBox.min[0]) && Number.isFinite(boundingBox.min[1]) && Number.isFinite(boundingBox.min[2]) && Number.isFinite(boundingBox.max[0]) && Number.isFinite(boundingBox.max[1]) && Number.isFinite(boundingBox.max[2]));
|
|
44
29
|
}
|
|
30
|
+
//# sourceMappingURL=compute-bounding-box.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/geometry/attributes/compute-bounding-box.ts"],"names":["makeAttributeIterator","assert","computeBoundingBox","positions","min","Number","Infinity","max","position","x","y","z","boundingBox","validateBoundingBox","isFinite"],"mappings":"AAAA,SAAQA,qBAAR,QAAoC,iCAApC;AACA,SAAQC,MAAR,QAAqB,iBAArB;AAcA,OAAO,SAASC,kBAAT,CAA4BC,SAAc,GAAG,EAA7C,EAAiD;AACtD,QAAMC,GAAG,GAAG,CAACC,MAAM,CAACC,QAAD,CAAP,EAAmBD,MAAM,CAACC,QAAD,CAAzB,EAAqCD,MAAM,CAACC,QAAD,CAA3C,CAAZ;AACA,QAAMC,GAAG,GAAG,CAAC,CAACD,QAAF,EAAY,CAACA,QAAb,EAAuB,CAACA,QAAxB,CAAZ;;AAEA,OAAK,MAAME,QAAX,IAAuBR,qBAAqB,CAACG,SAAD,CAA5C,EAAyD;AACvD,UAAMM,CAAC,GAAGD,QAAQ,CAAC,CAAD,CAAlB;AACA,UAAME,CAAC,GAAGF,QAAQ,CAAC,CAAD,CAAlB;AACA,UAAMG,CAAC,GAAGH,QAAQ,CAAC,CAAD,CAAlB;AAEA,QAAIC,CAAC,GAAGL,GAAG,CAAC,CAAD,CAAX,EAAgBA,GAAG,CAAC,CAAD,CAAH,GAASK,CAAT;AAChB,QAAIC,CAAC,GAAGN,GAAG,CAAC,CAAD,CAAX,EAAgBA,GAAG,CAAC,CAAD,CAAH,GAASM,CAAT;AAChB,QAAIC,CAAC,GAAGP,GAAG,CAAC,CAAD,CAAX,EAAgBA,GAAG,CAAC,CAAD,CAAH,GAASO,CAAT;AAEhB,QAAIF,CAAC,GAAGF,GAAG,CAAC,CAAD,CAAX,EAAgBA,GAAG,CAAC,CAAD,CAAH,GAASE,CAAT;AAChB,QAAIC,CAAC,GAAGH,GAAG,CAAC,CAAD,CAAX,EAAgBA,GAAG,CAAC,CAAD,CAAH,GAASG,CAAT;AAChB,QAAIC,CAAC,GAAGJ,GAAG,CAAC,CAAD,CAAX,EAAgBA,GAAG,CAAC,CAAD,CAAH,GAASI,CAAT;AACjB;;AAED,QAAMC,WAAW,GAAG;AAACR,IAAAA,GAAD;AAAMG,IAAAA;AAAN,GAApB;AACAM,EAAAA,mBAAmB,CAACD,WAAD,CAAnB;AACA,SAAOA,WAAP;AACD;;AAED,SAASC,mBAAT,CAA6BD,WAA7B,EAAuD;AACrDX,EAAAA,MAAM,CACJI,MAAM,CAACS,QAAP,CAAgBF,WAAW,CAACR,GAAZ,CAAgB,CAAhB,CAAhB,KACEC,MAAM,CAACS,QAAP,CAAgBF,WAAW,CAACR,GAAZ,CAAgB,CAAhB,CAAhB,CADF,IAEEC,MAAM,CAACS,QAAP,CAAgBF,WAAW,CAACR,GAAZ,CAAgB,CAAhB,CAAhB,CAFF,IAGEC,MAAM,CAACS,QAAP,CAAgBF,WAAW,CAACL,GAAZ,CAAgB,CAAhB,CAAhB,CAHF,IAIEF,MAAM,CAACS,QAAP,CAAgBF,WAAW,CAACL,GAAZ,CAAgB,CAAhB,CAAhB,CAJF,IAKEF,MAAM,CAACS,QAAP,CAAgBF,WAAW,CAACL,GAAZ,CAAgB,CAAhB,CAAhB,CANE,CAAN;AAQD","sourcesContent":["import {makeAttributeIterator} from '../iterators/attribute-iterator';\nimport {assert} from '../utils/assert';\n\n/**\n * Type for Bounding Box computing\n */\ntype BoundingBox = {\n min: number[];\n max: number[];\n};\n/**\n * Getting bounding box geometry according to positions parameters\n * @param positions\n * @returns Bounding Box\n */\nexport function computeBoundingBox(positions: any = []) {\n const min = [Number(Infinity), Number(Infinity), Number(Infinity)];\n const max = [-Infinity, -Infinity, -Infinity];\n // @ts-ignore\n for (const position of makeAttributeIterator(positions)) {\n const x = position[0];\n const y = position[1];\n const z = position[2];\n\n if (x < min[0]) min[0] = x;\n if (y < min[1]) min[1] = y;\n if (z < min[2]) min[2] = z;\n\n if (x > max[0]) max[0] = x;\n if (y > max[1]) max[1] = y;\n if (z > max[2]) max[2] = z;\n }\n\n const boundingBox = {min, max};\n validateBoundingBox(boundingBox);\n return boundingBox;\n}\n\nfunction validateBoundingBox(boundingBox: BoundingBox) {\n assert(\n Number.isFinite(boundingBox.min[0]) &&\n Number.isFinite(boundingBox.min[1]) &&\n Number.isFinite(boundingBox.min[2]) &&\n Number.isFinite(boundingBox.max[0]) &&\n Number.isFinite(boundingBox.max[1]) &&\n Number.isFinite(boundingBox.max[2])\n );\n}\n"],"file":"compute-bounding-box.js"}
|
|
@@ -1,30 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/* eslint-disable */
|
|
3
|
-
/**
|
|
4
|
-
import {getPositions} from './get-attribute-from-geometry.js';
|
|
5
1
|
|
|
6
|
-
|
|
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
|
-
*/
|
|
2
|
+
//# sourceMappingURL=compute-bounding-sphere.js.map
|
|
File without changes
|
|
@@ -1,146 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
export function computeTangents({indices, positions, normals, uvs}) {
|
|
4
|
-
var index = geometry.index;
|
|
5
|
-
var attributes = geometry.attributes;
|
|
6
1
|
|
|
7
|
-
|
|
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
|
-
*/
|
|
2
|
+
//# sourceMappingURL=compute-tangents.js.map
|
|
File without changes
|
|
@@ -1,48 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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;
|
|
1
|
+
import { Vector3 } from '@math.gl/core';
|
|
2
|
+
import { GL } from '../constants';
|
|
3
|
+
import { assert } from '../utils/assert';
|
|
4
|
+
import { makePrimitiveIterator } from '../iterators/primitive-iterator';
|
|
5
|
+
import { getPrimitiveModeType } from '../primitives/modes';
|
|
6
|
+
import { getPositions } from './get-attribute-from-geometry';
|
|
7
|
+
export function computeVertexNormals(geometry) {
|
|
8
|
+
assert(getPrimitiveModeType(geometry.mode) === GL.TRIANGLES, 'TRIANGLES required');
|
|
9
|
+
const {
|
|
10
|
+
values: positions
|
|
11
|
+
} = getPositions(geometry);
|
|
12
|
+
const normals = new Float32Array(positions.length);
|
|
13
|
+
const vectorA = new Vector3();
|
|
14
|
+
const vectorB = new Vector3();
|
|
15
|
+
const vectorC = new Vector3();
|
|
16
|
+
const vectorCB = new Vector3();
|
|
17
|
+
const vectorAB = new Vector3();
|
|
18
|
+
|
|
19
|
+
for (const primitive of makePrimitiveIterator(geometry)) {
|
|
20
|
+
vectorA.fromArray(positions, primitive.i1 * 3);
|
|
21
|
+
vectorB.fromArray(positions, primitive.i2 * 3 + 3);
|
|
22
|
+
vectorC.fromArray(positions, primitive.i3 * 3 + 6);
|
|
23
|
+
vectorCB.subVectors(vectorC, vectorB);
|
|
24
|
+
vectorAB.subVectors(vectorA, vectorB);
|
|
25
|
+
const normal = vectorCB.cross(vectorAB);
|
|
26
|
+
normal.normalize();
|
|
27
|
+
const {
|
|
28
|
+
primitiveIndex
|
|
29
|
+
} = primitive;
|
|
30
|
+
normals[primitiveIndex * 9 + 0] = normal.x;
|
|
31
|
+
normals[primitiveIndex * 9 + 1] = normal.y;
|
|
32
|
+
normals[primitiveIndex * 9 + 2] = normal.z;
|
|
33
|
+
normals[primitiveIndex * 9 + 3] = normal.x;
|
|
34
|
+
normals[primitiveIndex * 9 + 4] = normal.y;
|
|
35
|
+
normals[primitiveIndex * 9 + 5] = normal.z;
|
|
36
|
+
normals[primitiveIndex * 9 + 6] = normal.x;
|
|
37
|
+
normals[primitiveIndex * 9 + 7] = normal.y;
|
|
38
|
+
normals[primitiveIndex * 9 + 8] = normal.z;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return normals;
|
|
47
42
|
}
|
|
48
|
-
|
|
43
|
+
//# sourceMappingURL=compute-vertex-normals.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/geometry/attributes/compute-vertex-normals.ts"],"names":["Vector3","GL","assert","makePrimitiveIterator","getPrimitiveModeType","getPositions","computeVertexNormals","geometry","mode","TRIANGLES","values","positions","normals","Float32Array","length","vectorA","vectorB","vectorC","vectorCB","vectorAB","primitive","fromArray","i1","i2","i3","subVectors","normal","cross","normalize","primitiveIndex","x","y","z"],"mappings":"AACA,SAAQA,OAAR,QAAsB,eAAtB;AACA,SAAQC,EAAR,QAAiB,cAAjB;AACA,SAAQC,MAAR,QAAqB,iBAArB;AACA,SAAQC,qBAAR,QAAoC,iCAApC;AACA,SAAQC,oBAAR,QAAmC,qBAAnC;AACA,SAAQC,YAAR,QAA2B,+BAA3B;AAaA,OAAO,SAASC,oBAAT,CAA8BC,QAA9B,EAAgE;AAErEL,EAAAA,MAAM,CAACE,oBAAoB,CAACG,QAAQ,CAACC,IAAV,CAApB,KAAwCP,EAAE,CAACQ,SAA5C,EAAuD,oBAAvD,CAAN;AAEA,QAAM;AAACC,IAAAA,MAAM,EAAEC;AAAT,MAAsBN,YAAY,CAACE,QAAD,CAAxC;AAEA,QAAMK,OAAO,GAAG,IAAIC,YAAJ,CAAiBF,SAAS,CAACG,MAA3B,CAAhB;AAEA,QAAMC,OAAO,GAAG,IAAIf,OAAJ,EAAhB;AACA,QAAMgB,OAAO,GAAG,IAAIhB,OAAJ,EAAhB;AACA,QAAMiB,OAAO,GAAG,IAAIjB,OAAJ,EAAhB;AAEA,QAAMkB,QAAQ,GAAG,IAAIlB,OAAJ,EAAjB;AACA,QAAMmB,QAAQ,GAAG,IAAInB,OAAJ,EAAjB;;AAEA,OAAK,MAAMoB,SAAX,IAAwBjB,qBAAqB,CAACI,QAAD,CAA7C,EAAyD;AACvDQ,IAAAA,OAAO,CAACM,SAAR,CAAkBV,SAAlB,EAA6BS,SAAS,CAACE,EAAV,GAAe,CAA5C;AACAN,IAAAA,OAAO,CAACK,SAAR,CAAkBV,SAAlB,EAA6BS,SAAS,CAACG,EAAV,GAAe,CAAf,GAAmB,CAAhD;AACAN,IAAAA,OAAO,CAACI,SAAR,CAAkBV,SAAlB,EAA6BS,SAAS,CAACI,EAAV,GAAe,CAAf,GAAmB,CAAhD;AAEAN,IAAAA,QAAQ,CAACO,UAAT,CAAoBR,OAApB,EAA6BD,OAA7B;AACAG,IAAAA,QAAQ,CAACM,UAAT,CAAoBV,OAApB,EAA6BC,OAA7B;AACA,UAAMU,MAAM,GAAGR,QAAQ,CAACS,KAAT,CAAeR,QAAf,CAAf;AACAO,IAAAA,MAAM,CAACE,SAAP;AAEA,UAAM;AAACC,MAAAA;AAAD,QAAmBT,SAAzB;AAEAR,IAAAA,OAAO,CAACiB,cAAc,GAAG,CAAjB,GAAqB,CAAtB,CAAP,GAAkCH,MAAM,CAACI,CAAzC;AACAlB,IAAAA,OAAO,CAACiB,cAAc,GAAG,CAAjB,GAAqB,CAAtB,CAAP,GAAkCH,MAAM,CAACK,CAAzC;AACAnB,IAAAA,OAAO,CAACiB,cAAc,GAAG,CAAjB,GAAqB,CAAtB,CAAP,GAAkCH,MAAM,CAACM,CAAzC;AAEApB,IAAAA,OAAO,CAACiB,cAAc,GAAG,CAAjB,GAAqB,CAAtB,CAAP,GAAkCH,MAAM,CAACI,CAAzC;AACAlB,IAAAA,OAAO,CAACiB,cAAc,GAAG,CAAjB,GAAqB,CAAtB,CAAP,GAAkCH,MAAM,CAACK,CAAzC;AACAnB,IAAAA,OAAO,CAACiB,cAAc,GAAG,CAAjB,GAAqB,CAAtB,CAAP,GAAkCH,MAAM,CAACM,CAAzC;AAEApB,IAAAA,OAAO,CAACiB,cAAc,GAAG,CAAjB,GAAqB,CAAtB,CAAP,GAAkCH,MAAM,CAACI,CAAzC;AACAlB,IAAAA,OAAO,CAACiB,cAAc,GAAG,CAAjB,GAAqB,CAAtB,CAAP,GAAkCH,MAAM,CAACK,CAAzC;AACAnB,IAAAA,OAAO,CAACiB,cAAc,GAAG,CAAjB,GAAqB,CAAtB,CAAP,GAAkCH,MAAM,CAACM,CAAzC;AACD;;AAED,SAAOpB,OAAP;AACD","sourcesContent":["import type {TypedArray} from '../types';\nimport {Vector3} from '@math.gl/core';\nimport {GL} from '../constants';\nimport {assert} from '../utils/assert';\nimport {makePrimitiveIterator} from '../iterators/primitive-iterator';\nimport {getPrimitiveModeType} from '../primitives/modes';\nimport {getPositions} from './get-attribute-from-geometry';\n\ntype Geometry = {\n mode: any;\n indices?: {size: number; values: TypedArray};\n attributes?: {};\n};\n/**\n * Computes vertex normals for a geometry\n * @param param0\n * @returns\n */\n// eslint-disable-next-line max-statements\nexport function computeVertexNormals(geometry: Geometry): Float32Array {\n // Only support GL.TRIANGLES, GL.TRIANGLE_STRIP, GL.TRIANGLE_FAN\n assert(getPrimitiveModeType(geometry.mode) === GL.TRIANGLES, 'TRIANGLES required');\n\n const {values: positions} = getPositions(geometry);\n\n const normals = new Float32Array(positions.length);\n\n const vectorA = new Vector3();\n const vectorB = new Vector3();\n const vectorC = new Vector3();\n\n const vectorCB = new Vector3();\n const vectorAB = new Vector3();\n\n for (const primitive of makePrimitiveIterator(geometry)) {\n vectorA.fromArray(positions, primitive.i1 * 3);\n vectorB.fromArray(positions, primitive.i2 * 3 + 3);\n vectorC.fromArray(positions, primitive.i3 * 3 + 6);\n\n vectorCB.subVectors(vectorC, vectorB);\n vectorAB.subVectors(vectorA, vectorB);\n const normal = vectorCB.cross(vectorAB);\n normal.normalize();\n // @ts-ignore\n const {primitiveIndex} = primitive;\n\n normals[primitiveIndex * 9 + 0] = normal.x;\n normals[primitiveIndex * 9 + 1] = normal.y;\n normals[primitiveIndex * 9 + 2] = normal.z;\n\n normals[primitiveIndex * 9 + 3] = normal.x;\n normals[primitiveIndex * 9 + 4] = normal.y;\n normals[primitiveIndex * 9 + 5] = normal.z;\n\n normals[primitiveIndex * 9 + 6] = normal.x;\n normals[primitiveIndex * 9 + 7] = normal.y;\n normals[primitiveIndex * 9 + 8] = normal.z;\n }\n\n return normals;\n}\n"],"file":"compute-vertex-normals.js"}
|
|
@@ -1,33 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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));
|
|
1
|
+
export function convertBuffersToNonIndexed({
|
|
2
|
+
indices,
|
|
3
|
+
attributes
|
|
4
|
+
}) {
|
|
5
|
+
const geometry2 = new BufferGeometry();
|
|
6
|
+
|
|
7
|
+
for (const name in attributes) {
|
|
8
|
+
const attribute = attributes[name];
|
|
9
|
+
const array = attribute.array;
|
|
10
|
+
const itemSize = attribute.itemSize;
|
|
11
|
+
const array2 = new array.constructor(indices.length * itemSize);
|
|
12
|
+
let index = 0,
|
|
13
|
+
index2 = 0;
|
|
14
|
+
|
|
15
|
+
for (var i = 0, l = indices.length; i < l; i++) {
|
|
16
|
+
index = indices[i] * itemSize;
|
|
17
|
+
|
|
18
|
+
for (var j = 0; j < itemSize; j++) {
|
|
19
|
+
array2[index2++] = array[index++];
|
|
20
|
+
}
|
|
27
21
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
22
|
+
|
|
23
|
+
geometry2.addAttribute(name, new BufferAttribute(array2, itemSize));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
for (const group of this.groups) {
|
|
27
|
+
geometry2.addGroup(group.start, group.count, group.materialIndex);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return geometry2;
|
|
32
31
|
}
|
|
33
|
-
|
|
32
|
+
//# sourceMappingURL=convert-to-non-indexed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/geometry/attributes/convert-to-non-indexed.ts"],"names":["convertBuffersToNonIndexed","indices","attributes","geometry2","BufferGeometry","name","attribute","array","itemSize","array2","constructor","length","index","index2","i","l","j","addAttribute","BufferAttribute","group","groups","addGroup","start","count","materialIndex"],"mappings":"AAQA,OAAO,SAASA,0BAAT,CAAoC;AAACC,EAAAA,OAAD;AAAUC,EAAAA;AAAV,CAApC,EAAgE;AACrE,QAAMC,SAAS,GAAG,IAAIC,cAAJ,EAAlB;;AAEA,OAAK,MAAMC,IAAX,IAAmBH,UAAnB,EAA+B;AAC7B,UAAMI,SAAS,GAAGJ,UAAU,CAACG,IAAD,CAA5B;AAEA,UAAME,KAAK,GAAGD,SAAS,CAACC,KAAxB;AACA,UAAMC,QAAQ,GAAGF,SAAS,CAACE,QAA3B;AAEA,UAAMC,MAAM,GAAG,IAAIF,KAAK,CAACG,WAAV,CAAsBT,OAAO,CAACU,MAAR,GAAiBH,QAAvC,CAAf;AACA,QAAII,KAAK,GAAG,CAAZ;AAAA,QACEC,MAAM,GAAG,CADX;;AAGA,SAAK,IAAIC,CAAC,GAAG,CAAR,EAAWC,CAAC,GAAGd,OAAO,CAACU,MAA5B,EAAoCG,CAAC,GAAGC,CAAxC,EAA2CD,CAAC,EAA5C,EAAgD;AAC9CF,MAAAA,KAAK,GAAGX,OAAO,CAACa,CAAD,CAAP,GAAaN,QAArB;;AACA,WAAK,IAAIQ,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGR,QAApB,EAA8BQ,CAAC,EAA/B,EAAmC;AACjCP,QAAAA,MAAM,CAACI,MAAM,EAAP,CAAN,GAAmBN,KAAK,CAACK,KAAK,EAAN,CAAxB;AACD;AACF;;AACDT,IAAAA,SAAS,CAACc,YAAV,CAAuBZ,IAAvB,EAA6B,IAAIa,eAAJ,CAAoBT,MAApB,EAA4BD,QAA5B,CAA7B;AACD;;AAED,OAAK,MAAMW,KAAX,IAAoB,KAAKC,MAAzB,EAAiC;AAC/BjB,IAAAA,SAAS,CAACkB,QAAV,CAAmBF,KAAK,CAACG,KAAzB,EAAgCH,KAAK,CAACI,KAAtC,EAA6CJ,KAAK,CAACK,aAAnD;AACD;;AAED,SAAOrB,SAAP;AACD","sourcesContent":["/* eslint-disable */\n// @ts-nocheck\n/**\n * Converts indices of geometry.\n *\n * @param param0\n * @returns no indexed geometry\n */\nexport function convertBuffersToNonIndexed({indices, attributes}): any {\n const geometry2 = new BufferGeometry();\n\n for (const name in attributes) {\n const attribute = attributes[name];\n\n const array = attribute.array;\n const itemSize = attribute.itemSize;\n\n const array2 = new array.constructor(indices.length * itemSize);\n let index = 0,\n index2 = 0;\n\n for (var i = 0, l = indices.length; i < l; i++) {\n index = indices[i] * itemSize;\n for (var j = 0; j < itemSize; j++) {\n array2[index2++] = array[index++];\n }\n }\n geometry2.addAttribute(name, new BufferAttribute(array2, itemSize));\n }\n\n for (const group of this.groups) {\n geometry2.addGroup(group.start, group.count, group.materialIndex);\n }\n\n return geometry2;\n}\n"],"file":"convert-to-non-indexed.js"}
|
|
@@ -1,34 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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);
|
|
1
|
+
import isGeometry from '../is-geometry';
|
|
2
|
+
import { assert } from '../utils/assert';
|
|
3
|
+
export function getPositions(geometry) {
|
|
4
|
+
if (isGeometry(geometry)) {
|
|
5
|
+
const {
|
|
6
|
+
attributes
|
|
7
|
+
} = geometry;
|
|
8
|
+
const position = attributes.POSITION || attributes.positions;
|
|
9
|
+
assert(position);
|
|
10
|
+
return position;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
if (ArrayBuffer.isView(geometry)) {
|
|
14
|
+
return {
|
|
15
|
+
values: geometry,
|
|
16
|
+
size: 3
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (geometry) {
|
|
21
|
+
assert(geometry.values);
|
|
22
|
+
return geometry;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return assert(false);
|
|
33
26
|
}
|
|
34
|
-
|
|
27
|
+
//# sourceMappingURL=get-attribute-from-geometry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/geometry/attributes/get-attribute-from-geometry.ts"],"names":["isGeometry","assert","getPositions","geometry","attributes","position","POSITION","positions","ArrayBuffer","isView","values","size"],"mappings":"AAAA,OAAOA,UAAP,MAAuB,gBAAvB;AACA,SAAQC,MAAR,QAAqB,iBAArB;AASA,OAAO,SAASC,YAAT,CAAsBC,QAAtB,EAAqC;AAE1C,MAAIH,UAAU,CAACG,QAAD,CAAd,EAA0B;AACxB,UAAM;AAACC,MAAAA;AAAD,QAAeD,QAArB;AACA,UAAME,QAAQ,GAAGD,UAAU,CAACE,QAAX,IAAuBF,UAAU,CAACG,SAAnD;AACAN,IAAAA,MAAM,CAACI,QAAD,CAAN;AACA,WAAOA,QAAP;AACD;;AAGD,MAAIG,WAAW,CAACC,MAAZ,CAAmBN,QAAnB,CAAJ,EAAkC;AAChC,WAAO;AAACO,MAAAA,MAAM,EAAEP,QAAT;AAAmBQ,MAAAA,IAAI,EAAE;AAAzB,KAAP;AACD;;AAGD,MAAIR,QAAJ,EAAc;AACZF,IAAAA,MAAM,CAACE,QAAQ,CAACO,MAAV,CAAN;AACA,WAAOP,QAAP;AACD;;AAED,SAAOF,MAAM,CAAC,KAAD,CAAb;AACD","sourcesContent":["import isGeometry from '../is-geometry';\nimport {assert} from '../utils/assert';\n\n/**\n * analyze positions of geometry\n *\n * @param geometry\n * @returns Position| New geometry |assert\n */\n\nexport function getPositions(geometry: any) {\n // If geometry, extract positions\n if (isGeometry(geometry)) {\n const {attributes} = geometry;\n const position = attributes.POSITION || attributes.positions;\n assert(position);\n return position;\n }\n\n // If arraybuffer, assume 3 components\n if (ArrayBuffer.isView(geometry)) {\n return {values: geometry, size: 3};\n }\n\n // Else assume accessor object\n if (geometry) {\n assert(geometry.values);\n return geometry;\n }\n\n return assert(false);\n}\n"],"file":"get-attribute-from-geometry.js"}
|
|
@@ -1,20 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
}
|
|
1
|
+
export function normalize(normals = {}, vector) {
|
|
2
|
+
normals = this.attributes.normal;
|
|
3
|
+
|
|
4
|
+
for (let i = 0, il = normals.count; i < il; i++) {
|
|
5
|
+
vector.x = normals.getX(i);
|
|
6
|
+
vector.y = normals.getY(i);
|
|
7
|
+
vector.z = normals.getZ(i);
|
|
8
|
+
vector.normalize();
|
|
9
|
+
normals.setXYZ(i, vector.x, vector.y, vector.z);
|
|
10
|
+
}
|
|
19
11
|
}
|
|
20
|
-
|
|
12
|
+
//# sourceMappingURL=normalize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/geometry/attributes/normalize.ts"],"names":["normalize","normals","vector","attributes","normal","i","il","count","x","getX","y","getY","z","getZ","setXYZ"],"mappings":"AAQA,OAAO,SAASA,SAAT,CAAmBC,OAAY,GAAG,EAAlC,EAAsCC,MAAtC,EAAuD;AAE5DD,EAAAA,OAAO,GAAG,KAAKE,UAAL,CAAgBC,MAA1B;;AACA,OAAK,IAAIC,CAAC,GAAG,CAAR,EAAWC,EAAE,GAAGL,OAAO,CAACM,KAA7B,EAAoCF,CAAC,GAAGC,EAAxC,EAA4CD,CAAC,EAA7C,EAAiD;AAC/CH,IAAAA,MAAM,CAACM,CAAP,GAAWP,OAAO,CAACQ,IAAR,CAAaJ,CAAb,CAAX;AACAH,IAAAA,MAAM,CAACQ,CAAP,GAAWT,OAAO,CAACU,IAAR,CAAaN,CAAb,CAAX;AACAH,IAAAA,MAAM,CAACU,CAAP,GAAWX,OAAO,CAACY,IAAR,CAAaR,CAAb,CAAX;AACAH,IAAAA,MAAM,CAACF,SAAP;AACAC,IAAAA,OAAO,CAACa,MAAR,CAAeT,CAAf,EAAkBH,MAAM,CAACM,CAAzB,EAA4BN,MAAM,CAACQ,CAAnC,EAAsCR,MAAM,CAACU,CAA7C;AACD;AACF","sourcesContent":["/* eslint-disable */\nimport {Vector3} from '@math.gl/core';\n\n/**\n * Setting X, Y, Z for Vector\n * @param normals\n * @param vector\n */\nexport function normalize(normals: any = {}, vector: Vector3) {\n //@ts-ignore\n normals = this.attributes.normal;\n for (let i = 0, il = normals.count; i < il; i++) {\n vector.x = normals.getX(i);\n vector.y = normals.getY(i);\n vector.z = normals.getZ(i);\n vector.normalize();\n normals.setXYZ(i, vector.x, vector.y, vector.z);\n }\n}\n"],"file":"normalize.js"}
|
|
@@ -1,31 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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;
|
|
1
|
+
export function decodeRGB565(rgb565, target = [0, 0, 0]) {
|
|
2
|
+
const r5 = rgb565 >> 11 & 31;
|
|
3
|
+
const g6 = rgb565 >> 5 & 63;
|
|
4
|
+
const b5 = rgb565 & 31;
|
|
5
|
+
target[0] = r5 << 3;
|
|
6
|
+
target[1] = g6 << 2;
|
|
7
|
+
target[2] = b5 << 3;
|
|
8
|
+
return target;
|
|
18
9
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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);
|
|
10
|
+
export function encodeRGB565(rgb) {
|
|
11
|
+
const r5 = Math.floor(rgb[0] / 8) + 4;
|
|
12
|
+
const g6 = Math.floor(rgb[1] / 4) + 2;
|
|
13
|
+
const b5 = Math.floor(rgb[2] / 8) + 4;
|
|
14
|
+
return r5 + (g6 << 5) + (b5 << 11);
|
|
30
15
|
}
|
|
31
|
-
|
|
16
|
+
//# sourceMappingURL=rgb565.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/geometry/colors/rgb565.ts"],"names":["decodeRGB565","rgb565","target","r5","g6","b5","encodeRGB565","rgb","Math","floor"],"mappings":"AAMA,OAAO,SAASA,YAAT,CAAsBC,MAAtB,EAAsCC,MAAgB,GAAG,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,CAAzD,EAA8E;AACnF,QAAMC,EAAE,GAAIF,MAAM,IAAI,EAAX,GAAiB,EAA5B;AACA,QAAMG,EAAE,GAAIH,MAAM,IAAI,CAAX,GAAgB,EAA3B;AACA,QAAMI,EAAE,GAAGJ,MAAM,GAAG,EAApB;AAEAC,EAAAA,MAAM,CAAC,CAAD,CAAN,GAAYC,EAAE,IAAI,CAAlB;AACAD,EAAAA,MAAM,CAAC,CAAD,CAAN,GAAYE,EAAE,IAAI,CAAlB;AACAF,EAAAA,MAAM,CAAC,CAAD,CAAN,GAAYG,EAAE,IAAI,CAAlB;AAEA,SAAOH,MAAP;AACD;AAOD,OAAO,SAASI,YAAT,CAAsBC,GAAtB,EAA6C;AAClD,QAAMJ,EAAE,GAAGK,IAAI,CAACC,KAAL,CAAWF,GAAG,CAAC,CAAD,CAAH,GAAS,CAApB,IAAyB,CAApC;AACA,QAAMH,EAAE,GAAGI,IAAI,CAACC,KAAL,CAAWF,GAAG,CAAC,CAAD,CAAH,GAAS,CAApB,IAAyB,CAApC;AACA,QAAMF,EAAE,GAAGG,IAAI,CAACC,KAAL,CAAWF,GAAG,CAAC,CAAD,CAAH,GAAS,CAApB,IAAyB,CAApC;AACA,SAAOJ,EAAE,IAAIC,EAAE,IAAI,CAAV,CAAF,IAAkBC,EAAE,IAAI,EAAxB,CAAP;AACD","sourcesContent":["/**\n * Decode color values\n * @param rgb565\n * @param target\n * @returns target\n */\nexport function decodeRGB565(rgb565: number, target: number[] = [0, 0, 0]): number[] {\n const r5 = (rgb565 >> 11) & 31;\n const g6 = (rgb565 >> 5) & 63;\n const b5 = rgb565 & 31;\n\n target[0] = r5 << 3;\n target[1] = g6 << 2;\n target[2] = b5 << 3;\n\n return target;\n}\n\n/**\n * Encode color values\n * @param rgb\n * @returns color\n */\nexport function encodeRGB565(rgb: number[]): number {\n const r5 = Math.floor(rgb[0] / 8) + 4;\n const g6 = Math.floor(rgb[1] / 4) + 2;\n const b5 = Math.floor(rgb[2] / 8) + 4;\n return r5 + (g6 << 5) + (b5 << 11);\n}\n"],"file":"rgb565.js"}
|