Face3.html 3.8 KB

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