@@ -412,6 +412,30 @@ goog.require('olcs.core.OlLayerPrimitive');
412
412
} ;
413
413
414
414
415
+ /**
416
+ * Synchronizes the vector layer rendering properties (currently only
417
+ * 'opacity') to the given Cesium primitives.
418
+ * @param {!ol.layer.Vector } olLayer
419
+ * @param {!Cesium.PrimitiveCollection } csPrimitives
420
+ * @api
421
+ */
422
+ olcs . core . updateCesiumPrimitives = function ( olLayer , csPrimitives ) {
423
+ //FIXME Make this work for all geometry types, not just points
424
+ var bbs = csPrimitives . context . billboards ;
425
+ var opacity = olLayer . getOpacity ( ) ;
426
+ if ( ! goog . isDef ( opacity ) ) {
427
+ opacity = 1 ;
428
+ }
429
+ bbs . olLayerOpacity = opacity ;
430
+ var i , bb ;
431
+ for ( i = bbs . length - 1 ; i >= 0 ; -- i ) {
432
+ bb = bbs . get ( i ) ;
433
+ //FIXME Use Cesium.Color.fromAlpha after the next Cesium update
434
+ bb . color = new Cesium . Color ( 1.0 , 1.0 , 1.0 , bb . olStyleOpacity * opacity ) ;
435
+ }
436
+ } ;
437
+
438
+
415
439
/**
416
440
* Convert a 2D or 3D OpenLayers coordinate to Cesium.
417
441
* @param {ol.Coordinate } coordinate Ol3 coordinate.
@@ -789,16 +813,20 @@ goog.require('olcs.core.OlLayerPrimitive');
789
813
var position = olcs . core . ol4326CoordinateToCesiumCartesian ( center ) ;
790
814
var color ;
791
815
var opacity = imageStyle . getOpacity ( ) ;
792
- if ( goog . isDef ( opacity ) ) {
793
- color = new Cesium . Color ( 1.0 , 1.0 , 1.0 , opacity ) ;
816
+ if ( ! goog . isDef ( opacity ) ) {
817
+ opacity = 1 ;
794
818
}
819
+ //FIXME Use Cesium.Color.fromAlpha after the next Cesium update
820
+ color = new Cesium . Color ( 1.0 , 1.0 , 1.0 ,
821
+ opacity * billboards . olLayerOpacity ) ;
795
822
var bb = billboards . add ( {
796
823
// always update Cesium externs before adding a property
797
824
image : image ,
798
825
color : color ,
799
826
verticalOrigin : Cesium . VerticalOrigin . BOTTOM ,
800
827
position : position
801
828
} ) ;
829
+ bb . olStyleOpacity = opacity ;
802
830
if ( opt_newBillboardCallback ) {
803
831
opt_newBillboardCallback ( bb ) ;
804
832
}
0 commit comments