Skip to content

Commit

Permalink
add cache empty check and set a default value
Browse files Browse the repository at this point in the history
  • Loading branch information
lafflan committed May 10, 2024
1 parent a2f0682 commit 6c81187
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions examples/jsm/renderers/CSS2DRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,11 @@ class CSS2DRenderer {

}

const distanceA = cache.objects.get( a ).distanceToCameraSquared;
const distanceB = cache.objects.get( b ).distanceToCameraSquared;
const cacheDataA = cache.objects.get( a );
const distanceA = cacheDataA ? cacheDataA.distanceToCameraSquared : 0;

const cacheDataB = cache.objects.get( b );
const distanceB = cacheDataB ? cacheDataB.distanceToCameraSquared : 0;

return distanceA - distanceB;

Expand Down

0 comments on commit 6c81187

Please sign in to comment.