Render fidelity tools

May 17, 2024 ยท View on GitHub

This package contains tools and testing processes that enable the <model-viewer> project to ensure high-fidelity 3D model rendering.

If you are looking for the <model-viewer> web component, please refer to the <model-viewer> package and also the live docs and examples on modelviewer.dev.

Development

To get started, follow the instructions in the main README.md file.

In order to run npm run render-goldens, you must have imagemagick installed.

On macOS, you can install imagemagick with homebrew: brew install imagemagick

On Debian/Ubuntu/Pop!_OS you can install imagemagick with apt: sudo apt install imagemagick

The following commands are available when developing modelviewer.dev:

CommandDescription
npm run buildBuild artifacts required to run testing and review tools
npm run cleanDeletes all build artifacts
npm run testRun a render fidelity check comparing <model-viewer> to other renderers
npm run render-goldensRender the "golden" images for all renderers

Fidelity Test CLI

For npm run test, we support these command line options:

CommandDefaultDescription
-c, --configPath to configuration json.
-s, --scenarioLimit to specific scenarios. This now also allows you to specify multiple scenarios in the whitelist. You can use a full name or a partial name of scenarios and it will match against all that contain that scenario substring.
-p, --port9040Port for web server.
-d, --dry-runfalseLists which images would be rendered but doesn't render. Useful when trying to figure out which tests will run given that command line.
-q, --quietfalseHide the puppeteer controlled browser. This can allow you to work on the computer while it is running in the background.

To run a subset of scenarios do something like this:

% npm run test -- --scenario=texture --quiet

NOTE: In the above example, the -- is required to separate the arguments to npm run test from the arguments to the script itself.

After running npm run test, you can look at the results by starting a local web server (e.g. npx http-server) in this folder, then opening test/results-viewer.html in a browser.

Render Goldens CLI

For npm run render-goldens, we support these command line options:

CommandDefaultDescription
-c, --configPath to configuration json.
-s, --scenarioLimit to specific scenarios. This now also allows you to specify multiple scenarios in the whitelist. You can use a full name or a partial name of scenarios and it will match against all that contain that scenario substring.
-p, --port9040Port for web server.
-m, --missing-onlyfalseOnly render if an output image is missing. Very useful when adding new tests.
-d, --dry-runfalseLists which images would be rendered but doesn't render. Useful when trying to figure out which tests will run given that command line.
-q, --quietfalseHide the puppeteer controlled browser. This can allow you to work on the computer while it is running in the background.

To run a subset of renders or scenarios do something like this:

% npm run render-goldens -- --scenario=clearcoat -q 

NOTE: In the above example, the -- is required to separate the arguments to npm run render-goldens from the arguments to the script itself.