-
-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf(functions): Optimize remaps in join() operations. (#1242)
- Optimizes join() to use remapAttribute / remapIndices - Reduce allocations - Add benchmarks
- Loading branch information
1 parent
4adbe34
commit e9e618c
Showing
8 changed files
with
133 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { Document } from '@gltf-transform/core'; | ||
import { join } from '@gltf-transform/functions'; | ||
import { Task } from '../constants'; | ||
import { LOGGER, createTorusKnotPrimitive } from '../utils'; | ||
|
||
let _document: Document; | ||
|
||
export const tasks: Task[] = [ | ||
[ | ||
'join::sm', | ||
async () => { | ||
await _document.transform(join()); | ||
}, | ||
{ beforeEach: () => void (_document = createDocument(10, 64, 64)) }, // ~4000 vertices / prim | ||
], | ||
[ | ||
'join::md', | ||
async () => { | ||
await _document.transform(join()); | ||
}, | ||
{ beforeEach: () => void (_document = createDocument(4, 512, 512)) }, // ~250,000 vertices / prim | ||
], | ||
]; | ||
|
||
function createDocument(primCount: number, radialSegments: number, tubularSegments: number): Document { | ||
const document = new Document().setLogger(LOGGER); | ||
|
||
const scene = document.createScene(); | ||
for (let i = 0; i < primCount; i++) { | ||
const prim = createTorusKnotPrimitive(document, { radialSegments, tubularSegments }); | ||
const mesh = document.createMesh().addPrimitive(prim); | ||
const node = document.createNode().setMesh(mesh); | ||
scene.addChild(node); | ||
} | ||
|
||
return document; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters