Face3.html 3.9 KB

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