Estimate the GPU-resident byte footprint of a geometry by summing
the underlying typed-array byte lengths of every attribute (and
the index, if present). Mirrors what THREE.js will actually upload
— slightly overstates because we count the full backing array even
if count < array.length / itemSize, but that's the footprint that
matters for pool memory pressure.
The result is cached on geometry.userData.cachedByteSize so repeated
stats polls don't re-iterate attribute byteLengths. Grow paths
invalidate the cache via invalidateCachedByteSize(). The one change no
caller can invalidate for is the index WIDTH: the WebGPU backend rewrites a
narrow (Uint16) index to Uint32 in place at first upload (see
applyMeshIndices), after the commit measured it — so the cache is also
keyed on the index array's byte length, an O(1) check per poll.
Estimate the GPU-resident byte footprint of a geometry by summing the underlying typed-array byte lengths of every attribute (and the index, if present). Mirrors what THREE.js will actually upload — slightly overstates because we count the full backing array even if
count < array.length / itemSize, but that's the footprint that matters for pool memory pressure.The result is cached on
geometry.userData.cachedByteSizeso repeated stats polls don't re-iterate attribute byteLengths. Grow paths invalidate the cache viainvalidateCachedByteSize(). The one change no caller can invalidate for is the index WIDTH: the WebGPU backend rewrites a narrow (Uint16) index to Uint32 in place at first upload (seeapplyMeshIndices), after the commit measured it — so the cache is also keyed on the index array's byte length, an O(1) check per poll.