js: Reformat clusterizer source with Prettier

The test data is less readable now but such is life.
This commit is contained in:
Arseny Kapoulkine
2024-08-21 20:57:21 -07:00
parent 358747079b
commit ce29614613
4 changed files with 56 additions and 126 deletions
File diff suppressed because one or more lines are too long
+8 -1
View File
@@ -31,7 +31,14 @@ export const MeshoptClusterizer: {
supported: boolean;
ready: Promise<void>;
buildMeshlets: (indices: Uint32Array, vertex_positions: Float32Array, vertex_positions_stride: number, max_vertices: number, max_triangles: number, cone_weight?: number) => MeshletBuffers;
buildMeshlets: (
indices: Uint32Array,
vertex_positions: Float32Array,
vertex_positions_stride: number,
max_vertices: number,
max_triangles: number,
cone_weight?: number
) => MeshletBuffers;
computeClusterBounds: (indices: Uint32Array, vertex_positions: Float32Array, vertex_positions_stride: number) => Bounds;
computeMeshletBounds: (buffers: MeshletBuffers, vertex_positions: Float32Array, vertex_positions_stride: number) => Bounds | Bounds[];
extractMeshlet: (buffers: MeshletBuffers, index: number) => Meshlet;
File diff suppressed because one or more lines are too long
+14 -39
View File
@@ -6,59 +6,34 @@ process.on('unhandledRejection', (error) => {
process.exit(1);
});
const cubeWithNormals = {
vertices: new Float32Array([
// n = (0, 0, 1)
-1.0, -1.0, 1.0, 0.0, 0.0, 1.0,
1.0, -1.0, 1.0, 0.0, 0.0, 1.0,
1.0, 1.0, 1.0, 0.0, 0.0, 1.0,
-1.0, 1.0, 1.0, 0.0, 0.0, 1.0,
-1.0, -1.0, 1.0, 0.0, 0.0, 1.0, 1.0, -1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 1.0, -1.0, 1.0, 1.0, 0.0, 0.0, 1.0,
// n = (0, 0, -1)
-1.0, 1.0, -1.0, 0.0, 0.0, -1.0,
1.0, 1.0, -1.0, 0.0, 0.0, -1.0,
1.0, -1.0, -1.0, 0.0, 0.0, -1.0,
-1.0, -1.0, -1.0, 0.0, 0.0, -1.0,
-1.0, 1.0, -1.0, 0.0, 0.0, -1.0, 1.0, 1.0, -1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, 0.0, -1.0, 0.0, -1.0, -1.0, -1.0, 0.0, -1.0, 0.0, 1.0, -1.0, -1.0, 0.0, -1.0, 0.0,
]),
indices: new Uint32Array([
// n = (0, 0, 1)
0, 1, 2,
2, 3, 0,
0, 1, 2, 2, 3, 0,
// n = (0, 0, -1)
4, 5, 6,
6, 7, 4,
4, 5, 6, 6, 7, 4,
// n = (1, 0, 0)
8, 9, 10,
10, 11, 8,
8, 9, 10, 10, 11, 8,
// n = (-1, 0, 0)
12, 13, 14,
14, 15, 12,
12, 13, 14, 14, 15, 12,
// n = (0, 1, 0)
16, 17, 18,
18, 19, 16,
16, 17, 18, 18, 19, 16,
// n = (0, -1, 0)
20, 21, 22,
22, 23, 20,
20, 21, 22, 22, 23, 20,
]),
vertexStride: 6, // in floats
};
@@ -94,7 +69,7 @@ const tests = {
const bounds = clusterizer.computeClusterBounds(
cubeWithNormals.indices.subarray(indexOffset, 6 + indexOffset),
cubeWithNormals.vertices,
cubeWithNormals.vertexStride,
cubeWithNormals.vertexStride
);
assert.deepStrictEqual(
new Int32Array([bounds.coneAxisX, bounds.coneAxisY, bounds.coneAxisZ]),
@@ -128,7 +103,7 @@ const tests = {
},
};
clusterizer.ready.then(_ => {
clusterizer.ready.then((_) => {
let passed = 0;
let failed = 0;