Closed samreid closed 9 years ago
Hey @samreid why don't you go for this improvement
I reviewed the original specification given to Actual Concepts and noted that it said:
For “one color” light rays, two strategies should be implemented:
- scenery Line node instances should be pooled and reused (mutated) to avoid overhead in recreating and garbage collecting them.
- scenery Line node instances should be created and garbage collected for each change in lines The above strategies should be compared for performance on at least iPad/Safari (on iOS8), OSX/Chrome and Win/Firefox. If the performance is within 5%, then the simpler algorithm (2) should be used, otherwise the faster algorithm should be used.
@ChandrashekarBemagoni I would recommend the following changes specifically:
Actually, from https://github.com/phetsims/bending-light/issues/162 it seems like it would be even better to use canvasnode/webglnode to show all of the light rays in the Prisms screen.
So for this issue please focus on recommendation (1) from above, which is:
For the model for the first and 3rd screens, create 3 ray view instances. One for "incoming" "transmitted" and "reflected". Reuse these view elements when the model changes instead of recreating them in each frame. Set their positions using setLine() and set their opacity/color with setOpacity() and setFill().
It looks like the canvas node solution I'm developing for #162 will work well here. I'll reassign the issue to me.
Since we are using canvas to render all the solid light rays from #162, I have removed LightRayNode.js and will close this issue.
The First screen of Bending Light would go much faster if the LightRayNodes were mutated instead of destroyed/created at each frame. There is a call to set the start and end in one call: setLine. The create/destroy pattern is a direct port from the original Java but now this needs to be improved to have higher performance.
@ariel-phet who would you like to work on this?