DrawModes.html 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8" />
  5. <base href="../../" />
  6. <script src="list.js"></script>
  7. <script src="page.js"></script>
  8. <link type="text/css" rel="stylesheet" href="page.css" />
  9. </head>
  10. <body>
  11. <h1>Draw Mode Constants</h1>
  12. <p>
  13. These are valid values for Mesh.drawMode, and control how the list of vertices is interpeted once sent to the GPU.</p>
  14. </p>
  15. <h2>Draw Modes</h2>
  16. <code>
  17. THREE.TrianglesDrawMode<br />
  18. </code>
  19. <p>
  20. This is the default, and results in every three consecutive vertices (v0, v1, v2), (v2, v3, v5), ... being interpreted as a separate triangle. <br />
  21. If the number of vertices is not a multiple of 3, excess vertices are ignored.
  22. </p>
  23. <code>
  24. THREE.TriangleStripDrawMode<br />
  25. </code>
  26. <p>
  27. This will result in a series of triangles connected in a strip, given by (v0, v1, v2), (v2, v1, v3), (v2, v3, v4), ... so that every subsequent triangle shares two vertices with the previous triangle.
  28. </p>
  29. <code>
  30. THREE.TriangleFanDrawMode
  31. </code>
  32. <p>
  33. This will result in a series of triangles each sharing the first vertex (like a fan), given by (v0, v1, v2), (v0, v2, v3), (v0, v3, v4), ...
  34. </p>
  35. <h2>Usage</h2>
  36. <code>
  37. var geometry = new THREE.Geometry();
  38. geometry.vertices.push(
  39. new THREE.Vector3( -10, 10, 0 ),
  40. new THREE.Vector3( -10, -10, 0 ),
  41. new THREE.Vector3( 10, -10, 0 ),
  42. ...
  43. );
  44. geometry.faces.push( new THREE.Face3( 0, 1, 2 ), ... );
  45. var material = new THREE.MeshBasicMaterial( { color: 0xffff00 } );
  46. var mesh = new THREE.Mesh( geometry, material );
  47. mesh.drawMode = THREE.TrianglesDrawMode; //default
  48. scene.add( mesh );
  49. </code>
  50. <h2>Source</h2>
  51. [link:https://github.com/mrdoob/three.js/blob/master/src/constants.js src/constants.js]
  52. </body>
  53. </html>