@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.
- package/dist/es5/geometry/attributes/compute-bounding-box.js +17 -34
- package/dist/es5/geometry/attributes/compute-bounding-box.js.map +1 -1
- package/dist/es5/geometry/attributes/compute-vertex-normals.js +30 -45
- package/dist/es5/geometry/attributes/compute-vertex-normals.js.map +1 -1
- package/dist/es5/geometry/attributes/convert-to-non-indexed.js +14 -29
- package/dist/es5/geometry/attributes/convert-to-non-indexed.js.map +1 -1
- package/dist/es5/geometry/attributes/get-attribute-from-geometry.js +4 -2
- package/dist/es5/geometry/attributes/get-attribute-from-geometry.js.map +1 -1
- package/dist/es5/geometry/attributes/normalize.js +2 -4
- package/dist/es5/geometry/attributes/normalize.js.map +1 -1
- package/dist/es5/geometry/colors/rgb565.js +7 -8
- package/dist/es5/geometry/colors/rgb565.js.map +1 -1
- package/dist/es5/geometry/compression/attribute-compression.js +39 -41
- package/dist/es5/geometry/compression/attribute-compression.js.map +1 -1
- package/dist/es5/geometry/constants.js +6 -15
- package/dist/es5/geometry/constants.js.map +1 -1
- package/dist/es5/geometry/gl/gl-type.js +63 -79
- package/dist/es5/geometry/gl/gl-type.js.map +1 -1
- package/dist/es5/geometry/is-geometry.js +1 -5
- package/dist/es5/geometry/is-geometry.js.map +1 -1
- package/dist/es5/geometry/iterators/attribute-iterator.js +9 -38
- package/dist/es5/geometry/iterators/attribute-iterator.js.map +1 -1
- package/dist/es5/geometry/iterators/primitive-iterator.js +75 -116
- package/dist/es5/geometry/iterators/primitive-iterator.js.map +1 -1
- package/dist/es5/geometry/typed-arrays/typed-array-utils.js +8 -9
- package/dist/es5/geometry/typed-arrays/typed-array-utils.js.map +1 -1
- package/dist/es5/index.js +24 -24
- package/dist/esm/geometry/compression/attribute-compression.js +1 -1
- package/dist/esm/geometry/compression/attribute-compression.js.map +1 -1
- package/dist/esm/geometry/utils/assert.js +1 -1
- package/dist/esm/geometry/utils/assert.js.map +1 -1
- package/package.json +4 -4
|
@@ -9,42 +9,25 @@ var _attributeIterator = require("../iterators/attribute-iterator");
|
|
|
9
9
|
|
|
10
10
|
var _assert = require("../utils/assert");
|
|
11
11
|
|
|
12
|
-
function
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
try {
|
|
27
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
28
|
-
var position = _step.value;
|
|
29
|
-
var x = position[0];
|
|
30
|
-
var y = position[1];
|
|
31
|
-
var z = position[2];
|
|
32
|
-
if (x < min[0]) min[0] = x;
|
|
33
|
-
if (y < min[1]) min[1] = y;
|
|
34
|
-
if (z < min[2]) min[2] = z;
|
|
35
|
-
if (x > max[0]) max[0] = x;
|
|
36
|
-
if (y > max[1]) max[1] = y;
|
|
37
|
-
if (z > max[2]) max[2] = z;
|
|
38
|
-
}
|
|
39
|
-
} catch (err) {
|
|
40
|
-
_iterator.e(err);
|
|
41
|
-
} finally {
|
|
42
|
-
_iterator.f();
|
|
12
|
+
function computeBoundingBox(positions = []) {
|
|
13
|
+
const min = [Number(Infinity), Number(Infinity), Number(Infinity)];
|
|
14
|
+
const max = [-Infinity, -Infinity, -Infinity];
|
|
15
|
+
|
|
16
|
+
for (const position of (0, _attributeIterator.makeAttributeIterator)(positions)) {
|
|
17
|
+
const x = position[0];
|
|
18
|
+
const y = position[1];
|
|
19
|
+
const z = position[2];
|
|
20
|
+
if (x < min[0]) min[0] = x;
|
|
21
|
+
if (y < min[1]) min[1] = y;
|
|
22
|
+
if (z < min[2]) min[2] = z;
|
|
23
|
+
if (x > max[0]) max[0] = x;
|
|
24
|
+
if (y > max[1]) max[1] = y;
|
|
25
|
+
if (z > max[2]) max[2] = z;
|
|
43
26
|
}
|
|
44
27
|
|
|
45
|
-
|
|
46
|
-
min
|
|
47
|
-
max
|
|
28
|
+
const boundingBox = {
|
|
29
|
+
min,
|
|
30
|
+
max
|
|
48
31
|
};
|
|
49
32
|
validateBoundingBox(boundingBox);
|
|
50
33
|
return boundingBox;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/geometry/attributes/compute-bounding-box.ts"],"names":["computeBoundingBox","positions","min","Number","Infinity","max","position","x","y","z","boundingBox","validateBoundingBox","isFinite"],"mappings":";;;;;;;AAAA;;AACA
|
|
1
|
+
{"version":3,"sources":["../../../../src/geometry/attributes/compute-bounding-box.ts"],"names":["computeBoundingBox","positions","min","Number","Infinity","max","position","x","y","z","boundingBox","validateBoundingBox","isFinite"],"mappings":";;;;;;;AAAA;;AACA;;AAcO,SAASA,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,IAAuB,8CAAsBL,SAAtB,CAAvB,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;AACrD,sBACEP,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,CANJ;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"}
|
|
@@ -17,53 +17,38 @@ var _modes = require("../primitives/modes");
|
|
|
17
17
|
|
|
18
18
|
var _getAttributeFromGeometry = require("./get-attribute-from-geometry");
|
|
19
19
|
|
|
20
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
21
|
-
|
|
22
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
23
|
-
|
|
24
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
25
|
-
|
|
26
20
|
function computeVertexNormals(geometry) {
|
|
27
21
|
(0, _assert.assert)((0, _modes.getPrimitiveModeType)(geometry.mode) === _constants.GL.TRIANGLES, 'TRIANGLES required');
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
normals[primitiveIndex * 9 + 5] = normal.z;
|
|
59
|
-
normals[primitiveIndex * 9 + 6] = normal.x;
|
|
60
|
-
normals[primitiveIndex * 9 + 7] = normal.y;
|
|
61
|
-
normals[primitiveIndex * 9 + 8] = normal.z;
|
|
62
|
-
}
|
|
63
|
-
} catch (err) {
|
|
64
|
-
_iterator.e(err);
|
|
65
|
-
} finally {
|
|
66
|
-
_iterator.f();
|
|
22
|
+
const {
|
|
23
|
+
values: positions
|
|
24
|
+
} = (0, _getAttributeFromGeometry.getPositions)(geometry);
|
|
25
|
+
const normals = new Float32Array(positions.length);
|
|
26
|
+
const vectorA = new _core.Vector3();
|
|
27
|
+
const vectorB = new _core.Vector3();
|
|
28
|
+
const vectorC = new _core.Vector3();
|
|
29
|
+
const vectorCB = new _core.Vector3();
|
|
30
|
+
const vectorAB = new _core.Vector3();
|
|
31
|
+
|
|
32
|
+
for (const primitive of (0, _primitiveIterator.makePrimitiveIterator)(geometry)) {
|
|
33
|
+
vectorA.fromArray(positions, primitive.i1 * 3);
|
|
34
|
+
vectorB.fromArray(positions, primitive.i2 * 3 + 3);
|
|
35
|
+
vectorC.fromArray(positions, primitive.i3 * 3 + 6);
|
|
36
|
+
vectorCB.subVectors(vectorC, vectorB);
|
|
37
|
+
vectorAB.subVectors(vectorA, vectorB);
|
|
38
|
+
const normal = vectorCB.cross(vectorAB);
|
|
39
|
+
normal.normalize();
|
|
40
|
+
const {
|
|
41
|
+
primitiveIndex
|
|
42
|
+
} = primitive;
|
|
43
|
+
normals[primitiveIndex * 9 + 0] = normal.x;
|
|
44
|
+
normals[primitiveIndex * 9 + 1] = normal.y;
|
|
45
|
+
normals[primitiveIndex * 9 + 2] = normal.z;
|
|
46
|
+
normals[primitiveIndex * 9 + 3] = normal.x;
|
|
47
|
+
normals[primitiveIndex * 9 + 4] = normal.y;
|
|
48
|
+
normals[primitiveIndex * 9 + 5] = normal.z;
|
|
49
|
+
normals[primitiveIndex * 9 + 6] = normal.x;
|
|
50
|
+
normals[primitiveIndex * 9 + 7] = normal.y;
|
|
51
|
+
normals[primitiveIndex * 9 + 8] = normal.z;
|
|
67
52
|
}
|
|
68
53
|
|
|
69
54
|
return normals;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/geometry/attributes/compute-vertex-normals.ts"],"names":["computeVertexNormals","geometry","mode","GL","TRIANGLES","
|
|
1
|
+
{"version":3,"sources":["../../../../src/geometry/attributes/compute-vertex-normals.ts"],"names":["computeVertexNormals","geometry","mode","GL","TRIANGLES","values","positions","normals","Float32Array","length","vectorA","Vector3","vectorB","vectorC","vectorCB","vectorAB","primitive","fromArray","i1","i2","i3","subVectors","normal","cross","normalize","primitiveIndex","x","y","z"],"mappings":";;;;;;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAaO,SAASA,oBAAT,CAA8BC,QAA9B,EAAgE;AAErE,sBAAO,iCAAqBA,QAAQ,CAACC,IAA9B,MAAwCC,cAAGC,SAAlD,EAA6D,oBAA7D;AAEA,QAAM;AAACC,IAAAA,MAAM,EAAEC;AAAT,MAAsB,4CAAaL,QAAb,CAA5B;AAEA,QAAMM,OAAO,GAAG,IAAIC,YAAJ,CAAiBF,SAAS,CAACG,MAA3B,CAAhB;AAEA,QAAMC,OAAO,GAAG,IAAIC,aAAJ,EAAhB;AACA,QAAMC,OAAO,GAAG,IAAID,aAAJ,EAAhB;AACA,QAAME,OAAO,GAAG,IAAIF,aAAJ,EAAhB;AAEA,QAAMG,QAAQ,GAAG,IAAIH,aAAJ,EAAjB;AACA,QAAMI,QAAQ,GAAG,IAAIJ,aAAJ,EAAjB;;AAEA,OAAK,MAAMK,SAAX,IAAwB,8CAAsBf,QAAtB,CAAxB,EAAyD;AACvDS,IAAAA,OAAO,CAACO,SAAR,CAAkBX,SAAlB,EAA6BU,SAAS,CAACE,EAAV,GAAe,CAA5C;AACAN,IAAAA,OAAO,CAACK,SAAR,CAAkBX,SAAlB,EAA6BU,SAAS,CAACG,EAAV,GAAe,CAAf,GAAmB,CAAhD;AACAN,IAAAA,OAAO,CAACI,SAAR,CAAkBX,SAAlB,EAA6BU,SAAS,CAACI,EAAV,GAAe,CAAf,GAAmB,CAAhD;AAEAN,IAAAA,QAAQ,CAACO,UAAT,CAAoBR,OAApB,EAA6BD,OAA7B;AACAG,IAAAA,QAAQ,CAACM,UAAT,CAAoBX,OAApB,EAA6BE,OAA7B;AACA,UAAMU,MAAM,GAAGR,QAAQ,CAACS,KAAT,CAAeR,QAAf,CAAf;AACAO,IAAAA,MAAM,CAACE,SAAP;AAEA,UAAM;AAACC,MAAAA;AAAD,QAAmBT,SAAzB;AAEAT,IAAAA,OAAO,CAACkB,cAAc,GAAG,CAAjB,GAAqB,CAAtB,CAAP,GAAkCH,MAAM,CAACI,CAAzC;AACAnB,IAAAA,OAAO,CAACkB,cAAc,GAAG,CAAjB,GAAqB,CAAtB,CAAP,GAAkCH,MAAM,CAACK,CAAzC;AACApB,IAAAA,OAAO,CAACkB,cAAc,GAAG,CAAjB,GAAqB,CAAtB,CAAP,GAAkCH,MAAM,CAACM,CAAzC;AAEArB,IAAAA,OAAO,CAACkB,cAAc,GAAG,CAAjB,GAAqB,CAAtB,CAAP,GAAkCH,MAAM,CAACI,CAAzC;AACAnB,IAAAA,OAAO,CAACkB,cAAc,GAAG,CAAjB,GAAqB,CAAtB,CAAP,GAAkCH,MAAM,CAACK,CAAzC;AACApB,IAAAA,OAAO,CAACkB,cAAc,GAAG,CAAjB,GAAqB,CAAtB,CAAP,GAAkCH,MAAM,CAACM,CAAzC;AAEArB,IAAAA,OAAO,CAACkB,cAAc,GAAG,CAAjB,GAAqB,CAAtB,CAAP,GAAkCH,MAAM,CAACI,CAAzC;AACAnB,IAAAA,OAAO,CAACkB,cAAc,GAAG,CAAjB,GAAqB,CAAtB,CAAP,GAAkCH,MAAM,CAACK,CAAzC;AACApB,IAAAA,OAAO,CAACkB,cAAc,GAAG,CAAjB,GAAqB,CAAtB,CAAP,GAAkCH,MAAM,CAACM,CAAzC;AACD;;AAED,SAAOrB,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"}
|
|
@@ -5,23 +5,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.convertBuffersToNonIndexed = convertBuffersToNonIndexed;
|
|
7
7
|
|
|
8
|
-
function
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
var attribute = attributes[name];
|
|
21
|
-
var array = attribute.array;
|
|
22
|
-
var itemSize = attribute.itemSize;
|
|
23
|
-
var array2 = new array.constructor(indices.length * itemSize);
|
|
24
|
-
var index = 0,
|
|
8
|
+
function convertBuffersToNonIndexed({
|
|
9
|
+
indices,
|
|
10
|
+
attributes
|
|
11
|
+
}) {
|
|
12
|
+
const geometry2 = new BufferGeometry();
|
|
13
|
+
|
|
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,
|
|
25
20
|
index2 = 0;
|
|
26
21
|
|
|
27
22
|
for (var i = 0, l = indices.length; i < l; i++) {
|
|
@@ -35,18 +30,8 @@ function convertBuffersToNonIndexed(_ref) {
|
|
|
35
30
|
geometry2.addAttribute(name, new BufferAttribute(array2, itemSize));
|
|
36
31
|
}
|
|
37
32
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
try {
|
|
42
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
43
|
-
var group = _step.value;
|
|
44
|
-
geometry2.addGroup(group.start, group.count, group.materialIndex);
|
|
45
|
-
}
|
|
46
|
-
} catch (err) {
|
|
47
|
-
_iterator.e(err);
|
|
48
|
-
} finally {
|
|
49
|
-
_iterator.f();
|
|
33
|
+
for (const group of this.groups) {
|
|
34
|
+
geometry2.addGroup(group.start, group.count, group.materialIndex);
|
|
50
35
|
}
|
|
51
36
|
|
|
52
37
|
return geometry2;
|
|
@@ -1 +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","
|
|
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":";;;;;;;AAQO,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"}
|
|
@@ -13,8 +13,10 @@ var _assert = require("../utils/assert");
|
|
|
13
13
|
|
|
14
14
|
function getPositions(geometry) {
|
|
15
15
|
if ((0, _isGeometry.default)(geometry)) {
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
const {
|
|
17
|
+
attributes
|
|
18
|
+
} = geometry;
|
|
19
|
+
const position = attributes.POSITION || attributes.positions;
|
|
18
20
|
(0, _assert.assert)(position);
|
|
19
21
|
return position;
|
|
20
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/geometry/attributes/get-attribute-from-geometry.ts"],"names":["getPositions","geometry","attributes","position","POSITION","positions","ArrayBuffer","isView","values","size"],"mappings":";;;;;;;;;AAAA;;AACA;;AASO,SAASA,YAAT,CAAsBC,QAAtB,EAAqC;AAE1C,MAAI,yBAAWA,QAAX,CAAJ,EAA0B;AACxB,
|
|
1
|
+
{"version":3,"sources":["../../../../src/geometry/attributes/get-attribute-from-geometry.ts"],"names":["getPositions","geometry","attributes","position","POSITION","positions","ArrayBuffer","isView","values","size"],"mappings":";;;;;;;;;AAAA;;AACA;;AASO,SAASA,YAAT,CAAsBC,QAAtB,EAAqC;AAE1C,MAAI,yBAAWA,QAAX,CAAJ,EAA0B;AACxB,UAAM;AAACC,MAAAA;AAAD,QAAeD,QAArB;AACA,UAAME,QAAQ,GAAGD,UAAU,CAACE,QAAX,IAAuBF,UAAU,CAACG,SAAnD;AACA,wBAAOF,QAAP;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;AACZ,wBAAOA,QAAQ,CAACO,MAAhB;AACA,WAAOP,QAAP;AACD;;AAED,SAAO,oBAAO,KAAP,CAAP;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"}
|
|
@@ -5,12 +5,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.normalize = normalize;
|
|
7
7
|
|
|
8
|
-
function normalize() {
|
|
9
|
-
var normals = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
10
|
-
var vector = arguments.length > 1 ? arguments[1] : undefined;
|
|
8
|
+
function normalize(normals = {}, vector) {
|
|
11
9
|
normals = this.attributes.normal;
|
|
12
10
|
|
|
13
|
-
for (
|
|
11
|
+
for (let i = 0, il = normals.count; i < il; i++) {
|
|
14
12
|
vector.x = normals.getX(i);
|
|
15
13
|
vector.y = normals.getY(i);
|
|
16
14
|
vector.z = normals.getZ(i);
|
|
@@ -1 +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":";;;;;;;AAQO,SAASA,SAAT,
|
|
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":";;;;;;;AAQO,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"}
|
|
@@ -6,11 +6,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.decodeRGB565 = decodeRGB565;
|
|
7
7
|
exports.encodeRGB565 = encodeRGB565;
|
|
8
8
|
|
|
9
|
-
function decodeRGB565(rgb565) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var b5 = rgb565 & 31;
|
|
9
|
+
function decodeRGB565(rgb565, target = [0, 0, 0]) {
|
|
10
|
+
const r5 = rgb565 >> 11 & 31;
|
|
11
|
+
const g6 = rgb565 >> 5 & 63;
|
|
12
|
+
const b5 = rgb565 & 31;
|
|
14
13
|
target[0] = r5 << 3;
|
|
15
14
|
target[1] = g6 << 2;
|
|
16
15
|
target[2] = b5 << 3;
|
|
@@ -18,9 +17,9 @@ function decodeRGB565(rgb565) {
|
|
|
18
17
|
}
|
|
19
18
|
|
|
20
19
|
function encodeRGB565(rgb) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
const r5 = Math.floor(rgb[0] / 8) + 4;
|
|
21
|
+
const g6 = Math.floor(rgb[1] / 4) + 2;
|
|
22
|
+
const b5 = Math.floor(rgb[2] / 8) + 4;
|
|
24
23
|
return r5 + (g6 << 5) + (b5 << 11);
|
|
25
24
|
}
|
|
26
25
|
//# sourceMappingURL=rgb565.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/geometry/colors/rgb565.ts"],"names":["decodeRGB565","rgb565","target","r5","g6","b5","encodeRGB565","rgb","Math","floor"],"mappings":";;;;;;;;AAMO,SAASA,YAAT,CAAsBC,MAAtB,
|
|
1
|
+
{"version":3,"sources":["../../../../src/geometry/colors/rgb565.ts"],"names":["decodeRGB565","rgb565","target","r5","g6","b5","encodeRGB565","rgb","Math","floor"],"mappings":";;;;;;;;AAMO,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;;AAOM,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"}
|
|
@@ -22,26 +22,24 @@ var _core = require("@math.gl/core");
|
|
|
22
22
|
|
|
23
23
|
var _assert = require("../utils/assert");
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
const RIGHT_SHIFT = 1.0 / 256.0;
|
|
26
|
+
const LEFT_SHIFT = 256.0;
|
|
27
|
+
const scratchVector2 = new _core.Vector2();
|
|
28
|
+
const scratchVector3 = new _core.Vector3();
|
|
29
|
+
const scratchEncodeVector2 = new _core.Vector2();
|
|
30
|
+
const octEncodeScratch = new _core.Vector2();
|
|
31
|
+
const uint8ForceArray = new Uint8Array(1);
|
|
32
32
|
|
|
33
33
|
function forceUint8(value) {
|
|
34
34
|
uint8ForceArray[0] = value;
|
|
35
35
|
return uint8ForceArray[0];
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
function fromSNorm(value) {
|
|
39
|
-
var rangeMaximum = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 255;
|
|
38
|
+
function fromSNorm(value, rangeMaximum = 255) {
|
|
40
39
|
return (0, _core.clamp)(value, 0.0, rangeMaximum) / rangeMaximum * 2.0 - 1.0;
|
|
41
40
|
}
|
|
42
41
|
|
|
43
|
-
function toSNorm(value) {
|
|
44
|
-
var rangeMaximum = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 255;
|
|
42
|
+
function toSNorm(value, rangeMaximum = 255) {
|
|
45
43
|
return Math.round(((0, _core.clamp)(value, -1.0, 1.0) * 0.5 + 0.5) * rangeMaximum);
|
|
46
44
|
}
|
|
47
45
|
|
|
@@ -52,14 +50,14 @@ function signNotZero(value) {
|
|
|
52
50
|
function octEncodeInRange(vector, rangeMax, result) {
|
|
53
51
|
(0, _assert.assert)(vector);
|
|
54
52
|
(0, _assert.assert)(result);
|
|
55
|
-
|
|
53
|
+
const vector3 = scratchVector3.from(vector);
|
|
56
54
|
(0, _assert.assert)(Math.abs(vector3.magnitudeSquared() - 1.0) <= _core._MathUtils.EPSILON6);
|
|
57
55
|
result.x = vector.x / (Math.abs(vector.x) + Math.abs(vector.y) + Math.abs(vector.z));
|
|
58
56
|
result.y = vector.y / (Math.abs(vector.x) + Math.abs(vector.y) + Math.abs(vector.z));
|
|
59
57
|
|
|
60
58
|
if (vector.z < 0) {
|
|
61
|
-
|
|
62
|
-
|
|
59
|
+
const x = result.x;
|
|
60
|
+
const y = result.y;
|
|
63
61
|
result.x = (1.0 - Math.abs(y)) * signNotZero(x);
|
|
64
62
|
result.y = (1.0 - Math.abs(x)) * signNotZero(y);
|
|
65
63
|
}
|
|
@@ -94,7 +92,7 @@ function octDecodeInRange(x, y, rangeMax, result) {
|
|
|
94
92
|
result.z = 1.0 - (Math.abs(result.x) + Math.abs(result.y));
|
|
95
93
|
|
|
96
94
|
if (result.z < 0.0) {
|
|
97
|
-
|
|
95
|
+
const oldVX = result.x;
|
|
98
96
|
result.x = (1.0 - Math.abs(result.y)) * signNotZero(oldVX);
|
|
99
97
|
result.y = (1.0 - Math.abs(oldVX)) * signNotZero(result.y);
|
|
100
98
|
}
|
|
@@ -109,22 +107,22 @@ function octDecode(x, y, result) {
|
|
|
109
107
|
function octDecodeFromVector4(encoded, result) {
|
|
110
108
|
(0, _assert.assert)(encoded);
|
|
111
109
|
(0, _assert.assert)(result);
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
110
|
+
const x = encoded.x;
|
|
111
|
+
const y = encoded.y;
|
|
112
|
+
const z = encoded.z;
|
|
113
|
+
const w = encoded.w;
|
|
116
114
|
|
|
117
115
|
if (x < 0 || x > 255 || y < 0 || y > 255 || z < 0 || z > 255 || w < 0 || w > 255) {
|
|
118
116
|
throw new Error('x, y, z, and w must be unsigned normalized integers between 0 and 255');
|
|
119
117
|
}
|
|
120
118
|
|
|
121
|
-
|
|
122
|
-
|
|
119
|
+
const xOct16 = x * LEFT_SHIFT + y;
|
|
120
|
+
const yOct16 = z * LEFT_SHIFT + w;
|
|
123
121
|
return octDecodeInRange(xOct16, yOct16, 65535, result);
|
|
124
122
|
}
|
|
125
123
|
|
|
126
124
|
function octPackFloat(encoded) {
|
|
127
|
-
|
|
125
|
+
const vector2 = scratchVector2.from(encoded);
|
|
128
126
|
return 256.0 * vector2.x + vector2.y;
|
|
129
127
|
}
|
|
130
128
|
|
|
@@ -135,9 +133,9 @@ function octEncodeFloat(vector) {
|
|
|
135
133
|
|
|
136
134
|
function octDecodeFloat(value, result) {
|
|
137
135
|
(0, _assert.assert)(Number.isFinite(value));
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
136
|
+
const temp = value / 256.0;
|
|
137
|
+
const x = Math.floor(temp);
|
|
138
|
+
const y = (temp - x) * 256.0;
|
|
141
139
|
return octDecode(x, y, result);
|
|
142
140
|
}
|
|
143
141
|
|
|
@@ -146,35 +144,35 @@ function octPack(v1, v2, v3, result) {
|
|
|
146
144
|
(0, _assert.assert)(v2);
|
|
147
145
|
(0, _assert.assert)(v3);
|
|
148
146
|
(0, _assert.assert)(result);
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
147
|
+
const encoded1 = octEncodeFloat(v1);
|
|
148
|
+
const encoded2 = octEncodeFloat(v2);
|
|
149
|
+
const encoded3 = octEncode(v3, scratchEncodeVector2);
|
|
152
150
|
result.x = 65536.0 * encoded3.x + encoded1;
|
|
153
151
|
result.y = 65536.0 * encoded3.y + encoded2;
|
|
154
152
|
return result;
|
|
155
153
|
}
|
|
156
154
|
|
|
157
155
|
function octUnpack(packed, v1, v2, v3) {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
156
|
+
let temp = packed.x / 65536.0;
|
|
157
|
+
const x = Math.floor(temp);
|
|
158
|
+
const encodedFloat1 = (temp - x) * 65536.0;
|
|
161
159
|
temp = packed.y / 65536.0;
|
|
162
|
-
|
|
163
|
-
|
|
160
|
+
const y = Math.floor(temp);
|
|
161
|
+
const encodedFloat2 = (temp - y) * 65536.0;
|
|
164
162
|
octDecodeFloat(encodedFloat1, v1);
|
|
165
163
|
octDecodeFloat(encodedFloat2, v2);
|
|
166
164
|
octDecode(x, y, v3);
|
|
167
165
|
}
|
|
168
166
|
|
|
169
167
|
function compressTextureCoordinates(textureCoordinates) {
|
|
170
|
-
|
|
171
|
-
|
|
168
|
+
const x = textureCoordinates.x * 4095.0 | 0;
|
|
169
|
+
const y = textureCoordinates.y * 4095.0 | 0;
|
|
172
170
|
return 4096.0 * x + y;
|
|
173
171
|
}
|
|
174
172
|
|
|
175
173
|
function decompressTextureCoordinates(compressed, result) {
|
|
176
|
-
|
|
177
|
-
|
|
174
|
+
const temp = compressed / 4096.0;
|
|
175
|
+
const xZeroTo4095 = Math.floor(temp);
|
|
178
176
|
result.x = xZeroTo4095 / 4095.0;
|
|
179
177
|
result.y = (compressed - xZeroTo4095 * 4096) / 4095;
|
|
180
178
|
return result;
|
|
@@ -193,11 +191,11 @@ function zigZagDeltaDecode(uBuffer, vBuffer, heightBuffer) {
|
|
|
193
191
|
return value >> 1 ^ -(value & 1);
|
|
194
192
|
}
|
|
195
193
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
194
|
+
let u = 0;
|
|
195
|
+
let v = 0;
|
|
196
|
+
let height = 0;
|
|
199
197
|
|
|
200
|
-
for (
|
|
198
|
+
for (let i = 0; i < uBuffer.length; ++i) {
|
|
201
199
|
u += zigZagDecode(uBuffer[i]);
|
|
202
200
|
v += zigZagDecode(vBuffer[i]);
|
|
203
201
|
uBuffer[i] = u;
|