| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- /**
- * @Author: Caven
- * @Date: 2020-11-09 20:04:30
- */
-
- import { Cesium } from '@dc-modules/namespace'
- import State from '@dc-modules/state/State'
- import Parse from '@dc-modules/parse/Parse'
- import { Transform } from '@dc-modules/transform'
- import Overlay from '../Overlay'
-
- class VideoPrimitive extends Overlay {
- constructor(positions, video) {
- super()
- this._positions = Parse.parsePositions(positions)
- this._delegate = new Cesium.GroundPrimitive({
- geometryInstances: new Cesium.GeometryInstance({
- geometry: {}
- })
- })
- this._video = video
- this._state = State.INITIALIZED
- }
-
- get type() {
- return Overlay.getOverlayType('video_primitive')
- }
-
- set positions(positions) {
- this._positions = Parse.parsePositions(positions)
- this._delegate.geometryInstances.geometry = Cesium.PolygonGeometry.fromPositions(
- {
- positions: Transform.transformWGS84ArrayToCartesianArray(
- this._positions
- ),
- height: this._style?.height,
- extrudedHeight: this._style?.extrudedHeight,
- closeTop: this._style?.closeTop,
- closeBottom: this._style?.closeBottom,
- vertexFormat: Cesium.EllipsoidSurfaceAppearance.VERTEX_FORMAT
- }
- )
- return this
- }
-
- get positions() {
- return this._positions
- }
-
- set video(video) {
- this._video = video
- this._setAppearance()
- return this
- }
-
- get video() {
- return this._video
- }
-
- /**
- *
- * @private
- */
- _setAppearance() {
- this._delegate.appearance = new Cesium.EllipsoidSurfaceAppearance({
- material: Cesium.Material.fromType('Image', {
- image: this._video
- })
- })
- }
-
- _mountedHook() {
- /**
- * set the positions
- */
- this.positions = this._positions
-
- /**
- * initialize the Overlay parameter
- */
- this.video = this._video
- }
-
- /**
- * Sets Style
- * @param style
- * @returns {VideoPrimitive}
- */
- setStyle(style) {
- if (Object.keys(style).length === 0) {
- return this
- }
- this._style = style
- if (this._style?.classificationType) {
- this._delegate.classificationType = this._style.classificationType
- }
- return this
- }
- }
-
- Overlay.registerType('video_primitive')
-
- export default VideoPrimitive
|