title: Distance based addition of points to vertices (mesh geometry)
body: <p>I have a <code>THREE.Geometry</code> in my scene that contains over 5,000 vertices. What I want to do is to add <code>THREE.Points</code> to the scene for <strong>only 3 vertices</strong> of the mesh containing the geometry. I want to achieve something like this: </p>
  
  <p><a href="https://i.stack.imgur.com/o97yd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/o97yd.png" alt="enter image description here"></a></p>
  
  <p>I took the 3 vertices of the first face of the existing geometry and added them to the vertices of my new geometry, which is supposed to contain the 3 vertices. I used <code>THREE.Points</code> and <code>THREE.PointsMaterial</code> but I have tried out the same thing with <code>THREE.LineSegments</code> and <code>THREE.LineBasicMaterial</code> and the result is the same. (with the exception that instead of points there are lines).</p>
  
  <pre><code>var vertices = [
    mesh.geometry.faces[0].a,
    mesh.geometry.faces[0].b,
    mesh.geometry.faces[0].c
  ];
  
  
  vertices.forEach( function(vId,i){
    vertices[i].index = i;
    vertices[i] = mesh.geometry.vertices[vId].clone();
    vertices[i].l2w = mesh.localToWorld(vertices[i].clone());
    vertices[i].id = vId;
    vertices[i].distance = vertices[i].l2w.distanceTo(camera.position);
  
  })
  
  
  var plane_geom = new THREE.Geometry();
  plane_geom.vertices.push(vertices[0]);
  plane_geom.vertices.push(vertices[1]);
  plane_geom.vertices.push(vertices[2]);
  
  
  plane_geom.verticesNeedUpdate = true;
  plane_geom.elementsNeedUpdate = true;
  plane_geom.computeVertexNormals();
  
  
  var pointsMaterial2 = new THREE.PointsMaterial({
    size: 2,
    color: "red"
  });
  
  var plane_mesh =  new THREE.Points( plane_geom, pointsMaterial2 );
   scene.add( plane_mesh );
  
  
  mesh.geometry.dispose();
  mesh.material.dispose();
  scene.remove( mesh);
  </code></pre>
  
  <p>and my initial geometry is globally defined, is the geometry of the loaded STL-object and is of type <code>THREE.Geometry</code>. The mesh with this geometry is added to the scene in the init function. The geometry object looks as follows:</p>
  
  <pre><code>__directGeometry: Object { vertices: (30006) […], normals: (30006) […], 
  colors: (30006) […], … }
  __bufferGeometry: Object { uuid: "10EE834D-B19E-4C27-B831-F484D908DB06",                   
  name: "", type: "BufferGeometry", … }
  _listeners: Object { dispose: (1) […] }
  boundingBox: Object { min: {…}, max: {…} }
  boundingSphere: Object { center: {…}, radius: 135.73491999459804 }
  colors: Array []
  colorsNeedUpdate: false
  elementsNeedUpdate: false
  faceVertexUvs: Array [ [] ]
  faces: Array(10002) [ {…}, {…}, {…}, … ]
  groupsNeedUpdate: false
  id: 2
  lineDistances: Array []
  lineDistancesNeedUpdate: false
  morphNormals: Array []
  morphTargets: Array []
  name: ""
  normalsNeedUpdate: false
  skinIndices: Array []
  skinWeights: Array []
  type: "Geometry"
  uuid: "0EB01FF3-E9BF-4CAD-AA97-5EC2933F0D9C"
  uvsNeedUpdate: false
  vertices: Array(5003) [ {…}, {…}, {…}, … ]
  verticesNeedUpdate: false
  </code></pre>
  
  <p>After adding the new mesh <code>plane_mesh</code> with the new geometry to the scene, all the points (on each vertex) of the geometry are displayed (over 5,000 points). However, if I dispose the initial mesh from the scene, I can see just the 3 points. When printing out <code>plane_mesh</code> everything seems normal and the mesh contains only the 3 vertices... 
  After a lot of trial and error, I realized that all of the operations are performed on the initial mesh. Only after disposing of the mesh, <code>plane_mesh</code> is added to the scene. </p>
  
  <p>Any help would be greatly appreciated!</p>