Currently, I am working on a three.js project that involves displaying numerous spherical objects. To achieve this quickly, I decided to utilize buffergeometry. Upon researching, I came across a helpful post here, where I learned that I could transform normal geometry into buffergeometry using the following code:
var sphere = new THREE.SphereGeometry( 4, 0.05, 0.025 );
var geometry = THREE.BufferGeometryUtils.fromGeometry( sphere );
However, when implementing this code, it does not seem to work for me. The remaining portion of the code responsible for creating the object is as follows:
var positions = new Float32Array( x_GAMA.length * 3 );
for ( var i = 0; i < x_GAMA.length; i += 1 ) {
// positions
positions[ 3*i ] = x_GAMA[i]*10000;
positions[ 3*i + 1 ] = y_GAMA[i]*10000;
positions[ 3*i + 2 ] = z_GAMA[i]*10000;
}
geometry.addAttribute( 'position', new THREE.BufferAttribute( positions, 3 ) );
var material = new THREE.PointCloudMaterial( {size:1,color:0x999999} );
geometry.computeBoundingSphere();
particleSystem = new THREE.PointCloud( geometry, material );
scene.add( particleSystem );
When I replace the line
var geometry = new THREE.BufferGeometry();
it works fine, but it creates squares instead of spheres which is not what I desire. Does anyone have any insights as to why this approach is not working as expected? Thank you in advance.