javascript - BufferGeometry offsets and indices -
i wondering while "offsets" , "indices / index" are. offsets e.g. mentioned in https://github.com/mrdoob/three.js/blob/dev/src/core/buffergeometry.js , indices mentioned in indexedgeometry, can't find anymore in dev tree. although indices seem rather obvious , although dive code figure out maybe-correct answer myself i'd love hear "official" statement :)
thanks!
there 2 ways defining geometries:
non-indexed
"vertices": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, ... ], "normals": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, ... ]
in mode every triangle position defined , can't reuse data.
triangle 0: [ 0, 1, 2, 3, 4, 5, 6, 7, 8 ]
indexed
"indices": [ 0, 1, 2, ... ], "vertices": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, ... ], "normals": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, ... ]
in mode, indices define order of data. first triangle using indices 0
, 1
, , 2
. these indices used fetch vertices
, normals
data:
triangle 0: [ 0, 1, 2, 3, 4, 5, 6, 7, 8 ]
the main benefit of indexed possibility of reusing data , uploading less data gpu:
"indices": [ 0, 0, 0, ... ], "vertices": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, ... ] triangle 0: [ 0, 1, 2, 0, 1, 2, 0, 1, 2 ]
as per offsets...
with offsets can render specific ranges of geometry. instead of drawing triangle 0
triangle.length
, can draw triangle 200
triangle 400
.
Comments
Post a Comment