2
0

Face3.html 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <!DOCTYPE html>
  2. <html lang="zh">
  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. 在 [page:Geometry] 中被使用到的三角形面。这些三角形面会为所有标准几何体自动创建。
  13. 然而,如果你正在构建一个自定义几何体,你需要手动创建这些三角形面。
  14. </p>
  15. <h2>代码示例</h2>
  16. <code>
  17. const material = new THREE.MeshStandardMaterial( { color : 0x00cc00 } );
  18. // 创建仅有一个三角形面的几何体
  19. const geometry = new THREE.Geometry();
  20. geometry.vertices.push( new THREE.Vector3( -50, -50, 0 ) );
  21. geometry.vertices.push( new THREE.Vector3( 50, -50, 0 ) );
  22. geometry.vertices.push( new THREE.Vector3( 50, 50, 0 ) );
  23. // 利用顶点 0, 1, 2 创建一个面
  24. const normal = new THREE.Vector3( 0, 0, 1 ); //optional
  25. const color = new THREE.Color( 0xffaa00 ); //optional
  26. const materialIndex = 0; //optional
  27. const face = new THREE.Face3( 0, 1, 2, normal, color, materialIndex );
  28. // 将创建的面添加到几何体的面的队列
  29. geometry.faces.push( face );
  30. // 如果没有特别指明,面和顶点的法向量可以通过如下代码自动计算
  31. geometry.computeFaceNormals();
  32. geometry.computeVertexNormals();
  33. scene.add( new THREE.Mesh( geometry, material ) );
  34. </code>
  35. <h2>例子</h2>
  36. <p>
  37. [example:svg_sandbox svg / sandbox ]<br />
  38. [example:misc_exporter_obj exporter / obj ]<br />
  39. [example:webgl_shaders_vector WebGL / shaders / vector ]
  40. </p>
  41. <h2>构造函数</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 — 顶点 A 的索引。<br />
  45. b — 顶点 B 的索引。<br />
  46. c — 顶点 C 的索引。<br /><br />
  47. normal — (可选) 面的法向量 ([page:Vector3 Vector3]) 或顶点法向量队列。
  48. 如果参数传入单一矢量,则用该量设置面的法向量 [page:.normal],如果传入的是包含三个矢量的队列,
  49. 则用该量设置 [page:.vertexNormals]<br /><br />
  50. color — (可选) 面的颜色值 [page:Color color] 或顶点颜色值的队列。
  51. 如果参数传入单一矢量,则用该量设置 [page:.color],如果传入的是包含三个矢量的队列,
  52. 则用该量设置 [page:.vertexColors]<br /><br />
  53. materialIndex — (可选) 材质队列中与该面对应的材质的索引。
  54. </p>
  55. <h2>属性</h2>
  56. <h3>[property:Integer a]</h3>
  57. <p>
  58. 顶点 A 的索引。
  59. </p>
  60. <h3>[property:Integer b]</h3>
  61. <p>
  62. 顶点 B 的索引。
  63. </p>
  64. <h3>[property:Integer c]</h3>
  65. <p>
  66. 顶点 C 的索引。
  67. </p>
  68. <h3>[property:Vector3 normal]</h3>
  69. <p>
  70. 面的法向量 - 矢量展示 Face3 的方向。如果该量是通过调用 [page:Geometry.computeFaceNormals] 自动计算的,
  71. 该值等于归一化的两条边的差积。默认值是 *(0, 0, 0)*。
  72. </p>
  73. <h3>[property:Color color]</h3>
  74. <p>
  75. 面的颜色值 - 在被用于指定材质的 [page:Material.vertexColors vertexColors] 属性时,该值必须被设置为
  76. *true*。
  77. </p>
  78. <h3>[property:Array vertexNormals]</h3>
  79. <p>
  80. 包含三个 [page:Vector3 vertex normals] 的队列。
  81. </p>
  82. <h3>[property:Array vertexColors]</h3>
  83. <p>
  84. 包含 3 个顶点颜色值的队列 - 在被用于指定材质的 [page:Material.vertexColors vertexColors] 属性时,该值必须被设置为
  85. *true*。
  86. </p>
  87. <h3>[property:Integer materialIndex]</h3>
  88. <p>
  89. 材质队列中与该面相关的材质的索引。默认值为 *0*。
  90. </p>
  91. <h2>方法</h2>
  92. <h3>[method:Face3 clone]()</h3>
  93. <p>克隆该 Face3 对象。</p>
  94. <h3>[method:Face3 copy]( [param:Face3 face3] )</h3>
  95. <p>将参数指定的 Face3 对象的数据拷贝到当前对象。</p>
  96. <h2>源代码</h2>
  97. <p>
  98. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  99. </p>
  100. </body>
  101. </html>