-
-
Notifications
You must be signed in to change notification settings - Fork 35.9k
LightsNode: Fix castShadow
regression.
#31106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ const getLightNodeById = ( id, lightNodes ) => { | |
}; | ||
|
||
const _lightsNodeRef = /*@__PURE__*/ new WeakMap(); | ||
const _hashData = []; | ||
|
||
/** | ||
* This node represents the scene's lighting and manages the lighting model's life cycle | ||
|
@@ -114,27 +115,31 @@ class LightsNode extends Node { | |
*/ | ||
customCacheKey() { | ||
|
||
const hashData = []; | ||
const lights = this._lights; | ||
|
||
for ( let i = 0; i < lights.length; i ++ ) { | ||
|
||
const light = lights[ i ]; | ||
|
||
hashData.push( light.id ); | ||
_hashData.push( light.id ); | ||
_hashData.push( light.castShadow ? 1 : 0 ); | ||
|
||
if ( light.isSpotLight === true ) { | ||
|
||
const hashMap = ( light.map !== null ) ? light.map.id : - 1; | ||
const hashColorNode = ( light.colorNode ) ? light.colorNode.getCacheKey() : - 1; | ||
|
||
hashData.push( hashMap, hashColorNode ); | ||
_hashData.push( hashMap, hashColorNode ); | ||
|
||
} | ||
|
||
} | ||
|
||
return hashArray( hashData ); | ||
const cacheKey = hashArray( _hashData ); | ||
|
||
_hashData.length = 0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we have any source that I didn't do an extensive beachmark, but I had done some tests between creating a new array and using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can revisit the array management at any point again. Merging for now so the toggling issue is fixed on dev. |
||
|
||
return cacheKey; | ||
|
||
} | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.