LOD.html 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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:Array levels]</h3>
  46. <p>
  47. 一个包含有[page:Object level] objects(各层次物体)的数组。<br /><br />
  48. 每一个层级都是一个对象,具有以下两个属性:
  49. [page:Object3D object] —— 在这个层次中将要显示的[page:Object3D]。<br />
  50. [page:Float distance] —— 将显示这一细节层次的距离。
  51. </p>
  52. <h2>方法</h2>
  53. <p>共有方法请参见其基类[page:Object3D]。</p>
  54. <h3>[method:this addLevel]( [param:Object3D object], [param:Float distance] )</h3>
  55. <p>
  56. [page:Object3D object] —— 在这个层次中将要显示的[page:Object3D]。<br />
  57. [page:Float distance] —— 将显示这一细节层次的距离。<br /><br />
  58. 添加在一定距离和更大范围内显示的网格。通常来说,距离越远,网格中的细节就越少。
  59. </p>
  60. <h3>[method:LOD clone]()</h3>
  61. <p>
  62. 返回一个LOD对象及其所关联的在特定距离中的物体。
  63. </p>
  64. <h3>[method:Integer getCurrentLevel]()</h3>
  65. <p>
  66. Get the currently active LOD level. As index of the levels array.
  67. </p>
  68. <h3>[method:Object3D getObjectForDistance]( [param:Float distance] )</h3>
  69. <p>
  70. 获得第一个比[page:Float distance]大的[page:Object3D](网格)的引用。
  71. </p>
  72. <h3>[method:Array raycast]( [param:Raycaster raycaster], [param:Array intersects] )</h3>
  73. <p>
  74. 在一条投射出去的[page:Ray](射线)和这个LOD之间获得交互。
  75. [page:Raycaster.intersectObject]将会调用这个方法。
  76. </p>
  77. <h3>[method:Object toJSON]( meta )</h3>
  78. <p>
  79. 使用这个方法,为LOD对象中的每个细节层次创建一个JSON结构。
  80. </p>
  81. <h3>[method:null update]( [param:Camera camera] )</h3>
  82. <p>
  83. 基于每个[page:levels level]中的[page:Object3D object]和[page:Camera camera](摄像机)之间的距离,来设置其可见性。
  84. </p>
  85. <h2>源代码</h2>
  86. <p>
  87. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  88. </p>
  89. </body>
  90. </html>