-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Polygons on terrain #2865
Merged
Merged
Polygons on terrain #2865
Changes from 77 commits
Commits
Show all changes
82 commits
Select commit
Hold shift + click to select a range
c6c2d03
Ground primitive WIP.
bagnell 11770c1
Clamp positions to near plane. Shadow volume sides that are entirely …
bagnell c1c9c65
Merge branch 'globe-depth' into ground-primitive
bagnell 1b42df4
Merge branch 'globe-depth' into ground-primitive
bagnell ba6026a
Merge branch 'globe-depth' into ground-primitive
bagnell fe5fab1
Declare commands and properly release shaders.
bagnell 5d408bf
Update CHANGES.md.
bagnell 5496e4b
Merge branch 'globe-depth' into ground-primitive
bagnell 4d72baf
Clip polygon to the near plane of the first frustum WIP. Added debug …
bagnell 36b6772
More ground polygon WIP. Only extrude vertices in vertex shader. Vert…
bagnell 0790da0
Fix blinking polygon by slightly offsetting intersection point from t…
bagnell f0c8e24
Fix multi-frustum artifact on ground polygons volume.
bagnell 94e1336
Clean up intersection function to make it more clear and add comments.
bagnell 3a96b61
Some shader clean up and fixing a volume artifact WIP.
bagnell 60ab053
Remove ground polygon texture coordinates.
bagnell 0230cb0
Merge branch 'globe-depth' into ground-primitive
bagnell f1d5831
Add ground polygon development Sandcastle example.
bagnell 01d4d6a
Use the same normal for both extruded and non-extruded positions. Add…
bagnell d051c08
Fix artifact where more than one frustum was drawing at the far plane…
bagnell 94552de
Merge branch 'master' into ground-primitive
bagnell 063a0ac
Merge remote-tracking branch 'origin' into ground-primitive
bagnell 9b54673
Fix looking up at terrain when inside the shadow volume.
bagnell 239cd1c
Remove code for culled lines from the function to clip the line again…
bagnell a7eb9b6
Avoid computing eye coordinates multiple times.
bagnell f8877cd
Fix shadow volumes by using a different technique.
bagnell c344aa2
Move to more general ground primitive WIP.
bagnell e9affe0
Remove ground polygon for more general ground primitive.
bagnell fdd5e5b
Merge branch 'master' into ground-primitive
bagnell 23f6700
Add Columbus view support and per instance attribute support.
bagnell ff0a67a
Add commands for z-pass algorithm.
bagnell 50bf334
Add support for more geometry that can be clamped to the ground. Add …
bagnell face14c
Compute shadow volume height based on granularity. Overlap frustums w…
bagnell ea1fd7b
Merge branch 'master' into ground-primitive
bagnell 68c49f8
Remove z-pass optimization to fix multi-frustum artifact.
bagnell d55ff80
Fix rectangle geometry surface volume.
bagnell 2d1894c
Clean up primitive shadow volume creation.
bagnell 3e10cf5
Add picking support to ground primitive and remove model matrix option.
bagnell 6f546c6
Merge branch 'master' into ground-primitive
bagnell c99bd57
Reapply change from merge to reorganized code.
bagnell 84ff66e
Merge branch 'globe-pick' into ground-primitive
bagnell 3269056
Use a depth/stencil renderbuffer with the picking fbo.
bagnell 6ab9532
Merge branch 'master' into ground-primitive
bagnell 277930f
Merge branch 'depth-plane' into ground-primitive
bagnell 164dbc8
Add doc and properties forwarded to the primitive.
bagnell 9ef18a0
Clean up ground primitive example.
bagnell 5c9e945
Rename _createShadowVolume by removing the underscore and making it p…
bagnell 49d3769
Merge branch 'master' into ground-primitive
bagnell 198f857
Remove #ifdefs from shader checking for GL_EXT_frag_depth. The shader…
bagnell 282463f
Porting Primitive tests for GroundPrimitive WIP.
bagnell 256c47b
Add remaining tests.
bagnell cd15a4e
Update doc.
bagnell ff9a863
Update CHANGES.md.
bagnell deaf939
Merge branch 'master' into ground-primitive
bagnell f503bd0
Refactor Primitive and GroundPrimitive updates.
bagnell 1b7d5c2
Merge branch 'master' into ground-primitive
bagnell 7a3417e
Add hooks to Primitive to override render state, shader, and command …
bagnell ea855bb
The GroundPrimitive creates more commands that Primitive. Properly sy…
bagnell 71f0bc9
Add prototype versions of distanceSquaredTo and computePlaneDistances…
bagnell 001fdf6
Add OrientedBoundingBox.distanceSquaredTo.
bagnell 3043c44
Add OrientedBoundingBox.computePlaneDistances.
bagnell e4587c1
Add an isOccluded function to the prototypes of BoundingSphere and Or…
bagnell 71193a8
Add support for both bounding spheres and boxes to Scene.
bagnell 21d0118
Add hook to primitive for creating custom bounding volumes for geometry.
bagnell 7c23324
Remove unnecessary vector multiplies and magnitudes when getting dist…
bagnell a4e8fa9
Use OBBs as bounding volumes for ground primitives.
bagnell 6517e2d
Modify debugShowBoundingVolume to work with OBBs.
bagnell f10fecc
Merge branch 'master' into ground-primitive
bagnell 3d9ced1
Fix ground primitive bounding volumes when not in 3D.
bagnell e301a3c
Change geometryInstances to geometryInstance since batching is not su…
bagnell e9caa53
Fix tests.
bagnell 8155c35
Test optimization from review.
bagnell a18e6ab
Add tests for new BoundingSphere and OrientedBoundingBox functions.
bagnell b50d97a
Use scene instead of context for ground primitive rendering tests.
bagnell cc60873
Fix test.
bagnell 3a6ee56
Enable picking ground primitives when depthTestAgainstTerrain is false.
bagnell 2521859
Merge branch 'master' into ground-primitive
bagnell c320e39
Merge branch 'master' into ground-primitive
bagnell 79aed81
Update CHANGES.ms.
bagnell 870e68a
Merge branch 'master' into ground-primitive
bagnell d76b729
Fix after merge.
bagnell 9f6664d
Fix IE tests.
bagnell b9856c0
Add GroundPrimitive.isSupported.
bagnell 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
179 changes: 179 additions & 0 deletions
179
Apps/Sandcastle/gallery/development/Ground Primitive.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,179 @@ | ||
<!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="Draw a polygon or extruded polygon on the globe surface."> | ||
<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.9/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"></div> | ||
<script id="cesium_sandcastle_script"> | ||
function startup(Cesium) { | ||
"use strict"; | ||
//Sandcastle_Begin | ||
|
||
//Create the viewer. | ||
var viewer = new Cesium.Viewer('cesiumContainer'); | ||
var scene = viewer.scene; | ||
scene.terrainProvider = new Cesium.CesiumTerrainProvider({ | ||
url: '//cesiumjs.org/stk-terrain/tilesets/world/tiles', | ||
requestVertexNormals : true | ||
}); | ||
|
||
// Circle geometry | ||
scene.primitives.add(new Cesium.GroundPrimitive({ | ||
geometryInstance: new Cesium.GeometryInstance({ | ||
geometry : new Cesium.CircleGeometry({ | ||
center : Cesium.Cartesian3.fromDegrees(-95.0, 45.0), | ||
radius : 250000.0 | ||
}), | ||
attributes : { | ||
color : Cesium.ColorGeometryInstanceAttribute.fromColor(new Cesium.Color(1.0, 0.0, 0.0, 0.5)) | ||
}, | ||
id : 'circle' | ||
}) | ||
})); | ||
|
||
// Ellipse Geometry | ||
scene.primitives.add(new Cesium.GroundPrimitive({ | ||
geometryInstance: new Cesium.GeometryInstance({ | ||
geometry : new Cesium.EllipseGeometry({ | ||
center : Cesium.Cartesian3.fromDegrees(-105.0, 40.0), | ||
semiMinorAxis : 300000.0, | ||
semiMajorAxis : 400000.0 | ||
}), | ||
attributes : { | ||
color : Cesium.ColorGeometryInstanceAttribute.fromColor(new Cesium.Color(0.0, 1.0, 1.0, 0.5)) | ||
}, | ||
id : 'ellipse' | ||
}) | ||
})); | ||
|
||
// Corridor Geometry | ||
scene.primitives.add(new Cesium.GroundPrimitive({ | ||
geometryInstance : new Cesium.GeometryInstance({ | ||
geometry: new Cesium.CorridorGeometry({ | ||
positions : Cesium.Cartesian3.fromDegreesArray([ | ||
-112.0, 40.0, | ||
-117.0, 40.0, | ||
-117.0, 35.0 | ||
]), | ||
width : 200000.0 | ||
}), | ||
attributes : { | ||
color : Cesium.ColorGeometryInstanceAttribute.fromColor(new Cesium.Color(0.0, 0.0, 1.0, 0.5)) | ||
}, | ||
id : 'corridor' | ||
}) | ||
})); | ||
|
||
// Rectangle geometry | ||
scene.primitives.add(new Cesium.GroundPrimitive({ | ||
geometryInstance : new Cesium.GeometryInstance({ | ||
geometry : new Cesium.RectangleGeometry({ | ||
rectangle : Cesium.Rectangle.fromDegrees(-100.0, 30.0, -90.0, 40.0), | ||
rotation : Cesium.Math.toRadians(45) | ||
}), | ||
attributes: { | ||
color: Cesium.ColorGeometryInstanceAttribute.fromColor(new Cesium.Color(0.0, 1.0, 0.0, 0.5)) | ||
}, | ||
id : 'rectangle' | ||
}) | ||
})); | ||
|
||
// Polygon on Mount Saint Helens | ||
var positions = [new Cesium.Cartesian3(-2358138.847340281, -3744072.459541374, 4581158.5714175375), | ||
new Cesium.Cartesian3(-2357231.4925370603, -3745103.7886602185, 4580702.9757762635), | ||
new Cesium.Cartesian3(-2355912.902205431, -3744249.029778454, 4582402.154378103), | ||
new Cesium.Cartesian3(-2357208.0209552636, -3743553.4420488174, 4581961.863286629)]; | ||
var polygonHierarchy = { positions : positions }; | ||
|
||
var primitive = scene.primitives.add(new Cesium.GroundPrimitive({ | ||
geometryInstance : new Cesium.GeometryInstance({ | ||
geometry : new Cesium.PolygonGeometry({ | ||
polygonHierarchy : polygonHierarchy | ||
}), | ||
attributes: { | ||
color: Cesium.ColorGeometryInstanceAttribute.fromColor(Cesium.Color.RED.withAlpha(0.5)) | ||
}, | ||
id : 'polygon 1' | ||
}) | ||
})); | ||
|
||
// Same polygon slightly offset and overlapping. | ||
positions = scene.globe.ellipsoid.cartesianArrayToCartographicArray(positions); | ||
var delta = Cesium.Math.toRadians(0.01); | ||
for (var i = 0; i < positions.length; ++i) { | ||
var position = positions[i]; | ||
position.latitude += delta; | ||
position.longitude += delta; | ||
} | ||
positions = scene.globe.ellipsoid.cartographicArrayToCartesianArray(positions); | ||
polygonHierarchy = { positions : positions }; | ||
|
||
scene.primitives.add(new Cesium.GroundPrimitive({ | ||
geometryInstance : new Cesium.GeometryInstance({ | ||
geometry : new Cesium.PolygonGeometry({ | ||
polygonHierarchy : polygonHierarchy | ||
}), | ||
attributes: { | ||
color: Cesium.ColorGeometryInstanceAttribute.fromColor(Cesium.Color.BLUE.withAlpha(0.5)) | ||
}, | ||
id : 'polygon 2' | ||
}) | ||
})); | ||
|
||
Sandcastle.addToolbarButton('View Mount Saint Helens', function() { | ||
viewer.camera.lookAt(new Cesium.Cartesian3(-2354331.3069306486, -3742016.2427205616, 4581875.591571755), new Cesium.HeadingPitchRange(Cesium.Math.toRadians(20.0), Cesium.Math.toRadians(-35.0), 10000.0)); | ||
viewer.camera.lookAtTransform(Cesium.Matrix4.IDENTITY); | ||
}); | ||
|
||
var currentObject = undefined; | ||
var lastColor = undefined; | ||
|
||
var handler = new Cesium.ScreenSpaceEventHandler(scene.canvas); | ||
handler.setInputAction(function(movement) { | ||
var pickedObject = scene.pick(movement.endPosition); | ||
if (Cesium.defined(pickedObject) && pickedObject !== currentObject) { | ||
if (Cesium.defined(currentObject)) { | ||
currentObject.primitive.getGeometryInstanceAttributes(currentObject.id).color = lastColor; | ||
} | ||
|
||
currentObject = pickedObject; | ||
|
||
var attributes = currentObject.primitive.getGeometryInstanceAttributes(currentObject.id); | ||
lastColor = attributes.color; | ||
attributes.color = [255, 255, 0, 128]; | ||
} else if (!Cesium.defined(pickedObject) && Cesium.defined(currentObject)) { | ||
currentObject.primitive.getGeometryInstanceAttributes(currentObject.id).color = lastColor; | ||
currentObject = undefined; | ||
} | ||
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE); | ||
|
||
//Sandcastle_End | ||
Sandcastle.finishedLoading(); | ||
} | ||
if (typeof Cesium !== "undefined") { | ||
startup(Cesium); | ||
} else if (typeof require === "function") { | ||
require(["Cesium"], startup); | ||
} | ||
</script> | ||
</body> | ||
</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
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
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.
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.
Add these new functions to CHANGES.md.