Face3.html 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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>[name]</h1>
  12. <p class="desc">
  13. Triangular face used in [page:Geometry]. These are created automatically for all
  14. standard geometry types, however if you are building a custom geometry you will have to
  15. create them manually.
  16. </p>
  17. <h2>Examples</h2>
  18. <p>[example:svg_sandbox svg / sandbox ]</p>
  19. <p>[example:misc_exporter_obj exporter / obj ]</p>
  20. <p>[example:webgl_shaders_vector WebGL / shaders / vector ]</p>
  21. <code>
  22. var material = new THREE.MeshStandardMaterial( { color : 0x00cc00 } );
  23. //create a triangular geometry
  24. var geometry = new THREE.Geometry();
  25. geometry.vertices.push( new THREE.Vector3( -50, -50, 0 ) );
  26. geometry.vertices.push( new THREE.Vector3( 50, -50, 0 ) );
  27. geometry.vertices.push( new THREE.Vector3( 50, 50, 0 ) );
  28. //create a new face using vertices 0, 1, 2
  29. var normal = new THREE.Vector3( 0, 1, 0 ); //optional
  30. var color = new THREE.Color( 0xffaa00 ); //optional
  31. var materialIndex = 0; //optional
  32. var face = new THREE.Face3( 0, 1, 2, normal, color, materialIndex );
  33. //add the face to the geometry's faces array
  34. geometry.faces.push( face );
  35. //the face normals and vertex normals can be calculated automatically if not supplied above
  36. geometry.computeFaceNormals();
  37. geometry.computeVertexNormals();
  38. scene.add( new THREE.Mesh( geometry, material ) );
  39. </code>
  40. <h2>Constructor</h2>
  41. <h3>[name]( [param:Integer a], [param:Integer b], [param:Integer c], [param:Vector3 normal], [param:Color color], [param:Integer materialIndex] )</h3>
  42. <p>
  43. a — Vertex A index.<br />
  44. b — Vertex B index.<br />
  45. c — Vertex C index.<br /><br />
  46. normal — (optional) Face normal ([page:Vector3 Vector3]) or array of vertex normals.
  47. If a single vector is passed in, this sets [page:.normal], otherwise if an array of three
  48. vectors is passed in this sets [page:.vertexNormals]<br /><br />
  49. color — (optional) Face [page:Color color] or array of vertex [page:Color colors].
  50. If a single vector is passed in, this sets [page:.color], otherwise if an array of three
  51. vectors is passed in this sets [page:.vertexColors]<br /><br />
  52. materialIndex — (optional) which index of an array of materials to associate
  53. with the face.
  54. </p>
  55. <h2>Properties</h2>
  56. <h3>[property:Integer a]</h3>
  57. <p>
  58. Vertex A index.
  59. </p>
  60. <h3>[property:Integer b]</h3>
  61. <p>
  62. Vertex B index.
  63. </p>
  64. <h3>[property:Integer c]</h3>
  65. <p>
  66. Vertex C index.
  67. </p>
  68. <h3>[property:Vector3 normal]</h3>
  69. <p>
  70. Face normal - vector showing the direction of the Face3. If calculated automatically
  71. (using [page:Geometry.computeFaceNormals]), this is the normalized cross product of two edges of the
  72. triangle. Default is *(0, 0, 0)*.
  73. </p>
  74. <h3>[property:Color color]</h3>
  75. <p>
  76. Face color - for this to be used a material's [page:Material.vertexColors vertexColors] property
  77. must be set to [page:Materials THREE.FaceColors].
  78. </p>
  79. <h3>[property:Array vertexNormals]</h3>
  80. <p>
  81. Array of 3 [page:Vector3 vertex normals].
  82. </p>
  83. <h3>[property:Array vertexColors]</h3>
  84. <p>
  85. Array of 3 vertex colors - for these to be used a material's [page:Material.vertexColors vertexColors] property
  86. must be set to [page:Materials THREE.VertexColors].
  87. </p>
  88. <h3>[property:Integer materialIndex]</h3>
  89. <p>
  90. Material index (points to an index in the associated array of materials). Default is *0*.
  91. </p>
  92. <h2>Methods</h2>
  93. <h3>[method:Face3 clone]()</h3>
  94. <p>Creates a new clone of the Face3 object.</p>
  95. <h3>[method:Face3 copy]( [param:Face3 face3] )</h3>
  96. <p>Copy the parameters of another Face3 into this.</p>
  97. <h2>Source</h2>
  98. <p>
  99. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  100. </p>
  101. </body>
  102. </html>