@loaders.gl/math 4.0.0-alpha.9 → 4.0.0-beta.2
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/utils/coordinates.js +10 -0
- package/dist/es5/geometry/utils/coordinates.js.map +1 -0
- package/dist/es5/index.js +7 -0
- package/dist/es5/index.js.map +1 -1
- package/dist/esm/geometry/utils/coordinates.js +4 -0
- package/dist/esm/geometry/utils/coordinates.js.map +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/geometry/utils/coordinates.d.ts +6 -0
- package/dist/geometry/utils/coordinates.d.ts.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/geometry/utils/coordinates.ts +7 -0
- package/src/index.ts +2 -0
- package/dist/geometry/attributes/compute-bounding-box.js +0 -44
- package/dist/geometry/attributes/compute-bounding-sphere.js +0 -30
- package/dist/geometry/attributes/compute-tangents.js +0 -146
- package/dist/geometry/attributes/compute-vertex-normals.js +0 -48
- package/dist/geometry/attributes/convert-to-non-indexed.js +0 -33
- package/dist/geometry/attributes/get-attribute-from-geometry.js +0 -34
- package/dist/geometry/attributes/normalize.js +0 -20
- package/dist/geometry/colors/rgb565.js +0 -31
- package/dist/geometry/compression/attribute-compression.js +0 -352
- package/dist/geometry/constants.js +0 -34
- package/dist/geometry/gl/gl-type.js +0 -112
- package/dist/geometry/is-geometry.js +0 -14
- package/dist/geometry/iterators/attribute-iterator.js +0 -19
- package/dist/geometry/iterators/primitive-iterator.js +0 -88
- package/dist/geometry/primitives/modes.js +0 -71
- package/dist/geometry/typed-arrays/typed-array-utils.js +0 -25
- package/dist/geometry/utils/assert.js +0 -14
- package/dist/index.js +0 -46
- package/dist/utils/assert.js +0 -12
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coordinates.js","names":["emod","n"],"sources":["../../../../src/geometry/utils/coordinates.ts"],"sourcesContent":["/**\n * Handle UVs if they are out of range [0,1].\n * @param n\n */\nexport function emod(n: number): number {\n return ((n % 1) + 1) % 1;\n}\n"],"mappings":";;;;;;AAIO,SAASA,IAAIA,CAACC,CAAS,EAAU;EACtC,OAAO,CAAEA,CAAC,GAAG,CAAC,GAAI,CAAC,IAAI,CAAC;AAC1B"}
|
package/dist/es5/index.js
CHANGED
|
@@ -52,6 +52,12 @@ Object.defineProperty(exports, "decompressTextureCoordinates", {
|
|
|
52
52
|
return _attributeCompression.decompressTextureCoordinates;
|
|
53
53
|
}
|
|
54
54
|
});
|
|
55
|
+
Object.defineProperty(exports, "emod", {
|
|
56
|
+
enumerable: true,
|
|
57
|
+
get: function get() {
|
|
58
|
+
return _coordinates.emod;
|
|
59
|
+
}
|
|
60
|
+
});
|
|
55
61
|
Object.defineProperty(exports, "encodeRGB565", {
|
|
56
62
|
enumerable: true,
|
|
57
63
|
get: function get() {
|
|
@@ -157,4 +163,5 @@ var _computeVertexNormals = require("./geometry/attributes/compute-vertex-normal
|
|
|
157
163
|
var _rgb = require("./geometry/colors/rgb565");
|
|
158
164
|
var _typedArrayUtils = require("./geometry/typed-arrays/typed-array-utils");
|
|
159
165
|
var _attributeCompression = require("./geometry/compression/attribute-compression");
|
|
166
|
+
var _coordinates = require("./geometry/utils/coordinates");
|
|
160
167
|
//# sourceMappingURL=index.js.map
|
package/dist/es5/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_constants","require","_glType","_interopRequireDefault","_isGeometry","_attributeIterator","_primitiveIterator","_computeVertexNormals","_rgb","_typedArrayUtils","_attributeCompression"],"sources":["../../src/index.ts"],"sourcesContent":["export type TypedArrayConstructor =\n | Int8ArrayConstructor\n | Uint8ArrayConstructor\n | Int16ArrayConstructor\n | Uint16ArrayConstructor\n | Int32ArrayConstructor\n | Uint32ArrayConstructor\n | Int32ArrayConstructor\n | Uint32ArrayConstructor\n | Float32ArrayConstructor\n | Float64ArrayConstructor;\n\nexport {GL} from './geometry/constants';\n\n// GL support\nexport {GL_TYPE} from './geometry/constants';\nexport {default as GLType} from './geometry/gl/gl-type';\n\n// Geometry\nexport {default as isGeometry} from './geometry/is-geometry';\n\n// Iterators\nexport {makeAttributeIterator} from './geometry/iterators/attribute-iterator';\nexport {makePrimitiveIterator} from './geometry/iterators/primitive-iterator';\n\n// Helper methods\nexport {computeVertexNormals} from './geometry/attributes/compute-vertex-normals';\n\nexport {encodeRGB565, decodeRGB565} from './geometry/colors/rgb565';\n\n// Typed array utils\nexport {concatTypedArrays} from './geometry/typed-arrays/typed-array-utils';\n\n// Compression\nexport {\n octEncodeInRange,\n octEncode,\n octEncodeToVector4,\n octDecodeInRange,\n octDecode,\n octDecodeFromVector4,\n octPackFloat,\n octEncodeFloat,\n octDecodeFloat,\n octPack,\n octUnpack,\n compressTextureCoordinates,\n decompressTextureCoordinates,\n zigZagDeltaDecode\n} from './geometry/compression/attribute-compression';\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":["_constants","require","_glType","_interopRequireDefault","_isGeometry","_attributeIterator","_primitiveIterator","_computeVertexNormals","_rgb","_typedArrayUtils","_attributeCompression","_coordinates"],"sources":["../../src/index.ts"],"sourcesContent":["export type TypedArrayConstructor =\n | Int8ArrayConstructor\n | Uint8ArrayConstructor\n | Int16ArrayConstructor\n | Uint16ArrayConstructor\n | Int32ArrayConstructor\n | Uint32ArrayConstructor\n | Int32ArrayConstructor\n | Uint32ArrayConstructor\n | Float32ArrayConstructor\n | Float64ArrayConstructor;\n\nexport {GL} from './geometry/constants';\n\n// GL support\nexport {GL_TYPE} from './geometry/constants';\nexport {default as GLType} from './geometry/gl/gl-type';\n\n// Geometry\nexport {default as isGeometry} from './geometry/is-geometry';\n\n// Iterators\nexport {makeAttributeIterator} from './geometry/iterators/attribute-iterator';\nexport {makePrimitiveIterator} from './geometry/iterators/primitive-iterator';\n\n// Helper methods\nexport {computeVertexNormals} from './geometry/attributes/compute-vertex-normals';\n\nexport {encodeRGB565, decodeRGB565} from './geometry/colors/rgb565';\n\n// Typed array utils\nexport {concatTypedArrays} from './geometry/typed-arrays/typed-array-utils';\n\n// Compression\nexport {\n octEncodeInRange,\n octEncode,\n octEncodeToVector4,\n octDecodeInRange,\n octDecode,\n octDecodeFromVector4,\n octPackFloat,\n octEncodeFloat,\n octDecodeFloat,\n octPack,\n octUnpack,\n compressTextureCoordinates,\n decompressTextureCoordinates,\n zigZagDeltaDecode\n} from './geometry/compression/attribute-compression';\n\nexport {emod} from './geometry/utils/coordinates';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,IAAAA,UAAA,GAAAC,OAAA;AAIA,IAAAC,OAAA,GAAAC,sBAAA,CAAAF,OAAA;AAGA,IAAAG,WAAA,GAAAD,sBAAA,CAAAF,OAAA;AAGA,IAAAI,kBAAA,GAAAJ,OAAA;AACA,IAAAK,kBAAA,GAAAL,OAAA;AAGA,IAAAM,qBAAA,GAAAN,OAAA;AAEA,IAAAO,IAAA,GAAAP,OAAA;AAGA,IAAAQ,gBAAA,GAAAR,OAAA;AAGA,IAAAS,qBAAA,GAAAT,OAAA;AAiBA,IAAAU,YAAA,GAAAV,OAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coordinates.js","names":["emod","n"],"sources":["../../../../src/geometry/utils/coordinates.ts"],"sourcesContent":["/**\n * Handle UVs if they are out of range [0,1].\n * @param n\n */\nexport function emod(n: number): number {\n return ((n % 1) + 1) % 1;\n}\n"],"mappings":"AAIA,OAAO,SAASA,IAAIA,CAACC,CAAS,EAAU;EACtC,OAAO,CAAEA,CAAC,GAAG,CAAC,GAAI,CAAC,IAAI,CAAC;AAC1B"}
|
package/dist/esm/index.js
CHANGED
|
@@ -8,4 +8,5 @@ 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
|
+
export { emod } from './geometry/utils/coordinates';
|
|
11
12
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["GL","GL_TYPE","default","GLType","isGeometry","makeAttributeIterator","makePrimitiveIterator","computeVertexNormals","encodeRGB565","decodeRGB565","concatTypedArrays","octEncodeInRange","octEncode","octEncodeToVector4","octDecodeInRange","octDecode","octDecodeFromVector4","octPackFloat","octEncodeFloat","octDecodeFloat","octPack","octUnpack","compressTextureCoordinates","decompressTextureCoordinates","zigZagDeltaDecode"],"sources":["../../src/index.ts"],"sourcesContent":["export type TypedArrayConstructor =\n | Int8ArrayConstructor\n | Uint8ArrayConstructor\n | Int16ArrayConstructor\n | Uint16ArrayConstructor\n | Int32ArrayConstructor\n | Uint32ArrayConstructor\n | Int32ArrayConstructor\n | Uint32ArrayConstructor\n | Float32ArrayConstructor\n | Float64ArrayConstructor;\n\nexport {GL} from './geometry/constants';\n\n// GL support\nexport {GL_TYPE} from './geometry/constants';\nexport {default as GLType} from './geometry/gl/gl-type';\n\n// Geometry\nexport {default as isGeometry} from './geometry/is-geometry';\n\n// Iterators\nexport {makeAttributeIterator} from './geometry/iterators/attribute-iterator';\nexport {makePrimitiveIterator} from './geometry/iterators/primitive-iterator';\n\n// Helper methods\nexport {computeVertexNormals} from './geometry/attributes/compute-vertex-normals';\n\nexport {encodeRGB565, decodeRGB565} from './geometry/colors/rgb565';\n\n// Typed array utils\nexport {concatTypedArrays} from './geometry/typed-arrays/typed-array-utils';\n\n// Compression\nexport {\n octEncodeInRange,\n octEncode,\n octEncodeToVector4,\n octDecodeInRange,\n octDecode,\n octDecodeFromVector4,\n octPackFloat,\n octEncodeFloat,\n octDecodeFloat,\n octPack,\n octUnpack,\n compressTextureCoordinates,\n decompressTextureCoordinates,\n zigZagDeltaDecode\n} from './geometry/compression/attribute-compression';\n"],"mappings":"AAYA,SAAQA,EAAE,QAAO,sBAAsB;AAGvC,SAAQC,OAAO,QAAO,sBAAsB;AAC5C,SAAQC,OAAO,IAAIC,MAAM,QAAO,uBAAuB;AAGvD,SAAQD,OAAO,IAAIE,UAAU,QAAO,wBAAwB;AAG5D,SAAQC,qBAAqB,QAAO,yCAAyC;AAC7E,SAAQC,qBAAqB,QAAO,yCAAyC;AAG7E,SAAQC,oBAAoB,QAAO,8CAA8C;AAEjF,SAAQC,YAAY,EAAEC,YAAY,QAAO,0BAA0B;AAGnE,SAAQC,iBAAiB,QAAO,2CAA2C;AAG3E,SACEC,gBAAgB,EAChBC,SAAS,EACTC,kBAAkB,EAClBC,gBAAgB,EAChBC,SAAS,EACTC,oBAAoB,EACpBC,YAAY,EACZC,cAAc,EACdC,cAAc,EACdC,OAAO,EACPC,SAAS,EACTC,0BAA0B,EAC1BC,4BAA4B,EAC5BC,iBAAiB,QACZ,8CAA8C"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["GL","GL_TYPE","default","GLType","isGeometry","makeAttributeIterator","makePrimitiveIterator","computeVertexNormals","encodeRGB565","decodeRGB565","concatTypedArrays","octEncodeInRange","octEncode","octEncodeToVector4","octDecodeInRange","octDecode","octDecodeFromVector4","octPackFloat","octEncodeFloat","octDecodeFloat","octPack","octUnpack","compressTextureCoordinates","decompressTextureCoordinates","zigZagDeltaDecode","emod"],"sources":["../../src/index.ts"],"sourcesContent":["export type TypedArrayConstructor =\n | Int8ArrayConstructor\n | Uint8ArrayConstructor\n | Int16ArrayConstructor\n | Uint16ArrayConstructor\n | Int32ArrayConstructor\n | Uint32ArrayConstructor\n | Int32ArrayConstructor\n | Uint32ArrayConstructor\n | Float32ArrayConstructor\n | Float64ArrayConstructor;\n\nexport {GL} from './geometry/constants';\n\n// GL support\nexport {GL_TYPE} from './geometry/constants';\nexport {default as GLType} from './geometry/gl/gl-type';\n\n// Geometry\nexport {default as isGeometry} from './geometry/is-geometry';\n\n// Iterators\nexport {makeAttributeIterator} from './geometry/iterators/attribute-iterator';\nexport {makePrimitiveIterator} from './geometry/iterators/primitive-iterator';\n\n// Helper methods\nexport {computeVertexNormals} from './geometry/attributes/compute-vertex-normals';\n\nexport {encodeRGB565, decodeRGB565} from './geometry/colors/rgb565';\n\n// Typed array utils\nexport {concatTypedArrays} from './geometry/typed-arrays/typed-array-utils';\n\n// Compression\nexport {\n octEncodeInRange,\n octEncode,\n octEncodeToVector4,\n octDecodeInRange,\n octDecode,\n octDecodeFromVector4,\n octPackFloat,\n octEncodeFloat,\n octDecodeFloat,\n octPack,\n octUnpack,\n compressTextureCoordinates,\n decompressTextureCoordinates,\n zigZagDeltaDecode\n} from './geometry/compression/attribute-compression';\n\nexport {emod} from './geometry/utils/coordinates';\n"],"mappings":"AAYA,SAAQA,EAAE,QAAO,sBAAsB;AAGvC,SAAQC,OAAO,QAAO,sBAAsB;AAC5C,SAAQC,OAAO,IAAIC,MAAM,QAAO,uBAAuB;AAGvD,SAAQD,OAAO,IAAIE,UAAU,QAAO,wBAAwB;AAG5D,SAAQC,qBAAqB,QAAO,yCAAyC;AAC7E,SAAQC,qBAAqB,QAAO,yCAAyC;AAG7E,SAAQC,oBAAoB,QAAO,8CAA8C;AAEjF,SAAQC,YAAY,EAAEC,YAAY,QAAO,0BAA0B;AAGnE,SAAQC,iBAAiB,QAAO,2CAA2C;AAG3E,SACEC,gBAAgB,EAChBC,SAAS,EACTC,kBAAkB,EAClBC,gBAAgB,EAChBC,SAAS,EACTC,oBAAoB,EACpBC,YAAY,EACZC,cAAc,EACdC,cAAc,EACdC,OAAO,EACPC,SAAS,EACTC,0BAA0B,EAC1BC,4BAA4B,EAC5BC,iBAAiB,QACZ,8CAA8C;AAErD,SAAQC,IAAI,QAAO,8BAA8B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coordinates.d.ts","sourceRoot":"","sources":["../../../src/geometry/utils/coordinates.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAEtC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -9,4 +9,5 @@ export { computeVertexNormals } from './geometry/attributes/compute-vertex-norma
|
|
|
9
9
|
export { encodeRGB565, decodeRGB565 } from './geometry/colors/rgb565';
|
|
10
10
|
export { concatTypedArrays } from './geometry/typed-arrays/typed-array-utils';
|
|
11
11
|
export { octEncodeInRange, octEncode, octEncodeToVector4, octDecodeInRange, octDecode, octDecodeFromVector4, octPackFloat, octEncodeFloat, octDecodeFloat, octPack, octUnpack, compressTextureCoordinates, decompressTextureCoordinates, zigZagDeltaDecode } from './geometry/compression/attribute-compression';
|
|
12
|
+
export { emod } from './geometry/utils/coordinates';
|
|
12
13
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qBAAqB,GAC7B,oBAAoB,GACpB,qBAAqB,GACrB,qBAAqB,GACrB,sBAAsB,GACtB,qBAAqB,GACrB,sBAAsB,GACtB,qBAAqB,GACrB,sBAAsB,GACtB,uBAAuB,GACvB,uBAAuB,CAAC;AAE5B,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"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qBAAqB,GAC7B,oBAAoB,GACpB,qBAAqB,GACrB,qBAAqB,GACrB,sBAAsB,GACtB,qBAAqB,GACrB,sBAAsB,GACtB,qBAAqB,GACrB,sBAAsB,GACtB,uBAAuB,GACvB,uBAAuB,CAAC;AAE5B,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;AAEtD,OAAO,EAAC,IAAI,EAAC,MAAM,8BAA8B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/math",
|
|
3
|
-
"version": "4.0.0-
|
|
3
|
+
"version": "4.0.0-beta.2",
|
|
4
4
|
"description": "Experimental math classes for loaders.gl",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -31,9 +31,9 @@
|
|
|
31
31
|
"pre-build": "echo \"Nothing to build in @loaders.gl/math\""
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@loaders.gl/images": "4.0.0-
|
|
35
|
-
"@loaders.gl/loader-utils": "4.0.0-
|
|
34
|
+
"@loaders.gl/images": "4.0.0-beta.2",
|
|
35
|
+
"@loaders.gl/loader-utils": "4.0.0-beta.2",
|
|
36
36
|
"@math.gl/core": "^3.5.1"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "79c2033f755e88e11bc30a04428e3666b177b8fc"
|
|
39
39
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.computeBoundingBox = void 0;
|
|
4
|
-
const attribute_iterator_1 = require("../iterators/attribute-iterator");
|
|
5
|
-
const assert_1 = require("../utils/assert");
|
|
6
|
-
/**
|
|
7
|
-
* Getting bounding box geometry according to positions parameters
|
|
8
|
-
* @param positions
|
|
9
|
-
* @returns Bounding Box
|
|
10
|
-
*/
|
|
11
|
-
function computeBoundingBox(positions = []) {
|
|
12
|
-
const min = [Number(Infinity), Number(Infinity), Number(Infinity)];
|
|
13
|
-
const max = [-Infinity, -Infinity, -Infinity];
|
|
14
|
-
// @ts-ignore
|
|
15
|
-
for (const position of (0, attribute_iterator_1.makeAttributeIterator)(positions)) {
|
|
16
|
-
const x = position[0];
|
|
17
|
-
const y = position[1];
|
|
18
|
-
const z = position[2];
|
|
19
|
-
if (x < min[0])
|
|
20
|
-
min[0] = x;
|
|
21
|
-
if (y < min[1])
|
|
22
|
-
min[1] = y;
|
|
23
|
-
if (z < min[2])
|
|
24
|
-
min[2] = z;
|
|
25
|
-
if (x > max[0])
|
|
26
|
-
max[0] = x;
|
|
27
|
-
if (y > max[1])
|
|
28
|
-
max[1] = y;
|
|
29
|
-
if (z > max[2])
|
|
30
|
-
max[2] = z;
|
|
31
|
-
}
|
|
32
|
-
const boundingBox = { min, max };
|
|
33
|
-
validateBoundingBox(boundingBox);
|
|
34
|
-
return boundingBox;
|
|
35
|
-
}
|
|
36
|
-
exports.computeBoundingBox = computeBoundingBox;
|
|
37
|
-
function validateBoundingBox(boundingBox) {
|
|
38
|
-
(0, assert_1.assert)(Number.isFinite(boundingBox.min[0]) &&
|
|
39
|
-
Number.isFinite(boundingBox.min[1]) &&
|
|
40
|
-
Number.isFinite(boundingBox.min[2]) &&
|
|
41
|
-
Number.isFinite(boundingBox.max[0]) &&
|
|
42
|
-
Number.isFinite(boundingBox.max[1]) &&
|
|
43
|
-
Number.isFinite(boundingBox.max[2]));
|
|
44
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/* eslint-disable */
|
|
3
|
-
/**
|
|
4
|
-
import {getPositions} from './get-attribute-from-geometry';
|
|
5
|
-
|
|
6
|
-
export function computeBoundingSphere(geometry: any, boundingBox: object, vector: Vector3 ) {
|
|
7
|
-
const positions = getPositions(geometry);
|
|
8
|
-
|
|
9
|
-
const center = getBoundingBox(center);
|
|
10
|
-
box.setFromBufferAttribute(position);
|
|
11
|
-
box.getCenter(center);
|
|
12
|
-
|
|
13
|
-
// hoping to find a boundingSphere with a radius smaller than the
|
|
14
|
-
// boundingSphere of the boundingBox: sqrt(3) smaller in the best case
|
|
15
|
-
|
|
16
|
-
var maxRadiusSq = 0;
|
|
17
|
-
|
|
18
|
-
for (const position of makeAttributeIterator(positions)) {
|
|
19
|
-
vector.x = position[0];
|
|
20
|
-
vector.y = position[1];
|
|
21
|
-
vector.z = position[2];
|
|
22
|
-
maxRadiusSq = Math.max(maxRadiusSq, center.distanceToSquared(vector));
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const radius = Math.sqrt(maxRadiusSq);
|
|
26
|
-
assert(Number.isFinite(radius));
|
|
27
|
-
|
|
28
|
-
return {center, radius};
|
|
29
|
-
}
|
|
30
|
-
*/
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
export function computeTangents({indices, positions, normals, uvs}) {
|
|
4
|
-
var index = geometry.index;
|
|
5
|
-
var attributes = geometry.attributes;
|
|
6
|
-
|
|
7
|
-
// based on http://www.terathon.com/code/tangent.html
|
|
8
|
-
// (per vertex tangents)
|
|
9
|
-
|
|
10
|
-
if (
|
|
11
|
-
index === null ||
|
|
12
|
-
attributes.position === undefined ||
|
|
13
|
-
attributes.normal === undefined ||
|
|
14
|
-
attributes.uv === undefined
|
|
15
|
-
) {
|
|
16
|
-
console.warn(
|
|
17
|
-
'THREE.BufferGeometry: Missing required attributes (index, position, normal or uv) in BufferGeometry.computeTangents()'
|
|
18
|
-
);
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
var nVertices = positions.length / 3;
|
|
23
|
-
|
|
24
|
-
var tangents = new Float32Array(4 * nVertices); // size: 4
|
|
25
|
-
|
|
26
|
-
var tan1 = [],
|
|
27
|
-
tan2 = [];
|
|
28
|
-
|
|
29
|
-
for (var k = 0; k < nVertices; k++) {
|
|
30
|
-
tan1[k] = new THREE.Vector3();
|
|
31
|
-
tan2[k] = new THREE.Vector3();
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
var vA = new THREE.Vector3(),
|
|
35
|
-
vB = new THREE.Vector3(),
|
|
36
|
-
vC = new THREE.Vector3(),
|
|
37
|
-
uvA = new THREE.Vector2(),
|
|
38
|
-
uvB = new THREE.Vector2(),
|
|
39
|
-
uvC = new THREE.Vector2(),
|
|
40
|
-
sdir = new THREE.Vector3(),
|
|
41
|
-
tdir = new THREE.Vector3();
|
|
42
|
-
|
|
43
|
-
function handleTriangle(a, b, c) {
|
|
44
|
-
vA.fromArray(positions, a * 3);
|
|
45
|
-
vB.fromArray(positions, b * 3);
|
|
46
|
-
vC.fromArray(positions, c * 3);
|
|
47
|
-
|
|
48
|
-
uvA.fromArray(uvs, a * 2);
|
|
49
|
-
uvB.fromArray(uvs, b * 2);
|
|
50
|
-
uvC.fromArray(uvs, c * 2);
|
|
51
|
-
|
|
52
|
-
var x1 = vB.x - vA.x;
|
|
53
|
-
var x2 = vC.x - vA.x;
|
|
54
|
-
|
|
55
|
-
var y1 = vB.y - vA.y;
|
|
56
|
-
var y2 = vC.y - vA.y;
|
|
57
|
-
|
|
58
|
-
var z1 = vB.z - vA.z;
|
|
59
|
-
var z2 = vC.z - vA.z;
|
|
60
|
-
|
|
61
|
-
var s1 = uvB.x - uvA.x;
|
|
62
|
-
var s2 = uvC.x - uvA.x;
|
|
63
|
-
|
|
64
|
-
var t1 = uvB.y - uvA.y;
|
|
65
|
-
var t2 = uvC.y - uvA.y;
|
|
66
|
-
|
|
67
|
-
var r = 1.0 / (s1 * t2 - s2 * t1);
|
|
68
|
-
|
|
69
|
-
sdir.set((t2 * x1 - t1 * x2) * r, (t2 * y1 - t1 * y2) * r, (t2 * z1 - t1 * z2) * r);
|
|
70
|
-
|
|
71
|
-
tdir.set((s1 * x2 - s2 * x1) * r, (s1 * y2 - s2 * y1) * r, (s1 * z2 - s2 * z1) * r);
|
|
72
|
-
|
|
73
|
-
tan1[a].add(sdir);
|
|
74
|
-
tan1[b].add(sdir);
|
|
75
|
-
tan1[c].add(sdir);
|
|
76
|
-
|
|
77
|
-
tan2[a].add(tdir);
|
|
78
|
-
tan2[b].add(tdir);
|
|
79
|
-
tan2[c].add(tdir);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
var groups = geometry.groups;
|
|
83
|
-
|
|
84
|
-
if (groups.length === 0) {
|
|
85
|
-
groups = [
|
|
86
|
-
{
|
|
87
|
-
start: 0,
|
|
88
|
-
count: indices.length
|
|
89
|
-
}
|
|
90
|
-
];
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
for (var j = 0, jl = groups.length; j < jl; ++j) {
|
|
94
|
-
var group = groups[j];
|
|
95
|
-
|
|
96
|
-
var start = group.start;
|
|
97
|
-
var count = group.count;
|
|
98
|
-
|
|
99
|
-
for (var i = start, il = start + count; i < il; i += 3) {
|
|
100
|
-
handleTriangle(indices[i + 0], indices[i + 1], indices[i + 2]);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
var tmp = new THREE.Vector3(),
|
|
105
|
-
tmp2 = new THREE.Vector3();
|
|
106
|
-
var n = new THREE.Vector3(),
|
|
107
|
-
n2 = new THREE.Vector3();
|
|
108
|
-
var w, t, test;
|
|
109
|
-
|
|
110
|
-
function handleVertex(v) {
|
|
111
|
-
n.fromArray(normals, v * 3);
|
|
112
|
-
n2.copy(n);
|
|
113
|
-
|
|
114
|
-
t = tan1[v];
|
|
115
|
-
|
|
116
|
-
// Gram-Schmidt orthogonalize
|
|
117
|
-
|
|
118
|
-
tmp.copy(t);
|
|
119
|
-
tmp.sub(n.multiplyScalar(n.dot(t))).normalize();
|
|
120
|
-
|
|
121
|
-
// Calculate handedness
|
|
122
|
-
|
|
123
|
-
tmp2.crossVectors(n2, t);
|
|
124
|
-
test = tmp2.dot(tan2[v]);
|
|
125
|
-
w = test < 0.0 ? -1.0 : 1.0;
|
|
126
|
-
|
|
127
|
-
tangents[v * 4] = tmp.x;
|
|
128
|
-
tangents[v * 4 + 1] = tmp.y;
|
|
129
|
-
tangents[v * 4 + 2] = tmp.z;
|
|
130
|
-
tangents[v * 4 + 3] = w;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
for (var j = 0, jl = groups.length; j < jl; ++j) {
|
|
134
|
-
var group = groups[j];
|
|
135
|
-
|
|
136
|
-
var start = group.start;
|
|
137
|
-
var count = group.count;
|
|
138
|
-
|
|
139
|
-
for (var i = start, il = start + count; i < il; i += 3) {
|
|
140
|
-
handleVertex(indices[i + 0]);
|
|
141
|
-
handleVertex(indices[i + 1]);
|
|
142
|
-
handleVertex(indices[i + 2]);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
*/
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.computeVertexNormals = void 0;
|
|
4
|
-
const core_1 = require("@math.gl/core");
|
|
5
|
-
const constants_1 = require("../constants");
|
|
6
|
-
const assert_1 = require("../utils/assert");
|
|
7
|
-
const primitive_iterator_1 = require("../iterators/primitive-iterator");
|
|
8
|
-
const modes_1 = require("../primitives/modes");
|
|
9
|
-
const get_attribute_from_geometry_1 = require("./get-attribute-from-geometry");
|
|
10
|
-
/**
|
|
11
|
-
* Computes vertex normals for a geometry
|
|
12
|
-
* @param param0
|
|
13
|
-
* @returns
|
|
14
|
-
*/
|
|
15
|
-
// eslint-disable-next-line max-statements
|
|
16
|
-
function computeVertexNormals(geometry) {
|
|
17
|
-
// Only support GL.TRIANGLES, GL.TRIANGLE_STRIP, GL.TRIANGLE_FAN
|
|
18
|
-
(0, assert_1.assert)((0, modes_1.getPrimitiveModeType)(geometry.mode) === constants_1.GL.TRIANGLES, 'TRIANGLES required');
|
|
19
|
-
const { values: positions } = (0, get_attribute_from_geometry_1.getPositions)(geometry);
|
|
20
|
-
const normals = new Float32Array(positions.length);
|
|
21
|
-
const vectorA = new core_1.Vector3();
|
|
22
|
-
const vectorB = new core_1.Vector3();
|
|
23
|
-
const vectorC = new core_1.Vector3();
|
|
24
|
-
const vectorCB = new core_1.Vector3();
|
|
25
|
-
const vectorAB = new core_1.Vector3();
|
|
26
|
-
for (const primitive of (0, primitive_iterator_1.makePrimitiveIterator)(geometry)) {
|
|
27
|
-
vectorA.fromArray(positions, primitive.i1 * 3);
|
|
28
|
-
vectorB.fromArray(positions, primitive.i2 * 3 + 3);
|
|
29
|
-
vectorC.fromArray(positions, primitive.i3 * 3 + 6);
|
|
30
|
-
vectorCB.subVectors(vectorC, vectorB);
|
|
31
|
-
vectorAB.subVectors(vectorA, vectorB);
|
|
32
|
-
const normal = vectorCB.cross(vectorAB);
|
|
33
|
-
normal.normalize();
|
|
34
|
-
// @ts-ignore
|
|
35
|
-
const { primitiveIndex } = primitive;
|
|
36
|
-
normals[primitiveIndex * 9 + 0] = normal.x;
|
|
37
|
-
normals[primitiveIndex * 9 + 1] = normal.y;
|
|
38
|
-
normals[primitiveIndex * 9 + 2] = normal.z;
|
|
39
|
-
normals[primitiveIndex * 9 + 3] = normal.x;
|
|
40
|
-
normals[primitiveIndex * 9 + 4] = normal.y;
|
|
41
|
-
normals[primitiveIndex * 9 + 5] = normal.z;
|
|
42
|
-
normals[primitiveIndex * 9 + 6] = normal.x;
|
|
43
|
-
normals[primitiveIndex * 9 + 7] = normal.y;
|
|
44
|
-
normals[primitiveIndex * 9 + 8] = normal.z;
|
|
45
|
-
}
|
|
46
|
-
return normals;
|
|
47
|
-
}
|
|
48
|
-
exports.computeVertexNormals = computeVertexNormals;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.convertBuffersToNonIndexed = void 0;
|
|
4
|
-
/* eslint-disable */
|
|
5
|
-
// @ts-nocheck
|
|
6
|
-
/**
|
|
7
|
-
* Converts indices of geometry.
|
|
8
|
-
*
|
|
9
|
-
* @param param0
|
|
10
|
-
* @returns no indexed geometry
|
|
11
|
-
*/
|
|
12
|
-
function convertBuffersToNonIndexed({ indices, attributes }) {
|
|
13
|
-
const geometry2 = new BufferGeometry();
|
|
14
|
-
for (const name in attributes) {
|
|
15
|
-
const attribute = attributes[name];
|
|
16
|
-
const array = attribute.array;
|
|
17
|
-
const itemSize = attribute.itemSize;
|
|
18
|
-
const array2 = new array.constructor(indices.length * itemSize);
|
|
19
|
-
let index = 0, index2 = 0;
|
|
20
|
-
for (var i = 0, l = indices.length; i < l; i++) {
|
|
21
|
-
index = indices[i] * itemSize;
|
|
22
|
-
for (var j = 0; j < itemSize; j++) {
|
|
23
|
-
array2[index2++] = array[index++];
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
geometry2.addAttribute(name, new BufferAttribute(array2, itemSize));
|
|
27
|
-
}
|
|
28
|
-
for (const group of this.groups) {
|
|
29
|
-
geometry2.addGroup(group.start, group.count, group.materialIndex);
|
|
30
|
-
}
|
|
31
|
-
return geometry2;
|
|
32
|
-
}
|
|
33
|
-
exports.convertBuffersToNonIndexed = convertBuffersToNonIndexed;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getPositions = void 0;
|
|
7
|
-
const is_geometry_1 = __importDefault(require("../is-geometry"));
|
|
8
|
-
const assert_1 = require("../utils/assert");
|
|
9
|
-
/**
|
|
10
|
-
* analyze positions of geometry
|
|
11
|
-
*
|
|
12
|
-
* @param geometry
|
|
13
|
-
* @returns Position| New geometry |assert
|
|
14
|
-
*/
|
|
15
|
-
function getPositions(geometry) {
|
|
16
|
-
// If geometry, extract positions
|
|
17
|
-
if ((0, is_geometry_1.default)(geometry)) {
|
|
18
|
-
const { attributes } = geometry;
|
|
19
|
-
const position = attributes.POSITION || attributes.positions;
|
|
20
|
-
(0, assert_1.assert)(position);
|
|
21
|
-
return position;
|
|
22
|
-
}
|
|
23
|
-
// If arraybuffer, assume 3 components
|
|
24
|
-
if (ArrayBuffer.isView(geometry)) {
|
|
25
|
-
return { values: geometry, size: 3 };
|
|
26
|
-
}
|
|
27
|
-
// Else assume accessor object
|
|
28
|
-
if (geometry) {
|
|
29
|
-
(0, assert_1.assert)(geometry.values);
|
|
30
|
-
return geometry;
|
|
31
|
-
}
|
|
32
|
-
return (0, assert_1.assert)(false);
|
|
33
|
-
}
|
|
34
|
-
exports.getPositions = getPositions;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.normalize = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Setting X, Y, Z for Vector
|
|
6
|
-
* @param normals
|
|
7
|
-
* @param vector
|
|
8
|
-
*/
|
|
9
|
-
function normalize(normals = {}, vector) {
|
|
10
|
-
//@ts-ignore
|
|
11
|
-
normals = this.attributes.normal;
|
|
12
|
-
for (let i = 0, il = normals.count; i < il; i++) {
|
|
13
|
-
vector.x = normals.getX(i);
|
|
14
|
-
vector.y = normals.getY(i);
|
|
15
|
-
vector.z = normals.getZ(i);
|
|
16
|
-
vector.normalize();
|
|
17
|
-
normals.setXYZ(i, vector.x, vector.y, vector.z);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
exports.normalize = normalize;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.encodeRGB565 = exports.decodeRGB565 = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Decode color values
|
|
6
|
-
* @param rgb565
|
|
7
|
-
* @param target
|
|
8
|
-
* @returns target
|
|
9
|
-
*/
|
|
10
|
-
function decodeRGB565(rgb565, target = [0, 0, 0]) {
|
|
11
|
-
const r5 = (rgb565 >> 11) & 31;
|
|
12
|
-
const g6 = (rgb565 >> 5) & 63;
|
|
13
|
-
const b5 = rgb565 & 31;
|
|
14
|
-
target[0] = r5 << 3;
|
|
15
|
-
target[1] = g6 << 2;
|
|
16
|
-
target[2] = b5 << 3;
|
|
17
|
-
return target;
|
|
18
|
-
}
|
|
19
|
-
exports.decodeRGB565 = decodeRGB565;
|
|
20
|
-
/**
|
|
21
|
-
* Encode color values
|
|
22
|
-
* @param rgb
|
|
23
|
-
* @returns color
|
|
24
|
-
*/
|
|
25
|
-
function encodeRGB565(rgb) {
|
|
26
|
-
const r5 = Math.floor(rgb[0] / 8) + 4;
|
|
27
|
-
const g6 = Math.floor(rgb[1] / 4) + 2;
|
|
28
|
-
const b5 = Math.floor(rgb[2] / 8) + 4;
|
|
29
|
-
return r5 + (g6 << 5) + (b5 << 11);
|
|
30
|
-
}
|
|
31
|
-
exports.encodeRGB565 = encodeRGB565;
|