Port of https://github.com/phetsims/scenery/commit/211e9c42609f9e9010d383c981683ea24ac8dd84 for phet-core#11