-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Polylines on terrain via Primitive API #6615
Merged
Merged
Changes from 7 commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
bc4a24a
renderable polylines on terrain
likangning93 cbd2eb7
synchronization of ground polyline attributes by ID
likangning93 b2ac735
picking GroundPolylinePrimitive ignores material type (useful for das…
likangning93 bafa5f2
removed vertex normals for polyline shadow volumes
likangning93 0371307
Support for 2D/CV
likangning93 0c22456
add interpolation for long line segments, fixes for end normals
likangning93 ac29934
Sandcastle example for polylines on terrain via Primitive API [ci skip]
likangning93 ad8d711
fix some artifacts, fix doubledraw, add per-instance color support [c…
likangning93 4f71916
Merge branch 'master' into polylinesOnTerrain
likangning93 612152b
switch from batch table and many instances to fat vertices
likangning93 fe4849e
integrate ApproximateTerrainHeights into GroundPolylineGeometry, perm…
likangning93 5de9ded
some shader cleanup, restore automatic width attribute for polylines …
likangning93 9abaa8c
simulate morph [ci skip]
likangning93 e6e2c18
additional doc and Primitive parameters, fixed bounding volume comput…
likangning93 fe3531f
switch GroundPolylineGeometry to take cartesian positions
likangning93 02e7f22
split polyline shadow volumes across IDL and PM [ci skip]
likangning93 6a51e44
handle looping and normal projection for IDL/PM split [ci skip]
likangning93 63db595
fix additional IDL bugs [ci skip]
likangning93 9e39ecc
specs for GroundPolylineGeometry
likangning93 bed6ecf
special handling for lines near-parallel to IDL
likangning93 fd903d2
fix GroundPolylineGeometry test failure for built Cesium
likangning93 071a636
fix discontinuity for GroundPolylineGeometry due to plane origins bei…
likangning93 4aebfa1
specs for GroundPolylinePrimitive
likangning93 6ac0dd5
update Sandcastle example with Z-indexing demonstration
likangning93 5ee4a47
additional specs for GroundPolylinePrimitive, fix eslint errors
likangning93 436631a
reduce overdraw for tight corners
likangning93 d11829d
add defines to enable/disable varyings
likangning93 1d1850a
PR feedback
likangning93 1bd9695
Merge branch 'master' into polylinesOnTerrain
likangning93 6147990
remove custom pick commands for GroundPolylinePrimitive, picking what…
likangning93 43dbae2
performance tweak for polylines on terrain shader
likangning93 11d7bc4
adjust epsilons for polylines on terrain IDL handling
likangning93 7869029
typo fix
likangning93 eb95073
style/doc fixes, special geometry handling for sceneMode3D
likangning93 361c4cd
fix IDL split bug for CV and normalization error IDL/PM split bug
likangning93 fa7075f
push bottom vertices of volumes at far view distances
likangning93 81a23c8
fix artifacts in 2D and morph
likangning93 163d254
early discards
likangning93 403e500
remove unneeded options, add example doc for GroundPolylinePrimitive,…
likangning93 a822e15
update CHANGES.md
likangning93 3ec30e3
PR comments, back to breaking turns with larger angles
likangning93 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
229 changes: 229 additions & 0 deletions
229
Apps/Sandcastle/gallery/development/Polylines On Terrain.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,229 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no"> | ||
<meta name="description" content="Demonstration of Polylines On Terrain via the Primitive API."> | ||
<meta name="cesium-sandcastle-labels" content="Development"> | ||
<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); | ||
</style> | ||
<div id="cesiumContainer" class="fullSize"></div> | ||
<div id="loadingOverlay"><h1>Loading...</h1></div> | ||
<div id="toolbar"> | ||
<table><tbody> | ||
<tr> | ||
<td>Width</td> | ||
<td> | ||
<input type="range" min="1.0" max="32.0" step="1.0" data-bind="value: lineWidth, valueUpdate: 'input'"> | ||
<input type="text" size="5" data-bind="value: lineWidth"> | ||
</td> | ||
</tr> | ||
</tbody></table> | ||
</div> | ||
<script id="cesium_sandcastle_script"> | ||
function startup(Cesium) { | ||
'use strict'; | ||
//Sandcastle_Begin | ||
var worldTerrain = Cesium.createWorldTerrain({ | ||
requestWaterMask: true, | ||
requestVertexNormals: true | ||
}); | ||
|
||
var viewer = new Cesium.Viewer('cesiumContainer', { | ||
terrainProvider: worldTerrain | ||
}); | ||
|
||
var selectedId = 'polyline1'; | ||
var polylineOnTerrainPrimitive; | ||
|
||
var lineWidth = 16.0; | ||
var viewModel = { | ||
lineWidth : lineWidth | ||
}; | ||
|
||
Cesium.knockout.track(viewModel); | ||
|
||
var toolbar = document.getElementById('toolbar'); | ||
Cesium.knockout.applyBindings(viewModel, toolbar); | ||
|
||
Cesium.knockout.getObservable(viewModel, 'lineWidth').subscribe( | ||
function(newValue) { | ||
lineWidth = parseFloat(viewModel.lineWidth); | ||
if (Cesium.defined(selectedId)) { | ||
var attributes = polylineOnTerrainPrimitive.getGeometryInstanceAttributes(selectedId); | ||
lineWidth = parseFloat(viewModel.lineWidth); | ||
attributes.width = [lineWidth]; | ||
} | ||
} | ||
); | ||
|
||
var scene = viewer.scene; | ||
|
||
var leftHandler = new Cesium.ScreenSpaceEventHandler(scene.canvas); | ||
leftHandler.setInputAction(function(movement) { | ||
var pickedObject = viewer.scene.pick(movement.position); | ||
if (Cesium.defined(pickedObject)) { | ||
console.log(pickedObject.id); | ||
selectedId = pickedObject.id; | ||
|
||
// Sync line width in toolbar with selected | ||
var attributes = polylineOnTerrainPrimitive.getGeometryInstanceAttributes(selectedId); | ||
viewModel.lineWidth = attributes.width[0]; | ||
} else { | ||
selectedId = undefined; | ||
} | ||
}, Cesium.ScreenSpaceEventType.LEFT_CLICK); | ||
|
||
var polylineCartographics = [ | ||
Cesium.Cartographic.fromDegrees(-112.1340164450331, 36.05494287836128), | ||
Cesium.Cartographic.fromDegrees(-112.08821010582645, 36.097804071380715), | ||
Cesium.Cartographic.fromDegrees(-112.13296079730024, 36.168769146801104), | ||
Cesium.Cartographic.fromDegrees(-112.10828895143331, 36.20031318533197), | ||
Cesium.Cartographic.fromDegrees(-112.138548165717, 36.1691100215289), // hairpins | ||
Cesium.Cartographic.fromDegrees(-112.11482556496543, 36.20127524083297), | ||
Cesium.Cartographic.fromDegrees(-112.15921333464016, 36.17876011207708), | ||
Cesium.Cartographic.fromDegrees(-112.14700151155604, 36.21683132404626), | ||
Cesium.Cartographic.fromDegrees(-112.20919883052926, 36.19475754001766) | ||
]; | ||
|
||
var loopCartographics = [ | ||
Cesium.Cartographic.fromDegrees(-111.94500779274114, 36.27638678884143), | ||
Cesium.Cartographic.fromDegrees(-111.90983004392696, 36.07985366173454), | ||
Cesium.Cartographic.fromDegrees(-111.80360100637773, 36.13694878292542), | ||
Cesium.Cartographic.fromDegrees(-111.85510122419183, 36.26029588763386), | ||
Cesium.Cartographic.fromDegrees(-111.69141601804614, 36.05128770351902) | ||
]; | ||
|
||
var instance1 = new Cesium.GeometryInstance({ | ||
geometry : new Cesium.GroundPolylineGeometry({ | ||
positions : polylineCartographics, | ||
width : 16.0, | ||
loop : false | ||
}), | ||
id : 'polyline1' | ||
}); | ||
|
||
var instance2 = new Cesium.GeometryInstance({ | ||
geometry : new Cesium.GroundPolylineGeometry({ | ||
positions : loopCartographics, | ||
width : 8.0, | ||
loop : true | ||
}), | ||
id : 'polyline2' | ||
}); | ||
|
||
polylineOnTerrainPrimitive = new Cesium.GroundPolylinePrimitive({ | ||
polylineGeometryInstances : [instance1, instance2], | ||
debugShowShadowVolume : false | ||
}); | ||
scene.primitives.add(polylineOnTerrainPrimitive); | ||
|
||
applyGlowMaterial(); | ||
|
||
function applyColorMaterial() { | ||
polylineOnTerrainPrimitive.appearance.material = Cesium.Material.fromType('Color', { | ||
color : new Cesium.Color(0.0, 1.0, 1.0, 1.0) | ||
}); | ||
} | ||
function applyGlowMaterial() { | ||
polylineOnTerrainPrimitive.appearance.material = Cesium.Material.fromType('PolylineGlow', { | ||
innerWidth : 1.0 | ||
}); | ||
} | ||
function applyArrow() { | ||
polylineOnTerrainPrimitive.appearance.material = Cesium.Material.fromType('PolylineArrow'); | ||
} | ||
function applyDash() { | ||
polylineOnTerrainPrimitive.appearance.material = Cesium.Material.fromType('PolylineDash', { | ||
color : Cesium.Color.YELLOW | ||
}); | ||
} | ||
function applyOutline() { | ||
polylineOnTerrainPrimitive.appearance.material = Cesium.Material.fromType('PolylineOutline'); | ||
} | ||
|
||
Sandcastle.addToolbarButton('Toggle instance show', function() { | ||
if (Cesium.defined(selectedId)) { | ||
var attributes = polylineOnTerrainPrimitive.getGeometryInstanceAttributes(selectedId); | ||
attributes.show = [attributes.show[0] ? 0 : 1]; | ||
} | ||
}); | ||
|
||
Sandcastle.addToolbarButton('Show all', function() { | ||
if (Cesium.defined(selectedId)) { | ||
var attributes = polylineOnTerrainPrimitive.getGeometryInstanceAttributes('polyline1'); | ||
attributes.show = [1]; | ||
attributes = polylineOnTerrainPrimitive.getGeometryInstanceAttributes('polyline2'); | ||
attributes.show = [1]; | ||
} | ||
}); | ||
|
||
function lookAt() { | ||
viewer.camera.lookAt(Cesium.Cartographic.toCartesian(polylineCartographics[1]), new Cesium.Cartesian3(50000.0, 50000.0, 50000.0)); | ||
viewer.camera.lookAtTransform(Cesium.Matrix4.IDENTITY); | ||
} | ||
|
||
Sandcastle.addToolbarButton('reset view', function() { | ||
lookAt(); | ||
}); | ||
|
||
lookAt(); | ||
|
||
Sandcastle.addToolbarMenu([{ | ||
text : 'Materials' | ||
}, { | ||
text : 'Color', | ||
onselect : function() { | ||
applyColorMaterial(); | ||
Sandcastle.highlight(applyColorMaterial); | ||
} | ||
}, { | ||
text : 'Glow', | ||
onselect : function() { | ||
applyGlowMaterial(); | ||
Sandcastle.highlight(applyGlowMaterial); | ||
} | ||
}, { | ||
text : 'Arrow', | ||
onselect : function() { | ||
applyArrow(); | ||
Sandcastle.highlight(applyArrow); | ||
} | ||
}, { | ||
text : 'Dash', | ||
onselect : function() { | ||
applyDash(); | ||
Sandcastle.highlight(applyDash); | ||
} | ||
}, { | ||
text : 'Outline', | ||
onselect : function() { | ||
applyOutline(); | ||
Sandcastle.highlight(applyOutline); | ||
} | ||
}]); | ||
|
||
//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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could also use a separate super-simple example that just shows how to add a polyline on terrain with a material...even for the
development
label.