Hi,
I’ve gone through existing topics, but could not find anything that assists me in converting the following code to BufferGeometry.
It’s been years since this was put together, without any documentation on the code, so I’m not even sure what this is doing. What I observe, however, is that this essentially decides on which faces should show the texture.
How could I achieve the same with the “new” BufferGeometry?
const sgeo = this.geometry;
const vs = sgeo.vertices;
const faces = sgeo.faces;
const fuv = sgeo.faceVertexUvs[0];
const xlength = this.xlength;
const ylength = this.ylength;
for (var i = 0; i < fuv.length; i++) {
// Face uv
const f = fuv[i];
let x, y;
f[0].xp = vs[faces[i].a].x;
f[0].yp = vs[faces[i].a].y
f[1].xp = vs[faces[i].b].x;
f[1].yp = vs[faces[i].b].y
f[2].xp = vs[faces[i].c].x;
f[2].yp = vs[faces[i].c].y
for (var j = 0; j < 3; j++) {
f[j].x = (f[j].xp + this.offset.x) / xlength * nhs * o.hs + (ou - o.ou * nhs);
f[j].y = (f[j].yp + this.offset.y) / ylength * vhs * o.vs + (ov - o.ov * vhs);
}
}
this.geometry.uvsNeedUpdate = true;
this.setTexture(tex);
Thanks for assistance!