@@ -420,18 +420,36 @@ goog.require('olcs.core.OlLayerPrimitive');
420
420
* @api
421
421
*/
422
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
423
var opacity = olLayer . getOpacity ( ) ;
426
424
if ( ! goog . isDef ( opacity ) ) {
427
425
opacity = 1 ;
428
426
}
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
+ }
435
453
}
436
454
} ;
437
455
@@ -504,7 +522,8 @@ goog.require('olcs.core.OlLayerPrimitive');
504
522
geometry : geometry ,
505
523
attributes : {
506
524
color : Cesium . ColorGeometryInstanceAttribute . fromColor ( color )
507
- }
525
+ } ,
526
+ id : "id"
508
527
} ) ;
509
528
} ;
510
529
@@ -526,7 +545,7 @@ goog.require('olcs.core.OlLayerPrimitive');
526
545
}
527
546
var appearance = new Cesium . PerInstanceColorAppearance ( options ) ;
528
547
529
- var instances = createInstance ( geometry , color ) ;
548
+ var instances = [ createInstance ( geometry , color ) ] ;
530
549
531
550
var primitive = new Cesium . Primitive ( {
532
551
// always update Cesium externs before adding a property
@@ -714,9 +733,10 @@ goog.require('olcs.core.OlLayerPrimitive');
714
733
715
734
var outlinePrimitive = new Cesium . Primitive ( {
716
735
// 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
+ } ) ] ,
720
740
appearance : appearance
721
741
} ) ;
722
742
0 commit comments