Geometry.html 4.0 KB

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