title: How to make a 3D Mesh in RGL with shade3d or wire3d using tmesh3d in R
body: <p>I have some data which I have collected.</p>
  
  <p>It consists of Vertices and then Triangles which I have made using a meshing software. </p>
  
  <p>I am able to use R with </p>
  
  <p>trimesh(triangles, vertices)</p>
  
  <p>to make a nice mesh plot.</p>
  
  <p>But can't figure out how to use  RGL to make an interactive plot that I can view, and I can't work out how to colour the faces of the mesh based on a different value in the data frame. </p>
  
  <p>here are the vertices  in a data frame. x, y, z are the coordinates of the nodes/points (nn)</p>
  
  <pre><code>'data.frame':   23796 obs. of  7 variables:
   $ nn : int  0 1 2 3 4 5 6 7 8 9 ...
   $ x  : num  39.5 70.8 49 83.5 -16 ...
   $ y  : num  28.2 -2.97 -25.67 -9.1 -39.75 ...
   $ z: num  160 158 109 121 188 ...
   $ uni: num  3.87 6.64 5.02 4.48 1.91 ...
   $ bi : num  0.749 0.784 1.045 0.935 0.733 ...
  
  
  
  
  nn  x   y   z   uni bi
  0   39.527  28.202  160.219 3.86942 0.74871
  1   70.804  -2.966  157.578 6.64361 0.78373
  2   48.982  -25.674 109.022 5.02491 1.0451
  3   83.514  -9.096  120.988 4.47977 0.9348
  4   -16.04  -39.749 188.467 1.90873 0.73286
  5   74.526  -3.096  174.347 8.4263  0.70594
  6   54.93   -56.347 151.496 7.53334 2.17128
  7   56.936  -20.131 186.177 7.16118 1.44875
  8   -14.627 -47.1   162.185 2.13939 0.70887
  9   38.207  -59.201 147.993 5.83457 4.32971
  10  50.645  -32.04  110.418 5.3741  1.14543
  </code></pre>
  
  <p>The triangles for the vertices are</p>
  
  <pre><code>'data.frame':   47602 obs. of  7 variables:
   $ X  : int  3435 3161 18424 13600 1564 21598 21283 1171 51 9331 ...
   $ Y  : int  19658 17204 17467 19721 10099 19018 11341 2723 15729 5851 ...
   $ Z  : int  2764 9466 16955 2669 10091 21205 18399 20833 15865 9106 ...
  
  
  X   Y   Z
  3435    19658   2764
  3161    17204   9466
  18424   17467   16955
  13600   19721   2669
  1564    10099   10091
  21598   19018   21205
  21283   11341   18399
  1171    2723    20833
  51  15729   15865
  9331    5851    9106
  310 3513    9121
  5651    11928   15468  
  8594    2295    6852
  22725   22636   11114
  </code></pre>
  
  <p>I need to make this into a mesh as I can in trimesh, but with RGL and I need to colour the faces of the mesh based on a scale of uni, where &lt;0.5 is red, 0/5-1/5 is orange and >1.5 is green</p>
  
  <p><a href="http://i.stack.imgur.com/f3qk7.png" rel="nofollow">It looks something like this in trimesh but how to i do it in RGL for R, WITH COLOURING BASED ON VALUE ON UNI in the first data table</a></p>