You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While testing the sandcastle model coloring example found a tiny but annoying bug. When there are multiple models and colors are applied to them, all of them will have the same color.
Modified the sandcastle example to demonstrate it:
varviewer=newCesium.Viewer('cesiumContainer',{infoBox : false,selectionIndicator : false,shadows : true});varentity;functiongetColorBlendMode(colorBlendMode){returnCesium.ColorBlendMode[colorBlendMode.toUpperCase()];}functiongetColor(colorName,alpha){varcolor=Cesium.Color[colorName.toUpperCase()];returnCesium.Color.fromAlpha(color,parseFloat(alpha));}// The viewModel tracks the state of our mini application.varviewModel={color : 'Red',colors : ['White','Red','Green','Blue','Yellow','Gray'],alpha : 1.0,colorBlendMode : 'Highlight',colorBlendModes : ['Highlight','Replace','Mix'],colorBlendAmount : 0.5,colorBlendAmountEnabled : false,silhouetteColor : 'Red',silhouetteColors : ['Red','Green','Blue','Yellow','Gray'],silhouetteAlpha : 1.0,silhouetteSize : 2.0};// Convert the viewModel members into knockout observables.Cesium.knockout.track(viewModel);// Bind the viewModel to the DOM elements of the UI that call for it.vartoolbar=document.getElementById('toolbar');Cesium.knockout.applyBindings(viewModel,toolbar);Cesium.knockout.getObservable(viewModel,'color').subscribe(function(newValue){entity.model.color=getColor(newValue,viewModel.alpha);});Cesium.knockout.getObservable(viewModel,'alpha').subscribe(function(newValue){entity.model.color=getColor(viewModel.color,newValue);});Cesium.knockout.getObservable(viewModel,'colorBlendMode').subscribe(function(newValue){varcolorBlendMode=getColorBlendMode(newValue);entity.model.colorBlendMode=colorBlendMode;viewModel.colorBlendAmountEnabled=(colorBlendMode===Cesium.ColorBlendMode.MIX);});Cesium.knockout.getObservable(viewModel,'colorBlendAmount').subscribe(function(newValue){entity.model.colorBlendAmount=parseFloat(newValue);});Cesium.knockout.getObservable(viewModel,'silhouetteColor').subscribe(function(newValue){entity.model.silhouetteColor=getColor(newValue,viewModel.silhouetteAlpha);});Cesium.knockout.getObservable(viewModel,'silhouetteAlpha').subscribe(function(newValue){entity.model.silhouetteColor=getColor(viewModel.silhouetteColor,newValue);});Cesium.knockout.getObservable(viewModel,'silhouetteSize').subscribe(function(newValue){entity.model.silhouetteSize=parseFloat(newValue);});functioncreateModel(url,height){// viewer.entities.removeAll();varposition=Cesium.Cartesian3.fromDegrees(-123.0744619,44.0503706,height);varheading=Cesium.Math.toRadians(135);varpitch=0;varroll=0;varhpr=newCesium.HeadingPitchRoll(heading,pitch,roll);varorientation=Cesium.Transforms.headingPitchRollQuaternion(position,hpr);entity=viewer.entities.add({name : url,position : position,orientation : orientation,model : {uri : url,minimumPixelSize : 128,maximumScale : 20000,color : getColor(viewModel.color,viewModel.alpha),colorBlendMode : getColorBlendMode(viewModel.colorBlendMode),colorBlendAmount : parseFloat(viewModel.colorBlendAmount),silhouetteColor : getColor(viewModel.silhouetteColor,viewModel.silhouetteAlpha),silhouetteSize : parseFloat(viewModel.silhouetteSize)}});viewer.trackedEntity=entity;}functioncreateModel2(url,height){// viewer.entities.removeAll();varposition=Cesium.Cartesian3.fromDegrees(-123.0774619,44.0503706,height);varheading=Cesium.Math.toRadians(135);varpitch=0;varroll=0;varhpr=newCesium.HeadingPitchRoll(heading,pitch,roll);varorientation=Cesium.Transforms.headingPitchRollQuaternion(position,hpr);entity=viewer.entities.add({name : url,position : position,orientation : orientation,model : {uri : url,minimumPixelSize : 128,maximumScale : 20000,color : Cesium.Color.GREEN,silhouetteColor: Cesium.Color.BLUE,silhouetteSize: 5.0}});viewer.trackedEntity=entity;}createModel2('../../SampleData/models/CesiumAir/Cesium_Air.glb',5000.0);varoptions=[{text : 'Aircraft',onselect : function(){createModel('../../SampleData/models/CesiumAir/Cesium_Air.glb',5000.0);}},{text : 'Ground vehicle',onselect : function(){createModel('../../SampleData/models/CesiumGround/Cesium_Ground.glb',0);}},{text : 'Hot Air Balloon',onselect : function(){createModel('../../SampleData/models/CesiumBalloon/CesiumBalloon.glb',1000.0);}},{text : 'Milk truck',onselect : function(){createModel('../../SampleData/models/CesiumMilkTruck/CesiumMilkTruck-kmc.glb',0);}},{text : 'Skinned character',onselect : function(){createModel('../../SampleData/models/CesiumMan/Cesium_Man.glb',0);}}];Sandcastle.addToolbarMenu(options);Sandcastle.addToggleButton('Shadows',viewer.shadows,function(checked){viewer.shadows=checked;});
The color of the two initial planes should be different, one green and one red, however both are red.
Changing the color from the drop down will change the color of both models.
The silhouette color is applied correctly.
Thank you guys for your great work!
The text was updated successfully, but these errors were encountered:
While testing the sandcastle model coloring example found a tiny but annoying bug. When there are multiple models and colors are applied to them, all of them will have the same color.
Modified the sandcastle example to demonstrate it:
The color of the two initial planes should be different, one green and one red, however both are red.
Changing the color from the drop down will change the color of both models.
The silhouette color is applied correctly.
Thank you guys for your great work!
The text was updated successfully, but these errors were encountered: