Clock.html 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. <h1>[name]</h1>
  11. <p class="desc">
  12. Object for keeping track of time. This uses
  13. [link:https://developer.mozilla.org/en-US/docs/Web/API/Performance/now performance.now] if it is available, otherwise it reverts to the less
  14. accurate
  15. [link:https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Date/now Date.now].
  16. </p>
  17. <h2>Constructor</h2>
  18. <h3>[name]( [param:Boolean autoStart] )</h3>
  19. <p>
  20. autoStart — (optional) whether to automatically start the clock when
  21. [page:.getDelta]() is called for the first time. Default is `true`.
  22. </p>
  23. <h2>Properties</h2>
  24. <h3>[property:Boolean autoStart]</h3>
  25. <p>
  26. If set, starts the clock automatically when [page:.getDelta]() is called
  27. for the first time. Default is `true`.
  28. </p>
  29. <h3>[property:Float startTime]</h3>
  30. <p>
  31. Holds the time at which the clock's [page:Clock.start start] method was
  32. last called. Default is `0`.
  33. </p>
  34. <h3>[property:Float oldTime]</h3>
  35. <p>
  36. Holds the time at which the clock's [page:Clock.start start],
  37. [page:.getElapsedTime]() or [page:.getDelta]() methods were last called.
  38. Default is `0`.
  39. </p>
  40. <h3>[property:Float elapsedTime]</h3>
  41. <p>
  42. Keeps track of the total time that the clock has been running. Default is
  43. `0`.
  44. </p>
  45. <h3>[property:Boolean running]</h3>
  46. <p>Whether the clock is running or not. Default is `false`.</p>
  47. <h2>Methods</h2>
  48. <h3>[method:undefined start]()</h3>
  49. <p>
  50. Starts clock. Also sets the [page:.startTime] and [page:.oldTime] to the
  51. current time, sets [page:.elapsedTime] to `0` and [page:.running] to
  52. `true`.
  53. </p>
  54. <h3>[method:undefined stop]()</h3>
  55. <p>
  56. Stops clock and sets [page:Clock.oldTime oldTime] to the current time.
  57. </p>
  58. <h3>[method:Float getElapsedTime]()</h3>
  59. <p>
  60. Get the seconds passed since the clock started and sets [page:.oldTime] to
  61. the current time.<br />
  62. If [page:.autoStart] is `true` and the clock is not running, also starts
  63. the clock.
  64. </p>
  65. <h3>[method:Float getDelta]()</h3>
  66. <p>
  67. Get the seconds passed since the time [page:.oldTime] was set and sets
  68. [page:.oldTime] to the current time.<br />
  69. If [page:.autoStart] is `true` and the clock is not running, also starts
  70. the clock.
  71. </p>
  72. <h2>Source</h2>
  73. <p>
  74. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  75. </p>
  76. </body>
  77. </html>