Skip to content

Commit

Permalink
Merge pull request #280 from CesiumGS/gltf-extension-validation
Browse files Browse the repository at this point in the history
glTF extension validation
  • Loading branch information
lilleyse committed Oct 16, 2023
2 parents 94fc288 + 274560e commit e8a3d3e
Show file tree
Hide file tree
Showing 158 changed files with 22,006 additions and 1,091 deletions.
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,15 @@
"3d-tiles-validator": "./build/main"
},
"dependencies": {
"3d-tiles-tools": "^0.3.0",
"@gltf-transform/core": "^3.2.1",
"@gltf-transform/extensions": "^3.2.1",
"@gltf-transform/functions": "^3.2.1",
"3d-tiles-tools": "^0.3.1",
"cesium": "^1.97.0",
"gltf-validator": "^2.0.0-dev.3.9",
"minimatch": "^5.1.0",
"node-stream-zip": "^1.10.1",
"sharp": "^0.32.1",
"yargs": "^17.5.1"
},
"devDependencies": {
Expand Down
74 changes: 74 additions & 0 deletions specs/TilesetValidationSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,80 @@ describe("Tileset validation", function () {
expect(result.get(0).type).toEqual("VALUE_NOT_IN_RANGE");
});

it("detects issues in tilesetMetadataEntityPropertyEnumInvalidValue", async function () {
const result = await Validators.validateTilesetFile(
"specs/data/tilesets/tilesetMetadataEntityPropertyEnumInvalidValue.json"
);
expect(result.length).toEqual(1);
expect(result.get(0).type).toEqual(
"CLASS_PROPERTY_ENUM_VALUE_NAME_NOT_FOUND"
);
});

it("detects issues in tilesetMetadataEntityPropertyMaxNotInRange", async function () {
const result = await Validators.validateTilesetFile(
"specs/data/tilesets/tilesetMetadataEntityPropertyMaxNotInRange.json"
);
expect(result.length).toEqual(1);
expect(result.get(0).type).toEqual("METADATA_VALUE_NOT_IN_RANGE");
});

it("detects issues in tilesetMetadataEntityPropertyMaxWithNormalizedNotInRange", async function () {
const result = await Validators.validateTilesetFile(
"specs/data/tilesets/tilesetMetadataEntityPropertyMaxWithNormalizedNotInRange.json"
);
expect(result.length).toEqual(1);
expect(result.get(0).type).toEqual("METADATA_VALUE_NOT_IN_RANGE");
});

it("detects issues in tilesetMetadataEntityPropertyMaxWithOffsetNotInRange", async function () {
const result = await Validators.validateTilesetFile(
"specs/data/tilesets/tilesetMetadataEntityPropertyMaxWithOffsetNotInRange.json"
);
expect(result.length).toEqual(1);
expect(result.get(0).type).toEqual("METADATA_VALUE_NOT_IN_RANGE");
});

it("detects issues in tilesetMetadataEntityPropertyMaxWithScaleNotInRange", async function () {
const result = await Validators.validateTilesetFile(
"specs/data/tilesets/tilesetMetadataEntityPropertyMaxWithScaleNotInRange.json"
);
expect(result.length).toEqual(1);
expect(result.get(0).type).toEqual("METADATA_VALUE_NOT_IN_RANGE");
});

it("detects issues in tilesetMetadataEntityPropertyMinNotInRange", async function () {
const result = await Validators.validateTilesetFile(
"specs/data/tilesets/tilesetMetadataEntityPropertyMinNotInRange.json"
);
expect(result.length).toEqual(1);
expect(result.get(0).type).toEqual("METADATA_VALUE_NOT_IN_RANGE");
});

it("detects issues in tilesetMetadataEntityPropertyMinWithNormalizedNotInRange", async function () {
const result = await Validators.validateTilesetFile(
"specs/data/tilesets/tilesetMetadataEntityPropertyMinWithNormalizedNotInRange.json"
);
expect(result.length).toEqual(1);
expect(result.get(0).type).toEqual("METADATA_VALUE_NOT_IN_RANGE");
});

it("detects issues in tilesetMetadataEntityPropertyMinWithOffsetNotInRange", async function () {
const result = await Validators.validateTilesetFile(
"specs/data/tilesets/tilesetMetadataEntityPropertyMinWithOffsetNotInRange.json"
);
expect(result.length).toEqual(1);
expect(result.get(0).type).toEqual("METADATA_VALUE_NOT_IN_RANGE");
});

it("detects issues in tilesetMetadataEntityPropertyMinWithScaleNotInRange", async function () {
const result = await Validators.validateTilesetFile(
"specs/data/tilesets/tilesetMetadataEntityPropertyMinWithScaleNotInRange.json"
);
expect(result.length).toEqual(1);
expect(result.get(0).type).toEqual("METADATA_VALUE_NOT_IN_RANGE");
});

it("detects issues in tilesetSchemaUriInvalidType", async function () {
const result = await Validators.validateTilesetFile(
"specs/data/tilesets/tilesetSchemaUriInvalidType.json"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
{
"extensions" : {
"EXT_structural_metadata" : {
"schema" : {
"id": "FeatureIdAttributeAndPropertyTableSchema",
"classes" : {
"exampleMetadataClass" : {
"name" : "Example metadata class",
"description" : "An example metadata class",
"properties" : {
"example_VEC3_FLOAT32" : {
"name" : "Example VEC3 FLOAT32 property",
"description" : "An example property, with type VEC3, with component type FLOAT32",
"type" : "VEC3",
"componentType" : "FLOAT32"
}
}
}
}
},
"propertyTables" : [ {
"name" : "Example property table",
"class" : "exampleMetadataClass",
"count" : 4,
"properties" : {
"example_VEC3_FLOAT32" : {
"values" : 4
}
}
} ]
}
},
"extensionsUsed" : [ "EXT_mesh_features", "EXT_structural_metadata" ],
"accessors" : [ {
"bufferView" : 0,
"byteOffset" : 0,
"componentType" : 5123,
"count" : 24,
"type" : "SCALAR",
"max" : [ 15 ],
"min" : [ 0 ]
}, {
"bufferView" : 1,
"byteOffset" : 0,
"componentType" : 5126,
"count" : 16,
"type" : "VEC3",
"max" : [ 1.0, 1.0, 0.0 ],
"min" : [ 0.0, 0.0, 0.0 ]
}, {
"bufferView" : 2,
"byteOffset" : 0,
"componentType" : 5126,
"count" : 16,
"type" : "VEC3",
"max" : [ 0.0, 0.0, 1.0 ],
"min" : [ 0.0, 0.0, 1.0 ]
}, {
"bufferView" : 3,
"byteOffset" : 0,
"componentType" : 5120,
"count" : 16,
"type" : "SCALAR",
"max" : [ 123 ],
"min" : [ -123 ]
} ],
"asset" : {
"generator" : "JglTF from https://github.com/javagl/JglTF",
"version" : "2.0"
},
"buffers" : [ {
"uri" : "data:application/gltf-buffer;base64,AAABAAIAAQADAAIABAAFAAYABQAHAAYACAAJAAoACQALAAoADAANAA4ADQAPAA4AAAAAAAAAAAAAAAAAZmbmPgAAAAAAAAAAAAAAAGZm5j4AAAAAZmbmPmZm5j4AAAAAzcwMPwAAAAAAAAAAAACAPwAAAAAAAAAAzcwMP2Zm5j4AAAAAAACAP2Zm5j4AAAAAAAAAAM3MDD8AAAAAZmbmPs3MDD8AAAAAAAAAAAAAgD8AAAAAZmbmPgAAgD8AAAAAzcwMP83MDD8AAAAAAACAP83MDD8AAAAAzcwMPwAAgD8AAAAAAACAPwAAgD8AAAAAAAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/hQAAAIUAAACFAAAAhQAAAAEAAAABAAAAAQAAAAEAAAACAAAAAgAAAAIAAAACAAAAewAAAHsAAAB7AAAAewAAAA==",
"byteLength" : 496
}, {
"uri" : "data:application/gltf-buffer;base64,AAAAAM3MzD3NzEw+AACAP83MjD+amZk/AAAAQGZmBkDNzAxAAABAQGZmRkDNzExA",
"byteLength" : 48
} ],
"bufferViews" : [ {
"buffer" : 0,
"byteOffset" : 0,
"byteLength" : 48,
"target" : 34963
}, {
"buffer" : 0,
"byteOffset" : 48,
"byteLength" : 192,
"target" : 34962
}, {
"buffer" : 0,
"byteOffset" : 240,
"byteLength" : 192,
"target" : 34962
}, {
"buffer" : 0,
"byteOffset" : 432,
"byteLength" : 64,
"byteStride" : 4,
"target" : 34962
}, {
"buffer" : 1,
"byteOffset" : 0,
"byteLength" : 48
} ],
"materials" : [ {
"pbrMetallicRoughness" : {
"baseColorFactor" : [ 0.5, 1.0, 0.5, 1.0 ],
"metallicFactor" : 0.0,
"roughnessFactor" : 1.0
},
"alphaMode" : "OPAQUE",
"doubleSided" : true
} ],
"meshes" : [ {
"primitives" : [ {
"extensions" : {
"EXT_mesh_features" : {
"featureIds" : [ {
"featureCount" : 4,
"attribute" : 0,
"propertyTable" : 0
} ]
}
},
"attributes" : {
"POSITION" : 1,
"NORMAL" : 2,
"_FEATURE_ID_0" : 3
},
"indices" : 0,
"material" : 0,
"mode" : 4
} ]
} ],
"nodes" : [ {
"mesh" : 0
} ],
"scene" : 0,
"scenes" : [ {
"nodes" : [ 0 ]
} ]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
{
"extensions" : {
"EXT_structural_metadata" : {
"schema" : {
"id": "FeatureIdAttributeAndPropertyTableSchema",
"classes" : {
"exampleMetadataClass" : {
"name" : "Example metadata class",
"description" : "An example metadata class",
"properties" : {
"example_VEC3_FLOAT32" : {
"name" : "Example VEC3 FLOAT32 property",
"description" : "An example property, with type VEC3, with component type FLOAT32",
"type" : "VEC3",
"componentType" : "FLOAT32"
}
}
}
}
},
"propertyTables" : [ {
"name" : "Example property table",
"class" : "exampleMetadataClass",
"count" : 4,
"properties" : {
"example_VEC3_FLOAT32" : {
"values" : 4
}
}
} ]
}
},
"extensionsUsed" : [ "EXT_mesh_features", "EXT_structural_metadata" ],
"accessors" : [ {
"bufferView" : 0,
"byteOffset" : 0,
"componentType" : 5123,
"count" : 24,
"type" : "SCALAR",
"max" : [ 15 ],
"min" : [ 0 ]
}, {
"bufferView" : 1,
"byteOffset" : 0,
"componentType" : 5126,
"count" : 16,
"type" : "VEC3",
"max" : [ 1.0, 1.0, 0.0 ],
"min" : [ 0.0, 0.0, 0.0 ]
}, {
"bufferView" : 2,
"byteOffset" : 0,
"componentType" : 5126,
"count" : 16,
"type" : "VEC3",
"max" : [ 0.0, 0.0, 1.0 ],
"min" : [ 0.0, 0.0, 1.0 ]
}, {
"bufferView" : 3,
"byteOffset" : 0,
"componentType" : 5121,
"count" : 16,
"type" : "SCALAR",
"max" : [ 3 ],
"min" : [ 0 ]
} ],
"asset" : {
"generator" : "JglTF from https://github.com/javagl/JglTF",
"version" : "2.0"
},
"buffers" : [ {
"uri" : "data:application/gltf-buffer;base64,AAABAAIAAQADAAIABAAFAAYABQAHAAYACAAJAAoACQALAAoADAANAA4ADQAPAA4AAAAAAAAAAAAAAAAAZmbmPgAAAAAAAAAAAAAAAGZm5j4AAAAAZmbmPmZm5j4AAAAAzcwMPwAAAAAAAAAAAACAPwAAAAAAAAAAzcwMP2Zm5j4AAAAAAACAP2Zm5j4AAAAAAAAAAM3MDD8AAAAAZmbmPs3MDD8AAAAAAAAAAAAAgD8AAAAAZmbmPgAAgD8AAAAAzcwMP83MDD8AAAAAAACAP83MDD8AAAAAzcwMPwAAgD8AAAAAAACAPwAAgD8AAAAAAAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAQAAAAEAAAACAAAAAgAAAAIAAAACAAAAAwAAAAMAAAADAAAAAwAAAA==",
"byteLength" : 496
}, {
"uri" : "data:application/gltf-buffer;base64,AAAAAM3MzD3NzEw+AACAP83MjD+amZk/AAAAQGZmBkDNzAxAAABAQGZmRkDNzExA",
"byteLength" : 48
} ],
"bufferViews" : [ {
"buffer" : 0,
"byteOffset" : 0,
"byteLength" : 48,
"target" : 34963
}, {
"buffer" : 0,
"byteOffset" : 48,
"byteLength" : 192,
"target" : 34962
}, {
"buffer" : 0,
"byteOffset" : 240,
"byteLength" : 192,
"target" : 34962
}, {
"buffer" : 0,
"byteOffset" : 432,
"byteLength" : 64,
"byteStride" : 4,
"target" : 34962
}, {
"buffer" : 1,
"byteOffset" : 0,
"byteLength" : 48
} ],
"materials" : [ {
"pbrMetallicRoughness" : {
"baseColorFactor" : [ 0.5, 1.0, 0.5, 1.0 ],
"metallicFactor" : 0.0,
"roughnessFactor" : 1.0
},
"alphaMode" : "OPAQUE",
"doubleSided" : true
} ],
"meshes" : [ {
"primitives" : [ {
"extensions" : {
"EXT_mesh_features" : {
"featureIds" : [ {
"featureCount" : 4,
"attribute" : 0,
"propertyTable" : 12345
} ]
}
},
"attributes" : {
"POSITION" : 1,
"NORMAL" : 2,
"_FEATURE_ID_0" : 3
},
"indices" : 0,
"material" : 0,
"mode" : 4
} ]
} ],
"nodes" : [ {
"mesh" : 0
} ],
"scene" : 0,
"scenes" : [ {
"nodes" : [ 0 ]
} ]
}
Loading

0 comments on commit e8a3d3e

Please sign in to comment.