Skip to content

Commit

Permalink
Use smaller datasets for specular testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeshurun Hembd committed May 16, 2024
1 parent 6155fa4 commit 1207edd
Show file tree
Hide file tree
Showing 10 changed files with 246 additions and 245 deletions.
11 changes: 11 additions & 0 deletions Specs/Data/Models/glTF-2.0/BoxSpecular/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Box Specular

## Screenshot

![screenshot](screenshot/screenshot.png)

## License Information

Developed by Cesium for testing the KHR_materials_specular extension. Please follow the [Cesium Trademark Terms and Conditions](https://github.com/AnalyticalGraphicsInc/cesium/wiki/CesiumTrademark.pdf).

This model is licensed under a [Creative Commons Attribution 4.0 International License](http://creativecommons.org/licenses/by/4.0/).
Binary file not shown.
205 changes: 205 additions & 0 deletions Specs/Data/Models/glTF-2.0/BoxSpecular/glTF/BoxSpecular.gltf
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
{
"asset": {
"generator": "COLLADA2GLTF",
"version": "2.0"
},
"scene": 0,
"scenes": [
{
"nodes": [
0
]
}
],
"nodes": [
{
"children": [
1
],
"matrix": [
1.0,
0.0,
0.0,
0.0,
0.0,
0.0,
-1.0,
0.0,
0.0,
1.0,
0.0,
0.0,
0.0,
0.0,
0.0,
1.0
]
},
{
"mesh": 0
}
],
"meshes": [
{
"primitives": [
{
"attributes": {
"NORMAL": 1,
"POSITION": 2,
"TEXCOORD_0": 3
},
"indices": 0,
"mode": 4,
"material": 0
}
],
"name": "Mesh"
}
],
"accessors": [
{
"bufferView": 0,
"byteOffset": 0,
"componentType": 5123,
"count": 36,
"max": [
23
],
"min": [
0
],
"type": "SCALAR"
},
{
"bufferView": 1,
"byteOffset": 0,
"componentType": 5126,
"count": 24,
"max": [
1.0,
1.0,
1.0
],
"min": [
-1.0,
-1.0,
-1.0
],
"type": "VEC3"
},
{
"bufferView": 1,
"byteOffset": 288,
"componentType": 5126,
"count": 24,
"max": [
0.5,
0.5,
0.5
],
"min": [
-0.5,
-0.5,
-0.5
],
"type": "VEC3"
},
{
"bufferView": 2,
"byteOffset": 0,
"componentType": 5126,
"count": 24,
"max": [
6.0,
1.0
],
"min": [
0.0,
0.0
],
"type": "VEC2"
}
],
"materials": [
{
"pbrMetallicRoughness": {
"baseColorTexture": {
"index": 0
},
"metallicFactor": 0.0
},
"name": "Texture",
"extensions": {
"KHR_materials_specular": {
"specularFactor": 0.7,
"specularColorFactor": [
50,
0,
0
],
"specularTexture": {
"index": 0
},
"specularColorTexture": {
"index": 0
}
}
}
}
],
"textures": [
{
"sampler": 0,
"source": 0
}
],
"images": [
{
"uri": "CesiumLogoFlat.png"
}
],
"samplers": [
{
"magFilter": 9729,
"minFilter": 9986,
"wrapS": 10497,
"wrapT": 10497
}
],
"bufferViews": [
{
"buffer": 0,
"byteOffset": 768,
"byteLength": 72,
"target": 34963
},
{
"buffer": 0,
"byteOffset": 0,
"byteLength": 576,
"byteStride": 12,
"target": 34962
},
{
"buffer": 0,
"byteOffset": 576,
"byteLength": 192,
"byteStride": 8,
"target": 34962
}
],
"buffers": [
{
"byteLength": 840,
"uri": "BoxSpecular.bin"
}
],
"extensionsRequired": [
"KHR_draco_mesh_compression",
"KHR_materials_specular"
],
"extensionsUsed": [
"KHR_draco_mesh_compression",
"KHR_materials_specular"
]
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 0 additions & 15 deletions Specs/Data/Models/glTF-2.0/SpecularTest/LICENSE.md

This file was deleted.

53 changes: 0 additions & 53 deletions Specs/Data/Models/glTF-2.0/SpecularTest/README.md

This file was deleted.

Binary file not shown.
26 changes: 0 additions & 26 deletions Specs/Data/Models/glTF-2.0/SpecularTest/metadata.json

This file was deleted.

41 changes: 8 additions & 33 deletions packages/engine/Specs/Scene/GltfLoaderSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import {
TextureWrap,
VertexAttributeSemantic,
Quaternion,
defined,
} from "../../index.js";
import createScene from "../../../../Specs/createScene.js";
import generateJsonBuffer from "../../../../Specs/generateJsonBuffer.js";
Expand Down Expand Up @@ -124,7 +123,7 @@ describe(
const boxWeb3dQuantizedAttributes =
"./Data/Models/glTF-2.0/BoxWeb3dQuantizedAttributes/glTF/BoxWeb3dQuantizedAttributes.gltf";
const specularTestData =
"./Data/Models/glTF-2.0/SpecularTest/glTF-Binary/SpecularTest.glb";
"./Data/Models/glTF-2.0/BoxSpecular/glTF/BoxSpecular.gltf";

let scene;
const gltfLoaders = [];
Expand Down Expand Up @@ -4144,38 +4143,14 @@ describe(
it("loads model with KHR_materials_specular extension", async function () {
const gltfLoader = await loadGltf(specularTestData);

const { nodes } = gltfLoader.components;
const materials = nodes
.map((node) => node.primitives[0]?.material)
.filter(defined)
.filter((material) => defined(material.specular));

const specularFactors = materials
.map((material) => material.specular.specularFactor)
.filter(defined);
expect(specularFactors).toEqual([0, 0.051269, 0.212231, 0.520996, 1]);

const specularTextures = materials
.map((material) => material.specular.specularTexture)
.filter(defined);
expect(specularTextures.length).toBe(1);
expect(specularTextures[0].texture.width).toBe(64);

const specularColorFactors = materials
.map((material) => material.specular.specularColorFactor)
.filter(defined);
const expectedColorFactor = Cartesian3.fromElements(
0.051269,
0.051269,
0
);
expect(specularColorFactors[6]).toEqual(expectedColorFactor);
const { material } = gltfLoader.components.nodes[1].primitives[0];

const specularColorTextures = materials
.map((material) => material.specular.specularColorTexture)
.filter(defined);
expect(specularColorTextures.length).toBe(2);
expect(specularColorTextures[0].texture.width).toBe(64);
expect(material.specular.specularFactor).toEqual(0.7);
expect(material.specular.specularTexture.texture.width).toBe(256);
expect(material.specular.specularColorFactor).toEqual(
Cartesian3.fromElements(50, 0, 0)
);
expect(material.specular.specularTexture.texture.width).toBe(256);
});

it("parses copyright field", function () {
Expand Down

0 comments on commit 1207edd

Please sign in to comment.