In the glTF format,
mesh object positions go through three levels of indirection:
mesh -> accessor -> bufferView -> buffer.
How should mesh data be distributed across the accessors,
bufferViews, and buffers in a glTF file? Does it matter?
E.g. suppose I have two meshes, each with a POSITION attribute.
It seems that I have, essentially, four choices for laying out
the position data in the glTF file:
===============================================================
(A) one big shared accessor,bufferView,buffer for all positions
mesh 0 -+
+-> accessor 0 ---> bufferView 0 ---> buffer 0
mesh 1 -+
===============================================================
(B) accessor per mesh, one big shared bufferView,buffer
mesh 0 ---> accessor 0 -+
+-> bufferView 0 ---> buffer 0
mesh 1 ---> accessor 1 -+
===============================================================
(C) accessor,bufferView per mesh, one big shared buffer
mesh 0 ---> accessor 0 ---> bufferView 0 -+
+-> buffer 0
mesh 1 ---> accessor 1 ---> bufferView 1 -+
===============================================================
(D) accessor,bufferView,buffer per mesh
mesh 0 ---> accessor 0 ---> bufferView 0 ---> buffer 0
mesh 1 ---> accessor 1 ---> bufferView 1 ---> buffer 1
===============================================================
Of the above four layout choices, (A) produces the simplest most compact glTF files
(especially if the two meshes share some vertex positions).
So I’m not sure why I would ever use any of (B), (C), or (D).
The reason I’m asking is that I’m currently using (A) for creating my glTF files
(each file containing of thousands of meshes),
but I’m finding that it seems to have some problems when I
load the file into three.js and use it. For example:
- mesh bounding boxes aren’t being computed correctly by
Box3.setFromObject
(instead of producing a tight bounding box around only those vertices
referred to by the given mesh,
it produces a bounding box around all positions in the accessor… or maybe bufferView) - and I think maybe my single big buffer (or bufferView? or accessor?
not sure which) is getting duplicated many times in memory and/or GPU memory
(once per mesh that refers to it? there may be thousands),
which seems to be severely limiting the size of scene I can view.
So I think there must be an assumption (by threejs and/or other consumers
of glTF files) that I am using (B), (C), or (D) instead?
But I don’t know what is being assumed, or which layout I should use, in general.