| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- /*
- * @Author: Caven
- * @Date: 2020-02-25 18:28:36
- * @Last Modified by: Caven
- * @Last Modified time: 2020-04-16 20:29:02
- */
- import Cesium from '@/namespace'
- import Overlay from '@/core/overlay/Overlay'
-
- DC.Box = class extends Overlay {
- constructor(position, length, width, height) {
- if (!DC.Util.checkPosition(position)) {
- throw new Error('DC.Box: the position invalid')
- }
- super()
- this._position = position
- this._length = length
- this._width = width
- this._height = height
- this._delegate = new Cesium.Entity()
- this._state = DC.OverlayState.INITIALIZED
- this.type = DC.OverlayType.BOX
- }
-
- set position(position) {
- if (!DC.Util.checkPosition(position)) {
- throw new Error('DC.Box: the position invalid')
- }
- this._position = position
- }
-
- get position() {
- return this._position
- }
-
- set length(length) {
- this._length = length
- }
-
- get length() {
- return this._length
- }
-
- set width(width) {
- this._width = width
- }
-
- get width() {
- return this._width
- }
-
- set height(height) {
- this._height = height
- }
-
- get height() {
- return this._height
- }
-
- _mountedHook() {
- /**
- * set the location
- */
- this._delegate.position = new Cesium.CallbackProperty(time => {
- return DC.T.transformWGS84ToCartesian(this._position)
- })
- /**
- * set the orientation
- */
- this._delegate.orientation = new Cesium.CallbackProperty(time => {
- return Cesium.Transforms.headingPitchRollQuaternion(
- DC.T.transformWGS84ToCartesian(this._position),
- new Cesium.HeadingPitchRoll(
- Cesium.Math.toRadians(this._position.heading),
- Cesium.Math.toRadians(this._position.pitch),
- Cesium.Math.toRadians(this._position.roll)
- )
- )
- })
- /**
- * initialize the Overlay parameter
- */
- this._delegate.box = {
- ...this._style,
- dimensions: new Cesium.CallbackProperty(time => {
- return new Cesium.Cartesian3(this._length, this._width, this._height)
- })
- }
- }
-
- /**
- *
- * @param {*} style
- */
- setStyle(style) {
- if (Object.keys(style).length == 0) {
- return this
- }
- this._style = style
- this._delegate.box && DC.Util.merge(this._delegate.box, this._style)
- return this
- }
- }
-
- DC.OverlayType.BOX = 'box'
|