DrawModes.html 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 class="desc">
  13. These are valid values for [page:Mesh.drawMode], and control how the list of vertices is interpeted once sent to the GPU.
  14. </p>
  15. <h2>Draw Modes</h2>
  16. <code>
  17. THREE.TrianglesDrawMode
  18. </code>
  19. <p>
  20. This is the default, and results in every three consecutive vertices (v0, v1, v2), (v3, v4, v5), ...
  21. being interpreted as a separate triangle. <br />
  22. If the number of vertices is not a multiple of 3, excess vertices are ignored.
  23. </p>
  24. <code>
  25. THREE.TriangleStripDrawMode
  26. </code>
  27. <p>
  28. This will result in a series of triangles connected in a strip, given by (v0, v1, v2), (v2, v1, v3), (v2, v3, v4), ...
  29. so that every subsequent triangle shares two vertices with the previous triangle.
  30. </p>
  31. <code>
  32. THREE.TriangleFanDrawMode
  33. </code>
  34. <p>
  35. This will result in a series of triangles each sharing the first vertex (like a fan),
  36. given by (v0, v1, v2), (v0, v2, v3), (v0, v3, v4), ... <br /><br />
  37. <em>Note:</em> As of [link:https://en.wikipedia.org/wiki/DirectX#DirectX_10 DirectX10], this mode is not supported. As Chrome and Firefox
  38. render WebGL using [link:https://en.wikipedia.org/wiki/ANGLE_(software) ANGLE] on Windows,
  39. internally this mode will be converted to a supported mode, which will likely lead to lowered
  40. performance on those browsers.
  41. </p>
  42. <h2>Usage</h2>
  43. <code>
  44. var geometry = new THREE.BufferGeometry();
  45. var vertices = [];
  46. vertices.push( -10, 10, 0 );
  47. vertices.push( -10, -10, 0 );
  48. vertices.push( 10, -10, 0 );
  49. // ...
  50. geometry.addAttribute( 'position', new THREE.Float32BufferAttribute( vertices, 3 ) );
  51. var material = new THREE.MeshBasicMaterial( { color: 0xffff00 } );
  52. var mesh = new THREE.Mesh( geometry, material );
  53. mesh.drawMode = THREE.TrianglesDrawMode; //default
  54. scene.add( mesh );
  55. </code>
  56. <h2>Source</h2>
  57. <p>
  58. [link:https://github.com/mrdoob/three.js/blob/master/src/constants.js src/constants.js]
  59. </p>
  60. </body>
  61. </html>