-
-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(functions): Remove side effects of no-op meshopt() and quantize()…
… calls (#1438)
- Loading branch information
1 parent
8a67c1d
commit f7f9228
Showing
4 changed files
with
91 additions
and
10 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
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,27 @@ | ||
import test from 'ava'; | ||
import { Document } from '@gltf-transform/core'; | ||
import { meshopt } from '@gltf-transform/functions'; | ||
import { createTorusKnotPrimitive, logger } from '@gltf-transform/test-utils'; | ||
import { MeshoptEncoder } from 'meshoptimizer'; | ||
|
||
test('basic', async (t) => { | ||
const document = new Document().setLogger(logger); | ||
document.createMesh().addPrimitive(createTorusKnotPrimitive(document, { tubularSegments: 6 })); | ||
|
||
await document.transform(meshopt({ encoder: MeshoptEncoder })); | ||
|
||
t.true(hasMeshopt(document), 'adds extension'); | ||
}); | ||
|
||
test('noop', async (t) => { | ||
const document = new Document().setLogger(logger); | ||
await document.transform(meshopt({ encoder: MeshoptEncoder })); | ||
|
||
t.false(hasMeshopt(document), 'skips extension if no accessors found'); | ||
}); | ||
|
||
const hasMeshopt = (document: Document): boolean => | ||
document | ||
.getRoot() | ||
.listExtensionsUsed() | ||
.some((ext) => ext.extensionName === 'EXT_meshopt_compression'); |
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