I am trying to set the UV indicator indices on a face in BufferGeometry.
I start with geometry. Every facet of my geometry has a face.materialIndexcorresponding UV index. I am trying to convert this to BufferGeometry and then map to face.materialIndexwith BufferGeometry.
Here is what I still have:
const bufGeo = new BufferGeometry().fromGeometry( geometry );
const faceIndices = geometry.faces.map( face => face.materialIndex );
const indices = new Uint16Array( faceIndices );
bufGeo.setIndex( new BufferAttribute( indices, 1 ) );
Right now it seems to clog my grid and make it not draw at all. What am I doing wrong?
, , BufferGeometry, Three.js , DirectGeometry. , , - . , , Geo > BufGeo.
( setIndex):
const indices = new Uint16Array( faceIndices.length * 3 );
bufGeo.addAttribute( 'index', new BufferAttribute( indices, 1 ).copyIndicesArray( faceIndices ) );
. .