-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4336 from AnalyticalGraphicsInc/pnts-styling
3D Tiles - Point Cloud Styling
- Loading branch information
Showing
28 changed files
with
2,455 additions
and
501 deletions.
There are no files selected for viewing
170 changes: 170 additions & 0 deletions
170
Apps/Sandcastle/gallery/3D Tiles Point Cloud Styling.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1"> <!-- Use Chrome Frame in IE --> | ||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no"> | ||
<meta name="description" content="Use Viewer to start building new applications or easily embed Cesium into existing applications."> | ||
<meta name="cesium-sandcastle-labels" content="Showcases"> | ||
<title>Cesium Demo</title> | ||
<script type="text/javascript" src="../Sandcastle-header.js"></script> | ||
<script type="text/javascript" src="../../../ThirdParty/requirejs-2.1.20/require.js"></script> | ||
<script type="text/javascript"> | ||
require.config({ | ||
baseUrl : '../../../Source', | ||
waitSeconds : 60 | ||
}); | ||
</script> | ||
</head> | ||
<body class="sandcastle-loading" data-sandcastle-bucket="bucket-requirejs.html"> | ||
<style> | ||
@import url(../templates/bucket.css); | ||
#toolbar button { display: block; } | ||
</style> | ||
<div id="cesiumContainer" class="fullSize"></div> | ||
<div id="loadingOverlay"><h1>Loading...</h1></div> | ||
<div id="toolbar"></div> | ||
<script id="cesium_sandcastle_script"> | ||
function startup(Cesium) { | ||
'use strict'; | ||
//Sandcastle_Begin | ||
|
||
var viewer = new Cesium.Viewer('cesiumContainer', { | ||
scene3DOnly : true | ||
}); | ||
|
||
var scene = viewer.scene; | ||
var url = '../../../Specs/Data/Cesium3DTiles/PointCloud/PointCloudWithPerPointProperties/'; | ||
|
||
var tileset = scene.primitives.add(new Cesium.Cesium3DTileset({ | ||
url : url | ||
})); | ||
|
||
tileset.readyPromise.then(function(tileset) { | ||
var boundingSphere = tileset.boundingSphere; | ||
viewer.camera.viewBoundingSphere(boundingSphere, new Cesium.HeadingPitchRange(0, -2.0, 0)); | ||
}); | ||
|
||
var styles = []; | ||
function addStyle(name, style) { | ||
styles.push({ | ||
name : name, | ||
style : style | ||
}); | ||
} | ||
|
||
addStyle('No Style', {}); | ||
|
||
addStyle('Red', { | ||
color : "color('#ff0000')" | ||
}); | ||
|
||
addStyle('Color Gradient', { | ||
color : "color() * ${temperature}" | ||
}); | ||
|
||
addStyle('Step Red/Blue', { | ||
color : "${temperature} > 0.5 ? color('red') : color('blue')" | ||
}); | ||
|
||
addStyle('Interpolate Red/Blue', { | ||
color : "color('red') * ${temperature} + color('blue') * (1.0 - ${temperature})" | ||
}); | ||
|
||
addStyle('Color Ramp', { | ||
color : { | ||
conditions : [ | ||
["${temperature} < 0.1", "color('#000099')"], | ||
["${temperature} < 0.2", "color('#00cc99', 1.0)"], | ||
["${temperature} < 0.3", "color('#66ff33', 0.5)"], | ||
["${temperature} < 0.4", "rgba(255, 255, 0, 0.1)"], | ||
["${temperature} < 0.5", "rgb(255, 128, 0)"], | ||
["${temperature} < 0.6", "color('red')"], | ||
["${temperature} < 0.7", "color('rgb(255, 102, 102)')"], | ||
["${temperature} < 0.8", "hsl(0.875, 1.0, 0.6)"], | ||
["${temperature} < 0.9", "hsla(0.83, 1.0, 0.5, 0.1)"], | ||
["true", "color('#FFFFFF', 1.0)"] | ||
] | ||
} | ||
}); | ||
|
||
addStyle('Transparency', { | ||
color : "rgba(0, 255, 0, ${temperature})" | ||
}); | ||
|
||
addStyle('Hide Low Temperature', { | ||
color : "rgb(${temperature}*255, 0, 0)", | ||
show : "${temperature} > 0.3" | ||
}); | ||
|
||
addStyle('Show Subsections', { | ||
show : "${id} == 1 || ${id} > 250 && ${id} < 300" | ||
}); | ||
|
||
addStyle('Mod', { | ||
show : "${id} % 2 == 0" | ||
}); | ||
|
||
addStyle('Secondary Color', { | ||
color : { | ||
expression : "[${secondaryColor}[0], ${secondaryColor}[1], ${secondaryColor}[2], 1.0]", | ||
conditions : [ | ||
["${id} < 250", "${expression}"], | ||
["${id} < 500", "${expression} * ${expression}"], | ||
["${id} < 750", "${expression} / 5.0"], | ||
["${id} < 1000", "rgb(0, 0, Number(${expression}[0] < 0.5) * 255)"] | ||
] | ||
} | ||
}); | ||
|
||
addStyle('Use point colors', { | ||
color : "${COLOR} * ${temperature} + rgb(128,128,128)" | ||
}); | ||
|
||
addStyle('Use point positions', { | ||
show : "${POSITION}[0] > 0.5 || ${POSITION}[1] > 0.5 || ${POSITION}[2] > 0.5" | ||
}); | ||
|
||
addStyle('Color based on position', { | ||
color : "rgb(${POSITION}[0] * 255, ${POSITION}[1] * 255, ${POSITION}[2] * 255)" | ||
}); | ||
|
||
addStyle('Style point size', { | ||
color : "color('red')", | ||
pointSize : "${temperature} * 10" | ||
}); | ||
|
||
function setStyle(style) { | ||
tileset.style = new Cesium.Cesium3DTileStyle(style); | ||
} | ||
|
||
function getSetStyleFunction(style) { | ||
return function() { | ||
setStyle(style); | ||
}; | ||
} | ||
|
||
var styleOptions = []; | ||
for (var j = 0; j < styles.length; ++j) { | ||
var style = styles[j]; | ||
styleOptions.push({ | ||
text : style.name, | ||
onselect : getSetStyleFunction(style.style) | ||
}); | ||
} | ||
|
||
Sandcastle.addToolbarMenu(styleOptions); | ||
|
||
/////////////////////////////////////////////////////////////////////////////// | ||
|
||
//Sandcastle_End | ||
Sandcastle.finishedLoading(); | ||
} | ||
if (typeof Cesium !== "undefined") { | ||
startup(Cesium); | ||
} else if (typeof require === "function") { | ||
require(["Cesium"], startup); | ||
} | ||
</script> | ||
</body> | ||
</html> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.