google / model-viewer

Easily display interactive 3D models on the web and in AR!
https://modelviewer.dev
Apache License 2.0
6.71k stars 799 forks source link

enable complex arguments for "npm run render-goldens" command #4542

Closed bhouston closed 8 months ago

bhouston commented 8 months ago

This implements this idea: https://github.com/google/model-viewer/issues/4536

Options:
      --version       Show version number                              [boolean]
  -c, --config        Path to configuration json             [string] [required]
  -r, --renderer      Limit to specific renderers                        [array]
  -s, --scenario      Limit to specific scenarios                        [array]
  -p, --port          Port for web server               [number] [default: 9040]
  -m, --missing-only  Only render if an output image is missing
                                                      [boolean] [default: false]
  -d, --dry-run       Lists which images would be rendered but doesn't render
                                                      [boolean] [default: false]
  -q, --quiet         Hide the puppeteer controlled browser
                                                      [boolean] [default: false]
  -h, --help          Show help                                        [boolean]

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

% npm run render-goldens -- --renderer=filament --renderer=model-viewer --scenario=clearcoat -q 

Explanation of the new features: --renderer, this now allows you to specify multiple renderers in the whitelist, rather than only one. -- scenario, this now also allows you to specify multiple scenarios in the whitelist, rather than only one. It now also selects scenarios based on being a subset of the config.json scenario name, thus you can run all tests that contain say "transform" or "clearcoat". --missing-only is very useful when I add new tests and I don't want to render all other tests just to get goldens for the new ones. --dry-run, when I want to figure out which tests will run given that command line. --quiet, I can run update-screenshots in the background while working without Chrome constantly popping up to disrupt my flow. Also gives about a 10% speed boost on my machine. --port, allows me to run two of these at the same time, useful when I want to run two different renderers at the same time, or work on two separate branches simultaneously.

bhouston commented 8 months ago

@elalish I've updated the README for "npm run render-goldens."

bhouston commented 8 months ago

I've merged in the "npm run test" CLI update into this PR to make it simpler. I've also further updated the README to contain both sets of options in it.

bhouston commented 8 months ago

I've renamed "npm run update-screenshots" to "npm run render-goldens", it is much more accurate/descriptive, e.g. the script renders the images that go into the goldens folder.

bhouston commented 8 months ago

In the latest push I've made it so that the renderer you are testing for fidelity is configurable. It defaults to "model-viewer" (for full backwards compatibility) but you can specify any of the web-based renderers (filament, babylon, gltf-sample-viewer, three-gpu-renderer) and it works.