Reputation: 31
I'm trying to change faces coordinates by modify the vertices. The values of the variables are correct, but no change on the screen.
This is the plain
And this is my code :
var geometry = editor.selected.geometry;
var vertices = geometry.vertices;
vertices[1] = new THREE.Vector3(-100 / 3, 50, 0);
vertices[5] = new THREE.Vector3(-100 / 3, 0, 0);
var uvs = geometry.faceVertexUvs[0];
uvs[0] = [new THREE.Vector2(0, 1), new THREE.Vector2(0, 0.5), new THREE.Vector2(1 / 6, 1)];
uvs[1] = [new THREE.Vector2(0, 0.5), new THREE.Vector2(1 / 6, 0.5), new THREE.Vector2(1 / 6, 1)];
uvs[2] = [new THREE.Vector2(1 / 6, 1), new THREE.Vector2(1 / 6, 0.5), new THREE.Vector2(2 / 3, 1)];
uvs[3] = [new THREE.Vector2(1/ 6, 0.5), new THREE.Vector2(2 / 3, 0.5), new THREE.Vector2(2 / 3, 1)];
geometry.computeVertexNormals();
geometry.computeFaceNormals();
geometry.__dirtyVertices = true;
geometry.__dirtyNormals = true;
geometry.verticesNeedUpdate = true;
geometry.normalsNeedUpdate = true;
geometry.uvsNeedUpdate = true;
Any suggestions?
Upvotes: 1
Views: 460
Reputation: 12632
You are changing vertices that lie inside the border of the shape. Thats why you dont see a change. If you turn on wireframe
on your material you will see that the vertices do change. Take a look at this fiddle:
Also for your uvs
it should be:
var uvs = geometry.faceVertexUvs[0];
Upvotes: 1