Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

This issue occurs due to shader compilation and GPU resource allocation that happen the first time a specific light configuration (type and number of lights) is used.
Since three.js internally caches compiled shaders, removing lights does not cause them to be recompiled when the same types and number of lights are created again.

The best solution is to avoid creating and destroying lights during gameplay.
At the beginning of the game scene, create only the minimum number of lights that will be used simultaneously during gameplay, and place them somewhere outside the camera view.
After that, instead of adding or removing lights during gameplay, reuse them by updating their position and intensity.

Additional notes about using lights have been added to the WithThreeJS Extension page.
Please also refer to the “Notes on Using Lights” section at the following URL:
https://pandako.itch.io/with-threejs-extension-for-gdevelop