supermedium / aframe-environment-component

:sunrise_over_mountains: Infinite background environments for A-Frame in a line of HTML.
https://supermedium.com/aframe-environment-component/
MIT License
456 stars 112 forks source link

Only create stars if needed and dispose them when no longer needed #99

Closed mrxz closed 5 months ago

mrxz commented 5 months ago

When the sky is set to atmosphere the stars entity and mesh are generated. However, this also happens if the computed number of stars is 0, which is the case for several of the presets. While nothing is being drawn it still has some drawbacks:

  1. Three.js still prepares everything for this draw call (e.g. uniforms), which is just wasted effort
  2. The Quest browser logs a warning each frame (RENDER WARNING: Render count or primcount is 0.), which after logging 256 warnings stops any further WebGL errors from being logged.

This PR adds an additional check if the star count is 0, in which case the stars aren't created (or even disposed/removed if created prior).

dmarcos commented 5 months ago

Thank you!