Geometry.html 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <h1>[name]</h1>
  2. <div class="desc">Base class for geometries</div>
  3. <h2>Example</h2>
  4. <code>var geometry = new THREE.Geometry()
  5. geometry.vertices.push( new THREE.Vector3( -10, 10, 0 ) );
  6. geometry.vertices.push( new THREE.Vector3( -10, -10, 0 ) );
  7. geometry.vertices.push( new THREE.Vector3( 10, -10, 0 ) );
  8. geometry.faces.push( new THREE.Face3( 0, 1, 2 ) );
  9. geometry.computeBoundingSphere();
  10. </code>
  11. <h2>Constructor</h2>
  12. <h3>[name]()</h3>
  13. <h2>Properties</h2>
  14. <h3>.[page:Integer id]</h3>
  15. <div>
  16. Unique number of this geometry instance
  17. </div>
  18. <h3>.[page:Array vertices]</h3>
  19. <div>
  20. Array of [page:Vector3 vertices].
  21. </div>
  22. <h3>.[page:Array colors]</h3>
  23. <div>
  24. Array of vertex [page:Color colors], matching number and order of vertices.<br />
  25. Used in [page:ParticleSystem], [page:Line] and [page:Ribbon].<br />
  26. [page:Mesh Meshes] use per-face-use-of-vertex colors embedded directly in faces.
  27. </div>
  28. <h3>.[page:Array materials]</h3>
  29. <div>
  30. Array of [page:Material materials].
  31. </div>
  32. <h3>.[page:Array faces]</h3>
  33. <div>
  34. Array of [page:Face3 triangles] or/and [page:Face4 quads].
  35. </div>
  36. <h3>.[page:Array faceUvs]</h3>
  37. <div>
  38. Array of face [page:UV] layers.<br />
  39. Each UV layer is an array of [page:UV] matching order and number of faces.
  40. </div>
  41. <h3>.[page:Array faceVertexUvs]</h3>
  42. <div>
  43. Array of face [page:UV] layers.<br />
  44. Each UV layer is an array of [page:UV] matching order and number of vertices in faces.
  45. </div>
  46. <h3>.[page:Array morphTargets]</h3>
  47. <div>
  48. Array of morph targets. Each morph target is JS object:
  49. <code>{ name: "targetName", vertices: [ new THREE.Vertex(), ... ] }</code>
  50. Morph vertices match number and order of primary vertices.
  51. </div>
  52. <h3>.[page:Array morphColors]</h3>
  53. <div>
  54. Array of morph colors. Morph colors have similar structure as morph targets, each color set is JS object:
  55. <code>morphColor = { name: "colorName", colors: [ new THREE.Color(), ... ] }</code>
  56. Morph colors can match either number and order of faces (face colors) or number of vertices (vertex colors).
  57. </div>
  58. <h3>.[page:Array skinWeights]</h3>
  59. <div>
  60. Array of skinning weights, matching number and order of vertices.
  61. </div>
  62. <h3>.[page:Array skinIndices]</h3>
  63. <div>
  64. Array of skinning indices, matching number and order of vertices.
  65. </div>
  66. <h3>.[page:Object boundingBox]</h3>
  67. <div>
  68. Bounding box.
  69. <code>{ min: new THREE.Vector3(), max: new THREE.Vector3() }</code>
  70. </div>
  71. <h3>.[page:Object boundingSphere]</h3>
  72. <div>
  73. Bounding sphere.
  74. <code>{ radius: float }</code>
  75. </div>
  76. <h3>.[page:Boolean hasTangents]</h3>
  77. <div>
  78. True if geometry has tangents. Set in [page:Geometry Geometry.computeTangents].
  79. </div>
  80. <h3>.[page:Boolean dynamic]</h3>
  81. <div>
  82. Set to *true* if attribute buffers will need to change in runtime (using "dirty" flags).<br/>
  83. Unless set to true internal typed arrays corresponding to buffers will be deleted once sent to GPU.
  84. </div>
  85. <h2>Methods</h2>
  86. <h3>.applyMatrix( [page:Matrix4 matrix] )</h3>
  87. <div>
  88. Bakes matrix transform directly into vertex coordinates.
  89. </div>
  90. <h3>.computeCentroids()</h3>
  91. <div>
  92. Computes centroids for all faces.
  93. </div>
  94. <h3>.computeFaceNormals()</h3>
  95. <div>
  96. Computes face normals.
  97. </div>
  98. <h3>.computeVertexNormals()</h3>
  99. <div>
  100. Computes vertex normals by averaging face normals.<br />
  101. Face normals must be existing / computed beforehand.
  102. </div>
  103. <h3>.computeTangents()</h3>
  104. <div>
  105. Computes vertex tangents.<br />
  106. Based on [link:http://www.terathon.com/code/tangent.html]<br />
  107. Geometry must have vertex [page:UV UVs] (layer 0 will be used).
  108. </div>
  109. <h3>.computeBoundingBox()</h3>
  110. <div>
  111. Computes bounding box of the geometry, updating [page:Geometry Geometry.boundingBox] attribute.
  112. </div>
  113. <h3>.computeBoundingSphere()</h3>
  114. <div>
  115. Computes bounding sphere of the geometry, updating [page:Geometry Geometry.boundingSphere] attribute.
  116. </div>
  117. <h3>.mergeVertices()</h3>
  118. <div>
  119. Checks for duplicate vertices using hashmap.<br />
  120. Duplicated vertices are removed and faces' vertices are updated.
  121. </div>
  122. <h2>Source</h2>
  123. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]