|
39 | 39 | var scene = viewer.scene;
|
40 | 40 | scene.fog.enabled = false;
|
41 | 41 |
|
42 |
| -var tileStyle = new Cesium.Cesium3DTileStyle({ |
43 |
| - color: { |
44 |
| - conditions: [ |
45 |
| - ["${Height} >= 83", "color('purple', 0.5)"], |
46 |
| - ["${Height} >= 80", "color('red')"], |
47 |
| - ["${Height} >= 70", "color('orange')"], |
48 |
| - ["${Height} >= 12", "color('yellow')"], |
49 |
| - ["${Height} >= 7", "color('lime')"], |
50 |
| - ["${Height} >= 1", "color('cyan')"], |
51 |
| - ["true", "color('blue')"] |
52 |
| - ] |
53 |
| - }, |
54 |
| - meta: { |
55 |
| - description: "'Building id ${id} has height ${Height}.'" |
56 |
| - } |
57 |
| -}); |
58 |
| - |
59 | 42 | //var styleElements = [];
|
60 | 43 | //var numberofColors = 6;
|
61 | 44 | //var currentPropertyName = 'Height';
|
62 | 45 | var annotations = scene.primitives.add(new Cesium.LabelCollection());
|
63 | 46 |
|
64 | 47 | var tileset;
|
65 |
| -var tilesets = { |
66 |
| - 'Tileset': '../../../Specs/Data/Cesium3DTiles/Tilesets/Tileset/', |
67 |
| - 'Translucent': '../../../Specs/Data/Cesium3DTiles/Batched/BatchedTranslucent/', |
68 |
| - 'Translucent/Opaque': '../../../Specs/Data/Cesium3DTiles/Batched/BatchedTranslucentOpaqueMix/', |
69 |
| - 'Multi-color': '../../../Specs/Data/Cesium3DTiles/Batched/BatchedColors/', |
70 |
| - 'Request Volume': '../../../Specs/Data/Cesium3DTiles/Tilesets/TilesetWithViewerRequestVolume/', |
71 |
| - 'Batched': '../../../Specs/Data/Cesium3DTiles/Batched/BatchedWithBatchTable/', |
72 |
| - 'Instanced': '../../../Specs/Data/Cesium3DTiles/Instanced/InstancedWithBatchTable/', |
73 |
| - 'Instanced/Orientation': '../../../Specs/Data/Cesium3DTiles/Instanced/InstancedOrientationWithBatchTable/', |
74 |
| - 'Composite': '../../../Specs/Data/Cesium3DTiles/Composite/Composite/', |
75 |
| - 'PointCloud': '../../../Specs/Data/Cesium3DTiles/PointCloud/PointCloudRGB/', |
76 |
| - 'PointCloudConstantColor': '../../../Specs/Data/Cesium3DTiles/PointCloud/PointCloudConstantColor/', |
77 |
| - 'PointCloudNormals': '../../../Specs/Data/Cesium3DTiles/PointCloud/PointCloudQuantizedOctEncoded/', |
78 |
| - 'PointCloudBatched': '../../../Specs/Data/Cesium3DTiles/PointCloud/PointCloudBatched/' |
79 |
| -}; |
80 | 48 |
|
81 | 49 | var viewModel = {
|
82 | 50 | tilesets: [
|
|
163 | 131 | var boundingSphere = tileset.boundingSphere;
|
164 | 132 | viewer.camera.viewBoundingSphere(boundingSphere, new Cesium.HeadingPitchRange(0, -2.0, 0));
|
165 | 133 | viewer.camera.lookAtTransform(Cesium.Matrix4.IDENTITY);
|
| 134 | + |
| 135 | + var properties = tileset.properties; |
| 136 | + if (Cesium.defined(properties) && Cesium.defined(properties.Height)) { |
| 137 | + tileset.style = new Cesium.Cesium3DTileStyle({ |
| 138 | + color: { |
| 139 | + conditions: [ |
| 140 | + ["${Height} >= 83", "color('purple', 0.5)"], |
| 141 | + ["${Height} >= 80", "color('red')"], |
| 142 | + ["${Height} >= 70", "color('orange')"], |
| 143 | + ["${Height} >= 12", "color('yellow')"], |
| 144 | + ["${Height} >= 7", "color('lime')"], |
| 145 | + ["${Height} >= 1", "color('cyan')"], |
| 146 | + ["true", "color('blue')"] |
| 147 | + ] |
| 148 | + }, |
| 149 | + meta: { |
| 150 | + description: "'Building id ${id} has height ${Height}.'" |
| 151 | + } |
| 152 | + }); |
| 153 | + } |
166 | 154 | });
|
167 | 155 | });
|
168 | 156 |
|
|
276 | 264 | });
|
277 | 265 | }
|
278 | 266 | }
|
279 |
| -/* |
280 |
| -function createStylingFunctions(tileset) { |
281 |
| - // Styling //////////////////////////////////////////////////////////////////// |
282 |
| -
|
283 |
| - function getRandomColor() { |
284 |
| - var color = Cesium.Color.fromRandom(); |
285 |
| - color.alpha = 1.0; |
286 |
| - return color.toCssColorString(); |
287 |
| - } |
288 |
| -
|
289 |
| - function styleFunction(name) { |
290 |
| - var conditions = []; |
291 |
| - var intervalSize = Math.floor(100/numberofColors); |
292 |
| - for (var i = numberofColors; i >= 0; --i) { |
293 |
| - var cond = '${' + name + '} > ' + (i * intervalSize); |
294 |
| - conditions.push([cond, getRandomColor()]); |
295 |
| - } |
296 |
| - conditions.push(['true', getRandomColor()]); |
297 |
| -
|
298 |
| - tileset.style = new Cesium.Cesium3DTileStyle({ |
299 |
| - color : { |
300 |
| - conditions : conditions |
301 |
| - }, |
302 |
| - show : '${' + name + '} >= 0' |
303 |
| - }); |
304 |
| -
|
305 |
| - currentPropertyName = name; |
306 |
| - } |
307 |
| -
|
308 |
| - function getStyleFunction(name) { |
309 |
| - return function() { |
310 |
| - styleFunction(name); |
311 |
| - }; |
312 |
| - } |
313 |
| -
|
314 |
| - function addStyleUI() { |
315 |
| - var button; |
316 |
| -
|
317 |
| - var properties = tileset.properties; |
318 |
| - if (Cesium.defined(properties)) { |
319 |
| - for (var name in properties) { |
320 |
| - // Include all properties except longitude and latitude |
321 |
| - if (properties.hasOwnProperty(name) && (name !== 'Longitude') && (name !== 'Latitude')) { |
322 |
| - button = Sandcastle.addToolbarButton('Style with ' + name, getStyleFunction(name)); |
323 |
| - styleElements.push(button); |
324 |
| - } |
325 |
| - } |
326 |
| - } |
327 |
| -
|
328 |
| - button = Sandcastle.addToolbarButton('Custom style', function() { |
329 |
| - var style = new Cesium.Cesium3DTileStyle(); |
330 |
| - style.show = { |
331 |
| - evaluate : function(frameState, feature) { |
332 |
| - tileset.makeStyleDirty(); // Force the style to be constantly evaluated |
333 |
| - return Cesium.Math.nextRandomNumber() > 0.5; |
334 |
| - } |
335 |
| - }; |
336 |
| - style.color = { |
337 |
| - evaluateColor : function(frameState, feature, result) { |
338 |
| - tileset.makeStyleDirty(); // Force the style to be constantly evaluated |
339 |
| - return Cesium.Color.fromRandom(undefined, result); |
340 |
| - } |
341 |
| - }; |
342 |
| - tileset.style = style; |
343 |
| - }); |
344 |
| - styleElements.push(button); |
345 |
| -
|
346 |
| - button = Sandcastle.addToolbarButton('Remove style', function() { |
347 |
| - tileset.style = undefined; |
348 |
| - }); |
349 |
| - styleElements.push(button); |
350 |
| -
|
351 |
| - function setColorBlendMode(colorBlendMode) { |
352 |
| - return function() { |
353 |
| - tileset.colorBlendMode = colorBlendMode; |
354 |
| - }; |
355 |
| - } |
356 |
| -
|
357 |
| - var menu = Sandcastle.addToolbarMenu([{ |
358 |
| - text : 'Color Blend Mode' |
359 |
| - }, { |
360 |
| - text : 'Highlight', |
361 |
| - onselect : setColorBlendMode(Cesium.Cesium3DTileColorBlendMode.HIGHLIGHT) |
362 |
| - }, { |
363 |
| - text : 'Replace', |
364 |
| - onselect : setColorBlendMode(Cesium.Cesium3DTileColorBlendMode.REPLACE) |
365 |
| - }, { |
366 |
| - text : 'Mix', |
367 |
| - onselect : setColorBlendMode(Cesium.Cesium3DTileColorBlendMode.MIX) |
368 |
| - }]); |
369 |
| - styleElements.push(menu); |
370 |
| -
|
371 |
| - button = Sandcastle.addToolbarButton('colors++', function() { |
372 |
| - ++numberofColors; |
373 |
| - styleFunction(currentPropertyName); |
374 |
| - }); |
375 |
| - styleElements.push(button); |
376 |
| -
|
377 |
| - button = Sandcastle.addToolbarButton('colors--', function() { |
378 |
| - numberofColors = Math.max(numberofColors - 1, 1); |
379 |
| - styleFunction(currentPropertyName); |
380 |
| - }); |
381 |
| - styleElements.push(button); |
382 |
| -
|
383 |
| - var leftOperand = 0; |
384 |
| - var rightOperand = 0; |
385 |
| - var op = '=='; |
386 |
| -
|
387 |
| - // Left operand (properties and literals) |
388 |
| -
|
389 |
| - function getLeftOperandFunction(name) { |
390 |
| - return function() { |
391 |
| - leftOperand = name; |
392 |
| - updateExpression(); |
393 |
| - }; |
394 |
| - } |
395 |
| - addOperands('Expression left operand', getLeftOperandFunction); |
396 |
| -
|
397 |
| - // Operator |
398 |
| -
|
399 |
| - var ops = ['<', '<=', '>', '>=', '==', '!=']; |
400 |
| - var operators = [{ |
401 |
| - text : 'Operator', |
402 |
| - onselect : function() { |
403 |
| - } |
404 |
| - }]; |
405 |
| -
|
406 |
| - function getOperatorFunction(operator) { |
407 |
| - return function() { |
408 |
| - op = operator; |
409 |
| - updateExpression(); |
410 |
| - }; |
411 |
| - } |
412 |
| -
|
413 |
| - for (var i = 0; i < ops.length; ++i) { |
414 |
| - operators.push({ |
415 |
| - text : ops[i], |
416 |
| - onselect : getOperatorFunction(ops[i]) |
417 |
| - }); |
418 |
| - } |
419 |
| -
|
420 |
| - menu = Sandcastle.addToolbarMenu(operators); |
421 |
| - styleElements.push(menu); |
422 |
| -
|
423 |
| - // Right operand |
424 | 267 |
|
425 |
| - function getRightOperandFunction(operand) { |
426 |
| - return function() { |
427 |
| - rightOperand = operand; |
428 |
| - updateExpression(); |
429 |
| - }; |
430 |
| - } |
431 |
| - addOperands('Right operand', getRightOperandFunction); |
432 |
| -
|
433 |
| - function updateExpression() { |
434 |
| - var exp = '' + leftOperand + op + rightOperand; |
435 |
| - tileset.style = new Cesium.Cesium3DTileStyle({ show : exp }); |
436 |
| - } |
437 |
| - } |
438 |
| -
|
439 |
| - function addOperands(text, getOperandFunction) { |
440 |
| - var expressionOperands = [{ |
441 |
| - text : text, |
442 |
| - onselect : function() { |
443 |
| - } |
444 |
| - }]; |
445 |
| -
|
446 |
| - var properties = tileset.properties; |
447 |
| - for (var name in properties) { |
448 |
| - if (properties.hasOwnProperty(name)) { |
449 |
| - var property = '${' + name + '}'; |
450 |
| - expressionOperands.push({ |
451 |
| - text : property, |
452 |
| - onselect : getOperandFunction(property) |
453 |
| - }); |
454 |
| - } |
455 |
| - } |
456 |
| -
|
457 |
| - var oprs = [1, 10, 50, 100]; |
458 |
| - for (var j = 0; j < oprs.length; ++j) { |
459 |
| - expressionOperands.push({ |
460 |
| - text : oprs[j], |
461 |
| - onselect : getOperandFunction(oprs[j]) |
462 |
| - }); |
463 |
| - } |
464 |
| -
|
465 |
| - var menu = Sandcastle.addToolbarMenu(expressionOperands); |
466 |
| - styleElements.push(menu); |
467 |
| - } |
468 |
| -
|
469 |
| - // End of Styling ///////////////////////////////////////////////////////////// |
470 |
| -
|
471 |
| - return addStyleUI; |
472 |
| -} |
473 |
| -*/ |
474 | 268 | //Sandcastle_End
|
475 | 269 | Sandcastle.finishedLoading();
|
476 | 270 | }
|
|
0 commit comments