在Three.js的这个方法中可以观察各个Geometry的转换
Geometry
geometry.vertices
geometry.faceVertexUvs
geometry.faces
BufferGeometry
geometry.attributes
geometry.attributes.position
geometry.attributes.uv
geometry.attributes.normal
geometry.index
目前为止的观察,发现所有的Geometry都会到projectObject进行转换,最后转换成BufferGeometry。
Geometry操作起来比BufferGeometry简单,应该是把BufferGeometry在包装一次了。
BufferGeometry是接近WegGL操作的,有点难度,但是更强大。
function projectObject( object, camera, groupOrder, sortObjects )

Geometry
Geometry转换成BufferGeometry

BoxGeometry
BoxGeometry转换成BufferGeometry

CubeGeometry
CubeGeometry转换成BufferGeometry

但有些Geometry并不会转换成BufferGeometry
XXXXBufferGeometry就是了
比如ShapeBufferGeometry、ExtrudeBufferGeometry和InstancedBufferGeometry并没有转换成BufferGeometry
因为他们本身就是BufferGeometry
ShapeBufferGeometry

ExtrudeBufferGeometry
比ShapeBufferGeometry多了个groups

Threejs的computeBoundingSphere方法
不管是Geometry还是BufferGeometry都有computeBoundingSphere方法,而且是初始化中必须执行。
两者的区别:BufferGeometry的方法computeBoundingSphere认为一定存在attributes,然后对attributes的一些数据进行操作。
而Geometry不管是否存在attributes,也不操作attributes的数据操作。
执行computeBoundingSphere的地方【intersectsObject: function ()】

Geometry的computeBoundingSphere方法

BufferGeometry的computeBoundingSphere方法

结论
最后结论是只要掌握好BufferGeometry的attributes以及其他属性的用法,用BufferGeometry可以全部搞定,不需要其他的Geometry。
970

被折叠的 条评论
为什么被折叠?



