Face3.html 3.9 KB

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