MeshAttributeBuffer currently exposes a lot of functionality that would break in cases where it is created by a Mesh instance.
For instance Mesh.getBufferForAttributeType(type).setVertexCount(42) would result in issues because you should really be doing Mesh.setVertexCount(42).
At the moment, it seems like only Mesh.getBufferForAttributeType() and Mesh.getBuffers() expose attribute buffers. We could make these private. This would mostly break tests, but there's some other places where this is currently in use as well:
Many tests use mesh.getBufferForAttributeType(type).getVertexData(type). This can be replaced with mesh.getVertexData(type).
Some tests use getBufferForAttributeType to get info such as isUnused and the configuration of attributes.
CachedMeshData uses mesh.getBuffers() to read the bytes from each buffer and listen for changes.
ProjectAssetTypeMesh uses mesh.getBuffers() to read bytes and attribute configuration in order to write it to .rmesh files
PropertiesAssetContentMesh uses getBuffers() to show attribute types in UI. But it seems like changing the types from UI is currently not supported.
Finally getBuffers() can also be useful to serialize mesh data in order to transfer it from and to web workers.
I think the best approach here is to create another class type which does expose some of the functionality, while keeping others as getters only.
MeshAttributeBuffer
currently exposes a lot of functionality that would break in cases where it is created by aMesh
instance. For instanceMesh.getBufferForAttributeType(type).setVertexCount(42)
would result in issues because you should really be doingMesh.setVertexCount(42)
.At the moment, it seems like only
Mesh.getBufferForAttributeType()
andMesh.getBuffers()
expose attribute buffers. We could make these private. This would mostly break tests, but there's some other places where this is currently in use as well:mesh.getBufferForAttributeType(type).getVertexData(type)
. This can be replaced withmesh.getVertexData(type)
.getBufferForAttributeType
to get info such asisUnused
and the configuration of attributes.CachedMeshData
usesmesh.getBuffers()
to read the bytes from each buffer and listen for changes.ProjectAssetTypeMesh
usesmesh.getBuffers()
to read bytes and attribute configuration in order to write it to .rmesh filesPropertiesAssetContentMesh
usesgetBuffers()
to show attribute types in UI. But it seems like changing the types from UI is currently not supported.getBuffers()
can also be useful to serialize mesh data in order to transfer it from and to web workers.I think the best approach here is to create another class type which does expose some of the functionality, while keeping others as getters only.