Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

VideoPrimitive.js 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /**
  2. * @Author: Caven
  3. * @Date: 2020-11-09 20:04:30
  4. */
  5. import { Cesium } from '@dc-modules/namespace'
  6. import State from '@dc-modules/state/State'
  7. import Parse from '@dc-modules/parse/Parse'
  8. import { Transform } from '@dc-modules/transform'
  9. import Overlay from '../Overlay'
  10. class VideoPrimitive extends Overlay {
  11. constructor(positions, video) {
  12. super()
  13. this._positions = Parse.parsePositions(positions)
  14. this._delegate = new Cesium.GroundPrimitive({
  15. geometryInstances: new Cesium.GeometryInstance({
  16. geometry: {}
  17. })
  18. })
  19. this._video = video
  20. this.type = Overlay.getOverlayType('video_primitive')
  21. this._state = State.INITIALIZED
  22. }
  23. set positions(positions) {
  24. this._positions = Parse.parsePositions(positions)
  25. this._delegate.geometryInstances.geometry = Cesium.PolygonGeometry.fromPositions(
  26. {
  27. positions: Transform.transformWGS84ArrayToCartesianArray(
  28. this._positions
  29. ),
  30. height: this._style?.height,
  31. extrudedHeight: this._style?.extrudedHeight,
  32. closeTop: this._style?.closeTop,
  33. closeBottom: this._style?.closeBottom,
  34. vertexFormat: Cesium.EllipsoidSurfaceAppearance.VERTEX_FORMAT
  35. }
  36. )
  37. return this
  38. }
  39. get positions() {
  40. return this._positions
  41. }
  42. set video(video) {
  43. this._video = video
  44. this._setAppearance()
  45. return this
  46. }
  47. get video() {
  48. return this._video
  49. }
  50. /**
  51. *
  52. * @private
  53. */
  54. _setAppearance() {
  55. this._delegate.appearance = new Cesium.EllipsoidSurfaceAppearance({
  56. material: Cesium.Material.fromType('Image', {
  57. image: this._video
  58. })
  59. })
  60. }
  61. _mountedHook() {
  62. /**
  63. * set the positions
  64. */
  65. this.positions = this._positions
  66. /**
  67. * initialize the Overlay parameter
  68. */
  69. this.video = this._video
  70. }
  71. /**
  72. * Sets Style
  73. * @param style
  74. * @returns {VideoPrimitive}
  75. */
  76. setStyle(style) {
  77. if (Object.keys(style).length === 0) {
  78. return this
  79. }
  80. this._style = style
  81. if (this._style?.classificationType) {
  82. this._delegate.classificationType = this._style.classificationType
  83. }
  84. return this
  85. }
  86. }
  87. Overlay.registerType('video_primitive')
  88. export default VideoPrimitive