2
0

DrawModes.html 2.4 KB

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