Does converting a Geometry to a BufferGeometry in Three.js increase the number of vertices?

前端 未结 2 1354
走了就别回头了
走了就别回头了 2021-01-22 07:59

I\'ve been using the fromGeometry method to make BufferGeometry objects from regular Geometry objects, and I\'ve found that it seems the number of vertices increases during the

2条回答
  •  无人及你
    2021-01-22 08:17

    The best way to find out the answer to these questions is just to look at the three.js code. It is very accessible and generally easy to follow.

    First we can look up the BufferGeometry.fromGeometry method:

    fromGeometry: function ( geometry ) {
    
        geometry.__directGeometry = new THREE.DirectGeometry().fromGeometry( geometry );
    
        return this.fromDirectGeometry( geometry.__directGeometry );
    
    }
    

    Which you can see is calling DirectGeometry.fromGeometry

    fromGeometry: function ( geometry ) {
        // ...
        var vertices = geometry.vertices;
        // ...
        for ( var i = 0; i < faces.length; i ++ ) {
            // ...
            this.vertices.push( vertices[ face.a ], vertices[ face.b ], vertices[ face.c ] );
            // ...
        }
        // ...
    }
    

    And here you can clearly see that it is adding additional vertices that come from the geometry faces property. The answer by gaitat gives a great example as to why that is!

提交回复
热议问题