Clock.html 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. <h1>[name]</h1>
  11. <p class="desc">
  12. 该对象用于跟踪时间。如果[link:https://developer.mozilla.org/en-US/docs/Web/API/Performance/now performance.now]可用,则
  13. Clock 对象通过该方法实现,否则回落到使用略欠精准的[link:https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Date/now Date.now]来实现。
  14. </p>
  15. <h2>构造函数</h2>
  16. <h3>[name]( [param:Boolean autoStart] )</h3>
  17. <p>
  18. autoStart — (可选) 是否要在第一次调用 [page:.getDelta]() 时自动开启时钟。默认值是 *true*。
  19. </p>
  20. <h2>属性</h2>
  21. <h3>[property:Boolean autoStart]</h3>
  22. <p>
  23. 如果设置为 true,则在第一次调用 [page:.getDelta]() 时开启时钟。默认值是 *true*。
  24. </p>
  25. <h3>[property:Float startTime]</h3>
  26. <p>
  27. 存储时钟最后一次调用 [page:Clock.start start] 方法的时间。默认值是 *0*。
  28. </p>
  29. <h3>[property:Float oldTime]</h3>
  30. <p>
  31. 存储时钟最后一次调用 [page:Clock.start start], [page:.getElapsedTime]() 或 [page:.getDelta]() 方法的时间。默认值是 *0*。
  32. </p>
  33. <h3>[property:Float elapsedTime]</h3>
  34. <p>
  35. 保存时钟运行的总时长。默认值是 *0*。
  36. </p>
  37. <h3>[property:Boolean running]</h3>
  38. <p>
  39. 判断时钟是否在运行。默认值是 *false*。
  40. </p>
  41. <h2>方法</h2>
  42. <h3>[method:undefined start]()</h3>
  43. <p>
  44. 启动时钟。同时将 [page:Clock.startTime startTime] 和 [page:Clock.oldTime oldTime] 设置为当前时间。
  45. 设置 [page:Clock.elapsedTime elapsedTime] 为 *0*,并且设置 [page:Clock.running running] 为 *true*.
  46. </p>
  47. <h3>[method:undefined stop]()</h3>
  48. <p>
  49. 停止时钟。同时将 [page:Clock.oldTime oldTime] 设置为当前时间。
  50. </p>
  51. <h3>[method:Float getElapsedTime]()</h3>
  52. <p>
  53. 获取自时钟启动后的秒数,同时将 [page:.oldTime] 设置为当前时间。<br />
  54. 如果 [page:.autoStart] 设置为 *true* 且时钟并未运行,则该方法同时启动时钟。
  55. </p>
  56. <h3>[method:Float getDelta]()</h3>
  57. <p>
  58. 获取自 [page:.oldTime] 设置后到当前的秒数。 同时将 [page:.oldTime] 设置为当前时间。<br/>
  59. 如果 [page:.autoStart] 设置为 *true* 且时钟并未运行,则该方法同时启动时钟。
  60. </p>
  61. <h2>源代码</h2>
  62. <p>
  63. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  64. </p>
  65. </body>
  66. </html>