@loaders.gl/math 3.4.14 → 3.4.15
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 +16 -28
- package/dist/es5/geometry/attributes/compute-bounding-box.js.map +1 -1
- package/dist/es5/geometry/attributes/compute-vertex-normals.js +29 -38
- package/dist/es5/geometry/attributes/compute-vertex-normals.js.map +1 -1
- package/dist/es5/geometry/attributes/convert-to-non-indexed.js +13 -23
- 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 +3 -3
- package/dist/es5/geometry/colors/rgb565.js +7 -7
- package/dist/es5/geometry/colors/rgb565.js.map +1 -1
- package/dist/es5/geometry/compression/attribute-compression.js +39 -39
- package/dist/es5/geometry/compression/attribute-compression.js.map +1 -1
- package/dist/es5/geometry/constants.js +7 -8
- package/dist/es5/geometry/constants.js.map +1 -1
- package/dist/es5/geometry/gl/gl-type.js +56 -69
- package/dist/es5/geometry/gl/gl-type.js.map +1 -1
- package/dist/es5/geometry/is-geometry.js +1 -3
- package/dist/es5/geometry/is-geometry.js.map +1 -1
- package/dist/es5/geometry/iterators/attribute-iterator.js +8 -29
- package/dist/es5/geometry/iterators/attribute-iterator.js.map +1 -1
- package/dist/es5/geometry/iterators/primitive-iterator.js +46 -66
- package/dist/es5/geometry/iterators/primitive-iterator.js.map +1 -1
- package/dist/es5/geometry/typed-arrays/typed-array-utils.js +8 -8
- package/dist/es5/geometry/typed-arrays/typed-array-utils.js.map +1 -1
- package/dist/es5/index.js +24 -24
- package/package.json +4 -4
|
@@ -6,36 +6,24 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.computeBoundingBox = computeBoundingBox;
|
|
7
7
|
var _attributeIterator = require("../iterators/attribute-iterator");
|
|
8
8
|
var _assert = require("../utils/assert");
|
|
9
|
-
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; } } }; }
|
|
10
|
-
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); }
|
|
11
|
-
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; }
|
|
12
9
|
function computeBoundingBox() {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if (z < min[2]) min[2] = z;
|
|
27
|
-
if (x > max[0]) max[0] = x;
|
|
28
|
-
if (y > max[1]) max[1] = y;
|
|
29
|
-
if (z > max[2]) max[2] = z;
|
|
30
|
-
}
|
|
31
|
-
} catch (err) {
|
|
32
|
-
_iterator.e(err);
|
|
33
|
-
} finally {
|
|
34
|
-
_iterator.f();
|
|
10
|
+
let positions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
11
|
+
const min = [Number(Infinity), Number(Infinity), Number(Infinity)];
|
|
12
|
+
const max = [-Infinity, -Infinity, -Infinity];
|
|
13
|
+
for (const position of (0, _attributeIterator.makeAttributeIterator)(positions)) {
|
|
14
|
+
const x = position[0];
|
|
15
|
+
const y = position[1];
|
|
16
|
+
const z = position[2];
|
|
17
|
+
if (x < min[0]) min[0] = x;
|
|
18
|
+
if (y < min[1]) min[1] = y;
|
|
19
|
+
if (z < min[2]) min[2] = z;
|
|
20
|
+
if (x > max[0]) max[0] = x;
|
|
21
|
+
if (y > max[1]) max[1] = y;
|
|
22
|
+
if (z > max[2]) max[2] = z;
|
|
35
23
|
}
|
|
36
|
-
|
|
37
|
-
min
|
|
38
|
-
max
|
|
24
|
+
const boundingBox = {
|
|
25
|
+
min,
|
|
26
|
+
max
|
|
39
27
|
};
|
|
40
28
|
validateBoundingBox(boundingBox);
|
|
41
29
|
return boundingBox;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compute-bounding-box.js","names":["_attributeIterator","require","_assert","
|
|
1
|
+
{"version":3,"file":"compute-bounding-box.js","names":["_attributeIterator","require","_assert","computeBoundingBox","positions","arguments","length","undefined","min","Number","Infinity","max","position","makeAttributeIterator","x","y","z","boundingBox","validateBoundingBox","assert","isFinite"],"sources":["../../../../src/geometry/attributes/compute-bounding-box.ts"],"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"],"mappings":";;;;;;AAAA,IAAAA,kBAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAcO,SAASE,kBAAkBA,CAAA,EAAsB;EAAA,IAArBC,SAAc,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,EAAE;EACpD,MAAMG,GAAG,GAAG,CAACC,MAAM,CAACC,QAAQ,CAAC,EAAED,MAAM,CAACC,QAAQ,CAAC,EAAED,MAAM,CAACC,QAAQ,CAAC,CAAC;EAClE,MAAMC,GAAG,GAAG,CAAC,CAACD,QAAQ,EAAE,CAACA,QAAQ,EAAE,CAACA,QAAQ,CAAC;EAE7C,KAAK,MAAME,QAAQ,IAAI,IAAAC,wCAAqB,EAACT,SAAS,CAAC,EAAE;IACvD,MAAMU,CAAC,GAAGF,QAAQ,CAAC,CAAC,CAAC;IACrB,MAAMG,CAAC,GAAGH,QAAQ,CAAC,CAAC,CAAC;IACrB,MAAMI,CAAC,GAAGJ,QAAQ,CAAC,CAAC,CAAC;IAErB,IAAIE,CAAC,GAAGN,GAAG,CAAC,CAAC,CAAC,EAAEA,GAAG,CAAC,CAAC,CAAC,GAAGM,CAAC;IAC1B,IAAIC,CAAC,GAAGP,GAAG,CAAC,CAAC,CAAC,EAAEA,GAAG,CAAC,CAAC,CAAC,GAAGO,CAAC;IAC1B,IAAIC,CAAC,GAAGR,GAAG,CAAC,CAAC,CAAC,EAAEA,GAAG,CAAC,CAAC,CAAC,GAAGQ,CAAC;IAE1B,IAAIF,CAAC,GAAGH,GAAG,CAAC,CAAC,CAAC,EAAEA,GAAG,CAAC,CAAC,CAAC,GAAGG,CAAC;IAC1B,IAAIC,CAAC,GAAGJ,GAAG,CAAC,CAAC,CAAC,EAAEA,GAAG,CAAC,CAAC,CAAC,GAAGI,CAAC;IAC1B,IAAIC,CAAC,GAAGL,GAAG,CAAC,CAAC,CAAC,EAAEA,GAAG,CAAC,CAAC,CAAC,GAAGK,CAAC;EAC5B;EAEA,MAAMC,WAAW,GAAG;IAACT,GAAG;IAAEG;EAAG,CAAC;EAC9BO,mBAAmB,CAACD,WAAW,CAAC;EAChC,OAAOA,WAAW;AACpB;AAEA,SAASC,mBAAmBA,CAACD,WAAwB,EAAE;EACrD,IAAAE,cAAM,EACJV,MAAM,CAACW,QAAQ,CAACH,WAAW,CAACT,GAAG,CAAC,CAAC,CAAC,CAAC,IACjCC,MAAM,CAACW,QAAQ,CAACH,WAAW,CAACT,GAAG,CAAC,CAAC,CAAC,CAAC,IACnCC,MAAM,CAACW,QAAQ,CAACH,WAAW,CAACT,GAAG,CAAC,CAAC,CAAC,CAAC,IACnCC,MAAM,CAACW,QAAQ,CAACH,WAAW,CAACN,GAAG,CAAC,CAAC,CAAC,CAAC,IACnCF,MAAM,CAACW,QAAQ,CAACH,WAAW,CAACN,GAAG,CAAC,CAAC,CAAC,CAAC,IACnCF,MAAM,CAACW,QAAQ,CAACH,WAAW,CAACN,GAAG,CAAC,CAAC,CAAC,CACtC,CAAC;AACH"}
|
|
@@ -10,46 +10,37 @@ var _assert = require("../utils/assert");
|
|
|
10
10
|
var _primitiveIterator = require("../iterators/primitive-iterator");
|
|
11
11
|
var _modes = require("../primitives/modes");
|
|
12
12
|
var _getAttributeFromGeometry = require("./get-attribute-from-geometry");
|
|
13
|
-
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; } } }; }
|
|
14
|
-
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); }
|
|
15
|
-
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; }
|
|
16
13
|
function computeVertexNormals(geometry) {
|
|
17
14
|
(0, _assert.assert)((0, _modes.getPrimitiveModeType)(geometry.mode) === _constants.GL.TRIANGLES, 'TRIANGLES required');
|
|
18
|
-
|
|
19
|
-
positions
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
normals[primitiveIndex * 9 + 8] = normal.z;
|
|
48
|
-
}
|
|
49
|
-
} catch (err) {
|
|
50
|
-
_iterator.e(err);
|
|
51
|
-
} finally {
|
|
52
|
-
_iterator.f();
|
|
15
|
+
const {
|
|
16
|
+
values: positions
|
|
17
|
+
} = (0, _getAttributeFromGeometry.getPositions)(geometry);
|
|
18
|
+
const normals = new Float32Array(positions.length);
|
|
19
|
+
const vectorA = new _core.Vector3();
|
|
20
|
+
const vectorB = new _core.Vector3();
|
|
21
|
+
const vectorC = new _core.Vector3();
|
|
22
|
+
const vectorCB = new _core.Vector3();
|
|
23
|
+
const vectorAB = new _core.Vector3();
|
|
24
|
+
for (const primitive of (0, _primitiveIterator.makePrimitiveIterator)(geometry)) {
|
|
25
|
+
vectorA.fromArray(positions, primitive.i1 * 3);
|
|
26
|
+
vectorB.fromArray(positions, primitive.i2 * 3 + 3);
|
|
27
|
+
vectorC.fromArray(positions, primitive.i3 * 3 + 6);
|
|
28
|
+
vectorCB.subVectors(vectorC, vectorB);
|
|
29
|
+
vectorAB.subVectors(vectorA, vectorB);
|
|
30
|
+
const normal = vectorCB.cross(vectorAB);
|
|
31
|
+
normal.normalize();
|
|
32
|
+
const {
|
|
33
|
+
primitiveIndex
|
|
34
|
+
} = primitive;
|
|
35
|
+
normals[primitiveIndex * 9 + 0] = normal.x;
|
|
36
|
+
normals[primitiveIndex * 9 + 1] = normal.y;
|
|
37
|
+
normals[primitiveIndex * 9 + 2] = normal.z;
|
|
38
|
+
normals[primitiveIndex * 9 + 3] = normal.x;
|
|
39
|
+
normals[primitiveIndex * 9 + 4] = normal.y;
|
|
40
|
+
normals[primitiveIndex * 9 + 5] = normal.z;
|
|
41
|
+
normals[primitiveIndex * 9 + 6] = normal.x;
|
|
42
|
+
normals[primitiveIndex * 9 + 7] = normal.y;
|
|
43
|
+
normals[primitiveIndex * 9 + 8] = normal.z;
|
|
53
44
|
}
|
|
54
45
|
return normals;
|
|
55
46
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compute-vertex-normals.js","names":["_core","require","_constants","_assert","_primitiveIterator","_modes","_getAttributeFromGeometry","
|
|
1
|
+
{"version":3,"file":"compute-vertex-normals.js","names":["_core","require","_constants","_assert","_primitiveIterator","_modes","_getAttributeFromGeometry","computeVertexNormals","geometry","assert","getPrimitiveModeType","mode","GL","TRIANGLES","values","positions","getPositions","normals","Float32Array","length","vectorA","Vector3","vectorB","vectorC","vectorCB","vectorAB","primitive","makePrimitiveIterator","fromArray","i1","i2","i3","subVectors","normal","cross","normalize","primitiveIndex","x","y","z"],"sources":["../../../../src/geometry/attributes/compute-vertex-normals.ts"],"sourcesContent":["import type {TypedArray} from '@math.gl/core';\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"],"mappings":";;;;;;AACA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,kBAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,yBAAA,GAAAL,OAAA;AAaO,SAASM,oBAAoBA,CAACC,QAAkB,EAAgB;EAErE,IAAAC,cAAM,EAAC,IAAAC,2BAAoB,EAACF,QAAQ,CAACG,IAAI,CAAC,KAAKC,aAAE,CAACC,SAAS,EAAE,oBAAoB,CAAC;EAElF,MAAM;IAACC,MAAM,EAAEC;EAAS,CAAC,GAAG,IAAAC,sCAAY,EAACR,QAAQ,CAAC;EAElD,MAAMS,OAAO,GAAG,IAAIC,YAAY,CAACH,SAAS,CAACI,MAAM,CAAC;EAElD,MAAMC,OAAO,GAAG,IAAIC,aAAO,CAAC,CAAC;EAC7B,MAAMC,OAAO,GAAG,IAAID,aAAO,CAAC,CAAC;EAC7B,MAAME,OAAO,GAAG,IAAIF,aAAO,CAAC,CAAC;EAE7B,MAAMG,QAAQ,GAAG,IAAIH,aAAO,CAAC,CAAC;EAC9B,MAAMI,QAAQ,GAAG,IAAIJ,aAAO,CAAC,CAAC;EAE9B,KAAK,MAAMK,SAAS,IAAI,IAAAC,wCAAqB,EAACnB,QAAQ,CAAC,EAAE;IACvDY,OAAO,CAACQ,SAAS,CAACb,SAAS,EAAEW,SAAS,CAACG,EAAE,GAAG,CAAC,CAAC;IAC9CP,OAAO,CAACM,SAAS,CAACb,SAAS,EAAEW,SAAS,CAACI,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;IAClDP,OAAO,CAACK,SAAS,CAACb,SAAS,EAAEW,SAAS,CAACK,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;IAElDP,QAAQ,CAACQ,UAAU,CAACT,OAAO,EAAED,OAAO,CAAC;IACrCG,QAAQ,CAACO,UAAU,CAACZ,OAAO,EAAEE,OAAO,CAAC;IACrC,MAAMW,MAAM,GAAGT,QAAQ,CAACU,KAAK,CAACT,QAAQ,CAAC;IACvCQ,MAAM,CAACE,SAAS,CAAC,CAAC;IAElB,MAAM;MAACC;IAAc,CAAC,GAAGV,SAAS;IAElCT,OAAO,CAACmB,cAAc,GAAG,CAAC,GAAG,CAAC,CAAC,GAAGH,MAAM,CAACI,CAAC;IAC1CpB,OAAO,CAACmB,cAAc,GAAG,CAAC,GAAG,CAAC,CAAC,GAAGH,MAAM,CAACK,CAAC;IAC1CrB,OAAO,CAACmB,cAAc,GAAG,CAAC,GAAG,CAAC,CAAC,GAAGH,MAAM,CAACM,CAAC;IAE1CtB,OAAO,CAACmB,cAAc,GAAG,CAAC,GAAG,CAAC,CAAC,GAAGH,MAAM,CAACI,CAAC;IAC1CpB,OAAO,CAACmB,cAAc,GAAG,CAAC,GAAG,CAAC,CAAC,GAAGH,MAAM,CAACK,CAAC;IAC1CrB,OAAO,CAACmB,cAAc,GAAG,CAAC,GAAG,CAAC,CAAC,GAAGH,MAAM,CAACM,CAAC;IAE1CtB,OAAO,CAACmB,cAAc,GAAG,CAAC,GAAG,CAAC,CAAC,GAAGH,MAAM,CAACI,CAAC;IAC1CpB,OAAO,CAACmB,cAAc,GAAG,CAAC,GAAG,CAAC,CAAC,GAAGH,MAAM,CAACK,CAAC;IAC1CrB,OAAO,CAACmB,cAAc,GAAG,CAAC,GAAG,CAAC,CAAC,GAAGH,MAAM,CAACM,CAAC;EAC5C;EAEA,OAAOtB,OAAO;AAChB"}
|
|
@@ -4,19 +4,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.convertBuffersToNonIndexed = convertBuffersToNonIndexed;
|
|
7
|
-
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; } } }; }
|
|
8
|
-
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); }
|
|
9
|
-
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; }
|
|
10
7
|
function convertBuffersToNonIndexed(_ref) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
8
|
+
let {
|
|
9
|
+
indices,
|
|
10
|
+
attributes
|
|
11
|
+
} = _ref;
|
|
12
|
+
const geometry2 = new BufferGeometry();
|
|
13
|
+
for (const name in attributes) {
|
|
14
|
+
const attribute = attributes[name];
|
|
15
|
+
const array = attribute.array;
|
|
16
|
+
const itemSize = attribute.itemSize;
|
|
17
|
+
const array2 = new array.constructor(indices.length * itemSize);
|
|
18
|
+
let index = 0,
|
|
20
19
|
index2 = 0;
|
|
21
20
|
for (var i = 0, l = indices.length; i < l; i++) {
|
|
22
21
|
index = indices[i] * itemSize;
|
|
@@ -26,17 +25,8 @@ function convertBuffersToNonIndexed(_ref) {
|
|
|
26
25
|
}
|
|
27
26
|
geometry2.addAttribute(name, new BufferAttribute(array2, itemSize));
|
|
28
27
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
try {
|
|
32
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
33
|
-
var group = _step.value;
|
|
34
|
-
geometry2.addGroup(group.start, group.count, group.materialIndex);
|
|
35
|
-
}
|
|
36
|
-
} catch (err) {
|
|
37
|
-
_iterator.e(err);
|
|
38
|
-
} finally {
|
|
39
|
-
_iterator.f();
|
|
28
|
+
for (const group of this.groups) {
|
|
29
|
+
geometry2.addGroup(group.start, group.count, group.materialIndex);
|
|
40
30
|
}
|
|
41
31
|
return geometry2;
|
|
42
32
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convert-to-non-indexed.js","names":["convertBuffersToNonIndexed","_ref","indices","attributes","geometry2","BufferGeometry","name","attribute","array","itemSize","array2","constructor","length","index","index2","i","l","j","addAttribute","BufferAttribute","
|
|
1
|
+
{"version":3,"file":"convert-to-non-indexed.js","names":["convertBuffersToNonIndexed","_ref","indices","attributes","geometry2","BufferGeometry","name","attribute","array","itemSize","array2","constructor","length","index","index2","i","l","j","addAttribute","BufferAttribute","group","groups","addGroup","start","count","materialIndex"],"sources":["../../../../src/geometry/attributes/convert-to-non-indexed.ts"],"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"],"mappings":";;;;;;AAQO,SAASA,0BAA0BA,CAAAC,IAAA,EAA6B;EAAA,IAA5B;IAACC,OAAO;IAAEC;EAAU,CAAC,GAAAF,IAAA;EAC9D,MAAMG,SAAS,GAAG,IAAIC,cAAc,CAAC,CAAC;EAEtC,KAAK,MAAMC,IAAI,IAAIH,UAAU,EAAE;IAC7B,MAAMI,SAAS,GAAGJ,UAAU,CAACG,IAAI,CAAC;IAElC,MAAME,KAAK,GAAGD,SAAS,CAACC,KAAK;IAC7B,MAAMC,QAAQ,GAAGF,SAAS,CAACE,QAAQ;IAEnC,MAAMC,MAAM,GAAG,IAAIF,KAAK,CAACG,WAAW,CAACT,OAAO,CAACU,MAAM,GAAGH,QAAQ,CAAC;IAC/D,IAAII,KAAK,GAAG,CAAC;MACXC,MAAM,GAAG,CAAC;IAEZ,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEC,CAAC,GAAGd,OAAO,CAACU,MAAM,EAAEG,CAAC,GAAGC,CAAC,EAAED,CAAC,EAAE,EAAE;MAC9CF,KAAK,GAAGX,OAAO,CAACa,CAAC,CAAC,GAAGN,QAAQ;MAC7B,KAAK,IAAIQ,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGR,QAAQ,EAAEQ,CAAC,EAAE,EAAE;QACjCP,MAAM,CAACI,MAAM,EAAE,CAAC,GAAGN,KAAK,CAACK,KAAK,EAAE,CAAC;MACnC;IACF;IACAT,SAAS,CAACc,YAAY,CAACZ,IAAI,EAAE,IAAIa,eAAe,CAACT,MAAM,EAAED,QAAQ,CAAC,CAAC;EACrE;EAEA,KAAK,MAAMW,KAAK,IAAI,IAAI,CAACC,MAAM,EAAE;IAC/BjB,SAAS,CAACkB,QAAQ,CAACF,KAAK,CAACG,KAAK,EAAEH,KAAK,CAACI,KAAK,EAAEJ,KAAK,CAACK,aAAa,CAAC;EACnE;EAEA,OAAOrB,SAAS;AAClB"}
|
|
@@ -9,8 +9,10 @@ var _isGeometry = _interopRequireDefault(require("../is-geometry"));
|
|
|
9
9
|
var _assert = require("../utils/assert");
|
|
10
10
|
function getPositions(geometry) {
|
|
11
11
|
if ((0, _isGeometry.default)(geometry)) {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
const {
|
|
13
|
+
attributes
|
|
14
|
+
} = geometry;
|
|
15
|
+
const position = attributes.POSITION || attributes.positions;
|
|
14
16
|
(0, _assert.assert)(position);
|
|
15
17
|
return position;
|
|
16
18
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-attribute-from-geometry.js","names":["_isGeometry","_interopRequireDefault","require","_assert","getPositions","geometry","isGeometry","attributes","position","POSITION","positions","assert","ArrayBuffer","isView","values","size"],"sources":["../../../../src/geometry/attributes/get-attribute-from-geometry.ts"],"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"],"mappings":";;;;;;;AAAA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AASO,SAASE,YAAYA,CAACC,QAAa,EAAE;EAE1C,IAAI,IAAAC,mBAAU,EAACD,QAAQ,CAAC,EAAE;IACxB,
|
|
1
|
+
{"version":3,"file":"get-attribute-from-geometry.js","names":["_isGeometry","_interopRequireDefault","require","_assert","getPositions","geometry","isGeometry","attributes","position","POSITION","positions","assert","ArrayBuffer","isView","values","size"],"sources":["../../../../src/geometry/attributes/get-attribute-from-geometry.ts"],"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"],"mappings":";;;;;;;AAAA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AASO,SAASE,YAAYA,CAACC,QAAa,EAAE;EAE1C,IAAI,IAAAC,mBAAU,EAACD,QAAQ,CAAC,EAAE;IACxB,MAAM;MAACE;IAAU,CAAC,GAAGF,QAAQ;IAC7B,MAAMG,QAAQ,GAAGD,UAAU,CAACE,QAAQ,IAAIF,UAAU,CAACG,SAAS;IAC5D,IAAAC,cAAM,EAACH,QAAQ,CAAC;IAChB,OAAOA,QAAQ;EACjB;EAGA,IAAII,WAAW,CAACC,MAAM,CAACR,QAAQ,CAAC,EAAE;IAChC,OAAO;MAACS,MAAM,EAAET,QAAQ;MAAEU,IAAI,EAAE;IAAC,CAAC;EACpC;EAGA,IAAIV,QAAQ,EAAE;IACZ,IAAAM,cAAM,EAACN,QAAQ,CAACS,MAAM,CAAC;IACvB,OAAOT,QAAQ;EACjB;EAEA,OAAO,IAAAM,cAAM,EAAC,KAAK,CAAC;AACtB"}
|
|
@@ -5,10 +5,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.normalize = normalize;
|
|
7
7
|
function normalize() {
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
let normals = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
9
|
+
let vector = arguments.length > 1 ? arguments[1] : undefined;
|
|
10
10
|
normals = this.attributes.normal;
|
|
11
|
-
for (
|
|
11
|
+
for (let i = 0, il = normals.count; i < il; i++) {
|
|
12
12
|
vector.x = normals.getX(i);
|
|
13
13
|
vector.y = normals.getY(i);
|
|
14
14
|
vector.z = normals.getZ(i);
|
|
@@ -6,19 +6,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.decodeRGB565 = decodeRGB565;
|
|
7
7
|
exports.encodeRGB565 = encodeRGB565;
|
|
8
8
|
function decodeRGB565(rgb565) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
let target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [0, 0, 0];
|
|
10
|
+
const r5 = rgb565 >> 11 & 31;
|
|
11
|
+
const g6 = rgb565 >> 5 & 63;
|
|
12
|
+
const b5 = rgb565 & 31;
|
|
13
13
|
target[0] = r5 << 3;
|
|
14
14
|
target[1] = g6 << 2;
|
|
15
15
|
target[2] = b5 << 3;
|
|
16
16
|
return target;
|
|
17
17
|
}
|
|
18
18
|
function encodeRGB565(rgb) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
const r5 = Math.floor(rgb[0] / 8) + 4;
|
|
20
|
+
const g6 = Math.floor(rgb[1] / 4) + 2;
|
|
21
|
+
const b5 = Math.floor(rgb[2] / 8) + 4;
|
|
22
22
|
return r5 + (g6 << 5) + (b5 << 11);
|
|
23
23
|
}
|
|
24
24
|
//# sourceMappingURL=rgb565.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rgb565.js","names":["decodeRGB565","rgb565","target","arguments","length","undefined","r5","g6","b5","encodeRGB565","rgb","Math","floor"],"sources":["../../../../src/geometry/colors/rgb565.ts"],"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"],"mappings":";;;;;;;AAMO,SAASA,YAAYA,CAACC,MAAc,EAA0C;EAAA,IAAxCC,MAAgB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;EACvE,
|
|
1
|
+
{"version":3,"file":"rgb565.js","names":["decodeRGB565","rgb565","target","arguments","length","undefined","r5","g6","b5","encodeRGB565","rgb","Math","floor"],"sources":["../../../../src/geometry/colors/rgb565.ts"],"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"],"mappings":";;;;;;;AAMO,SAASA,YAAYA,CAACC,MAAc,EAA0C;EAAA,IAAxCC,MAAgB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;EACvE,MAAMG,EAAE,GAAIL,MAAM,IAAI,EAAE,GAAI,EAAE;EAC9B,MAAMM,EAAE,GAAIN,MAAM,IAAI,CAAC,GAAI,EAAE;EAC7B,MAAMO,EAAE,GAAGP,MAAM,GAAG,EAAE;EAEtBC,MAAM,CAAC,CAAC,CAAC,GAAGI,EAAE,IAAI,CAAC;EACnBJ,MAAM,CAAC,CAAC,CAAC,GAAGK,EAAE,IAAI,CAAC;EACnBL,MAAM,CAAC,CAAC,CAAC,GAAGM,EAAE,IAAI,CAAC;EAEnB,OAAON,MAAM;AACf;AAOO,SAASO,YAAYA,CAACC,GAAa,EAAU;EAClD,MAAMJ,EAAE,GAAGK,IAAI,CAACC,KAAK,CAACF,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC;EACrC,MAAMH,EAAE,GAAGI,IAAI,CAACC,KAAK,CAACF,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC;EACrC,MAAMF,EAAE,GAAGG,IAAI,CAACC,KAAK,CAACF,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC;EACrC,OAAOJ,EAAE,IAAIC,EAAE,IAAI,CAAC,CAAC,IAAIC,EAAE,IAAI,EAAE,CAAC;AACpC"}
|
|
@@ -19,23 +19,23 @@ exports.octUnpack = octUnpack;
|
|
|
19
19
|
exports.zigZagDeltaDecode = zigZagDeltaDecode;
|
|
20
20
|
var _core = require("@math.gl/core");
|
|
21
21
|
var _assert = require("../utils/assert");
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
const RIGHT_SHIFT = 1.0 / 256.0;
|
|
23
|
+
const LEFT_SHIFT = 256.0;
|
|
24
|
+
const scratchVector2 = new _core.Vector2();
|
|
25
|
+
const scratchVector3 = new _core.Vector3();
|
|
26
|
+
const scratchEncodeVector2 = new _core.Vector2();
|
|
27
|
+
const octEncodeScratch = new _core.Vector2();
|
|
28
|
+
const uint8ForceArray = new Uint8Array(1);
|
|
29
29
|
function forceUint8(value) {
|
|
30
30
|
uint8ForceArray[0] = value;
|
|
31
31
|
return uint8ForceArray[0];
|
|
32
32
|
}
|
|
33
33
|
function fromSNorm(value) {
|
|
34
|
-
|
|
34
|
+
let rangeMaximum = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 255;
|
|
35
35
|
return (0, _core.clamp)(value, 0.0, rangeMaximum) / rangeMaximum * 2.0 - 1.0;
|
|
36
36
|
}
|
|
37
37
|
function toSNorm(value) {
|
|
38
|
-
|
|
38
|
+
let rangeMaximum = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 255;
|
|
39
39
|
return Math.round(((0, _core.clamp)(value, -1.0, 1.0) * 0.5 + 0.5) * rangeMaximum);
|
|
40
40
|
}
|
|
41
41
|
function signNotZero(value) {
|
|
@@ -44,13 +44,13 @@ function signNotZero(value) {
|
|
|
44
44
|
function octEncodeInRange(vector, rangeMax, result) {
|
|
45
45
|
(0, _assert.assert)(vector);
|
|
46
46
|
(0, _assert.assert)(result);
|
|
47
|
-
|
|
47
|
+
const vector3 = scratchVector3.from(vector);
|
|
48
48
|
(0, _assert.assert)(Math.abs(vector3.magnitudeSquared() - 1.0) <= _core._MathUtils.EPSILON6);
|
|
49
49
|
result.x = vector.x / (Math.abs(vector.x) + Math.abs(vector.y) + Math.abs(vector.z));
|
|
50
50
|
result.y = vector.y / (Math.abs(vector.x) + Math.abs(vector.y) + Math.abs(vector.z));
|
|
51
51
|
if (vector.z < 0) {
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
const x = result.x;
|
|
53
|
+
const y = result.y;
|
|
54
54
|
result.x = (1.0 - Math.abs(y)) * signNotZero(x);
|
|
55
55
|
result.y = (1.0 - Math.abs(x)) * signNotZero(y);
|
|
56
56
|
}
|
|
@@ -78,7 +78,7 @@ function octDecodeInRange(x, y, rangeMax, result) {
|
|
|
78
78
|
result.y = fromSNorm(y, rangeMax);
|
|
79
79
|
result.z = 1.0 - (Math.abs(result.x) + Math.abs(result.y));
|
|
80
80
|
if (result.z < 0.0) {
|
|
81
|
-
|
|
81
|
+
const oldVX = result.x;
|
|
82
82
|
result.x = (1.0 - Math.abs(result.y)) * signNotZero(oldVX);
|
|
83
83
|
result.y = (1.0 - Math.abs(oldVX)) * signNotZero(result.y);
|
|
84
84
|
}
|
|
@@ -90,19 +90,19 @@ function octDecode(x, y, result) {
|
|
|
90
90
|
function octDecodeFromVector4(encoded, result) {
|
|
91
91
|
(0, _assert.assert)(encoded);
|
|
92
92
|
(0, _assert.assert)(result);
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
93
|
+
const x = encoded.x;
|
|
94
|
+
const y = encoded.y;
|
|
95
|
+
const z = encoded.z;
|
|
96
|
+
const w = encoded.w;
|
|
97
97
|
if (x < 0 || x > 255 || y < 0 || y > 255 || z < 0 || z > 255 || w < 0 || w > 255) {
|
|
98
98
|
throw new Error('x, y, z, and w must be unsigned normalized integers between 0 and 255');
|
|
99
99
|
}
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
const xOct16 = x * LEFT_SHIFT + y;
|
|
101
|
+
const yOct16 = z * LEFT_SHIFT + w;
|
|
102
102
|
return octDecodeInRange(xOct16, yOct16, 65535, result);
|
|
103
103
|
}
|
|
104
104
|
function octPackFloat(encoded) {
|
|
105
|
-
|
|
105
|
+
const vector2 = scratchVector2.from(encoded);
|
|
106
106
|
return 256.0 * vector2.x + vector2.y;
|
|
107
107
|
}
|
|
108
108
|
function octEncodeFloat(vector) {
|
|
@@ -111,9 +111,9 @@ function octEncodeFloat(vector) {
|
|
|
111
111
|
}
|
|
112
112
|
function octDecodeFloat(value, result) {
|
|
113
113
|
(0, _assert.assert)(Number.isFinite(value));
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
114
|
+
const temp = value / 256.0;
|
|
115
|
+
const x = Math.floor(temp);
|
|
116
|
+
const y = (temp - x) * 256.0;
|
|
117
117
|
return octDecode(x, y, result);
|
|
118
118
|
}
|
|
119
119
|
function octPack(v1, v2, v3, result) {
|
|
@@ -121,32 +121,32 @@ function octPack(v1, v2, v3, result) {
|
|
|
121
121
|
(0, _assert.assert)(v2);
|
|
122
122
|
(0, _assert.assert)(v3);
|
|
123
123
|
(0, _assert.assert)(result);
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
124
|
+
const encoded1 = octEncodeFloat(v1);
|
|
125
|
+
const encoded2 = octEncodeFloat(v2);
|
|
126
|
+
const encoded3 = octEncode(v3, scratchEncodeVector2);
|
|
127
127
|
result.x = 65536.0 * encoded3.x + encoded1;
|
|
128
128
|
result.y = 65536.0 * encoded3.y + encoded2;
|
|
129
129
|
return result;
|
|
130
130
|
}
|
|
131
131
|
function octUnpack(packed, v1, v2, v3) {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
132
|
+
let temp = packed.x / 65536.0;
|
|
133
|
+
const x = Math.floor(temp);
|
|
134
|
+
const encodedFloat1 = (temp - x) * 65536.0;
|
|
135
135
|
temp = packed.y / 65536.0;
|
|
136
|
-
|
|
137
|
-
|
|
136
|
+
const y = Math.floor(temp);
|
|
137
|
+
const encodedFloat2 = (temp - y) * 65536.0;
|
|
138
138
|
octDecodeFloat(encodedFloat1, v1);
|
|
139
139
|
octDecodeFloat(encodedFloat2, v2);
|
|
140
140
|
octDecode(x, y, v3);
|
|
141
141
|
}
|
|
142
142
|
function compressTextureCoordinates(textureCoordinates) {
|
|
143
|
-
|
|
144
|
-
|
|
143
|
+
const x = textureCoordinates.x * 4095.0 | 0;
|
|
144
|
+
const y = textureCoordinates.y * 4095.0 | 0;
|
|
145
145
|
return 4096.0 * x + y;
|
|
146
146
|
}
|
|
147
147
|
function decompressTextureCoordinates(compressed, result) {
|
|
148
|
-
|
|
149
|
-
|
|
148
|
+
const temp = compressed / 4096.0;
|
|
149
|
+
const xZeroTo4095 = Math.floor(temp);
|
|
150
150
|
result.x = xZeroTo4095 / 4095.0;
|
|
151
151
|
result.y = (compressed - xZeroTo4095 * 4096) / 4095;
|
|
152
152
|
return result;
|
|
@@ -161,10 +161,10 @@ function zigZagDeltaDecode(uBuffer, vBuffer, heightBuffer) {
|
|
|
161
161
|
function zigZagDecode(value) {
|
|
162
162
|
return value >> 1 ^ -(value & 1);
|
|
163
163
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
for (
|
|
164
|
+
let u = 0;
|
|
165
|
+
let v = 0;
|
|
166
|
+
let height = 0;
|
|
167
|
+
for (let i = 0; i < uBuffer.length; ++i) {
|
|
168
168
|
u += zigZagDecode(uBuffer[i]);
|
|
169
169
|
v += zigZagDecode(vBuffer[i]);
|
|
170
170
|
uBuffer[i] = u;
|