You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Animation.js 805B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /**
  2. * @Author: Caven
  3. * @Date: 2020-12-20 16:32:22
  4. */
  5. class Animation {
  6. constructor(viewer) {
  7. this._viewer = viewer
  8. this._options = {}
  9. }
  10. _bindEvent() {}
  11. _unbindEvent() {}
  12. /**
  13. * Start globe rotate
  14. * @returns {Animation}
  15. */
  16. start() {
  17. this._viewer.clock.shouldAnimate = true
  18. this._unbindEvent()
  19. if (this._options.duration) {
  20. let timer = setTimeout(() => {
  21. this._unbindEvent()
  22. this._options.callback &&
  23. this._options.callback.call(this._options.context || this)
  24. clearTimeout(timer)
  25. }, Number(this._options.duration) * 1e3)
  26. }
  27. this._bindEvent()
  28. return this
  29. }
  30. /**
  31. * Stop globe rotate
  32. * @returns {Animation}
  33. */
  34. stop() {
  35. this._unbindEvent()
  36. return this
  37. }
  38. }
  39. export default Animation