Add public getMeshGeometry to Babylon Lite API

Currently, Babylon Lite provides updateMeshGeometry to write geometry data to a mesh, but there is no public function to read that data back. Developers are forced to rely on internal fields (_cpuPositions, etc.) which are not part of the public API and may change.

Would it be possible to add a symmetrical getMeshGeometry(mesh: Mesh) function that returns copies of the CPU-side geometry (positions, normals, indices, UVs, tangents, colors) if available?

Want to suggest a PR? feels like a perfectly tree-shakable function that won’t harm any other part of the implementation

Seems in this case there is no need to add a new scene to the Lab?
Do we need more atomic functions as, for example, getMeshPositions?
(like updateMeshPositions, updateMeshUvs etc)
Do we need a common interface like
engine: EngineContext,
mesh:Mesh,
positions:Float32Array,
normals:Float32Array,
indices:Uint32Array,
uvs?:Float32Array<ArrayBufferLike>,
uvs2?:Float32Array<ArrayBufferLike>,
tangents?:Float32Array<ArrayBufferLike>,
colors?:Float32Array<ArrayBufferLike>,

or it is OK as it is now?

Seems there are too much questions which I cannot solve at my side :slight_smile:

1 Like

Great questions :slight_smile:

let’s start with the getMeshGeometry for now. No need for a new scene for that, this is just a help function. a unit test would be nice, just to be sure the function works

PR created

1 Like

Merged! thanks mate!

1 Like