@loaders.gl/math 4.0.0-alpha.5 → 4.0.0-alpha.7
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 +46 -0
- package/dist/es5/geometry/attributes/compute-bounding-box.js.map +1 -0
- package/dist/es5/geometry/attributes/compute-bounding-sphere.js +2 -0
- package/dist/es5/geometry/attributes/compute-bounding-sphere.js.map +1 -0
- package/dist/es5/geometry/attributes/compute-tangents.js +2 -0
- package/dist/es5/geometry/attributes/compute-tangents.js.map +1 -0
- package/dist/es5/geometry/attributes/compute-vertex-normals.js +56 -0
- package/dist/es5/geometry/attributes/compute-vertex-normals.js.map +1 -0
- package/dist/es5/geometry/attributes/convert-to-non-indexed.js +43 -0
- package/dist/es5/geometry/attributes/convert-to-non-indexed.js.map +1 -0
- package/dist/es5/geometry/attributes/get-attribute-from-geometry.js +29 -0
- package/dist/es5/geometry/attributes/get-attribute-from-geometry.js.map +1 -0
- package/dist/es5/geometry/attributes/normalize.js +19 -0
- package/dist/es5/geometry/attributes/normalize.js.map +1 -0
- package/dist/es5/geometry/colors/rgb565.js +24 -0
- package/dist/es5/geometry/colors/rgb565.js.map +1 -0
- package/dist/es5/geometry/compression/attribute-compression.js +178 -0
- package/dist/es5/geometry/compression/attribute-compression.js.map +1 -0
- package/dist/es5/geometry/constants.js +40 -0
- package/dist/es5/geometry/constants.js.map +1 -0
- package/dist/es5/geometry/gl/gl-type.js +92 -0
- package/dist/es5/geometry/gl/gl-type.js.map +1 -0
- package/dist/es5/geometry/is-geometry.js +12 -0
- package/dist/es5/geometry/is-geometry.js.map +1 -0
- package/dist/es5/geometry/iterators/attribute-iterator.js +38 -0
- package/dist/es5/geometry/iterators/attribute-iterator.js.map +1 -0
- package/dist/es5/geometry/iterators/primitive-iterator.js +102 -0
- package/dist/es5/geometry/iterators/primitive-iterator.js.map +1 -0
- package/dist/es5/geometry/primitives/modes.js +56 -0
- package/dist/es5/geometry/primitives/modes.js.map +1 -0
- package/dist/es5/geometry/typed-arrays/typed-array-utils.js +24 -0
- package/dist/es5/geometry/typed-arrays/typed-array-utils.js.map +1 -0
- package/dist/es5/geometry/utils/assert.js +12 -0
- package/dist/es5/geometry/utils/assert.js.map +1 -0
- package/dist/es5/index.js +160 -0
- package/dist/es5/index.js.map +1 -0
- package/dist/es5/utils/assert.js +12 -0
- package/dist/es5/utils/assert.js.map +1 -0
- package/dist/esm/geometry/attributes/compute-bounding-box.js +28 -0
- package/dist/esm/geometry/attributes/compute-bounding-box.js.map +1 -0
- package/dist/esm/geometry/attributes/compute-bounding-sphere.js +2 -0
- package/dist/esm/geometry/attributes/compute-bounding-sphere.js.map +1 -0
- package/dist/esm/geometry/attributes/compute-tangents.js +2 -0
- package/dist/esm/geometry/attributes/compute-tangents.js.map +1 -0
- package/dist/esm/geometry/attributes/compute-vertex-normals.js +41 -0
- package/dist/esm/geometry/attributes/compute-vertex-normals.js.map +1 -0
- package/dist/esm/geometry/attributes/convert-to-non-indexed.js +27 -0
- package/dist/esm/geometry/attributes/convert-to-non-indexed.js.map +1 -0
- package/dist/esm/geometry/attributes/get-attribute-from-geometry.js +24 -0
- package/dist/esm/geometry/attributes/get-attribute-from-geometry.js.map +1 -0
- package/dist/esm/geometry/attributes/normalize.js +13 -0
- package/dist/esm/geometry/attributes/normalize.js.map +1 -0
- package/dist/esm/geometry/colors/rgb565.js +17 -0
- package/dist/esm/geometry/colors/rgb565.js.map +1 -0
- package/dist/esm/geometry/compression/attribute-compression.js +159 -0
- package/dist/esm/geometry/compression/attribute-compression.js.map +1 -0
- package/dist/esm/geometry/constants.js +29 -0
- package/dist/esm/geometry/constants.js.map +1 -0
- package/dist/esm/geometry/gl/gl-type.js +72 -0
- package/dist/esm/geometry/gl/gl-type.js.map +1 -0
- package/dist/esm/geometry/is-geometry.js +4 -0
- package/dist/esm/geometry/is-geometry.js.map +1 -0
- package/dist/esm/geometry/iterators/attribute-iterator.js +11 -0
- package/dist/esm/geometry/iterators/attribute-iterator.js.map +1 -0
- package/dist/esm/geometry/iterators/primitive-iterator.js +76 -0
- package/dist/esm/geometry/iterators/primitive-iterator.js.map +1 -0
- package/dist/esm/geometry/primitives/modes.js +48 -0
- package/dist/esm/geometry/primitives/modes.js.map +1 -0
- package/dist/esm/geometry/typed-arrays/typed-array-utils.js +18 -0
- package/dist/esm/geometry/typed-arrays/typed-array-utils.js.map +1 -0
- package/dist/esm/geometry/utils/assert.js +6 -0
- package/dist/esm/geometry/utils/assert.js.map +1 -0
- package/dist/esm/index.js +11 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/utils/assert.js +6 -0
- package/dist/esm/utils/assert.js.map +1 -0
- package/dist/geometry/attributes/compute-bounding-box.js +41 -27
- package/dist/geometry/attributes/compute-bounding-sphere.js +29 -1
- package/dist/geometry/attributes/compute-tangents.js +145 -1
- package/dist/geometry/attributes/compute-vertex-normals.d.ts +2 -2
- package/dist/geometry/attributes/compute-vertex-normals.d.ts.map +1 -1
- package/dist/geometry/attributes/compute-vertex-normals.js +47 -42
- package/dist/geometry/attributes/convert-to-non-indexed.js +31 -30
- package/dist/geometry/attributes/get-attribute-from-geometry.js +33 -26
- package/dist/geometry/attributes/normalize.js +19 -11
- package/dist/geometry/colors/rgb565.js +29 -14
- package/dist/geometry/compression/attribute-compression.d.ts +7 -1
- package/dist/geometry/compression/attribute-compression.d.ts.map +1 -1
- package/dist/geometry/compression/attribute-compression.js +339 -162
- package/dist/geometry/constants.d.ts +1 -1
- package/dist/geometry/constants.d.ts.map +1 -1
- package/dist/geometry/constants.js +30 -24
- package/dist/geometry/gl/gl-type.d.ts +1 -1
- package/dist/geometry/gl/gl-type.d.ts.map +1 -1
- package/dist/geometry/gl/gl-type.js +101 -74
- package/dist/geometry/is-geometry.js +13 -3
- package/dist/geometry/iterators/attribute-iterator.js +17 -11
- package/dist/geometry/iterators/primitive-iterator.js +85 -79
- package/dist/geometry/primitives/modes.js +67 -54
- package/dist/geometry/typed-arrays/typed-array-utils.js +23 -20
- package/dist/geometry/utils/assert.js +13 -5
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +46 -11
- package/dist/utils/assert.js +11 -5
- package/package.json +6 -6
- package/src/geometry/attributes/compute-vertex-normals.ts +1 -1
- package/src/geometry/compression/attribute-compression.ts +7 -1
- package/src/geometry/gl/gl-type.ts +1 -1
- package/src/index.ts +12 -0
- package/dist/geometry/attributes/compute-bounding-box.js.map +0 -1
- package/dist/geometry/attributes/compute-bounding-sphere.js.map +0 -1
- package/dist/geometry/attributes/compute-tangents.js.map +0 -1
- package/dist/geometry/attributes/compute-vertex-normals.js.map +0 -1
- package/dist/geometry/attributes/convert-to-non-indexed.js.map +0 -1
- package/dist/geometry/attributes/get-attribute-from-geometry.js.map +0 -1
- package/dist/geometry/attributes/normalize.js.map +0 -1
- package/dist/geometry/colors/rgb565.js.map +0 -1
- package/dist/geometry/compression/attribute-compression.js.map +0 -1
- package/dist/geometry/constants.js.map +0 -1
- package/dist/geometry/gl/gl-type.js.map +0 -1
- package/dist/geometry/is-geometry.js.map +0 -1
- package/dist/geometry/iterators/attribute-iterator.js.map +0 -1
- package/dist/geometry/iterators/primitive-iterator.js.map +0 -1
- package/dist/geometry/primitives/modes.js.map +0 -1
- package/dist/geometry/typed-arrays/typed-array-utils.js.map +0 -1
- package/dist/geometry/types.d.ts +0 -13
- package/dist/geometry/types.d.ts.map +0 -1
- package/dist/geometry/types.js +0 -2
- package/dist/geometry/types.js.map +0 -1
- package/dist/geometry/utils/assert.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/utils/assert.js.map +0 -1
- package/src/geometry/types.ts +0 -25
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { GL } from '../constants';
|
|
2
|
+
export function getPrimitiveModeType(mode) {
|
|
3
|
+
switch (mode) {
|
|
4
|
+
case GL.POINTS:
|
|
5
|
+
return GL.POINTS;
|
|
6
|
+
case GL.LINES:
|
|
7
|
+
case GL.LINE_STRIP:
|
|
8
|
+
case GL.LINE_LOOP:
|
|
9
|
+
return GL.LINES;
|
|
10
|
+
case GL.TRIANGLES:
|
|
11
|
+
case GL.TRIANGLE_STRIP:
|
|
12
|
+
case GL.TRIANGLE_FAN:
|
|
13
|
+
return GL.TRIANGLES;
|
|
14
|
+
default:
|
|
15
|
+
throw new Error('Unknown primitive mode');
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export function isPrimitiveModeExpandable(mode) {
|
|
19
|
+
switch (mode) {
|
|
20
|
+
case GL.LINE_STRIP:
|
|
21
|
+
case GL.LINE_LOOP:
|
|
22
|
+
case GL.TRIANGLE_STRIP:
|
|
23
|
+
case GL.TRIANGLE_FAN:
|
|
24
|
+
return true;
|
|
25
|
+
default:
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export function getPrimitiveModeExpandedLength(mode, length) {
|
|
30
|
+
switch (mode) {
|
|
31
|
+
case GL.POINTS:
|
|
32
|
+
return length;
|
|
33
|
+
case GL.LINES:
|
|
34
|
+
return length;
|
|
35
|
+
case GL.LINE_STRIP:
|
|
36
|
+
return length;
|
|
37
|
+
case GL.LINE_LOOP:
|
|
38
|
+
return length + 1;
|
|
39
|
+
case GL.TRIANGLES:
|
|
40
|
+
return length;
|
|
41
|
+
case GL.TRIANGLE_STRIP:
|
|
42
|
+
case GL.TRIANGLE_FAN:
|
|
43
|
+
return (length - 2) * 3;
|
|
44
|
+
default:
|
|
45
|
+
throw new Error('Unknown length');
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=modes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modes.js","names":["GL","getPrimitiveModeType","mode","POINTS","LINES","LINE_STRIP","LINE_LOOP","TRIANGLES","TRIANGLE_STRIP","TRIANGLE_FAN","Error","isPrimitiveModeExpandable","getPrimitiveModeExpandedLength","length"],"sources":["../../../../src/geometry/primitives/modes.ts"],"sourcesContent":["import {GL} from '../constants';\n\n/**\n * Different methods of working with geometries depending on glType\n /**\n\n/**\n * @param mode\n * @returns draw points | lines | triangles\n */\nexport function getPrimitiveModeType(mode?: number): number {\n switch (mode) {\n case GL.POINTS: // draw single points.\n return GL.POINTS;\n case GL.LINES: // draw lines. Each set of two vertices is treated as a separate line segment.\n case GL.LINE_STRIP: // draw lines. Each vertex connects to the one after it.\n case GL.LINE_LOOP: // draw a connected group of line segments from the first vertex to the last\n return GL.LINES;\n case GL.TRIANGLES:\n case GL.TRIANGLE_STRIP:\n case GL.TRIANGLE_FAN: // draw a connected group of triangles.\n return GL.TRIANGLES;\n default:\n throw new Error('Unknown primitive mode');\n }\n}\n/**\n * @param mode\n * @returns true | false\n */\nexport function isPrimitiveModeExpandable(mode: number): boolean {\n switch (mode) {\n case GL.LINE_STRIP: // draw lines. Each vertex connects to the one after it.\n case GL.LINE_LOOP: // draw a connected group of line segments from the first vertex to the last\n case GL.TRIANGLE_STRIP: // draw a connected group of triangles.\n case GL.TRIANGLE_FAN: // draw a connected group of triangles.\n return true;\n default:\n return false;\n }\n}\n/**\n * Returns new length depends on glType\n * @param mode\n * @param length\n * @returns new length\n */\nexport function getPrimitiveModeExpandedLength(mode: number, length: number): number {\n switch (mode) {\n case GL.POINTS: // draw single points.\n return length;\n case GL.LINES: // draw lines. Each set of two vertices is treated as a separate line segment.\n return length;\n case GL.LINE_STRIP: // draw lines. Each vertex connects to the one after it.\n return length;\n case GL.LINE_LOOP: // draw a connected group of line segments from the first vertex to the last\n return length + 1;\n case GL.TRIANGLES: // draw triangles. Each set of three vertices creates a separate triangle.\n return length;\n case GL.TRIANGLE_STRIP: // draw a connected group of triangles.\n case GL.TRIANGLE_FAN: // draw a connected group of triangles.\n return (length - 2) * 3;\n default:\n throw new Error('Unknown length');\n }\n}\n"],"mappings":"AAAA,SAAQA,EAAE,QAAO,cAAc;AAU/B,OAAO,SAASC,oBAAoBA,CAACC,IAAa,EAAU;EAC1D,QAAQA,IAAI;IACV,KAAKF,EAAE,CAACG,MAAM;MACZ,OAAOH,EAAE,CAACG,MAAM;IAClB,KAAKH,EAAE,CAACI,KAAK;IACb,KAAKJ,EAAE,CAACK,UAAU;IAClB,KAAKL,EAAE,CAACM,SAAS;MACf,OAAON,EAAE,CAACI,KAAK;IACjB,KAAKJ,EAAE,CAACO,SAAS;IACjB,KAAKP,EAAE,CAACQ,cAAc;IACtB,KAAKR,EAAE,CAACS,YAAY;MAClB,OAAOT,EAAE,CAACO,SAAS;IACrB;MACE,MAAM,IAAIG,KAAK,CAAC,wBAAwB,CAAC;EAC7C;AACF;AAKA,OAAO,SAASC,yBAAyBA,CAACT,IAAY,EAAW;EAC/D,QAAQA,IAAI;IACV,KAAKF,EAAE,CAACK,UAAU;IAClB,KAAKL,EAAE,CAACM,SAAS;IACjB,KAAKN,EAAE,CAACQ,cAAc;IACtB,KAAKR,EAAE,CAACS,YAAY;MAClB,OAAO,IAAI;IACb;MACE,OAAO,KAAK;EAChB;AACF;AAOA,OAAO,SAASG,8BAA8BA,CAACV,IAAY,EAAEW,MAAc,EAAU;EACnF,QAAQX,IAAI;IACV,KAAKF,EAAE,CAACG,MAAM;MACZ,OAAOU,MAAM;IACf,KAAKb,EAAE,CAACI,KAAK;MACX,OAAOS,MAAM;IACf,KAAKb,EAAE,CAACK,UAAU;MAChB,OAAOQ,MAAM;IACf,KAAKb,EAAE,CAACM,SAAS;MACf,OAAOO,MAAM,GAAG,CAAC;IACnB,KAAKb,EAAE,CAACO,SAAS;MACf,OAAOM,MAAM;IACf,KAAKb,EAAE,CAACQ,cAAc;IACtB,KAAKR,EAAE,CAACS,YAAY;MAClB,OAAO,CAACI,MAAM,GAAG,CAAC,IAAI,CAAC;IACzB;MACE,MAAM,IAAIH,KAAK,CAAC,gBAAgB,CAAC;EACrC;AACF"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export function concatTypedArrays() {
|
|
2
|
+
let arrays = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
3
|
+
let byteLength = 0;
|
|
4
|
+
for (let i = 0; i < arrays.length; ++i) {
|
|
5
|
+
byteLength += arrays[i].byteLength;
|
|
6
|
+
}
|
|
7
|
+
const buffer = new Uint8Array(byteLength);
|
|
8
|
+
let byteOffset = 0;
|
|
9
|
+
for (let i = 0; i < arrays.length; ++i) {
|
|
10
|
+
const data = new Uint8Array(arrays[i].buffer);
|
|
11
|
+
byteLength = data.length;
|
|
12
|
+
for (let j = 0; j < byteLength; ++j) {
|
|
13
|
+
buffer[byteOffset++] = data[j];
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return buffer;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=typed-array-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typed-array-utils.js","names":["concatTypedArrays","arrays","arguments","length","undefined","byteLength","i","buffer","Uint8Array","byteOffset","data","j"],"sources":["../../../../src/geometry/typed-arrays/typed-array-utils.ts"],"sourcesContent":["/**\n * Concats typed arrays\n * @param arrays\n * @returns new Uint8Array\n */\nexport function concatTypedArrays(arrays: any = []): Uint8Array {\n let byteLength = 0;\n for (let i = 0; i < arrays.length; ++i) {\n byteLength += arrays[i].byteLength;\n }\n const buffer = new Uint8Array(byteLength);\n\n let byteOffset = 0;\n for (let i = 0; i < arrays.length; ++i) {\n const data = new Uint8Array(arrays[i].buffer);\n byteLength = data.length;\n for (let j = 0; j < byteLength; ++j) {\n buffer[byteOffset++] = data[j];\n }\n }\n return buffer;\n}\n"],"mappings":"AAKA,OAAO,SAASA,iBAAiBA,CAAA,EAA+B;EAAA,IAA9BC,MAAW,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,EAAE;EAChD,IAAIG,UAAU,GAAG,CAAC;EAClB,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGL,MAAM,CAACE,MAAM,EAAE,EAAEG,CAAC,EAAE;IACtCD,UAAU,IAAIJ,MAAM,CAACK,CAAC,CAAC,CAACD,UAAU;EACpC;EACA,MAAME,MAAM,GAAG,IAAIC,UAAU,CAACH,UAAU,CAAC;EAEzC,IAAII,UAAU,GAAG,CAAC;EAClB,KAAK,IAAIH,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGL,MAAM,CAACE,MAAM,EAAE,EAAEG,CAAC,EAAE;IACtC,MAAMI,IAAI,GAAG,IAAIF,UAAU,CAACP,MAAM,CAACK,CAAC,CAAC,CAACC,MAAM,CAAC;IAC7CF,UAAU,GAAGK,IAAI,CAACP,MAAM;IACxB,KAAK,IAAIQ,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGN,UAAU,EAAE,EAAEM,CAAC,EAAE;MACnCJ,MAAM,CAACE,UAAU,EAAE,CAAC,GAAGC,IAAI,CAACC,CAAC,CAAC;IAChC;EACF;EACA,OAAOJ,MAAM;AACf"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assert.js","names":["assert","condition","message","Error","concat"],"sources":["../../../../src/geometry/utils/assert.ts"],"sourcesContent":["/**\n * Throws error message\n * @param condition checks if an attribute equal to condition\n * @param message error message\n */\nexport function assert(condition: any, message?: any): void {\n if (!condition) {\n throw new Error(`math.gl assertion failed. ${message}`);\n }\n}\n"],"mappings":"AAKA,OAAO,SAASA,MAAMA,CAACC,SAAc,EAAEC,OAAa,EAAQ;EAC1D,IAAI,CAACD,SAAS,EAAE;IACd,MAAM,IAAIE,KAAK,8BAAAC,MAAA,CAA8BF,OAAO,CAAE,CAAC;EACzD;AACF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { GL } from './geometry/constants';
|
|
2
|
+
export { GL_TYPE } from './geometry/constants';
|
|
3
|
+
export { default as GLType } from './geometry/gl/gl-type';
|
|
4
|
+
export { default as isGeometry } from './geometry/is-geometry';
|
|
5
|
+
export { makeAttributeIterator } from './geometry/iterators/attribute-iterator';
|
|
6
|
+
export { makePrimitiveIterator } from './geometry/iterators/primitive-iterator';
|
|
7
|
+
export { computeVertexNormals } from './geometry/attributes/compute-vertex-normals';
|
|
8
|
+
export { encodeRGB565, decodeRGB565 } from './geometry/colors/rgb565';
|
|
9
|
+
export { concatTypedArrays } from './geometry/typed-arrays/typed-array-utils';
|
|
10
|
+
export { octEncodeInRange, octEncode, octEncodeToVector4, octDecodeInRange, octDecode, octDecodeFromVector4, octPackFloat, octEncodeFloat, octDecodeFloat, octPack, octUnpack, compressTextureCoordinates, decompressTextureCoordinates, zigZagDeltaDecode } from './geometry/compression/attribute-compression';
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assert.js","names":["assert","condition","message","Error"],"sources":["../../../src/utils/assert.ts"],"sourcesContent":["// Replacement for the external assert method to reduce bundle size\n// Note: We don't use the second \"message\" argument in calling code,\n// so no need to support it here\nexport function assert(condition: Boolean, message?: string): void {\n if (!condition) {\n throw new Error(message || '3d-tile loader: assertion failed.');\n }\n}\n"],"mappings":"AAGA,OAAO,SAASA,MAAMA,CAACC,SAAkB,EAAEC,OAAgB,EAAQ;EACjE,IAAI,CAACD,SAAS,EAAE;IACd,MAAM,IAAIE,KAAK,CAACD,OAAO,IAAI,mCAAmC,CAAC;EACjE;AACF"}
|
|
@@ -1,30 +1,44 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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;
|
|
25
35
|
}
|
|
26
|
-
|
|
36
|
+
exports.computeBoundingBox = computeBoundingBox;
|
|
27
37
|
function validateBoundingBox(boundingBox) {
|
|
28
|
-
|
|
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]));
|
|
29
44
|
}
|
|
30
|
-
//# sourceMappingURL=compute-bounding-box.js.map
|
|
@@ -1,2 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
import {getPositions} from './get-attribute-from-geometry.js';
|
|
1
5
|
|
|
2
|
-
|
|
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,2 +1,146 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
export function computeTangents({indices, positions, normals, uvs}) {
|
|
4
|
+
var index = geometry.index;
|
|
5
|
+
var attributes = geometry.attributes;
|
|
1
6
|
|
|
2
|
-
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compute-vertex-normals.d.ts","sourceRoot":"","sources":["../../../src/geometry/attributes/compute-vertex-normals.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"compute-vertex-normals.d.ts","sourceRoot":"","sources":["../../../src/geometry/attributes/compute-vertex-normals.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AAQ9C,KAAK,QAAQ,GAAG;IACd,IAAI,EAAE,GAAG,CAAC;IACV,OAAO,CAAC,EAAE;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,UAAU,CAAA;KAAC,CAAC;IAC7C,UAAU,CAAC,EAAE,EAAE,CAAC;CACjB,CAAC;AACF;;;;GAIG;AAEH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,QAAQ,GAAG,YAAY,CAyCrE"}
|
|
@@ -1,43 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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;
|
|
42
47
|
}
|
|
43
|
-
|
|
48
|
+
exports.computeVertexNormals = computeVertexNormals;
|
|
@@ -1,32 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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));
|
|
21
27
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
for (const group of this.groups) {
|
|
27
|
-
geometry2.addGroup(group.start, group.count, group.materialIndex);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return geometry2;
|
|
28
|
+
for (const group of this.groups) {
|
|
29
|
+
geometry2.addGroup(group.start, group.count, group.materialIndex);
|
|
30
|
+
}
|
|
31
|
+
return geometry2;
|
|
31
32
|
}
|
|
32
|
-
|
|
33
|
+
exports.convertBuffersToNonIndexed = convertBuffersToNonIndexed;
|
|
@@ -1,27 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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);
|
|
26
33
|
}
|
|
27
|
-
|
|
34
|
+
exports.getPositions = getPositions;
|