0

So, I want to make a simple terrain editor. So, on mouseDown, I want the selected face to move up. The intersection works great, and I try to modify the geometry like so:

        var intersects2 = ray.intersectObjects([plane]);
        if (intersects2.length > 0) {
            var face = intersects2[0].face;
            var obj1 = intersects2[0].object;

            var geo = obj1.geometry;

            geo.vertices[face.a].z += 50;
            geo.vertices[100].z += 50;
            geo.vertices[0].z += 50;


            geo.computeVertexNormals();
            geo.computeFaceNormals();

            geo.__dirtyVertices = true;
            geo.__dirtyNormals = true;

            console.log(face.a);

        }

The console log shows the correct vertex index, but nothing on the plane moves. Any ideas why?

The plane is created like this:

    var planegeo = new THREE.PlaneGeometry( 500, 500, 10, 10 );
    planegeo.dynamic = true;
    plane = new THREE.Mesh( planegeo, new THREE.MeshPhongMaterial( { color: 0x99ff66 } ) );
    plane.receiveShadow = true;
    scene.add( plane );
David Menard
  • 2,261
  • 3
  • 43
  • 67

1 Answers1

2

Looking at your code, it looks like you are using syntax pre R49. It may just be that you need to update your dirty flag code to (assuming you are now using a newer library!):

geo.verticesNeedUpdate = true;
geo.normalsNeedUpdate = true;
Neil
  • 7,861
  • 4
  • 53
  • 74