1- import { getCenter , getCenterByCartesian } from " ../Utils/PlotUtil"
1+ import { getCenter , getCenterByCartesian } from ' ../Utils/PlotUtil' ;
22
33/**
44 * @class module:3DPlot.BasePlotPrimitive
@@ -31,7 +31,7 @@ class BasePlotPrimitive {
3131
3232 this . _positions = [ ] ;
3333
34- const { positions} = this . _elem ;
34+ const { positions } = this . _elem ;
3535 for ( let i = 0 ; i < positions . length ; i += 1 ) {
3636 const tempPos = this . _elem . positions [ i ] ;
3737 this . _positions . push ( Cesium . Cartesian3 . fromDegrees ( tempPos . x , tempPos . y ) ) ;
@@ -49,10 +49,10 @@ class BasePlotPrimitive {
4949 */
5050 _elemPropsUpdateHandler ( event ) {
5151 if ( event . type === 'positions' ) {
52- let { _positionBillboards, _shapeBillboards} = this ;
52+ let { _positionBillboards, _shapeBillboards } = this ;
5353 const positions = event . value ;
5454
55- if ( _positionBillboards && _shapeBillboards ) {
55+ if ( _positionBillboards && _shapeBillboards ) {
5656 let prevCenter = getCenterByCartesian ( this . _positions ) ;
5757 let center = getCenter ( positions ) ;
5858 let cartographicStart = Cesium . Cartographic . fromDegrees ( prevCenter . geometry . coordinates [ 0 ] , prevCenter . geometry . coordinates [ 1 ] , 0 ) ;
@@ -62,15 +62,23 @@ class BasePlotPrimitive {
6262 //更新位置点坐标
6363 let _positionBillboard = _positionBillboards . get ( 0 ) ;
6464 let _positionBillboardCart = Cesium . Cartographic . fromCartesian ( _positionBillboard . position ) ;
65- let positionPoint = Cesium . Cartesian3 . fromDegrees ( center . geometry . coordinates [ 0 ] , center . geometry . coordinates [ 1 ] , _positionBillboardCart . height ) ;
65+ let positionPoint = Cesium . Cartesian3 . fromDegrees (
66+ center . geometry . coordinates [ 0 ] ,
67+ center . geometry . coordinates [ 1 ] ,
68+ _positionBillboardCart . height
69+ ) ;
6670 _positionBillboard . position = positionPoint ;
6771 //更新控制点坐标
6872 //平移图元和形状控制点
6973 for ( let i = 0 ; i < positions . length ; i ++ ) {
7074 let shapePoint = _shapeBillboards . get ( i ) ;
71- if ( shapePoint . _isEdit === false ) {
75+ if ( shapePoint . _isEdit === false ) {
7276 let shapePointCart = Cesium . Cartographic . fromCartesian ( shapePoint . position ) ;
73- shapePoint . position = Cesium . Cartesian3 . fromDegrees ( Cesium . Math . toDegrees ( shapePointCart . longitude ) + offsetLng , Cesium . Math . toDegrees ( shapePointCart . latitude ) + offsetLat , 600 ) ;
77+ shapePoint . position = Cesium . Cartesian3 . fromDegrees (
78+ Cesium . Math . toDegrees ( shapePointCart . longitude ) + offsetLng ,
79+ Cesium . Math . toDegrees ( shapePointCart . latitude ) + offsetLat ,
80+ 600
81+ ) ;
7482 }
7583 }
7684 }
@@ -253,6 +261,26 @@ class BasePlotPrimitive {
253261 }
254262 }
255263
264+ getStyleJSON ( ) {
265+ const object = this . _elem . getStyleJSON ( ) ;
266+ const baseAttrNames = this . getPrimitiveBaseSaveAttributes ( ) ;
267+ baseAttrNames . forEach ( ( t ) => {
268+ object [ t ] = this [ t ] ;
269+ } ) ;
270+ return object ;
271+ }
272+
273+ setStyleJSON ( object ) {
274+ this . _elem . setStyleJSON ( object ) ;
275+ const baseAttrNames = this . getPrimitiveBaseSaveAttributes ( ) ;
276+ const keys = Object . keys ( object ) ;
277+ keys . forEach ( ( t ) => {
278+ if ( baseAttrNames . indexOf ( t ) > - 1 ) {
279+ this [ t ] = object [ t ] ;
280+ }
281+ } ) ;
282+ }
283+
256284 /**
257285 * @description : 初始化保存属性(必须和extend扩展数组对应)
258286 * @function module:3DPlot.BasePlotPrimitive.initBaseSaveAttributes
@@ -352,7 +380,7 @@ class BasePlotPrimitive {
352380 type : 'Image' ,
353381 uniforms : {
354382 image : this . getColorRamp ( [ 0.0 , 1 ] , [ wallColor , WallGradColor ] , true ) ,
355- repeat : { x : 1 , y : 1 }
383+ repeat : { x : 1 , y : 1 }
356384 }
357385 }
358386 } )
@@ -456,7 +484,7 @@ class BasePlotPrimitive {
456484 * @return {Object } style 图元样式
457485 */
458486 getStyle ( ) {
459- return this . _elem . getStyleJSON ( ) ;
487+ return this . getStyleJSON ( ) ;
460488 }
461489}
462490
0 commit comments