LOD.html 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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. [page:Object3D] &rarr;
  11. <h1>多细节层次([name],Levels of Detail)</h1>
  12. <p class="desc">
  13. 多细节层次 —— 在显示网格时,根据摄像机距离物体的距离,来使用更多或者更少的几何体来对其进行显示。<br /><br />
  14. 每一个级别都和一个几何体相关联,且在渲染时,可以根据给定的距离,来在这些级别对应的几何体之间进行切换。
  15. 通常情况下,你会创建多个几何体,比如说三个,一个距离很远(低细节),一个距离适中(中等细节),还有一个距离非常近(高质量)。
  16. </p>
  17. <h2>代码示例</h2>
  18. <code>
  19. const lod = new THREE.LOD();
  20. //Create spheres with 3 levels of detail and create new LOD levels for them
  21. for( let i = 0; i < 3; i++ ) {
  22. const geometry = new THREE.IcosahedronGeometry( 10, 3 - i );
  23. const mesh = new THREE.Mesh( geometry, material );
  24. lod.addLevel( mesh, i * 75 );
  25. }
  26. scene.add( lod );
  27. </code>
  28. <h2>例子</h2>
  29. <p>
  30. [example:webgl_lod webgl / lod ]
  31. </p>
  32. <h2>Constructor</h2>
  33. <h3>[name]( )</h3>
  34. <p>
  35. 创建一个新的 [name].
  36. </p>
  37. <h2>属性</h2>
  38. <p>共有属性请参见其基类[page:Object3D]。</p>
  39. <h3>[property:Boolean autoUpdate]</h3>
  40. <p>
  41. Whether the LOD object is updated automatically by the renderer per frame or not.
  42. If set to false, you have to call [page:LOD.update]() in the render loop by yourself.
  43. Default is true.
  44. </p>
  45. <h3>[property:Boolean isLOD]</h3>
  46. <p>
  47. Read-only flag to check if a given object is of type [name].
  48. </p>
  49. <h3>[property:Array levels]</h3>
  50. <p>
  51. 一个包含有[page:Object level] objects(各层次物体)的数组。<br /><br />
  52. 每一个层级都是一个对象,具有以下两个属性:
  53. [page:Object3D object] —— 在这个层次中将要显示的[page:Object3D]。<br />
  54. [page:Float distance] —— 将显示这一细节层次的距离。<br />
  55. [page:Float hysteresis] —— Threshold used to avoid flickering at LOD boundaries, as a fraction of distance.
  56. </p>
  57. <h2>方法</h2>
  58. <p>共有方法请参见其基类[page:Object3D]。</p>
  59. <h3>[method:this addLevel]( [param:Object3D object], [param:Float distance], [param:Float hysteresis] )</h3>
  60. <p>
  61. [page:Object3D object] —— 在这个层次中将要显示的[page:Object3D]。<br />
  62. [page:Float distance] —— 将显示这一细节层次的距离。<br />
  63. [page:Float hysteresis] —— Threshold used to avoid flickering at LOD boundaries, as a fraction of distance. Default 0.0.<br /><br />
  64. 添加在一定距离和更大范围内显示的网格。通常来说,距离越远,网格中的细节就越少。
  65. </p>
  66. <h3>[method:Integer getCurrentLevel]()</h3>
  67. <p>
  68. Get the currently active LOD level. As index of the levels array.
  69. </p>
  70. <h3>[method:Object3D getObjectForDistance]( [param:Float distance] )</h3>
  71. <p>
  72. 获得第一个比[page:Float distance]大的[page:Object3D](网格)的引用。
  73. </p>
  74. <h3>[method:undefined raycast]( [param:Raycaster raycaster], [param:Array intersects] )</h3>
  75. <p>
  76. 在一条投射出去的[page:Ray](射线)和这个LOD之间获得交互。
  77. [page:Raycaster.intersectObject]将会调用这个方法。
  78. </p>
  79. <h3>[method:Object toJSON]( meta )</h3>
  80. <p>
  81. 使用这个方法,为LOD对象中的每个细节层次创建一个JSON结构。
  82. </p>
  83. <h3>[method:undefined update]( [param:Camera camera] )</h3>
  84. <p>
  85. 基于每个[page:levels level]中的[page:Object3D object]和[page:Camera camera](摄像机)之间的距离,来设置其可见性。
  86. </p>
  87. <h2>源代码</h2>
  88. <p>
  89. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  90. </p>
  91. </body>
  92. </html>