How to use faceVertexUvs from new version of three.js?

how to use faceVertexUvs from new version of three.js?

    var geom = new BufferGeometry();
    
    ....
    
//Don't know to write here?

    // geom.faceVertexUvs[0][0] = [ new Vector2(0, 0),new Vector2(1, 0),new Vector2(0, 1)];
    
    // geom.faceVertexUvs[0][1] = [ new Vector2(0, 1),new Vector2(1, 0),new Vector2(1, 1)];



I try to write this,but not work.

where is wrong?

             var uv = [new Vector2(0, 0), new Vector2(1, 0), new Vector2(0, 1)];

                var uv2 = [new Vector2(0, 1), new Vector2(1, 0), new Vector2(1, 1)];

                var uvAttribute:Array<BufferAttribute> = geom.getAttribute('uv');

                var uvAttribute2:Array<BufferAttribute> =geom.getAttribute('uv2');

                for (var i=0;i<uvAttribute.length;i++) {

                    uvAttribute[i].setXY(i, uv[i].x, uv[i].y);

                }

                for (var j=0;i<uvAttribute2.length;j++) {

                    uvAttribute2[j].setXY(j, uv[j].x, uv[j].y);

                }

Simple examples from the Collection of examples from discourse.threejs.org

BufferGeometryNonIndexed

BufferGeometryIndexed

uvAttribute[i].setXY(i, uv[i].x, uv[i].y);,
try it this way
uvAttribute.setXY(i, uv[i].x, uv[i].y);

The same way for uvAttribute2.

1 Like