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.

VideoPrimitive.js 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. vertexFormat: Cesium.EllipsoidSurfaceAppearance.VERTEX_FORMAT
  31. }
  32. )
  33. return this
  34. }
  35. get positions() {
  36. return this._positions
  37. }
  38. set video(video) {
  39. this._video = video
  40. this._setAppearance()
  41. return this
  42. }
  43. get video() {
  44. return this._video
  45. }
  46. /**
  47. *
  48. * @private
  49. */
  50. _setAppearance() {
  51. this._delegate.appearance = new Cesium.EllipsoidSurfaceAppearance({
  52. material: Cesium.Material.fromType('Image', {
  53. image: this._video
  54. })
  55. })
  56. }
  57. _mountedHook() {
  58. /**
  59. * set the positions
  60. */
  61. this.positions = this._positions
  62. this.video = this._video
  63. }
  64. }
  65. Overlay.registerType('video_primitive')
  66. export default VideoPrimitive