@loaders.gl/math 3.4.11 → 3.4.12
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/package.json +4 -4
- 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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/math",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.12",
|
|
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": "3.4.
|
|
35
|
-
"@loaders.gl/loader-utils": "3.4.
|
|
34
|
+
"@loaders.gl/images": "3.4.12",
|
|
35
|
+
"@loaders.gl/loader-utils": "3.4.12",
|
|
36
36
|
"@math.gl/core": "^3.5.1"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "85254762ae3082f608a863291deef09f2b40c6cf"
|
|
39
39
|
}
|
|
@@ -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;
|
|
@@ -1,352 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// This file is derived from the Cesium code base under Apache 2 license
|
|
3
|
-
// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md
|
|
4
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
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 = void 0;
|
|
6
|
-
// Attribute compression and decompression functions.
|
|
7
|
-
const core_1 = require("@math.gl/core");
|
|
8
|
-
const assert_1 = require("../utils/assert");
|
|
9
|
-
const RIGHT_SHIFT = 1.0 / 256.0;
|
|
10
|
-
const LEFT_SHIFT = 256.0;
|
|
11
|
-
const scratchVector2 = new core_1.Vector2();
|
|
12
|
-
const scratchVector3 = new core_1.Vector3();
|
|
13
|
-
const scratchEncodeVector2 = new core_1.Vector2();
|
|
14
|
-
const octEncodeScratch = new core_1.Vector2();
|
|
15
|
-
const uint8ForceArray = new Uint8Array(1);
|
|
16
|
-
/**
|
|
17
|
-
* Force a value to Uint8
|
|
18
|
-
*
|
|
19
|
-
* @param value
|
|
20
|
-
* @returns
|
|
21
|
-
*/
|
|
22
|
-
function forceUint8(value) {
|
|
23
|
-
uint8ForceArray[0] = value;
|
|
24
|
-
return uint8ForceArray[0];
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Converts a SNORM value in the range [0, rangeMaximum] to a scalar in the range [-1.0, 1.0].
|
|
28
|
-
*
|
|
29
|
-
* @param value SNORM value in the range [0, rangeMaximum]
|
|
30
|
-
* @param [rangeMaximum=255] The maximum value in the SNORM range, 255 by default.
|
|
31
|
-
* @returns Scalar in the range [-1.0, 1.0].
|
|
32
|
-
*
|
|
33
|
-
* @see CesiumMath.toSNorm
|
|
34
|
-
*/
|
|
35
|
-
function fromSNorm(value, rangeMaximum = 255) {
|
|
36
|
-
return ((0, core_1.clamp)(value, 0.0, rangeMaximum) / rangeMaximum) * 2.0 - 1.0;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Converts a scalar value in the range [-1.0, 1.0] to a SNORM in the range [0, rangeMaximum].
|
|
40
|
-
*
|
|
41
|
-
* @param value The scalar value in the range [-1.0, 1.0]
|
|
42
|
-
* @param [rangeMaximum=255] The maximum value in the mapped range, 255 by default.
|
|
43
|
-
* @returns A SNORM value, where 0 maps to -1.0 and rangeMaximum maps to 1.0.
|
|
44
|
-
*
|
|
45
|
-
* @see CesiumMath.fromSNorm
|
|
46
|
-
*/
|
|
47
|
-
function toSNorm(value, rangeMaximum = 255) {
|
|
48
|
-
return Math.round(((0, core_1.clamp)(value, -1.0, 1.0) * 0.5 + 0.5) * rangeMaximum);
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Returns 1.0 if the given value is positive or zero, and -1.0 if it is negative.
|
|
52
|
-
* This is similar to `Math.sign` except that returns 1.0 instead of
|
|
53
|
-
* 0.0 when the input value is 0.0.
|
|
54
|
-
*
|
|
55
|
-
* @param value The value to return the sign of.
|
|
56
|
-
* @returns The sign of value.
|
|
57
|
-
*/
|
|
58
|
-
function signNotZero(value) {
|
|
59
|
-
return value < 0.0 ? -1.0 : 1.0;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Encodes a normalized vector into 2 SNORM values in the range of [0-rangeMax] following the 'oct' encoding.
|
|
63
|
-
*
|
|
64
|
-
* Oct encoding is a compact representation of unit length vectors.
|
|
65
|
-
* The 'oct' encoding is described in "A Survey of Efficient Representations of Independent Unit Vectors",
|
|
66
|
-
* Cigolle et al 2014: {@link http://jcgt.org/published/0003/02/01/}
|
|
67
|
-
*
|
|
68
|
-
* @param vector The normalized vector to be compressed into 2 component 'oct' encoding.
|
|
69
|
-
* @param result The 2 component oct-encoded unit length vector.
|
|
70
|
-
* @param rangeMax The maximum value of the SNORM range. The encoded vector is stored in log2(rangeMax+1) bits.
|
|
71
|
-
* @returns The 2 component oct-encoded unit length vector.
|
|
72
|
-
*
|
|
73
|
-
* @exception vector must be normalized.
|
|
74
|
-
*
|
|
75
|
-
* @see octDecodeInRange
|
|
76
|
-
*/
|
|
77
|
-
function octEncodeInRange(vector, rangeMax, result) {
|
|
78
|
-
(0, assert_1.assert)(vector);
|
|
79
|
-
(0, assert_1.assert)(result);
|
|
80
|
-
const vector3 = scratchVector3.from(vector);
|
|
81
|
-
(0, assert_1.assert)(Math.abs(vector3.magnitudeSquared() - 1.0) <= core_1._MathUtils.EPSILON6);
|
|
82
|
-
result.x = vector.x / (Math.abs(vector.x) + Math.abs(vector.y) + Math.abs(vector.z));
|
|
83
|
-
result.y = vector.y / (Math.abs(vector.x) + Math.abs(vector.y) + Math.abs(vector.z));
|
|
84
|
-
if (vector.z < 0) {
|
|
85
|
-
const x = result.x;
|
|
86
|
-
const y = result.y;
|
|
87
|
-
result.x = (1.0 - Math.abs(y)) * signNotZero(x);
|
|
88
|
-
result.y = (1.0 - Math.abs(x)) * signNotZero(y);
|
|
89
|
-
}
|
|
90
|
-
result.x = toSNorm(result.x, rangeMax);
|
|
91
|
-
result.y = toSNorm(result.y, rangeMax);
|
|
92
|
-
return result;
|
|
93
|
-
}
|
|
94
|
-
exports.octEncodeInRange = octEncodeInRange;
|
|
95
|
-
/**
|
|
96
|
-
* Encodes a normalized vector into 2 SNORM values in the range of [0-255] following the 'oct' encoding.
|
|
97
|
-
*
|
|
98
|
-
* @param vector The normalized vector to be compressed into 2 byte 'oct' encoding.
|
|
99
|
-
* @param result The 2 byte oct-encoded unit length vector.
|
|
100
|
-
* @returns he 2 byte oct-encoded unit length vector.
|
|
101
|
-
*
|
|
102
|
-
* @exception vector must be normalized.
|
|
103
|
-
*
|
|
104
|
-
* @see octEncodeInRange
|
|
105
|
-
* @see octDecode
|
|
106
|
-
*/
|
|
107
|
-
function octEncode(vector, result) {
|
|
108
|
-
return octEncodeInRange(vector, 255, result);
|
|
109
|
-
}
|
|
110
|
-
exports.octEncode = octEncode;
|
|
111
|
-
/**
|
|
112
|
-
* Encodes a normalized vector into 4-byte vector
|
|
113
|
-
* @param vector The normalized vector to be compressed into 4 byte 'oct' encoding.
|
|
114
|
-
* @param result The 4 byte oct-encoded unit length vector.
|
|
115
|
-
* @returns The 4 byte oct-encoded unit length vector.
|
|
116
|
-
*
|
|
117
|
-
* @exception vector must be normalized.
|
|
118
|
-
*
|
|
119
|
-
* @see octEncodeInRange
|
|
120
|
-
* @see octDecodeFromVector4
|
|
121
|
-
*/
|
|
122
|
-
function octEncodeToVector4(vector, result) {
|
|
123
|
-
octEncodeInRange(vector, 65535, octEncodeScratch);
|
|
124
|
-
result.x = forceUint8(octEncodeScratch.x * RIGHT_SHIFT);
|
|
125
|
-
result.y = forceUint8(octEncodeScratch.x);
|
|
126
|
-
result.z = forceUint8(octEncodeScratch.y * RIGHT_SHIFT);
|
|
127
|
-
result.w = forceUint8(octEncodeScratch.y);
|
|
128
|
-
return result;
|
|
129
|
-
}
|
|
130
|
-
exports.octEncodeToVector4 = octEncodeToVector4;
|
|
131
|
-
/**
|
|
132
|
-
* Decodes a unit-length vector in 'oct' encoding to a normalized 3-component vector.
|
|
133
|
-
*
|
|
134
|
-
* @param x The x component of the oct-encoded unit length vector.
|
|
135
|
-
* @param y The y component of the oct-encoded unit length vector.
|
|
136
|
-
* @param rangeMax The maximum value of the SNORM range. The encoded vector is stored in log2(rangeMax+1) bits.
|
|
137
|
-
* @param result The decoded and normalized vector
|
|
138
|
-
* @returns The decoded and normalized vector.
|
|
139
|
-
*
|
|
140
|
-
* @exception x and y must be unsigned normalized integers between 0 and rangeMax.
|
|
141
|
-
*
|
|
142
|
-
* @see octEncodeInRange
|
|
143
|
-
*/
|
|
144
|
-
function octDecodeInRange(x, y, rangeMax, result) {
|
|
145
|
-
(0, assert_1.assert)(result);
|
|
146
|
-
if (x < 0 || x > rangeMax || y < 0 || y > rangeMax) {
|
|
147
|
-
throw new Error(`x and y must be unsigned normalized integers between 0 and ${rangeMax}`);
|
|
148
|
-
}
|
|
149
|
-
result.x = fromSNorm(x, rangeMax);
|
|
150
|
-
result.y = fromSNorm(y, rangeMax);
|
|
151
|
-
result.z = 1.0 - (Math.abs(result.x) + Math.abs(result.y));
|
|
152
|
-
if (result.z < 0.0) {
|
|
153
|
-
const oldVX = result.x;
|
|
154
|
-
result.x = (1.0 - Math.abs(result.y)) * signNotZero(oldVX);
|
|
155
|
-
result.y = (1.0 - Math.abs(oldVX)) * signNotZero(result.y);
|
|
156
|
-
}
|
|
157
|
-
return result.normalize();
|
|
158
|
-
}
|
|
159
|
-
exports.octDecodeInRange = octDecodeInRange;
|
|
160
|
-
/**
|
|
161
|
-
* Decodes a unit-length vector in 2 byte 'oct' encoding to a normalized 3-component vector.
|
|
162
|
-
*
|
|
163
|
-
* @param x The x component of the oct-encoded unit length vector.
|
|
164
|
-
* @param y The y component of the oct-encoded unit length vector.
|
|
165
|
-
* @param result The decoded and normalized vector.
|
|
166
|
-
* @returns he decoded and normalized vector.
|
|
167
|
-
*
|
|
168
|
-
* @exception x and y must be an unsigned normalized integer between 0 and 255.
|
|
169
|
-
*
|
|
170
|
-
* @see octDecodeInRange
|
|
171
|
-
*/
|
|
172
|
-
function octDecode(x, y, result) {
|
|
173
|
-
return octDecodeInRange(x, y, 255, result);
|
|
174
|
-
}
|
|
175
|
-
exports.octDecode = octDecode;
|
|
176
|
-
/**
|
|
177
|
-
* Decodes a unit-length vector in 4 byte 'oct' encoding to a normalized 3-component vector.
|
|
178
|
-
*
|
|
179
|
-
* @param encoded The oct-encoded unit length vector.
|
|
180
|
-
* @param esult The decoded and normalized vector.
|
|
181
|
-
* @returns The decoded and normalized vector.
|
|
182
|
-
*
|
|
183
|
-
* @exception x, y, z, and w must be unsigned normalized integers between 0 and 255.
|
|
184
|
-
*
|
|
185
|
-
* @see octDecodeInRange
|
|
186
|
-
* @see octEncodeToVector4
|
|
187
|
-
*/
|
|
188
|
-
function octDecodeFromVector4(encoded, result) {
|
|
189
|
-
(0, assert_1.assert)(encoded);
|
|
190
|
-
(0, assert_1.assert)(result);
|
|
191
|
-
const x = encoded.x;
|
|
192
|
-
const y = encoded.y;
|
|
193
|
-
const z = encoded.z;
|
|
194
|
-
const w = encoded.w;
|
|
195
|
-
if (x < 0 || x > 255 || y < 0 || y > 255 || z < 0 || z > 255 || w < 0 || w > 255) {
|
|
196
|
-
throw new Error('x, y, z, and w must be unsigned normalized integers between 0 and 255');
|
|
197
|
-
}
|
|
198
|
-
const xOct16 = x * LEFT_SHIFT + y;
|
|
199
|
-
const yOct16 = z * LEFT_SHIFT + w;
|
|
200
|
-
return octDecodeInRange(xOct16, yOct16, 65535, result);
|
|
201
|
-
}
|
|
202
|
-
exports.octDecodeFromVector4 = octDecodeFromVector4;
|
|
203
|
-
/**
|
|
204
|
-
* Packs an oct encoded vector into a single floating-point number.
|
|
205
|
-
*
|
|
206
|
-
* @param encoded The oct encoded vector.
|
|
207
|
-
* @returns The oct encoded vector packed into a single float.
|
|
208
|
-
*
|
|
209
|
-
*/
|
|
210
|
-
function octPackFloat(encoded) {
|
|
211
|
-
const vector2 = scratchVector2.from(encoded);
|
|
212
|
-
return 256.0 * vector2.x + vector2.y;
|
|
213
|
-
}
|
|
214
|
-
exports.octPackFloat = octPackFloat;
|
|
215
|
-
/**
|
|
216
|
-
* Encodes a normalized vector into 2 SNORM values in the range of [0-255] following the 'oct' encoding and
|
|
217
|
-
* stores those values in a single float-point number.
|
|
218
|
-
*
|
|
219
|
-
* @param vector The normalized vector to be compressed into 2 byte 'oct' encoding.
|
|
220
|
-
* @returns The 2 byte oct-encoded unit length vector.
|
|
221
|
-
*
|
|
222
|
-
* @exception vector must be normalized.
|
|
223
|
-
*/
|
|
224
|
-
function octEncodeFloat(vector) {
|
|
225
|
-
octEncode(vector, scratchEncodeVector2);
|
|
226
|
-
return octPackFloat(scratchEncodeVector2);
|
|
227
|
-
}
|
|
228
|
-
exports.octEncodeFloat = octEncodeFloat;
|
|
229
|
-
/**
|
|
230
|
-
* Decodes a unit-length vector in 'oct' encoding packed in a floating-point number to a normalized 3-component vector.
|
|
231
|
-
*
|
|
232
|
-
* @param value The oct-encoded unit length vector stored as a single floating-point number.
|
|
233
|
-
* @param result The decoded and normalized vector
|
|
234
|
-
* @returns The decoded and normalized vector.
|
|
235
|
-
*
|
|
236
|
-
*/
|
|
237
|
-
function octDecodeFloat(value, result) {
|
|
238
|
-
(0, assert_1.assert)(Number.isFinite(value));
|
|
239
|
-
const temp = value / 256.0;
|
|
240
|
-
const x = Math.floor(temp);
|
|
241
|
-
const y = (temp - x) * 256.0;
|
|
242
|
-
return octDecode(x, y, result);
|
|
243
|
-
}
|
|
244
|
-
exports.octDecodeFloat = octDecodeFloat;
|
|
245
|
-
/**
|
|
246
|
-
* Encodes three normalized vectors into 6 SNORM values in the range of [0-255] following the 'oct' encoding and
|
|
247
|
-
* packs those into two floating-point numbers.
|
|
248
|
-
*
|
|
249
|
-
* @param v1 A normalized vector to be compressed.
|
|
250
|
-
* @param v2 A normalized vector to be compressed.
|
|
251
|
-
* @param v3 A normalized vector to be compressed.
|
|
252
|
-
* @param result The 'oct' encoded vectors packed into two floating-point numbers.
|
|
253
|
-
* @returns The 'oct' encoded vectors packed into two floating-point numbers.
|
|
254
|
-
*
|
|
255
|
-
*/
|
|
256
|
-
function octPack(v1, v2, v3, result) {
|
|
257
|
-
(0, assert_1.assert)(v1);
|
|
258
|
-
(0, assert_1.assert)(v2);
|
|
259
|
-
(0, assert_1.assert)(v3);
|
|
260
|
-
(0, assert_1.assert)(result);
|
|
261
|
-
const encoded1 = octEncodeFloat(v1);
|
|
262
|
-
const encoded2 = octEncodeFloat(v2);
|
|
263
|
-
const encoded3 = octEncode(v3, scratchEncodeVector2);
|
|
264
|
-
result.x = 65536.0 * encoded3.x + encoded1;
|
|
265
|
-
result.y = 65536.0 * encoded3.y + encoded2;
|
|
266
|
-
return result;
|
|
267
|
-
}
|
|
268
|
-
exports.octPack = octPack;
|
|
269
|
-
/**
|
|
270
|
-
* Decodes three unit-length vectors in 'oct' encoding packed into a floating-point number to a normalized 3-component vector.
|
|
271
|
-
*
|
|
272
|
-
* @param packed The three oct-encoded unit length vectors stored as two floating-point number.
|
|
273
|
-
* @param v1 One decoded and normalized vector.
|
|
274
|
-
* @param v2 One decoded and normalized vector.
|
|
275
|
-
* @param v3 One decoded and normalized vector.
|
|
276
|
-
*/
|
|
277
|
-
function octUnpack(packed, v1, v2, v3) {
|
|
278
|
-
let temp = packed.x / 65536.0;
|
|
279
|
-
const x = Math.floor(temp);
|
|
280
|
-
const encodedFloat1 = (temp - x) * 65536.0;
|
|
281
|
-
temp = packed.y / 65536.0;
|
|
282
|
-
const y = Math.floor(temp);
|
|
283
|
-
const encodedFloat2 = (temp - y) * 65536.0;
|
|
284
|
-
octDecodeFloat(encodedFloat1, v1);
|
|
285
|
-
octDecodeFloat(encodedFloat2, v2);
|
|
286
|
-
octDecode(x, y, v3);
|
|
287
|
-
}
|
|
288
|
-
exports.octUnpack = octUnpack;
|
|
289
|
-
/**
|
|
290
|
-
* Pack texture coordinates into a single float. The texture coordinates will only preserve 12 bits of precision.
|
|
291
|
-
*
|
|
292
|
-
* @param textureCoordinates The texture coordinates to compress. Both coordinates must be in the range 0.0-1.0.
|
|
293
|
-
* @returns The packed texture coordinates.
|
|
294
|
-
*
|
|
295
|
-
*/
|
|
296
|
-
function compressTextureCoordinates(textureCoordinates) {
|
|
297
|
-
// Move x and y to the range 0-4095;
|
|
298
|
-
const x = (textureCoordinates.x * 4095.0) | 0;
|
|
299
|
-
const y = (textureCoordinates.y * 4095.0) | 0;
|
|
300
|
-
return 4096.0 * x + y;
|
|
301
|
-
}
|
|
302
|
-
exports.compressTextureCoordinates = compressTextureCoordinates;
|
|
303
|
-
/**
|
|
304
|
-
* Decompresses texture coordinates that were packed into a single float.
|
|
305
|
-
*
|
|
306
|
-
* @param compressed The compressed texture coordinates.
|
|
307
|
-
* @param result The decompressed texture coordinates.
|
|
308
|
-
* @returns The modified result parameter.
|
|
309
|
-
*
|
|
310
|
-
*/
|
|
311
|
-
function decompressTextureCoordinates(compressed, result) {
|
|
312
|
-
const temp = compressed / 4096.0;
|
|
313
|
-
const xZeroTo4095 = Math.floor(temp);
|
|
314
|
-
result.x = xZeroTo4095 / 4095.0;
|
|
315
|
-
result.y = (compressed - xZeroTo4095 * 4096) / 4095;
|
|
316
|
-
return result;
|
|
317
|
-
}
|
|
318
|
-
exports.decompressTextureCoordinates = decompressTextureCoordinates;
|
|
319
|
-
/**
|
|
320
|
-
* Decodes delta and ZigZag encoded vertices. This modifies the buffers in place.
|
|
321
|
-
*
|
|
322
|
-
* @param uBuffer The buffer view of u values.
|
|
323
|
-
* @param vBuffer The buffer view of v values.
|
|
324
|
-
* @param [heightBuffer] The buffer view of height values.
|
|
325
|
-
*
|
|
326
|
-
* @link https://github.com/AnalyticalGraphicsInc/quantized-mesh|quantized-mesh-1.0 terrain format
|
|
327
|
-
*/
|
|
328
|
-
function zigZagDeltaDecode(uBuffer, vBuffer, heightBuffer) {
|
|
329
|
-
(0, assert_1.assert)(uBuffer);
|
|
330
|
-
(0, assert_1.assert)(vBuffer);
|
|
331
|
-
(0, assert_1.assert)(uBuffer.length === vBuffer.length);
|
|
332
|
-
if (heightBuffer) {
|
|
333
|
-
(0, assert_1.assert)(uBuffer.length === heightBuffer.length);
|
|
334
|
-
}
|
|
335
|
-
function zigZagDecode(value) {
|
|
336
|
-
return (value >> 1) ^ -(value & 1);
|
|
337
|
-
}
|
|
338
|
-
let u = 0;
|
|
339
|
-
let v = 0;
|
|
340
|
-
let height = 0;
|
|
341
|
-
for (let i = 0; i < uBuffer.length; ++i) {
|
|
342
|
-
u += zigZagDecode(uBuffer[i]);
|
|
343
|
-
v += zigZagDecode(vBuffer[i]);
|
|
344
|
-
uBuffer[i] = u;
|
|
345
|
-
vBuffer[i] = v;
|
|
346
|
-
if (heightBuffer) {
|
|
347
|
-
height += zigZagDecode(heightBuffer[i]);
|
|
348
|
-
heightBuffer[i] = height;
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
exports.zigZagDeltaDecode = zigZagDeltaDecode;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Subset of WebGL constants
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.GL = exports.GL_TYPE = exports.GL_PRIMITIVE_MODE = exports.GL_PRIMITIVE = void 0;
|
|
5
|
-
exports.GL_PRIMITIVE = {
|
|
6
|
-
POINTS: 0x0000,
|
|
7
|
-
LINES: 0x0001,
|
|
8
|
-
TRIANGLES: 0x0004 // Triangles. Each set of three vertices creates a separate triangle.
|
|
9
|
-
};
|
|
10
|
-
// Primitive modes
|
|
11
|
-
exports.GL_PRIMITIVE_MODE = {
|
|
12
|
-
POINTS: 0x0000,
|
|
13
|
-
LINES: 0x0001,
|
|
14
|
-
LINE_LOOP: 0x0002,
|
|
15
|
-
LINE_STRIP: 0x0003,
|
|
16
|
-
TRIANGLES: 0x0004,
|
|
17
|
-
TRIANGLE_STRIP: 0x0005,
|
|
18
|
-
TRIANGLE_FAN: 0x0006 // Triangles. A connected group of triangles.
|
|
19
|
-
// Each vertex connects to the previous and the first vertex in the fan.
|
|
20
|
-
};
|
|
21
|
-
exports.GL_TYPE = {
|
|
22
|
-
BYTE: 5120,
|
|
23
|
-
UNSIGNED_BYTE: 5121,
|
|
24
|
-
SHORT: 5122,
|
|
25
|
-
UNSIGNED_SHORT: 5123,
|
|
26
|
-
INT: 5124,
|
|
27
|
-
UNSIGNED_INT: 5125,
|
|
28
|
-
FLOAT: 5126,
|
|
29
|
-
DOUBLE: 5130
|
|
30
|
-
};
|
|
31
|
-
exports.GL = {
|
|
32
|
-
...exports.GL_PRIMITIVE_MODE,
|
|
33
|
-
...exports.GL_TYPE
|
|
34
|
-
};
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const constants_1 = require("../constants");
|
|
4
|
-
const GL_TYPE_TO_ARRAY_TYPE = {
|
|
5
|
-
[constants_1.GL_TYPE.DOUBLE]: Float64Array,
|
|
6
|
-
[constants_1.GL_TYPE.FLOAT]: Float32Array,
|
|
7
|
-
[constants_1.GL_TYPE.UNSIGNED_SHORT]: Uint16Array,
|
|
8
|
-
[constants_1.GL_TYPE.UNSIGNED_INT]: Uint32Array,
|
|
9
|
-
[constants_1.GL_TYPE.UNSIGNED_BYTE]: Uint8Array,
|
|
10
|
-
[constants_1.GL_TYPE.BYTE]: Int8Array,
|
|
11
|
-
[constants_1.GL_TYPE.SHORT]: Int16Array,
|
|
12
|
-
[constants_1.GL_TYPE.INT]: Int32Array
|
|
13
|
-
};
|
|
14
|
-
const NAME_TO_GL_TYPE = {
|
|
15
|
-
DOUBLE: constants_1.GL_TYPE.DOUBLE,
|
|
16
|
-
FLOAT: constants_1.GL_TYPE.FLOAT,
|
|
17
|
-
UNSIGNED_SHORT: constants_1.GL_TYPE.UNSIGNED_SHORT,
|
|
18
|
-
UNSIGNED_INT: constants_1.GL_TYPE.UNSIGNED_INT,
|
|
19
|
-
UNSIGNED_BYTE: constants_1.GL_TYPE.UNSIGNED_BYTE,
|
|
20
|
-
BYTE: constants_1.GL_TYPE.BYTE,
|
|
21
|
-
SHORT: constants_1.GL_TYPE.SHORT,
|
|
22
|
-
INT: constants_1.GL_TYPE.INT
|
|
23
|
-
};
|
|
24
|
-
const ERR_TYPE_CONVERSION = 'Failed to convert GL type';
|
|
25
|
-
// Converts TYPED ARRAYS to corresponding GL constant
|
|
26
|
-
// Used to auto deduce gl parameter types
|
|
27
|
-
class GLType {
|
|
28
|
-
// Signature: fromTypedArray(new Uint8Array())
|
|
29
|
-
// Signature: fromTypedArray(Uint8Array)
|
|
30
|
-
/**
|
|
31
|
-
* Returns the size, in bytes, of the corresponding datatype
|
|
32
|
-
* @param arrayOrType
|
|
33
|
-
* @returns glType a a string
|
|
34
|
-
*/
|
|
35
|
-
static fromTypedArray(arrayOrType) {
|
|
36
|
-
// If typed array, look up constructor
|
|
37
|
-
arrayOrType = ArrayBuffer.isView(arrayOrType) ? arrayOrType.constructor : arrayOrType;
|
|
38
|
-
for (const glType in GL_TYPE_TO_ARRAY_TYPE) {
|
|
39
|
-
const ArrayType = GL_TYPE_TO_ARRAY_TYPE[glType];
|
|
40
|
-
if (ArrayType === arrayOrType) {
|
|
41
|
-
return glType;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
throw new Error(ERR_TYPE_CONVERSION);
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Extracts name for glType from array NAME_TO_GL_TYPE
|
|
48
|
-
* @param name
|
|
49
|
-
* @returns glType as a number
|
|
50
|
-
*/
|
|
51
|
-
static fromName(name) {
|
|
52
|
-
const glType = NAME_TO_GL_TYPE[name];
|
|
53
|
-
if (!glType) {
|
|
54
|
-
throw new Error(ERR_TYPE_CONVERSION);
|
|
55
|
-
}
|
|
56
|
-
return glType;
|
|
57
|
-
}
|
|
58
|
-
// Converts GL constant to corresponding typed array type
|
|
59
|
-
// eslint-disable-next-line complexity
|
|
60
|
-
static getArrayType(glType) {
|
|
61
|
-
switch (glType) {
|
|
62
|
-
/*eslint-disable*/
|
|
63
|
-
// @ts-ignore
|
|
64
|
-
case constants_1.GL_TYPE.UNSIGNED_SHORT_5_6_5:
|
|
65
|
-
// @ts-ignore
|
|
66
|
-
case constants_1.GL_TYPE.UNSIGNED_SHORT_4_4_4_4:
|
|
67
|
-
// @ts-ignore
|
|
68
|
-
case constants_1.GL_TYPE.UNSIGNED_SHORT_5_5_5_1:
|
|
69
|
-
/* eslint-enable*/
|
|
70
|
-
return Uint16Array;
|
|
71
|
-
default:
|
|
72
|
-
const ArrayType = GL_TYPE_TO_ARRAY_TYPE[glType];
|
|
73
|
-
if (!ArrayType) {
|
|
74
|
-
throw new Error(ERR_TYPE_CONVERSION);
|
|
75
|
-
}
|
|
76
|
-
return ArrayType;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Returns the size in bytes of one element of the provided WebGL type
|
|
81
|
-
* @param glType
|
|
82
|
-
* @returns size of glType
|
|
83
|
-
*/
|
|
84
|
-
static getByteSize(glType) {
|
|
85
|
-
const ArrayType = GLType.getArrayType(glType);
|
|
86
|
-
return ArrayType.BYTES_PER_ELEMENT;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Returns `true` if `glType` is a valid WebGL data type.
|
|
90
|
-
* @param glType
|
|
91
|
-
* @returns boolean
|
|
92
|
-
*/
|
|
93
|
-
static validate(glType) {
|
|
94
|
-
return Boolean(GLType.getArrayType(glType));
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Creates a typed view of an array of bytes
|
|
98
|
-
* @param glType The type of typed array (ArrayBuffer view) to create
|
|
99
|
-
* @param buffer The buffer storage to use for the view.
|
|
100
|
-
* @param byteOffset The offset, in bytes, to the first element in the view
|
|
101
|
-
* @param length The number of elements in the view. Defaults to buffer length
|
|
102
|
-
* @returns A typed array view of the buffer
|
|
103
|
-
*/
|
|
104
|
-
static createTypedArray(glType, buffer, byteOffset = 0, length) {
|
|
105
|
-
if (length === undefined) {
|
|
106
|
-
length = (buffer.byteLength - byteOffset) / GLType.getByteSize(glType);
|
|
107
|
-
}
|
|
108
|
-
const ArrayType = GLType.getArrayType(glType);
|
|
109
|
-
return new ArrayType(buffer, byteOffset, length);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
exports.default = GLType;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/**
|
|
4
|
-
* Checking if it is geometry
|
|
5
|
-
* @param geometry
|
|
6
|
-
*/
|
|
7
|
-
function isGeometry(geometry) {
|
|
8
|
-
return (geometry &&
|
|
9
|
-
typeof geometry === 'object' &&
|
|
10
|
-
geometry.mode &&
|
|
11
|
-
geometry.attributes &&
|
|
12
|
-
typeof geometry.attributes === 'object');
|
|
13
|
-
}
|
|
14
|
-
exports.default = isGeometry;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.makeAttributeIterator = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Iterates over a single attribute
|
|
6
|
-
* NOTE: For performance, re-yields the same modified element
|
|
7
|
-
* @param param0
|
|
8
|
-
*/
|
|
9
|
-
function* makeAttributeIterator(values, size) {
|
|
10
|
-
const ArrayType = values.constructor;
|
|
11
|
-
const element = new ArrayType(size);
|
|
12
|
-
for (let i = 0; i < values.length; i += size) {
|
|
13
|
-
for (let j = 0; j < size; j++) {
|
|
14
|
-
element[j] = element[i + j];
|
|
15
|
-
}
|
|
16
|
-
yield element;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
exports.makeAttributeIterator = makeAttributeIterator;
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.makePrimitiveIterator = void 0;
|
|
4
|
-
const constants_1 = require("../constants");
|
|
5
|
-
const modes_1 = require("../primitives/modes");
|
|
6
|
-
const loader_utils_1 = require("@loaders.gl/loader-utils");
|
|
7
|
-
/**
|
|
8
|
-
* Will iterate over each primitive, expanding (dereferencing) indices
|
|
9
|
-
* @param indices
|
|
10
|
-
* @param attributes
|
|
11
|
-
* @param mode
|
|
12
|
-
* @param start
|
|
13
|
-
* @param end
|
|
14
|
-
*/
|
|
15
|
-
// eslint-disable-next-line complexity
|
|
16
|
-
function* makePrimitiveIterator(indices, attributes = {}, mode, start = 0, end) {
|
|
17
|
-
// support indices being an object with a values array
|
|
18
|
-
if (indices) {
|
|
19
|
-
indices = indices.values || indices.value || indices;
|
|
20
|
-
}
|
|
21
|
-
// Autodeduce length from indices
|
|
22
|
-
if (end === undefined) {
|
|
23
|
-
end = indices ? indices.length : start;
|
|
24
|
-
}
|
|
25
|
-
// iteration info
|
|
26
|
-
const info = {
|
|
27
|
-
attributes,
|
|
28
|
-
type: (0, modes_1.getPrimitiveModeType)(mode),
|
|
29
|
-
i1: 0,
|
|
30
|
-
i2: 0,
|
|
31
|
-
i3: 0
|
|
32
|
-
};
|
|
33
|
-
let i = start;
|
|
34
|
-
// @ts-ignore
|
|
35
|
-
while (i < end) {
|
|
36
|
-
switch (mode) {
|
|
37
|
-
case constants_1.GL.POINTS: // draw single points.
|
|
38
|
-
info.i1 = i;
|
|
39
|
-
i += 1;
|
|
40
|
-
break;
|
|
41
|
-
case constants_1.GL.LINES: // draw lines. Each set of two vertices is treated as a separate line segment.
|
|
42
|
-
info.i1 = i;
|
|
43
|
-
info.i2 = i + 1;
|
|
44
|
-
i += 2;
|
|
45
|
-
break;
|
|
46
|
-
case constants_1.GL.LINE_STRIP: // draw lines. Each vertex connects to the one after it.
|
|
47
|
-
info.i1 = i;
|
|
48
|
-
info.i2 = i + 1;
|
|
49
|
-
i += 1;
|
|
50
|
-
break;
|
|
51
|
-
case constants_1.GL.LINE_LOOP: // draw a connected group of line segments from the first vertex to the last
|
|
52
|
-
info.i1 = i;
|
|
53
|
-
info.i2 = i + 1;
|
|
54
|
-
i += 1;
|
|
55
|
-
break;
|
|
56
|
-
case constants_1.GL.TRIANGLES: // draw triangles. Each set of three vertices creates a separate triangle.
|
|
57
|
-
info.i1 = i;
|
|
58
|
-
info.i2 = i + 1;
|
|
59
|
-
info.i3 = i + 2;
|
|
60
|
-
i += 3;
|
|
61
|
-
break;
|
|
62
|
-
case constants_1.GL.TRIANGLE_STRIP: // draw a connected group of triangles.
|
|
63
|
-
info.i1 = i;
|
|
64
|
-
info.i2 = i + 1;
|
|
65
|
-
i += 1;
|
|
66
|
-
break;
|
|
67
|
-
case constants_1.GL.TRIANGLE_FAN: // draw a connected group of triangles.
|
|
68
|
-
info.i1 = 1;
|
|
69
|
-
info.i2 = i;
|
|
70
|
-
info.i3 = i + 1;
|
|
71
|
-
i += 1;
|
|
72
|
-
break;
|
|
73
|
-
default:
|
|
74
|
-
(0, loader_utils_1.assert)(false);
|
|
75
|
-
}
|
|
76
|
-
// if indices are present, lookup actual vertices in indices
|
|
77
|
-
if (indices) {
|
|
78
|
-
if ('i1' in info) {
|
|
79
|
-
info.i1 = indices[info.i1];
|
|
80
|
-
info.i2 = indices[info.i2];
|
|
81
|
-
info.i3 = indices[info.i3];
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
// @ts-ignore
|
|
85
|
-
yield info;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
exports.makePrimitiveIterator = makePrimitiveIterator;
|
|
@@ -1,71 +0,0 @@
|
|
|
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;
|
|
@@ -1,25 +0,0 @@
|
|
|
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;
|
|
@@ -1,14 +0,0 @@
|
|
|
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.js
DELETED
|
@@ -1,46 +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.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.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
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;
|