forked from donmccurdy/glTF-Transform
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[functions] Add tests for listTextureChannels, listTextureSlots (donm…
- Loading branch information
1 parent
1b32fe0
commit 7379982
Showing
2 changed files
with
54 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,54 @@ | ||
require('source-map-support').install(); | ||
|
||
import test from 'tape'; | ||
import { Document, TextureChannel } from '@gltf-transform/core'; | ||
import { listTextureChannels, getTextureChannelMask } from '@gltf-transform/functions'; | ||
import { MaterialsSheen } from '@gltf-transform/extensions'; | ||
|
||
const { R, G, B, A } = TextureChannel; | ||
|
||
test('@gltf-transform/functions::listTextureChannels', (t) => { | ||
// TODO(test) | ||
const document = new Document(); | ||
const textureA = document.createTexture(); | ||
const textureB = document.createTexture(); | ||
const sheenExtension = document.createExtension(MaterialsSheen); | ||
const sheen = sheenExtension.createSheen().setSheenRoughnessTexture(textureB); | ||
const material = document | ||
.createMaterial() | ||
.setAlphaMode('BLEND') | ||
.setBaseColorTexture(textureA) | ||
.setExtension('KHR_materials_sheen', sheen); | ||
|
||
t.deepEquals(listTextureChannels(document, textureA), [R, G, B, A], 'baseColorTexture RGBA'); | ||
t.deepEquals(listTextureChannels(document, textureB), [A], 'sheenColorTexture A'); | ||
|
||
material.setAlphaMode('OPAQUE'); | ||
t.deepEquals(listTextureChannels(document, textureA), [R, G, B], 'baseColorTexture RGB'); | ||
|
||
sheen.setSheenColorTexture(textureB); | ||
t.deepEquals(listTextureChannels(document, textureB), [R, G, B, A], 'sheenColorTexture RGBA'); | ||
t.end(); | ||
}); | ||
|
||
test('@gltf-transform/functions::getTextureChannelMask', (t) => { | ||
// TODO(test) | ||
const document = new Document(); | ||
const textureA = document.createTexture(); | ||
const textureB = document.createTexture(); | ||
const sheenExtension = document.createExtension(MaterialsSheen); | ||
const sheen = sheenExtension.createSheen().setSheenRoughnessTexture(textureB); | ||
const material = document | ||
.createMaterial() | ||
.setAlphaMode('BLEND') | ||
.setBaseColorTexture(textureA) | ||
.setExtension('KHR_materials_sheen', sheen); | ||
|
||
t.equals(getTextureChannelMask(document, textureA), R | G | B | A, 'baseColorTexture RGBA'); | ||
t.equals(getTextureChannelMask(document, textureB), A, 'sheenColorTexture A'); | ||
|
||
material.setAlphaMode('OPAQUE'); | ||
t.equals(getTextureChannelMask(document, textureA), R | G | B, 'baseColorTexture RGB'); | ||
|
||
sheen.setSheenColorTexture(textureB); | ||
t.equals(getTextureChannelMask(document, textureB), R | G | B | A, 'sheenColorTexture RGBA'); | ||
t.end(); | ||
}); |
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 |
---|---|---|
@@ -1,8 +1,18 @@ | ||
require('source-map-support').install(); | ||
|
||
import test from 'tape'; | ||
import { Document } from '@gltf-transform/core'; | ||
import { listTextureSlots } from '@gltf-transform/functions'; | ||
import { MaterialsSheen } from '@gltf-transform/extensions'; | ||
|
||
test('@gltf-transform/functions::listTextureSlots', (t) => { | ||
// TODO(test) | ||
const document = new Document(); | ||
const textureA = document.createTexture(); | ||
const textureB = document.createTexture(); | ||
const sheenExtension = document.createExtension(MaterialsSheen); | ||
const sheen = sheenExtension.createSheen().setSheenColorTexture(textureB); | ||
document.createMaterial().setBaseColorTexture(textureA).setExtension('KHR_materials_sheen', sheen); | ||
t.deepEquals(listTextureSlots(document, textureA), ['baseColorTexture'], 'baseColorTexture'); | ||
t.deepEquals(listTextureSlots(document, textureB), ['sheenColorTexture'], 'sheenColorTexture'); | ||
t.end(); | ||
}); |