How to dispose BufferAttribute Array on updates?

We are trying to update a BufferAttribute with new position data. We want to dispose it on upload. When the buffer gets created, we utilize onUploadCallback to dispose the array data on CPU. We were expecting onUploadCallback to be called during update as well. It appears it is not. Currently, our work around is to create a new BufferAttribute since it calls the onUploadCallback.

We were wondering if WebGLAttributes.update should also call onUploadCallback or if our current approach is correct ?

Thanks !

I think it’s okay to enhance WebGLAttributes.update() so this behavior is true. I see no reason why an update of an existing buffer should not execute onUploadCallback(). In both cases, data are uploaded to the GPU and user might want to free the reference to BufferAttribute.array.

Do you want to make a PR with this proposal?

Thanks for your guidance.
I created https://github.com/mrdoob/three.js/pull/18016

1 Like