LightsNode: Fix castShadow regression.#31106
Conversation
📦 Bundle sizeFull ESM build, minified and gzipped.
🌳 Bundle size after tree-shakingMinimal build including a renderer, camera, empty scene, and dependencies.
|
| return hashArray( hashData ); | ||
| const cacheKey = hashArray( _hashData ); | ||
|
|
||
| _hashData.length = 0; |
There was a problem hiding this comment.
Do we have any source that .length=0 is better than other alternatives?
I didn't do an extensive beachmark, but I had done some tests between creating a new array and using .length=0 and creating a new array worked better. It seems that both force the GC, using null values after use was what worked best for small arrays.
There was a problem hiding this comment.
I've tried to find the original issue/PR where we discussed this but without success so far. It's many years ago but at that time, setting a zero length was the fastest way to clear an array. And it does no create a new array object like the previous approach which invalidates the previous object.
I'm surprised to hear that .length=0 triggers the GC. The array itself is just empty and the reference to it is not set to null or cleared.
There was a problem hiding this comment.
We can revisit the array management at any point again. Merging for now so the toggling issue is fixed on dev.
* LightsNode: Fix `castShadow` regression. * Update AnalyticLightNode.js
* LightsNode: Fix `castShadow` regression. * Update AnalyticLightNode.js
Related issue: https://discourse.threejs.org/t/webgpu-shadow-tests-and-findings/82561
Description
Toggling
light.castShadowwithWebGPURendererhas currently no effect.The bit that checks the light state per frame is
LightsNode.customCacheKey(). In this method we have to implement all checks that detect state changes of lights.