#faceVertexUvs error in three.js 0.159

12 messages · Page 1 of 1 (latest)

solid ginkgo
#

I got i Uncaught TypeError: Cannot set properties of undefined (setting '0') in newEggGeometry.faceVertexUvs[0] = [] in three.js 0.159
how can I fix that?
` const newEggGeometry = new THREE.LatheGeometry(points, 32);

  // Adjust UV mapping // benschiller_xyz
  newEggGeometry.faceVertexUvs[0] = [];
  for (let i = 0; i < newEggGeometry.faces.length; i++) {
    const face = newEggGeometry.faces[i];
    const v1 = newEggGeometry.vertices[face.a];
    const v2 = newEggGeometry.vertices[face.b];
    const v3 = newEggGeometry.vertices[face.c];
    newEggGeometry.faceVertexUvs[0].push([
      new THREE.Vector2((v1.x + 1) / 2, (v1.y + 1) / 1),
      new THREE.Vector2((v2.x + 1) / 2, (v2.y + 1) / 2),
      new THREE.Vector2((v3.x + 1) / 2, (v3.y + 1) / 2),
    ]);
  }
  newEggGeometry.uvsNeedUpdate = true;`
latent pine
#

you cant fix it, the property you are trying to use was removed long time ago, get a more recent tutorial

#

or, use ancient 3js version

solid ginkgo
latent pine
#

either that,

or, use ancient 3js version

#

well, actually there was a 3rd option but I requires git archeology now I think

#

there was a replacement of old Geometry class in examples/jsm/deprecated, I think, that made this code work with newer versions, but later it was removed too

solid ginkgo
#

whoops! 🤕

solid ginkgo
#

is there any way to get this result in three.js 0.159?

latent pine
#

yes, obviously - 2 of 3 discussed options would work with 159

solid ginkgo
latent pine
#

well 1 of the options was to use ancient 3js - this one does NOT work with 159
2nd was to rewrite the code - this one does work with 159
3rd was to find a deprecated helper class in git history - this one most probably does work too