When i try this on a dodecahedron, the array has 107 vertices instead of the 20 it needs to have, how do i select 1 specific vertex and animate this 1 vertex
const geoDodeca = new THREE.DodecahedronGeometry( 3, 0 );
// geoDodeca.attributes.position.needsUpdate = true;
const matDodeca = new THREE.MeshLambertMaterial(
{
// wireframe: true,
color: 0x0077ff,
depthTest: true,
depthWrite: true,
flatShading: true,
dithering: true,
transparent: true,
opacity: 0.3
}
)
let meshDodeca = new THREE.Mesh(geoDodeca, matDodeca);
meshDodeca.name = 'dodecaMesh';
arrObjects.push(meshDodeca)
// :. selecting the dodeca vertices
const positionAttribute = meshDodeca.geometry.getAttribute( 'position' );
positionAttribute.needsUpdate = true;
positionAttribute.setUsage( THREE.DynamicDrawUsage );
const vertex = new THREE.Vector3();
// for ( let i = 0; i < 20; i ++ ) {
for ( let i = 0; i < positionAttribute.count; i ++ ) {
vertex.fromBufferAttribute( positionAttribute, i );
// do something with vertex
// vertex.set( ... ); // update vertex
// positionAttribute.setXYZ( i, vertex.x, vertex.y, vertex.z );
console.log('Vtx id: ' + i + ' ' + vertex.x + ', ' + vertex.y + ', ' + vertex.z )
// console.log(vertex)
}