LOD.html 3.5 KB

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