@@ -412,6 +412,30 @@ goog.require('olcs.core.OlLayerPrimitive');
412412 } ;
413413
414414
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+
415439 /**
416440 * Convert a 2D or 3D OpenLayers coordinate to Cesium.
417441 * @param {ol.Coordinate } coordinate Ol3 coordinate.
@@ -789,16 +813,20 @@ goog.require('olcs.core.OlLayerPrimitive');
789813 var position = olcs . core . ol4326CoordinateToCesiumCartesian ( center ) ;
790814 var color ;
791815 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 ;
794818 }
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 ) ;
795822 var bb = billboards . add ( {
796823 // always update Cesium externs before adding a property
797824 image : image ,
798825 color : color ,
799826 verticalOrigin : Cesium . VerticalOrigin . BOTTOM ,
800827 position : position
801828 } ) ;
829+ bb . olStyleOpacity = opacity ;
802830 if ( opt_newBillboardCallback ) {
803831 opt_newBillboardCallback ( bb ) ;
804832 }
0 commit comments