Clock.html 2.5 KB

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