Skip to content

Commit 0b7a3d3

Browse files
authored
Add script for running the validator (KhronosGroup#496)
* Add script for validating models * Validator results are save as raw .log files and a summary README * Remove the validatedAt property from the validator output, to reduce diff noise * Add launch configuration for validating models * Add documentation on validating models
1 parent 3d7642b commit 0b7a3d3

File tree

195 files changed

+9114
-37
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

195 files changed

+9114
-37
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414
/Source/UpgradeLog.htm
1515
/tempImages
1616
/ScreenshotGenerator
17-
/package-lock.json
17+
/Tools/node_modules

.vscode/launch.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@
2323
"type": "coreclr",
2424
"request": "attach",
2525
"processId": "${command:pickProcess}"
26+
},
27+
{
28+
"name": "Validate Models",
29+
"type": "node",
30+
"request": "launch",
31+
"program": "${workspaceFolder}/Tools/validate.js",
2632
}
2733
]
28-
}
34+
}

CONTRIBUTING.md

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,41 @@
1-
# Contributing to the glTF Asset Generator
1+
# Contributing to the glTF Asset Generator
2+
3+
## Dependencies
4+
1. Install [Visual Studio Code.](https://code.visualstudio.com/Download) (VS Code)
5+
2. Install the extension [C# for VS Code (powered by OmniSharp)](https://marketplace.visualstudio.com/items?itemName=ms-vscode.csharp).
6+
3. Install [npm.](https://www.npmjs.com/get-npm)
27

38
## Set Up
4-
1. Use `git clone https://github.com/KhronosGroup/glTF-Asset-Generator.git` to download the repro.
5-
2. [Install and launch VS Code.](https://code.visualstudio.com/Download)
6-
3. Open the local copy of the repro in VS Code.
7-
1. Select `Explorer` from the sidebar.
8-
2. Select `Open Folder`.
9-
3. Select the location of the `glTF-Asset-Generator` folder.
10-
4. Install the extension [C# for VS Code (powered by OmniSharp)](https://marketplace.visualstudio.com/items?itemName=ms-vscode.csharp). There will likely be a popup prompt to take this action.
11-
1. After installation, either relaunch VS Code or reload the extension.
9+
1. Download the repro.
10+
1. `git clone https://github.com/KhronosGroup/glTF-Asset-Generator.git`
11+
2. Run `npm install` from the [Tools](Tools) folder.
12+
3. Launch VS Code.
13+
1. Open the local copy of the repro in VS Code.
14+
2. Select `Explorer` from the sidebar.
15+
3. Select `Open Folder`.
16+
4. Select the location of the [glTF-Asset-Generator](https://github.com/KhronosGroup/glTF-Asset-Generator) folder.
1217
5. Press F5 or select `Start Debugging` from the debug menu.
1318

1419
## Best Practices
15-
+ Write readable code.
20+
+ Write readable code.
1621
+ Developers that encounter issues with the models generated by this code will want to look into the code to see how that model is put together.
1722
+ By default, add properties instead of removing properties when creating a model to reduce code complexity.
1823

1924
+ Aim to have fewer than thirteen rows and fewer than seven columns in the model group's readme table (not counting headers).
2025
+ Each model added creates another row. Having too many rows in a table makes it difficult to read due to needing scrolling too much to view the entire model group's readme. Consider splitting the model group into two or more that are closely related.
2126
+ Each property being tested adds another column, and usually adds another model as well. Having too many columns results in results in github's markdown squishing the table to make everything fit.
2227

23-
+ Clearly identify models that are designed to fail to load. (Negative tests)
24-
+ A client that is conformant with the glTF 2.0 spec is expected to successfully render any model created by the glTF Asset Generator, unless explicitly noted otherwise.
28+
+ Clearly identify models that are designed to fail to load. (Negative tests)
29+
+ A client that is conformant with the glTF 2.0 spec is expected to successfully render any model created by the glTF Asset Generator, unless explicitly noted otherwise.
2530
+ If a model (or entire group of models) are not expected to load on a conformant client, then the model(s) must be marked as such in the readme.
2631
+ Models that are not valid need the `Valid` bool set to false, even if they are not necessarily expected to fail to load. See "Flag Model as Not Valid" in [Adding Models Advanced](Documents/Adding_Models_Advanced.md).
2732

2833
## Common Errors
29-
+ The error message `Configured debug type 'coreclr'` is encountered when debugging in VS Code
34+
+ The error message `Configured debug type 'coreclr'` is encountered when debugging in VS Code
3035
+ This is caused by debugging without [C# for VS Code (powered by OmniSharp)](https://marketplace.visualstudio.com/items?itemName=ms-vscode.csharp) being correctly installed and loaded.
3136
+ Be sure to reload the extension after installing it, or relaunching VS Code.
3237
+ Error message encountered while debugging `Unhandled Exception: System.UnauthorizedAccessException: Access to the path is denied.`
33-
+ A file could not be overwritten.
38+
+ A file could not be overwritten.
3439
+ Check that the file isn't open in another program and that it isn't set to readonly.
3540
+ Error message encountered while debugging `An unhandled exception of type 'System.IO.IOException' occurred in System.IO.FileSystem.dll: 'The requested operation cannot be performed on a file with a user-mapped section open'`
3641
+ Encountered when running the debugger again too quickly after having just run it.

Documentation/Adding_Models.md

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
# Creating a New Model Group
22
1. [Create a Model Group Readme Template in Markdown.](#create-a-model-group-readme-template-in-markdown)
33
2. [Create a New Model Group Class.](#create-a-new-model-group-class)
4-
3. Delete undesired models and screenshots from the local [Output](../Output) folder. (Files will be overwritten, but not deleted)
4+
3. Delete undesired models and screenshots from the local [Output](../Output) folder. (Files will be overwritten, but not deleted)
55
4. Compile and run the build.
6-
5. [Generate Screenshots.](#generate-screenshots)
6+
5. [Validate Models](#validate-models)
7+
6. [Generate Screenshots.](#generate-screenshots)
78

89
## Create a Model Group Readme Template in Markdown
910
Every model group will generate a readme. The code starts with a template specific to that model group, then inserts a generated table based on the models created.
@@ -15,7 +16,7 @@ Every model group will generate a readme. The code starts with a template specif
1516

1617
### Readme Tips
1718
+ Models will be listed in the readme in the order they are created in code.
18-
+ Property names and values as listed in the readme are formatted by the [ReadmeStringHelper](../Source/ReadmeStringHelper.cs) class, which adds spaces, fixes capitalization, and converts values into strings.
19+
+ Property names and values as listed in the readme are formatted by the [ReadmeStringHelper](../Source/ReadmeStringHelper.cs) class, which adds spaces, fixes capitalization, and converts values into strings.
1920
+ Use `":white_check_mark:"` :white_check_mark: to show that something is enabled or has a positive result. Use `":x:"` :x: to show something is disabled or has a negative result.
2021
+ When including images in a table, use a thumbnail that is the size the image is expected to be viewed at, and link it to a full-size image. This avoids issues with images being stretched.
2122

@@ -26,10 +27,10 @@ These models are intended to test...
2627
The following table shows the properties that are set for every model.
2728
2829
~~HeaderTable~~
29-
30-
The following table shows the properties that are set for a given model.
3130
32-
~~Table~~
31+
The following table shows the properties that are set for a given model.
32+
33+
~~Table~~
3334
```
3435

3536
### Figures
@@ -44,25 +45,25 @@ Use images to better explain how a model is setup. This is especially useful for
4445
3. Declare the images as being used in a model group.
4546
+ At the top of the model group class that will be using this image, add `UseFigure(imageList, "IMAGEFILENAME");`
4647
4. Insert the image into the readme template.
47-
+ This can be done with either markdown or HTML formatting.
48+
+ This can be done with either markdown or HTML formatting.
4849
`![alt-text](Figures/IMAGEFILENAME.png)`
4950
`<img src="Figures/IMAGEFILENAME.png">`
5051

5152
Be careful of adding images that are too large to a model group's readme, as this can cause weird spacing issues with markdown tables.
52-
+ Clamp the size of the image to keep the image from changing cell widths and heights too much
53+
+ Clamp the size of the image to keep the image from changing cell widths and heights too much.
5354
`<img src="Figures/BigImage.png" width="144" height="144" align="middle">`
5455

5556
## Create a New Model Group Class
5657
1. Create a copy of the [ModelGroup_Template](../Source/Resources/Templates/ModelGroup_Template.cs) and place it under the [ModelGroups](../Source/ModelGroups) folder.
5758
2. Name the Class and .cs file as appropriate for what is being tested. For related model groups, use a CATEGORY_NAME format.
5859
3. Add the name of the model group to the `ModelGroupId` enum in [ModelGroup](../Source/ModelGroup.cs) (in alphabetical order). Then in the new class set the `Id` as that enum.
59-
4. Call the class from [Program](../Source/Program.cs). This is done by creating an instance of the class to add to the `allModelGroups` list (in alphabetical order).
60-
5. Add code to the new model group. Add new values to the `PropertyName` enum in `Property.cs` as needed.
60+
4. Call the class from [Program](../Source/Program.cs). This is done by creating an instance of the class to add to the `allModelGroups` list (in alphabetical order).
61+
5. Add code to the new model group. Add new values to the `PropertyName` enum in `Property.cs` as needed.
6162

6263
### Structure of a Model Group
6364
Declare the following values at the beginning of the constructor
6465
+ Add the figures being used to the `UseFigure` list (See [Figures](#figures) above)
65-
+ Declare the textures being used and add them to the `UseTexture` list.
66+
+ Declare the textures being used and add them to the `UseTexture` list.
6667
`var TextureImage = UseTexture(imageList, "FILENAME")`
6768
+ Declare camera position(s) if a custom one will be used.
6869
+ Declare property values that will be used in more than one model. Add properties used by every model to the `CommonProperties` list.
@@ -75,19 +76,19 @@ Assemble the model in the `CreateModel` function.
7576
+ Call `setProperties`, which will set the desired test values on the component model objects.
7677
+ Assemble and return the model, creating a new `Model` object using the component model objects.
7778

78-
Add helper functions that reduce duplicate code below `CreateModel`.
79+
Add helper functions that reduce duplicate code below `CreateModel`.
7980
+ Generally, this is where the properties list is populated, which is used in creating the model group readme (See [Properties](#properties) below)
8081
+ These functions should be specific to the one model group.
8182

8283
Create the anonymous methods
83-
Inside of the code block `this.Models = new List<Model>` is where the values for each specific model will be set.
84+
Inside of the code block `this.Models = new List<Model>` is where the values for each specific model will be set.
8485
If no values are set on a model, leave a comment to show that was intentional.
8586
```C#
8687
CreateModel((properties, meshPrimitive) => {
8788
// There are no properties set on this model.
8889
}),
8990
```
90-
Otherwise, modify the component model objects that were passed in with the desired test values.
91+
Otherwise, modify the component model objects that were passed in with the desired test values.
9192
Be careful to only modify the objects and not replace them! If the object is set equal to a new object, then the ref will point at a new object instead of updating the desired object. Instead only modify values of the object, or work with lists of objects.
9293

9394
At the bottom of the model group `GenerateUsedPropertiesList()` is called. This is used in creating the model group readme and won't need to be modified.
@@ -99,22 +100,27 @@ At the bottom of the model group `GenerateUsedPropertiesList()` is called. This
99100

100101
## Generate Screenshots
101102
1. Download the [screenshotGenerator](https://github.com/kcoley/screenshotGenerator)
102-
+ Follow the directions in that repro's readme on how to build the generator.
103-
+ Place the folder containing the Screenshot Generator inside of the local glTF-Asset-Generator directory `.\glTF-Asset-Generator\ScreenshotGenerator\`
103+
+ Follow the directions in that repro's readme on how to build the generator.
104+
+ Place the folder containing the Screenshot Generator inside of the local glTF-Asset-Generator directory `.\glTF-Asset-Generator\ScreenshotGenerator\`
104105
2. Run the PowerShell script [SampleImageHelper.ps1](../SampleImageHelper.ps1)
105106

106-
Screenshots are generated in a step separately from running the glTF Asset Generator, which also includes the moving of textures and figures into the output folders.
107+
Screenshots are generated in a step separately from running the glTF Asset Generator, which also includes the moving of textures and figures into the output folders.
107108
This is done to speed up debugging. The creation of screenshots is a time intensive process and often the screenshots are not needed until the majority of debugging has been completed.
108109

110+
## Validate Models
111+
Run the `Validate Models` VS Code launch configuration in order to use the [glTF-Validator](https://github.com/KhronosGroup/glTF-Validator) to validate the generated models. The results are saved under in the [ValidatorResults folder](../ValidatorResults).
112+
This script can also be run directly from the [Tools](../Tools) folder with the command `npm run validate`.
113+
New and modified models are expected to have been validated before being checked in.
114+
109115
## Properties
110116
Properties are attributes that can be set on a model. For example, Doublesided is a property and it can have a value of true or false.
111117

112-
For each tested property that is set on a model, a [Property](../Source/Property.cs) object needs to be created.
118+
For each tested property that is set on a model, a [Property](../Source/Property.cs) object needs to be created.
113119
```C#
114120
properties.Add(new Property(PropertyName.PROPERTYNAME, PROPERTYVALUE));
115121
```
116-
The enum will be the name of a column on the readme. The value will be displayed in that column.
117-
Readme columns are ordered based on the int value for `PropertyName` enums in the [Property](../Source/Property.cs) class.
122+
The enum will be the name of a column on the readme. The value will be displayed in that column.
123+
Readme columns are ordered based on the int value for `PropertyName` enums in the [Property](../Source/Property.cs) class.
118124
If having a property name doesn't make sense, use `Description` as the enum and use an explanatory string as the value.
119125

120126
## Runtime Layer

Source/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ private static void Main(string[] args)
109109
}
110110
}
111111

112-
// Write out the master manifest JSON containing all of the model groups
112+
// Write out the master manifest JSON containing all of the model groups.
113113
using (var writeManifest = new StreamWriter(Path.Combine(outputFolder, "Manifest.json")))
114114
{
115115
jsonSerializer.Serialize(writeManifest, manifestMaster.ToArray());

Tools/package-lock.json

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Tools/package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"scripts": {
3+
"validate": "node validate.js"
4+
},
5+
"dependencies": {
6+
"gltf-validator": "^2.0.0-dev.2.7"
7+
}
8+
}

0 commit comments

Comments
 (0)