@@ -420,18 +420,36 @@ goog.require('olcs.core.OlLayerPrimitive');
420420 * @api
421421 */
422422 olcs . core . updateCesiumPrimitives = function ( olLayer , csPrimitives ) {
423- //FIXME Make this work for all geometry types, not just points
424- var bbs = csPrimitives . context . billboards ;
425423 var opacity = olLayer . getOpacity ( ) ;
426424 if ( ! goog . isDef ( opacity ) ) {
427425 opacity = 1 ;
428426 }
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 ) ;
427+ csPrimitives . olLayerOpacity = opacity ;
428+ var i , bb , j , prim , geoms , geom , color ;
429+ for ( i = csPrimitives . length - 1 ; i >= 0 ; -- i ) {
430+ prim = csPrimitives . get ( i ) ;
431+ if ( prim instanceof Cesium . PrimitiveCollection ) {
432+ olcs . core . updateCesiumPrimitives ( olLayer , prim ) ;
433+ } else {
434+ if ( ! prim . ready ) continue ;
435+ var attrs = prim . getGeometryInstanceAttributes ( "id" ) ;
436+ if ( ! attrs ) continue ;
437+ color = attrs . color ;
438+ if ( color ) {
439+ //FIXME This currently overrides style opacity with layer opacity
440+ color [ 3 ] = Cesium . Color . floatToByte ( opacity ) ;
441+ attrs . color = color ;
442+ }
443+ }
444+ }
445+ if ( csPrimitives instanceof olcs . core . OlLayerPrimitive ) {
446+ var bbs = csPrimitives . context . billboards ;
447+ bbs . olLayerOpacity = opacity ;
448+ for ( i = bbs . length - 1 ; i >= 0 ; -- i ) {
449+ bb = bbs . get ( i ) ;
450+ //FIXME Use Cesium.Color.fromAlpha after the next Cesium update
451+ bb . color = new Cesium . Color ( 1.0 , 1.0 , 1.0 , bb . olStyleOpacity * opacity ) ;
452+ }
435453 }
436454 } ;
437455
@@ -504,7 +522,8 @@ goog.require('olcs.core.OlLayerPrimitive');
504522 geometry : geometry ,
505523 attributes : {
506524 color : Cesium . ColorGeometryInstanceAttribute . fromColor ( color )
507- }
525+ } ,
526+ id : "id"
508527 } ) ;
509528 } ;
510529
@@ -526,7 +545,7 @@ goog.require('olcs.core.OlLayerPrimitive');
526545 }
527546 var appearance = new Cesium . PerInstanceColorAppearance ( options ) ;
528547
529- var instances = createInstance ( geometry , color ) ;
548+ var instances = [ createInstance ( geometry , color ) ] ;
530549
531550 var primitive = new Cesium . Primitive ( {
532551 // always update Cesium externs before adding a property
@@ -714,9 +733,10 @@ goog.require('olcs.core.OlLayerPrimitive');
714733
715734 var outlinePrimitive = new Cesium . Primitive ( {
716735 // always update Cesium externs before adding a property
717- geometryInstances : new Cesium . GeometryInstance ( {
718- geometry : outlineGeometry
719- } ) ,
736+ geometryInstances : [ new Cesium . GeometryInstance ( {
737+ geometry : outlineGeometry ,
738+ id : "id"
739+ } ) ] ,
720740 appearance : appearance
721741 } ) ;
722742
0 commit comments