title: Three.js Efficiently Mapping Uvs to Plane
body: <p>I'm working on a game where there are many walls of the same texture but at different lengths/heights. Currently I am cloning a base texture and setting the repeat values for each wall. This creates to many textures in memory.</p>
  
  <p>What I want to do is to alter the planes uvs to fit the textures properly. I took a stab at this a came up with some meh results.</p>
  
  <pre><code>            var X = 2000;
              var Y = 1000;
  
              var seg = Math.ceil(X/Y);
  
              var wallgeo = new THREE.PlaneGeometry(X,Y,seg,1);
  
              var uvs = [];
              for(var i=0,len=wallgeo.faces.length;i&lt;len;i+=2){
                  uvs.push([new THREE.Vector2(0,1),new THREE.Vector2(0,0),new THREE.Vector2(1,1)]);
                  uvs.push([new THREE.Vector2(0,0),new THREE.Vector2(1,0),new THREE.Vector2(1,1)]);               
              }       
  
              wallgeo.faceVertexUvs = [uvs];
              wallgeo.uvsNeedUpdate = true;
  
              var walltex = DDSLoader.load('materialmaptextures/21_2048.dds');
              var wallmat = new THREE.MeshPhongMaterial({map:walltex, transparent:true, wireframe:false});
              wall = new THREE.Mesh(wallgeo,wallmat);
              wall.position.set(0,Y/2,-300);
  
              scene.add(wall);
  </code></pre>
  
  <p>The problems with this as you can probably tell are that for one additional faces are created, not a huge deal but I would really like to avoid this. Most importantly if the planes length is not evenly divisible by its height the texture will stretch/compress. Also, the planes height segments in this are fixed causing restrictions.</p>
  
  <p>I'm not so much concerned with creating additional faces. Is this necessary? Can one face have more than one uv per triangle? Does it need to?</p>
  
  <p>I am new to messing with Uv's, there has got to be an efficient way to make my walls not look absurd without blowing up memory, right?</p>
  
  <p>Demo: <a href="http://www.titansoftime.com/uv.php" rel="noreferrer">http://www.titansoftime.com/uv.php</a></p>