BufferGeometry偏移量和索引 [英] BufferGeometry offsets and indices
问题描述
我只想知道一段时间究竟是什么抵消和指数/指数。偏移是例如在 https://github.com/mrdoob/three中提到IndexedGeometry中提到了.js / blob / dev / src / core / BufferGeometry.js 和索引,但我现在无法在开发树中找到它。
虽然指数看起来相当明显,虽然我可以深入研究代码,为自己找出一些可能正确的答案,我很乐意听到官方陈述:)
I was just wondering for a while now what exactly "offsets" and "indices / index" are. Offsets are e.g. mentioned in https://github.com/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 :)
谢谢!
推荐答案
定义几何有两种方法:
非索引
"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 ]
已编入索引
"indices": [ 0, 1, 2, ... ],
"vertices": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, ... ],
"normals": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, ... ]
在此模式下,索引定义数据的顺序。第一个三角形是使用索引 0
, 1
, 2
。这些索引将用于获取顶点
和法线
数据:
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 ]
索引的主要好处是可以重用数据并将较少的数据上传到GPU:
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 ]
根据抵消 ...
借助抵消,您可以渲染特定的范围几何。而不是从三角形0
到 triangle.length
,您可以从三角形200
到三角形400
。
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
.
这篇关于BufferGeometry偏移量和索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!