@loaders.gl/math 3.1.0-alpha.5 → 3.1.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/geometry/attributes/compute-bounding-box.d.ts +1 -0
- package/dist/geometry/attributes/compute-bounding-box.d.ts.map +1 -0
- package/dist/geometry/attributes/compute-bounding-box.js +44 -0
- package/dist/geometry/attributes/compute-bounding-sphere.d.ts +1 -0
- package/dist/geometry/attributes/compute-bounding-sphere.d.ts.map +1 -0
- package/dist/geometry/attributes/compute-bounding-sphere.js +30 -0
- package/dist/geometry/attributes/compute-tangents.d.ts +1 -0
- package/dist/geometry/attributes/compute-tangents.d.ts.map +1 -0
- package/dist/geometry/attributes/compute-tangents.js +146 -0
- package/dist/geometry/attributes/compute-vertex-normals.d.ts +1 -0
- package/dist/geometry/attributes/compute-vertex-normals.d.ts.map +1 -0
- package/dist/geometry/attributes/compute-vertex-normals.js +48 -0
- package/dist/geometry/attributes/convert-to-non-indexed.d.ts +1 -0
- package/dist/geometry/attributes/convert-to-non-indexed.d.ts.map +1 -0
- package/dist/geometry/attributes/convert-to-non-indexed.js +33 -0
- package/dist/geometry/attributes/get-attribute-from-geometry.d.ts +1 -0
- package/dist/geometry/attributes/get-attribute-from-geometry.d.ts.map +1 -0
- package/dist/geometry/attributes/get-attribute-from-geometry.js +34 -0
- package/dist/geometry/attributes/normalize.d.ts +1 -0
- package/dist/geometry/attributes/normalize.d.ts.map +1 -0
- package/dist/geometry/attributes/normalize.js +20 -0
- package/dist/geometry/colors/rgb565.d.ts +1 -0
- package/dist/geometry/colors/rgb565.d.ts.map +1 -0
- package/dist/geometry/colors/rgb565.js +31 -0
- package/dist/geometry/compression/attribute-compression.d.ts +1 -0
- package/dist/geometry/compression/attribute-compression.d.ts.map +1 -0
- package/dist/geometry/compression/attribute-compression.js +352 -0
- package/dist/geometry/constants.d.ts +1 -0
- package/dist/geometry/constants.d.ts.map +1 -0
- package/dist/geometry/constants.js +34 -0
- package/dist/geometry/gl/gl-type.d.ts +1 -0
- package/dist/geometry/gl/gl-type.d.ts.map +1 -0
- package/dist/geometry/gl/gl-type.js +112 -0
- package/dist/geometry/is-geometry.d.ts +1 -0
- package/dist/geometry/is-geometry.d.ts.map +1 -0
- package/dist/geometry/is-geometry.js +14 -0
- package/dist/geometry/iterators/attribute-iterator.d.ts +1 -0
- package/dist/geometry/iterators/attribute-iterator.d.ts.map +1 -0
- package/dist/geometry/iterators/attribute-iterator.js +19 -0
- package/dist/geometry/iterators/primitive-iterator.d.ts +1 -0
- package/dist/geometry/iterators/primitive-iterator.d.ts.map +1 -0
- package/dist/geometry/iterators/primitive-iterator.js +88 -0
- package/dist/geometry/primitives/modes.d.ts +1 -0
- package/dist/geometry/primitives/modes.d.ts.map +1 -0
- package/dist/geometry/primitives/modes.js +71 -0
- package/dist/geometry/typed-arrays/typed-array-utils.d.ts +1 -0
- package/dist/geometry/typed-arrays/typed-array-utils.d.ts.map +1 -0
- package/dist/geometry/typed-arrays/typed-array-utils.js +25 -0
- package/dist/geometry/types.d.ts +1 -0
- package/dist/geometry/types.d.ts.map +1 -0
- package/dist/geometry/types.js +2 -0
- package/dist/geometry/utils/assert.d.ts +1 -0
- package/dist/geometry/utils/assert.d.ts.map +1 -0
- package/dist/geometry/utils/assert.js +14 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +46 -0
- package/dist/utils/assert.d.ts +1 -0
- package/dist/utils/assert.d.ts.map +1 -0
- package/dist/utils/assert.js +12 -0
- package/package.json +5 -6
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPrimitiveModeExpandedLength = exports.isPrimitiveModeExpandable = exports.getPrimitiveModeType = void 0;
|
|
4
|
+
const constants_1 = require("../constants");
|
|
5
|
+
/**
|
|
6
|
+
* Different methods of working with geometries depending on glType
|
|
7
|
+
/**
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @param mode
|
|
11
|
+
* @returns draw points | lines | triangles
|
|
12
|
+
*/
|
|
13
|
+
function getPrimitiveModeType(mode) {
|
|
14
|
+
switch (mode) {
|
|
15
|
+
case constants_1.GL.POINTS: // draw single points.
|
|
16
|
+
return constants_1.GL.POINTS;
|
|
17
|
+
case constants_1.GL.LINES: // draw lines. Each set of two vertices is treated as a separate line segment.
|
|
18
|
+
case constants_1.GL.LINE_STRIP: // draw lines. Each vertex connects to the one after it.
|
|
19
|
+
case constants_1.GL.LINE_LOOP: // draw a connected group of line segments from the first vertex to the last
|
|
20
|
+
return constants_1.GL.LINES;
|
|
21
|
+
case constants_1.GL.TRIANGLES:
|
|
22
|
+
case constants_1.GL.TRIANGLE_STRIP:
|
|
23
|
+
case constants_1.GL.TRIANGLE_FAN: // draw a connected group of triangles.
|
|
24
|
+
return constants_1.GL.TRIANGLES;
|
|
25
|
+
default:
|
|
26
|
+
throw new Error('Unknown primitive mode');
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.getPrimitiveModeType = getPrimitiveModeType;
|
|
30
|
+
/**
|
|
31
|
+
* @param mode
|
|
32
|
+
* @returns true | false
|
|
33
|
+
*/
|
|
34
|
+
function isPrimitiveModeExpandable(mode) {
|
|
35
|
+
switch (mode) {
|
|
36
|
+
case constants_1.GL.LINE_STRIP: // draw lines. Each vertex connects to the one after it.
|
|
37
|
+
case constants_1.GL.LINE_LOOP: // draw a connected group of line segments from the first vertex to the last
|
|
38
|
+
case constants_1.GL.TRIANGLE_STRIP: // draw a connected group of triangles.
|
|
39
|
+
case constants_1.GL.TRIANGLE_FAN: // draw a connected group of triangles.
|
|
40
|
+
return true;
|
|
41
|
+
default:
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.isPrimitiveModeExpandable = isPrimitiveModeExpandable;
|
|
46
|
+
/**
|
|
47
|
+
* Returns new length depends on glType
|
|
48
|
+
* @param mode
|
|
49
|
+
* @param length
|
|
50
|
+
* @returns new length
|
|
51
|
+
*/
|
|
52
|
+
function getPrimitiveModeExpandedLength(mode, length) {
|
|
53
|
+
switch (mode) {
|
|
54
|
+
case constants_1.GL.POINTS: // draw single points.
|
|
55
|
+
return length;
|
|
56
|
+
case constants_1.GL.LINES: // draw lines. Each set of two vertices is treated as a separate line segment.
|
|
57
|
+
return length;
|
|
58
|
+
case constants_1.GL.LINE_STRIP: // draw lines. Each vertex connects to the one after it.
|
|
59
|
+
return length;
|
|
60
|
+
case constants_1.GL.LINE_LOOP: // draw a connected group of line segments from the first vertex to the last
|
|
61
|
+
return length + 1;
|
|
62
|
+
case constants_1.GL.TRIANGLES: // draw triangles. Each set of three vertices creates a separate triangle.
|
|
63
|
+
return length;
|
|
64
|
+
case constants_1.GL.TRIANGLE_STRIP: // draw a connected group of triangles.
|
|
65
|
+
case constants_1.GL.TRIANGLE_FAN: // draw a connected group of triangles.
|
|
66
|
+
return (length - 2) * 3;
|
|
67
|
+
default:
|
|
68
|
+
throw new Error('Unknown length');
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
exports.getPrimitiveModeExpandedLength = getPrimitiveModeExpandedLength;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typed-array-utils.d.ts","sourceRoot":"","sources":["../../../src/geometry/typed-arrays/typed-array-utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,GAAE,GAAQ,GAAG,UAAU,CAgB9D"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.concatTypedArrays = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Concats typed arrays
|
|
6
|
+
* @param arrays
|
|
7
|
+
* @returns new Uint8Array
|
|
8
|
+
*/
|
|
9
|
+
function concatTypedArrays(arrays = []) {
|
|
10
|
+
let byteLength = 0;
|
|
11
|
+
for (let i = 0; i < arrays.length; ++i) {
|
|
12
|
+
byteLength += arrays[i].byteLength;
|
|
13
|
+
}
|
|
14
|
+
const buffer = new Uint8Array(byteLength);
|
|
15
|
+
let byteOffset = 0;
|
|
16
|
+
for (let i = 0; i < arrays.length; ++i) {
|
|
17
|
+
const data = new Uint8Array(arrays[i].buffer);
|
|
18
|
+
byteLength = data.length;
|
|
19
|
+
for (let j = 0; j < byteLength; ++j) {
|
|
20
|
+
buffer[byteOffset++] = data[j];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return buffer;
|
|
24
|
+
}
|
|
25
|
+
exports.concatTypedArrays = concatTypedArrays;
|
package/dist/geometry/types.d.ts
CHANGED
|
@@ -10,3 +10,4 @@ export declare type Vector4 = {
|
|
|
10
10
|
export declare type TypedIntArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Int32Array | Uint32Array;
|
|
11
11
|
export declare type TypedFloatArray = Uint16Array | Float32Array | Float64Array;
|
|
12
12
|
export declare type TypedArray = TypedIntArray | TypedFloatArray;
|
|
13
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/geometry/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,oBAAY,OAAO,GAAG;IACpB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAGF,oBAAY,aAAa,GACrB,SAAS,GACT,UAAU,GACV,iBAAiB,GACjB,UAAU,GACV,WAAW,GACX,UAAU,GACV,WAAW,GACX,UAAU,GACV,WAAW,CAAC;AAEhB,oBAAY,eAAe,GAAG,WAAW,GAAG,YAAY,GAAG,YAAY,CAAC;AAExE,oBAAY,UAAU,GAAG,aAAa,GAAG,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assert.d.ts","sourceRoot":"","sources":["../../../src/geometry/utils/assert.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,SAAS,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,GAAG,GAAG,IAAI,CAI1D"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.assert = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Throws error message
|
|
6
|
+
* @param condition checks if an attribute equal to condition
|
|
7
|
+
* @param message error message
|
|
8
|
+
*/
|
|
9
|
+
function assert(condition, message) {
|
|
10
|
+
if (!condition) {
|
|
11
|
+
throw new Error(`math.gl assertion failed. ${message}`);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.assert = assert;
|
package/dist/index.d.ts
CHANGED
|
@@ -8,3 +8,4 @@ export { computeVertexNormals } from './geometry/attributes/compute-vertex-norma
|
|
|
8
8
|
export { encodeRGB565, decodeRGB565 } from './geometry/colors/rgb565';
|
|
9
9
|
export { concatTypedArrays } from './geometry/typed-arrays/typed-array-utils';
|
|
10
10
|
export { octEncodeInRange, octEncode, octEncodeToVector4, octDecodeInRange, octDecode, octDecodeFromVector4, octPackFloat, octEncodeFloat, octDecodeFloat, octPack, octUnpack, compressTextureCoordinates, decompressTextureCoordinates, zigZagDeltaDecode } from './geometry/compression/attribute-compression';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,EAAE,EAAC,MAAM,sBAAsB,CAAC;AAGxC,OAAO,EAAC,OAAO,EAAC,MAAM,sBAAsB,CAAC;AAC7C,OAAO,EAAC,OAAO,IAAI,MAAM,EAAC,MAAM,uBAAuB,CAAC;AAGxD,OAAO,EAAC,OAAO,IAAI,UAAU,EAAC,MAAM,wBAAwB,CAAC;AAG7D,OAAO,EAAC,qBAAqB,EAAC,MAAM,yCAAyC,CAAC;AAC9E,OAAO,EAAC,qBAAqB,EAAC,MAAM,yCAAyC,CAAC;AAG9E,OAAO,EAAC,oBAAoB,EAAC,MAAM,8CAA8C,CAAC;AAElF,OAAO,EAAC,YAAY,EAAE,YAAY,EAAC,MAAM,0BAA0B,CAAC;AAGpE,OAAO,EAAC,iBAAiB,EAAC,MAAM,2CAA2C,CAAC;AAG5E,OAAO,EACL,gBAAgB,EAChB,SAAS,EACT,kBAAkB,EAClB,gBAAgB,EAChB,SAAS,EACT,oBAAoB,EACpB,YAAY,EACZ,cAAc,EACd,cAAc,EACd,OAAO,EACP,SAAS,EACT,0BAA0B,EAC1B,4BAA4B,EAC5B,iBAAiB,EAClB,MAAM,8CAA8C,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.zigZagDeltaDecode = exports.decompressTextureCoordinates = exports.compressTextureCoordinates = exports.octUnpack = exports.octPack = exports.octDecodeFloat = exports.octEncodeFloat = exports.octPackFloat = exports.octDecodeFromVector4 = exports.octDecode = exports.octDecodeInRange = exports.octEncodeToVector4 = exports.octEncode = exports.octEncodeInRange = exports.concatTypedArrays = exports.decodeRGB565 = exports.encodeRGB565 = exports.computeVertexNormals = exports.makePrimitiveIterator = exports.makeAttributeIterator = exports.isGeometry = exports.GLType = exports.GL_TYPE = exports.GL = void 0;
|
|
7
|
+
var constants_1 = require("./geometry/constants");
|
|
8
|
+
Object.defineProperty(exports, "GL", { enumerable: true, get: function () { return constants_1.GL; } });
|
|
9
|
+
// GL support
|
|
10
|
+
var constants_2 = require("./geometry/constants");
|
|
11
|
+
Object.defineProperty(exports, "GL_TYPE", { enumerable: true, get: function () { return constants_2.GL_TYPE; } });
|
|
12
|
+
var gl_type_1 = require("./geometry/gl/gl-type");
|
|
13
|
+
Object.defineProperty(exports, "GLType", { enumerable: true, get: function () { return __importDefault(gl_type_1).default; } });
|
|
14
|
+
// Geometry
|
|
15
|
+
var is_geometry_1 = require("./geometry/is-geometry");
|
|
16
|
+
Object.defineProperty(exports, "isGeometry", { enumerable: true, get: function () { return __importDefault(is_geometry_1).default; } });
|
|
17
|
+
// Iterators
|
|
18
|
+
var attribute_iterator_1 = require("./geometry/iterators/attribute-iterator");
|
|
19
|
+
Object.defineProperty(exports, "makeAttributeIterator", { enumerable: true, get: function () { return attribute_iterator_1.makeAttributeIterator; } });
|
|
20
|
+
var primitive_iterator_1 = require("./geometry/iterators/primitive-iterator");
|
|
21
|
+
Object.defineProperty(exports, "makePrimitiveIterator", { enumerable: true, get: function () { return primitive_iterator_1.makePrimitiveIterator; } });
|
|
22
|
+
// Helper methods
|
|
23
|
+
var compute_vertex_normals_1 = require("./geometry/attributes/compute-vertex-normals");
|
|
24
|
+
Object.defineProperty(exports, "computeVertexNormals", { enumerable: true, get: function () { return compute_vertex_normals_1.computeVertexNormals; } });
|
|
25
|
+
var rgb565_1 = require("./geometry/colors/rgb565");
|
|
26
|
+
Object.defineProperty(exports, "encodeRGB565", { enumerable: true, get: function () { return rgb565_1.encodeRGB565; } });
|
|
27
|
+
Object.defineProperty(exports, "decodeRGB565", { enumerable: true, get: function () { return rgb565_1.decodeRGB565; } });
|
|
28
|
+
// Typed array utils
|
|
29
|
+
var typed_array_utils_1 = require("./geometry/typed-arrays/typed-array-utils");
|
|
30
|
+
Object.defineProperty(exports, "concatTypedArrays", { enumerable: true, get: function () { return typed_array_utils_1.concatTypedArrays; } });
|
|
31
|
+
// Compression
|
|
32
|
+
var attribute_compression_1 = require("./geometry/compression/attribute-compression");
|
|
33
|
+
Object.defineProperty(exports, "octEncodeInRange", { enumerable: true, get: function () { return attribute_compression_1.octEncodeInRange; } });
|
|
34
|
+
Object.defineProperty(exports, "octEncode", { enumerable: true, get: function () { return attribute_compression_1.octEncode; } });
|
|
35
|
+
Object.defineProperty(exports, "octEncodeToVector4", { enumerable: true, get: function () { return attribute_compression_1.octEncodeToVector4; } });
|
|
36
|
+
Object.defineProperty(exports, "octDecodeInRange", { enumerable: true, get: function () { return attribute_compression_1.octDecodeInRange; } });
|
|
37
|
+
Object.defineProperty(exports, "octDecode", { enumerable: true, get: function () { return attribute_compression_1.octDecode; } });
|
|
38
|
+
Object.defineProperty(exports, "octDecodeFromVector4", { enumerable: true, get: function () { return attribute_compression_1.octDecodeFromVector4; } });
|
|
39
|
+
Object.defineProperty(exports, "octPackFloat", { enumerable: true, get: function () { return attribute_compression_1.octPackFloat; } });
|
|
40
|
+
Object.defineProperty(exports, "octEncodeFloat", { enumerable: true, get: function () { return attribute_compression_1.octEncodeFloat; } });
|
|
41
|
+
Object.defineProperty(exports, "octDecodeFloat", { enumerable: true, get: function () { return attribute_compression_1.octDecodeFloat; } });
|
|
42
|
+
Object.defineProperty(exports, "octPack", { enumerable: true, get: function () { return attribute_compression_1.octPack; } });
|
|
43
|
+
Object.defineProperty(exports, "octUnpack", { enumerable: true, get: function () { return attribute_compression_1.octUnpack; } });
|
|
44
|
+
Object.defineProperty(exports, "compressTextureCoordinates", { enumerable: true, get: function () { return attribute_compression_1.compressTextureCoordinates; } });
|
|
45
|
+
Object.defineProperty(exports, "decompressTextureCoordinates", { enumerable: true, get: function () { return attribute_compression_1.decompressTextureCoordinates; } });
|
|
46
|
+
Object.defineProperty(exports, "zigZagDeltaDecode", { enumerable: true, get: function () { return attribute_compression_1.zigZagDeltaDecode; } });
|
package/dist/utils/assert.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assert.d.ts","sourceRoot":"","sources":["../../src/utils/assert.ts"],"names":[],"mappings":"AAGA,wBAAgB,MAAM,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAIjE"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.assert = void 0;
|
|
4
|
+
// Replacement for the external assert method to reduce bundle size
|
|
5
|
+
// Note: We don't use the second "message" argument in calling code,
|
|
6
|
+
// so no need to support it here
|
|
7
|
+
function assert(condition, message) {
|
|
8
|
+
if (!condition) {
|
|
9
|
+
throw new Error(message || '3d-tile loader: assertion failed.');
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.assert = assert;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/math",
|
|
3
|
-
"version": "3.1.0-
|
|
3
|
+
"version": "3.1.0-beta.1",
|
|
4
4
|
"description": "Experimental math classes for loaders.gl",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -28,13 +28,12 @@
|
|
|
28
28
|
"README.md"
|
|
29
29
|
],
|
|
30
30
|
"scripts": {
|
|
31
|
-
"pre-build": "echo \"Nothing to build in @loaders.gl/math\""
|
|
32
|
-
"post-build": "tsc"
|
|
31
|
+
"pre-build": "echo \"Nothing to build in @loaders.gl/math\""
|
|
33
32
|
},
|
|
34
33
|
"dependencies": {
|
|
35
|
-
"@loaders.gl/images": "3.1.0-
|
|
36
|
-
"@loaders.gl/loader-utils": "3.1.0-
|
|
34
|
+
"@loaders.gl/images": "3.1.0-beta.1",
|
|
35
|
+
"@loaders.gl/loader-utils": "3.1.0-beta.1",
|
|
37
36
|
"@math.gl/core": "^3.5.1"
|
|
38
37
|
},
|
|
39
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "980cdefb4e8ec9ef9c951d20c78cf77777707f49"
|
|
40
39
|
}
|