Im trying to make a three js document which shows lots of spherical objects, the quickest way to do this is by using buffergeometry. From this post here I learned that I could convert normal geometry into buffergeometry using:
var sphere = new THREE.SphereGeometry( 4, 0.05, 0.025 ); var geometry = THREE.BufferGeometryUtils.fromGeometry( sphere );But this does not seem to work for me, the rest of the code that creates the object reads:
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 );It works fine if I use var geometry = new THREE.BufferGeometry(); but this creates squares which I do not want. Anyone have any idea why this does not seem to work? Thanks in advance.
1 Answer
In Three.js r71 you can create Sphere Buffer Geometry like this:
var sphereGeometry = new THREE.SphereGeometry( 4, 3, 2 );
var bufferSphereGeometry = new THREE.BufferGeometry().fromGeometry( sphereGeometry );In r72 dev you can do ít straightforward like this:
// constructor: radius, widthSegments, heightSegments, phiStart, phiLength, thetaStart, thetaLength
var sphereGeo = new THREE.SphereBufferGeometry( 4, 3, 2 ); //r72