title: THREE.js custom tangent attribute how do i load it
body: <p>I'm looking at this example:</p>
  
  <p><a href="http://threejs.org/examples/webgl_custom_attributes.html" rel="nofollow">http://threejs.org/examples/webgl_custom_attributes.html</a></p>
  
  <p>and notice that the custom displacement attribute gets filled by vertices.length</p>
  
  <pre><code>for ( var v = 0; v &lt; vertices.length; v++ ) {
      values[ v ] = 0;
      noise[ v ] = Math.random() * 5;
      }
  </code></pre>
  
  <p>My question is, how does this relate to the number of normals, uvs and tangents? </p>
  
  <p>When i export my model from 3ds max, i have more UVs than vertices. I need to assign tangents per this UV number because they are different at seams. I can't export a mesh that has double vertices at seams but while still keeping the averaged normals. But i have been able to export tangents and bitangents as another JSON model (i export them as vertex pos). </p>
  
  <p>How exactly does all of this work, because i assume, even though that there are less vertices than UVs, the GPU actually breaks this apart and doubles the vertices at every UV seam, but i have no idea how to map all of this in the attribute buffer. </p>
  
  <p><strong>updated</strong></p>
  
  <p>I wrote a little exporter for max, basically mimicking the JSON structure:</p>
  
  <pre><code>"vertices": [floats],
  "vertices_count": 486,
  "uvs": [[floats]],
  "uv_count": 364,
  "PH_normal":[floats],
  "PH_normal_count": 546,
  "PH_tangent":[floats],
  "PH_tangent_count": 546,
  "PH_binormal":[floats],
  "PH_binormals_count": 546,
  "faces":[integers, actually the 42 structure from the json, i did it for comparison],
  "PH_customIndex":[integers, this is how i mapped the values from exported normals,tangents and binormals to face3],
  "PH_customIndexNum":960,
  "PH_UVindex":[integers, this is how i mapped the values |faceVertexUvs[ 0 ][ 0 ]| from the exported uvs above],
  "PH_UVindexNum":960,
  "PH_FaceIndex":[integers, this is how i mapped the faces to vertices],
  "PH_FaceIndexNum":960
  </code></pre>
  
  <p>My .geometry.faces[0] has an additional array called vertexBinormals in addition to vertexTangents and vertexNormals.</p>
  
  <p>Essentially, i don't understand how to map these vertexBinormals values to an attribute and map it according to the rest. I was able to succeed in rendering what i wanted by copying the code for the tangent buffer (although i resized it to hold 3 values);</p>
  
  <p><strong>update2*</strong></p>
  
  <p>This actually seems to work fine (will post something live). </p>
  
  <p>But the question would be, in case of the above export results, using:</p>
  
  <pre><code>var attributes= {
      bitangents: {
          type: 'v3',
          value: []
      }
  };
  </code></pre>
  
  <p>The model has 320 faces, 162 vertices, and 182 uvs, normals, tangents and binormals. How should i fill this array in order to just give it to a shaderMaterial?</p>
  
  <p><strong>update</strong>
     initWebGLObjects()
         geometry.geometryGroupsList[A].faces3[]</p>
  
  <p>gives a "faces3" array of 320 in the case above, 
  then further down</p>
  
  <pre><code>if (Ha.tangentsNeedUpdate &amp;&amp; Ha.hasTangents) {
      //loops through things and fills 
      j.bindBuffer(j.ARRAY_BUFFER, w.__webglTangentBuffer);
  </code></pre>
  
  <p>this buffer gets written in 3,840 times, 3 times per face 4 values each time.
  i filled another one in the same manner only using 3 values, and this seemed to have worked, the tangent normal map maps 1:1 to what i exported.</p>