Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow CZML polylines and paths to use materials. #1904

Merged
merged 1 commit into from
Jul 11, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions Apps/CesiumViewer/Gallery/Vehicle.czml
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,16 @@
"verticalOrigin":"CENTER"
},
"path":{
"color":[
{
"interval":"2012-08-04T16:00:00Z/2012-08-04T18:00:00Z",
"rgba":[
255,255,0,255
]
}
],
"outlineWidth":0.0,
"material":{
"solidColor":{
"color":{
"interval":"2012-08-04T16:00:00Z/2012-08-04T18:00:00Z",
"rgba":[
255,255,0,255
]
}
}
},
"width":[
{
"interval":"2012-08-04T16:00:00Z/2012-08-04T18:00:00Z",
Expand Down
91 changes: 56 additions & 35 deletions Apps/CesiumViewer/Gallery/simple.czml
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,15 @@
-1.3522077240237877,0.6932383436059149,0,-1.3630314740519183,0.6933402355423893,0,-1.3671958658568963,0.6933164116349497,0,-1.3680725973741055,0.6933103378544294,0,-1.3756294390644388,0.693299289626768,0,-1.37759145155452,0.693285710886166,0,-1.3857323154905137,0.6932329317993553,0,-1.387204693159873,0.6932497043584019,0,-1.3921642397583167,0.6932764600632868,0,-1.3948369679907713,0.6932740164944832,0,-1.403752356914346,0.6932421638673993,0,-1.4054136839844849,0.6932660224548367,0,-1.4054203339781848,0.6974061187809533,0,-1.40542577948586,0.6985302157572724,0,-1.4054446815793686,0.7009683713811051,0,-1.4054013802466303,0.7051660984836011,0,-1.4054152208071435,0.7064882030988564,0,-1.405374066131245,0.7092531367782914,0,-1.405344517975858,0.7130398911135833,0,-1.4053553041696831,0.7137921630703696,0,-1.4053903506948033,0.717847558527404,0,-1.4053391082894005,0.7241248283511975,0,-1.4054076823049872,0.724226301809922,0,-1.4053853251132624,0.7304339504245932,0,-1.4053495111334156,0.732809309071272,0,-1.3921311340866651,0.7377041737073639,0,-1.3921036273290417,0.7330926289989202,0,-1.3894979895551738,0.7330486468055195,0,-1.3798484450375388,0.7330586305001696,0,-1.3773883852209647,0.7330357493325297,0,-1.3666816595180005,0.7330283146713379,0,-1.3649219132838528,0.7330070217223114,0,-1.3569064163205986,0.7329918900387238,0,-1.354599770992057,0.7330180002614316,0,-1.3433550648083268,0.7330904667885002,0,-1.342653826195758,0.7330826651925256,0,-1.3362924480939438,0.7330909906599572,0,-1.328981348766283,0.7330498535192947,0,-1.3282799705255588,0.7330296775356948,0,-1.317369878937513,0.7329750316713255,0,-1.3156783227347815,0.7330097463386135,0,-1.3150298279817356,0.7329135612488367,0,-1.314652993784966,0.7323625607125478,0,-1.3139482994025766,0.7321239392772451,0,-1.313439099339346,0.7307498413128194,0,-1.3119864438784967,0.730731794657347,0,-1.3115849481938966,0.7305214824566543,0,-1.3111742895338896,0.7304061685456499,0,-1.3110525702187852,0.7301933081536464,0,-1.3103904967805342,0.7297947098063845,0,-1.3106869061243591,0.7294990335104291,0,-1.3106926482391603,0.7291819769374323,0,-1.31006717438301,0.7290287195687776,0,-1.3099912873941209,0.7282685936295457,0,-1.3101384361377446,0.7280613880956304,0,-1.3098927634269164,0.7267083737010938,0,-1.3102614817770415,0.7262854105154587,0,-1.3102163475385047,0.7261352772658493,0,-1.3094348237109952,0.7254602361685523,0,-1.3092568000409661,0.7250021744241752,0,-1.308504580282513,0.7240255927322389,0,-1.3078199921164888,0.72403864782177,0,-1.3072264926882589,0.7236467166299556,0,-1.307169245851595,0.7233461185166344,0,-1.3066244760589671,0.7233894550695429,0,-1.3053806318405998,0.7230886126517037,0,-1.304717877749918,0.7230926094796837,0,-1.3044598132746381,0.7229514646847072,0,-1.304466742212013,0.7225949985688139,0,-1.3038530144070728,0.7221311597980974,0,-1.3037620652441313,0.7217037983975161,0,-1.3053608047669052,0.7210299440396993,0,-1.3054040889283545,0.7207376013315654,0,-1.3059460661823945,0.7205192954872712,0,-1.3066654038056376,0.7195438482063814,0,-1.3066038809082192,0.7191939794384397,0,-1.307509392852277,0.7180478912764205,0,-1.3081242027013054,0.7175373648956472,0,-1.308728104256843,0.717319652461049,0,-1.3088029439804343,0.7170121428373868,0,-1.3084086390699141,0.7170281126169686,0,-1.3090170610213867,0.7166757130974598,0,-1.3096123057176687,0.7160773791853247,0,-1.3102183365700435,0.7157721733780154,0,-1.3110323583836496,0.7155894722475611,0,-1.3114282515208273,0.715192915896617,0,-1.3113623303982265,0.7149382548578634,0,-1.3103886282856712,0.7138982478932651,0,-1.3102830183588716,0.7135714872902171,0,-1.3099828739776964,0.7133519073843598,0,-1.3099502537461944,0.7130661620241878,0,-1.3107343082404708,0.71278013738274,0,-1.3105539981986583,0.7124678106579555,0,-1.3107517440349952,0.7119489067090039,0,-1.31127146832641,0.711618131825877,0,-1.311969495533574,0.7116548186295764,0,-1.3123766984036227,0.7111869655638845,0,-1.312273898452243,0.7107655382832366,0,-1.3125810939125313,0.7101058734983065,0,-1.3122094259121033,0.7098219258392405,0,-1.3126432625232558,0.7094893707227551,0,-1.312451642745932,0.7092008153872138,0,-1.3124943858525955,0.7088611393395713,0,-1.3123744118489564,0.7083205235010411,0,-1.3124452547722973,0.708092164574061,0,-1.3121783938297178,0.7078498255687451,0,-1.311170361152473,0.7079894345182887,0,-1.3103895005747963,0.707650107564989,0,-1.3101083802768658,0.7072250674577409,0,-1.3102207619963784,0.7060949839922579,0,-1.309999715938635,0.7054652167207774,0,-1.3093681334206897,0.7051362570197143,0,-1.3090052619072645,0.705263631186341,0,-1.3085229574630952,0.7051907985987479,0,-1.3081275878407266,0.704161490481042,0,-1.3078189262517947,0.7039573043817338,0,-1.3076207789382897,0.7036127588721909,0,-1.3069140774300372,0.7033606983954779,0,-1.3062526671932404,0.7024681543136311,0,-1.3044385887704104,0.701233735108179,0,-1.3042056919320535,0.7007377298965646,0,-1.304568964853792,0.7003023050552322,0,-1.3060128412908008,0.7001592403389345,0,-1.3067616226475691,0.699494182468726,0,-1.3082325342309757,0.6991443834599382,0,-1.3087087299920748,0.6987265340836812,0,-1.3097941505737305,0.698265086353168,0,-1.310184580829599,0.6978768726763835,0,-1.3104732932768435,0.6977082912802286,0,-1.3109336414681285,0.6977250115221181,0,-1.3114380592151826,0.6973624890931379,0,-1.3115653635501037,0.6969928457322186,0,-1.3113672162189656,0.6963321861243438,0,-1.311491064806832,0.6960654124902647,0,-1.3122363904438565,0.6959921609813949,0,-1.313307848385792,0.6955209219518895,0,-1.3134255708764333,0.69543595930277,0,-1.3150346253356304,0.6954879526165308,0,-1.316335524310828,0.6946234384593984,0,-1.3171997767525299,0.6951045210815227,0,-1.319179975605344,0.6953413971468251,0,-1.3202367902547627,0.695309754284478,0,-1.3211230163524166,0.694998230372876,0,-1.3220100103668133,0.6942036166803666,0,-1.322522002814063,0.6933243719682792,0,-1.3228041702830704,0.6933123989973828,0,-1.3288801694793237,0.6932838277389112,0,-1.330519016712254,0.693277265241703,0,-1.3363957516005893,0.6932495491982945,0,-1.3402469439857425,0.6932668452760358,0,-1.3438479258876066,0.6932604746923505,0,-1.347761635982283,0.6932567744504896,0,-1.3520094545588786,0.6932461975964622,0,-1.3522077240237877,0.6932383436059149,0
]
},
"color":{
"rgba":[
255,0,0,255
]
"material":{
"solidColor":{
"color":{
"rgba":[
255,0,0,255
]
}
}
},
"width":1,
"show":true
},
"position":{
Expand Down Expand Up @@ -172,12 +175,15 @@
"verticalOrigin":"CENTER"
},
"path":{
"color":{
"rgba":[
0,255,0,255
]
"material":{
"solidColor":{
"color":{
"rgba":[
0,255,0,255
]
}
}
},
"width":1,
"resolution":60,
"show":[
{
Expand Down Expand Up @@ -2655,12 +2661,15 @@
"verticalOrigin":"CENTER"
},
"path":{
"color":{
"rgba":[
255,0,255,255
]
"material":{
"solidColor":{
"color":{
"rgba":[
255,0,255,255
]
}
}
},
"width":1,
"resolution":60,
"show":[
{
Expand Down Expand Up @@ -3371,12 +3380,15 @@
"verticalOrigin":"CENTER"
},
"path":{
"color":{
"rgba":[
255,255,0,255
]
"material":{
"solidColor":{
"color":{
"rgba":[
255,255,0,255
]
}
}
},
"width":1,
"resolution":60,
"show":[
{
Expand Down Expand Up @@ -3759,18 +3771,21 @@
"2012-03-15T10:16:06.97400000000198Z/2012-03-15T10:33:59.3549999999959Z","2012-03-15T11:04:09.73799999999756Z/2012-03-15T11:21:04.51900000000023Z","2012-03-15T11:52:06.94400000000314Z/2012-03-15T12:08:18.8840000000055Z","2012-03-15T12:40:57.2069999999949Z/2012-03-15T12:54:39.301999999996Z","2012-03-15T13:29:44.5040000000008Z/2012-03-15T13:41:05.96899999999732Z","2012-03-15T14:20:16.8450000000012Z/2012-03-15T14:25:48.0559999999969Z","2012-03-16T07:01:44.4309999999823Z/2012-03-16T07:06:19.6309999999939Z","2012-03-16T07:46:00.457999999984168Z/2012-03-16T07:57:20.8470000000088Z","2012-03-16T08:32:14.5289999999804Z/2012-03-16T08:46:17.0109999999986Z","2012-03-16T09:18:28.4590000000026Z/2012-03-16T09:35:16.6410000000033Z"
],
"polyline":{
"color":{
"rgba":[
0,255,0,255
]
"material":{
"solidColor":{
"color":{
"rgba":[
0,255,0,255
]
}
}
},
"positions":{
"references":[
"Satellite/Geoeye1#position",
"Satellite/ISS#position"
]
},
"width":1,
"show":[
{
"interval":"0000-01-01T00:00:00Z/2012-03-15T10:16:06.97400000000198Z",
Expand Down Expand Up @@ -3867,18 +3882,21 @@
"2012-03-15T10:52:19.3940000000002Z/2012-03-15T11:02:24.5570000000007Z","2012-03-15T12:28:24.0339999999997Z/2012-03-15T12:38:34.6399999999994Z","2012-03-15T14:06:02.09799999999814Z/2012-03-15T14:14:48.5310000000027Z","2012-03-15T15:43:15.2350000000006Z/2012-03-15T15:52:06.56500000000233Z","2012-03-15T17:19:26.3190000000031Z/2012-03-15T17:29:36.0240000000049Z","2012-03-15T18:55:44.7079999999987Z/2012-03-15T19:05:17.7339999999967Z","2012-03-16T09:56:05.90600000001723Z/2012-03-16T10:00:00Z"
],
"polyline":{
"color":{
"rgba":[
0,255,255,255
]
"material":{
"solidColor":{
"color":{
"rgba":[
0,255,255,255
]
}
}
},
"positions":{
"references":[
"Facility/AGI#position",
"Satellite/ISS#position"
]
},
"width":1,
"show":[
{
"interval":"0000-01-01T00:00:00Z/2012-03-15T10:52:19.3940000000002Z",
Expand Down Expand Up @@ -3944,18 +3962,21 @@
"name":"AGI to Sensor",
"parent":"eeff9f33-2672-414a-964f-721602a28983",
"polyline":{
"color":{
"rgba":[
0,255,255,255
]
"material":{
"solidColor":{
"color":{
"rgba":[
0,255,255,255
]
}
}
},
"positions":{
"references":[
"Facility/AGI#position",
"Satellite/Geoeye1/Sensor/Sensor#position"
]
},
"width":1,
"show":false
}
}
Expand Down
13 changes: 8 additions & 5 deletions Apps/Sandcastle/gallery/CZML.html
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,14 @@
"verticalOrigin" : "CENTER"
},
"path" : {
"color" : [{
"interval" : "2012-08-04T16:00:00Z/2012-08-04T18:00:00Z",
"rgba" : [255, 255, 0, 255]
}],
"outlineWidth" : 0.0,
"material":{
"solidColor":{
"color" : [{
"interval" : "2012-08-04T16:00:00Z/2012-08-04T18:00:00Z",
"rgba" : [255, 255, 0, 255]
}]
}
},
"width" : [{
"interval" : "2012-08-04T16:00:00Z/2012-08-04T18:00:00Z",
"number" : 5.0
Expand Down
81 changes: 19 additions & 62 deletions Source/DataSources/CzmlDataSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ define([
'./PathGraphics',
'./PointGraphics',
'./PolygonGraphics',
'./PolylineGlowMaterialProperty',
'./PolylineGraphics',
'./PolylineOutlineMaterialProperty',
'./PositionPropertyArray',
Expand Down Expand Up @@ -124,6 +125,7 @@ define([
PathGraphics,
PointGraphics,
PolygonGraphics,
PolylineGlowMaterialProperty,
PolylineGraphics,
PolylineOutlineMaterialProperty,
PositionPropertyArray,
Expand Down Expand Up @@ -834,6 +836,21 @@ define([
processPacketData(Color, existingMaterial, 'oddColor', materialData.oddColor, undefined, sourceUri, entityCollection);
processPacketData(Number, existingMaterial, 'offset', materialData.offset, undefined, sourceUri, entityCollection);
processPacketData(Number, existingMaterial, 'repeat', materialData.repeat, undefined, sourceUri, entityCollection);
} else if (defined(packetData.polylineOutline)) {
if (!(existingMaterial instanceof PolylineOutlineMaterialProperty)) {
existingMaterial = new PolylineOutlineMaterialProperty();
}
materialData = packetData.polylineOutline;
processPacketData(Color, existingMaterial, 'color', materialData.color, undefined, sourceUri, entityCollection);
processPacketData(Color, existingMaterial, 'outlineColor', materialData.outlineColor, undefined, sourceUri, entityCollection);
processPacketData(Number, existingMaterial, 'outlineWidth', materialData.outlineWidth, undefined, sourceUri, entityCollection);
} else if (defined(packetData.polylineOutline)) {
if (!(existingMaterial instanceof PolylineGlowMaterialProperty)) {
existingMaterial = new PolylineGlowMaterialProperty();
}
materialData = packetData.polylineOutline;
processPacketData(Color, existingMaterial, 'color', materialData.color, undefined, sourceUri, entityCollection);
processPacketData(Number, existingMaterial, 'glowPower', materialData.glowPower, undefined, sourceUri, entityCollection);
}

if (defined(existingInterval)) {
Expand Down Expand Up @@ -1252,42 +1269,12 @@ define([
entity.path = path = new PathGraphics();
}

//Since CZML does not support PolylineOutlineMaterial, we map its properties into one.
var materialToProcess = path.material;
if (defined(interval)) {
var materialInterval;
var composite = materialToProcess;
if (!(composite instanceof CompositeMaterialProperty)) {
composite = new CompositeMaterialProperty();
path.material = composite;
if (defined(materialToProcess)) {
materialInterval = Iso8601.MAXIMUM_INTERVAL.clone();
materialInterval.data = materialToProcess;
composite.intervals.addInterval(materialInterval);
}
}
materialInterval = composite.intervals.findInterval(interval);
if (defined(materialInterval)) {
materialToProcess = materialInterval.data;
} else {
materialToProcess = new PolylineOutlineMaterialProperty();
materialInterval = interval.clone();
materialInterval.data = materialToProcess;
composite.intervals.addInterval(materialInterval);
}
} else if (!(materialToProcess instanceof PolylineOutlineMaterialProperty)) {
materialToProcess = new PolylineOutlineMaterialProperty();
path.material = materialToProcess;
}

processPacketData(Boolean, path, 'show', pathData.show, interval, sourceUri, entityCollection);
processPacketData(Number, path, 'width', pathData.width, interval, sourceUri, entityCollection);
processPacketData(Number, path, 'resolution', pathData.resolution, interval, sourceUri, entityCollection);
processPacketData(Number, path, 'leadTime', pathData.leadTime, interval, sourceUri, entityCollection);
processPacketData(Number, path, 'trailTime', pathData.trailTime, interval, sourceUri, entityCollection);
processPacketData(Color, materialToProcess, 'color', pathData.color, interval, sourceUri, entityCollection);
processPacketData(Color, materialToProcess, 'outlineColor', pathData.outlineColor, interval, sourceUri, entityCollection);
processPacketData(Number, materialToProcess, 'outlineWidth', pathData.outlineWidth, interval, sourceUri, entityCollection);
processMaterialPacketData(path, 'material', pathData.material, interval, sourceUri, entityCollection);
}

function processPoint(entity, packet, entityCollection, sourceUri) {
Expand Down Expand Up @@ -1426,39 +1413,9 @@ define([
entity.polyline = polyline = new PolylineGraphics();
}

//Since CZML does not support PolylineOutlineMaterial, we map its properties into one.
var materialToProcess = polyline.material;
if (defined(interval)) {
var materialInterval;
var composite = materialToProcess;
if (!(composite instanceof CompositeMaterialProperty)) {
composite = new CompositeMaterialProperty();
polyline.material = composite;
if (defined(materialToProcess)) {
materialInterval = Iso8601.MAXIMUM_INTERVAL.clone();
materialInterval.data = materialToProcess;
composite.intervals.addInterval(materialInterval);
}
}
materialInterval = composite.intervals.findInterval(interval);
if (defined(materialInterval)) {
materialToProcess = materialInterval.data;
} else {
materialToProcess = new PolylineOutlineMaterialProperty();
materialInterval = interval.clone();
materialInterval.data = materialToProcess;
composite.intervals.addInterval(materialInterval);
}
} else if (!(materialToProcess instanceof PolylineOutlineMaterialProperty)) {
materialToProcess = new PolylineOutlineMaterialProperty();
polyline.material = materialToProcess;
}

processPacketData(Boolean, polyline, 'show', polylineData.show, interval, sourceUri, entityCollection);
processPacketData(Number, polyline, 'width', polylineData.width, interval, sourceUri, entityCollection);
processPacketData(Color, materialToProcess, 'color', polylineData.color, interval, sourceUri, entityCollection);
processPacketData(Color, materialToProcess, 'outlineColor', polylineData.outlineColor, interval, sourceUri, entityCollection);
processPacketData(Number, materialToProcess, 'outlineWidth', polylineData.outlineWidth, interval, sourceUri, entityCollection);
processMaterialPacketData(polyline, 'material', polylineData.material, interval, sourceUri, entityCollection);
processPositions(polyline, polylineData.positions, entityCollection);
}

Expand Down
Loading