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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /**
  2. * @Author: Caven
  3. * @Date: 2022-02-20 13:46:53
  4. */
  5. import State from '@dc-modules/state/State'
  6. import { Layer } from '@dc-modules/layer'
  7. import S3MTilesLayer from 's3m-lib/S3MTiles/S3MTilesLayer'
  8. class S3MLayer extends Layer {
  9. constructor(id, url, options = {}) {
  10. super(id)
  11. this._url = url
  12. this._options = options
  13. }
  14. get type() {
  15. return Layer.getLayerType('s3m')
  16. }
  17. get readyPromise() {
  18. return this._delegate.readyPromise
  19. }
  20. _onAdd(viewer) {
  21. this._viewer = viewer
  22. delete this._options['context']
  23. delete this._options['url']
  24. this._delegate = new S3MTilesLayer({
  25. context: this._viewer.scene.context,
  26. url: this._url,
  27. ...this._options
  28. })
  29. this._viewer.scene.primitives.add(this._delegate)
  30. this._addedHook && this._addedHook()
  31. this._state = State.ADDED
  32. }
  33. _onRemove() {
  34. if (!this._delegate) {
  35. return
  36. }
  37. this._viewer.scene.primitives.remove(this._delegate)
  38. this._removedHook && this._removedHook()
  39. this._state = State.REMOVED
  40. }
  41. }
  42. Layer.registerType('s3m')
  43. export default S3MLayer