BufferGeometry not accepting attributes?

Hi, I’m trying to create a buffer geometry from a Tetrahedron geometry and somehow it tells me bGeometry doesn have an addAttribute function… What am I doing here? I’m just passing position parameter because I only want to rotate this solid, nothing else.

var geometry = new THREE.TetrahedronGeometry(800, 2);
var bGeometry = new THREE.BufferGeometry().fromGeometry(geometry);
var positions = [];
geometry.faces.forEach( function ( face, index ) {
            positions.push( geometry.vertices[ face.a ].x );
            positions.push( geometry.vertices[ face.a ].y );
            positions.push( geometry.vertices[ face.a ].z );
            positions.push( geometry.vertices[ face.b ].x );
            positions.push( geometry.vertices[ face.b ].y );
            positions.push( geometry.vertices[ face.b ].z );
            positions.push( geometry.vertices[ face.c ].x );
            positions.push( geometry.vertices[ face.c ].y );
            positions.push( geometry.vertices[ face.c ].z );
        })
  console.log(bGeometry);
  bGeometry.addAtribute( 'position', new THREE.Float32BufferAttribute( positions, 3 ) );
  solid = new THREE.Mesh(bGeometry, material);
  solid.position.set(900, 200 , 0);

And on animation…

solid.rotation.x += 0.001;
solid.rotation.y += 0.001;
solid.rotation.z += 0.001;

I see a typo in your code: bGeometry.addAtribute().

A t is missing. Is this maybe the problem?

1 Like

@Mugen87 and @nvassalo,

The mis-spelled bGeometry.addAtribute is the problem, if there are any other problems, it has to do with deprecated code. And I don’t really see any, so fix that, and you should be good.

That was exactly it, of course…Thanks guys @Mugen87 @TheCodeCrafter

No problem :wink: