phetsims / faradays-electromagnetic-lab

"Faraday's Electromagnetic Lab" is an educational simulation in HTML5, by PhET Interactive Simulations.
GNU General Public License v3.0
1 stars 0 forks source link

Electrons are missing from Screenshot. #116

Closed pixelzoom closed 8 months ago

pixelzoom commented 8 months ago

Reported by @kathy-phet on Slack. The electrons are not captured when you take a "Screenshot" via the PhET menu, see below. Microsoft Windows 11 Enterprise, Chrome 123.

This is probably a scenery problem with Sprites, see ElectronsNode.ts. But since the field visualization (FieldNode.ts) is also using Sprites, I don't know why it would be captured while the electrons are not.

Faraday's Electromagnetic Lab screenshot

pixelzoom commented 8 months ago

I see this problem on macOS 14.4 with all browsers: Chrome 123, Safari 17.4, Firefox 123.

pixelzoom commented 8 months ago

FEL Sprites are currently rendered using Canvas because of the problem in https://github.com/phetsims/faradays-electromagnetic-lab/issues/109. But setting webgl: true in FELSim for does NOT fix the problem.

jonathanolson commented 8 months ago

I see canvasBounds being set in FieldNode, but NOT in ElectronsNode. I believe the absence of this is preventing it from showing up in screenshots.

This seems like a large landmine I've laid. I think it is reasonable to say "if a Sprites instance draws something, it should have a non-negative-area bounds". I think it's also reasonable to add an assertSlow that says "every sprite drawn with non-zero alpha should overlap with the CanvasBounds" (it would be stronger to say contained inside, HOWEVER we might have sprites with a good amount of transparent padding).

jonathanolson commented 8 months ago

Added canvasBounds in ElectronsNode (let me know if that's not good for performance), and assertions in Scenery that should get the majority of things. I'm going to opt out of the assertSlow for now, potentially to add in the future (but it isn't as trivial to add).

pixelzoom commented 8 months ago

Thanks @jonathanolson. Performance seems fine, and electrons are now captured in Screenshot.

Closing.