three.js: vertices need update not working - r72

With r71 I could update vertices of my BoxGeometry for as below:

  var vertices = [];
  vertices.push(new THREE.Vector3(0.5, 0.5, 0.5));
  vertices.push(new THREE.Vector3(0.5, 0.5, -0.5));
  vertices.push(new THREE.Vector3(0.5, -0.5, 0.5));
  vertices.push(new THREE.Vector3(0.5, -0.5, -0.5));
  vertices.push(new THREE.Vector3(-0.5, 0.5, -0.5));
  vertices.push(new THREE.Vector3(-0.5, 0.5, 0.5));
  vertices.push(new THREE.Vector3(-0.5, -0.5, -0.5));
  vertices.push(new THREE.Vector3(-0.5, -0.5, 0.5));

  this._mesh.geometry.vertices = vertices;
  this._mesh.geometry.applyMatrix(
      new THREE.Matrix4().makeTranslation(
        dataCoordinates.x,
        dataCoordinates.y,
        dataCoordinates.z));
  this._mesh.geometry.verticesNeedUpdate = true;

It doesn’t work anymore on r72.

It doesn’t raise any error.

Is it supposed to work? If not, which is the current best practice to update vertices of a geometry?

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Reactions: 1
  • Comments: 30 (14 by maintainers)

Commits related to this issue

Most upvoted comments

If the decision is to not support the reassignment of any attribute, and require copy() or set() instead, then this issue can be closed.

I vote to consider reassignment as an invalid operation and close the issue.

Is this open issue still not fixed?

Seems like a workaround is to do delete box.geometry.__directGeometry;. Maybe we can do add a new flag that recreated the DirectGeometry.

@jniac Please read my comments above. Change UV values using Vector2.set() – do not replace the faceVertexUvs array.

@WestLangley Thanks - just calling “set” on every single vertex of the vertices array seems to work.

r72 (working): http://codepen.io/nicolasrannou/pen/zvqyrj