I cannot seem to get my normal data into the buffergeometry.
This is my current code.
let Id = 0;
let geometry = new THREE.BufferGeometry();
let vertices = [...];
let indices = [...];
let normals = [0.002, 0.1, 3.0, ...];
geometry.setIndex(new THREE.BufferAttribute(indices, 1));
geometry.setAttribute( 'position', new THREE.Float32BufferAttribute(vertices, 3));
geometry.computeFaceNormals();
geometry.computeVertexNormals();
const texture = new THREE.TextureLoader().load('Textures/DefaultTexture.jpg');
const material = new THREE.MeshPhongMaterial({map: texture});
MeshArray[Id] = new THREE.Mesh(geometry, material);
Scene.add(MeshArray[Id]);
Id++;
if i call this⦠instead of computeFaceNormals()ā¦
geometry.setAttrubite( ānormalā , new THREE.Float32BufferAttribute(normals, 3));
then i get this in the consoleā¦
geometry.setAttrubite is not a function at [line];
it doesnāt work like that, you need a unique vertex wherever there is something colliding, be it index, uv, normal, etc. Lets put it like this, best case scenario, the attribute with the most elements will win, thats how many vertices you will have. Worst case scenario youll have as many vertices as you have triangles aka a triangle soup.