最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - BufferGeometry offsets and indices - Stack Overflow

programmeradmin0浏览0评论

I was just wondering for a while now what exactly "offsets" and "indices / index" are. Offsets are e.g. mentioned in .js/blob/dev/src/core/BufferGeometry.js and indices were mentioned in IndexedGeometry, however I can't currently find it anymore in the dev tree. Although indices seem rather obvious and although I could dive into the code to figure out some maybe-correct answer for myself I'd love to hear an "official" statement :)

Thanks!

I was just wondering for a while now what exactly "offsets" and "indices / index" are. Offsets are e.g. mentioned in https://github./mrdoob/three.js/blob/dev/src/core/BufferGeometry.js and indices were mentioned in IndexedGeometry, however I can't currently find it anymore in the dev tree. Although indices seem rather obvious and although I could dive into the code to figure out some maybe-correct answer for myself I'd love to hear an "official" statement :)

Thanks!

Share Improve this question edited Feb 3, 2016 at 16:04 Wilt 44.6k15 gold badges161 silver badges214 bronze badges asked May 30, 2014 at 6:47 DoidelDoidel 1,7791 gold badge16 silver badges21 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 8

There are two ways to 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 this mode every triangle position is as defined and you 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 this mode, indices define the order of the data. The first triangle is using indices 0, 1, and 2. These indices will be used to fetch the vertices and normals data:

triangle 0: [ 0, 1, 2,  3, 4, 5,  6, 7, 8 ]

The main benefit of indexed is the possibility of reusing data and uploading less data to the 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 you can render specific ranges of your geometry. Instead of drawing from triangle 0 to triangle.length, you can draw from triangle 200 to triangle 400.

发布评论

评论列表(0)

  1. 暂无评论