LOD.html 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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. [page:Object3D] &rarr;
  11. <h1>[name]</h1>
  12. <p class="desc">
  13. Level of Detail - show meshes with more or less geometry based on distance
  14. from the camera.<br /><br />
  15. Every level is associated with an object, and rendering can be switched
  16. between them at the distances specified. Typically you would create, say,
  17. three meshes, one for far away (low detail), one for mid range (medium
  18. detail) and one for close up (high detail).
  19. </p>
  20. <h2>Code Example</h2>
  21. <code>
  22. const lod = new THREE.LOD();
  23. //Create spheres with 3 levels of detail and create new LOD levels for them
  24. for( let i = 0; i < 3; i++ ) {
  25. const geometry = new THREE.IcosahedronGeometry( 10, 3 - i );
  26. const mesh = new THREE.Mesh( geometry, material );
  27. lod.addLevel( mesh, i * 75 );
  28. }
  29. scene.add( lod );
  30. </code>
  31. <h2>Examples</h2>
  32. <p>[example:webgl_lod webgl / lod ]</p>
  33. <h2>Constructor</h2>
  34. <h3>[name]( )</h3>
  35. <p>Creates a new [name].</p>
  36. <h2>Properties</h2>
  37. <p>See the base [page:Object3D] class for common properties.</p>
  38. <h3>[property:Boolean autoUpdate]</h3>
  39. <p>
  40. Whether the LOD object is updated automatically by the renderer per frame
  41. or not. If set to false, you have to call [page:LOD.update]() in the
  42. render loop by yourself. Default is true.
  43. </p>
  44. <h3>[property:Boolean isLOD]</h3>
  45. <p>Read-only flag to check if a given object is of type [name].</p>
  46. <h3>[property:Array levels]</h3>
  47. <p>
  48. An array of [page:Object level] objects<br /><br />
  49. Each level is an object with the following properties:<br />
  50. [page:Object3D object] - The [page:Object3D] to display at this level.<br />
  51. [page:Float distance] - The distance at which to display this level of
  52. detail.<br />
  53. [page:Float hysteresis] - Threshold used to avoid flickering at LOD
  54. boundaries, as a fraction of distance.
  55. </p>
  56. <h2>Methods</h2>
  57. <p>See the base [page:Object3D] class for common methods.</p>
  58. <h3>
  59. [method:this addLevel]( [param:Object3D object], [param:Float distance], [param:Float hysteresis] )
  60. </h3>
  61. <p>
  62. [page:Object3D object] - The [page:Object3D] to display at this level.<br />
  63. [page:Float distance] - The distance at which to display this level of
  64. detail. Default `0.0`.<br />
  65. [page:Float hysteresis] - Threshold used to avoid flickering at LOD
  66. boundaries, as a fraction of distance. Default `0.0`.<br /><br />
  67. Adds a mesh that will display at a certain distance and greater. Typically
  68. the further away the distance, the lower the detail on the mesh.
  69. </p>
  70. <h3>
  71. [method:Boolean removeLevel]( [param:Float distance])
  72. </h3>
  73. <p>
  74. distance - Distance of the level to delete.<br /><br />
  75. Removes an existing level, based on the distance from the camera.
  76. Returns `true` when the level has been removed. Otherwise `false`.
  77. </p>
  78. <h3>[method:Integer getCurrentLevel]()</h3>
  79. <p>Get the currently active LOD level. As index of the levels array.</p>
  80. <h3>[method:Object3D getObjectForDistance]( [param:Float distance] )</h3>
  81. <p>
  82. Get a reference to the first [page:Object3D] (mesh) that is greater than
  83. [page:Float distance].
  84. </p>
  85. <h3>
  86. [method:undefined raycast]( [param:Raycaster raycaster], [param:Array intersects] )
  87. </h3>
  88. <p>
  89. Get intersections between a casted [page:Ray] and this LOD.
  90. [page:Raycaster.intersectObject] will call this method.
  91. </p>
  92. <h3>[method:Object toJSON]( meta )</h3>
  93. <p>Create a JSON structure with details of this LOD object.</p>
  94. <h3>[method:undefined update]( [param:Camera camera] )</h3>
  95. <p>
  96. Set the visibility of each [page:levels level]'s [page:Object3D object]
  97. based on distance from the [page:Camera camera].
  98. </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>