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

Increase max clipping planes using textures #6201

Merged
merged 38 commits into from
Mar 9, 2018
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
0317622
proof-of-concept oct32 normals and in-shader transform for clipping p…
likangning93 Jan 30, 2018
44a2662
proof-of-concept for sharing ClippingPlaneCollections over b3dm tiles…
likangning93 Feb 1, 2018
3f40dc2
working with i3dm and pts
likangning93 Feb 7, 2018
4b7b0ea
merged in master
likangning93 Feb 7, 2018
15e3a1e
add attenuation to demo
likangning93 Feb 7, 2018
a0a9706
clipping planes working with globe
likangning93 Feb 7, 2018
a5e6ff4
fix problem with globe rendering before clipping planes are updated
likangning93 Feb 7, 2018
a42261a
packed new clipping plane params to fewer uniforms
likangning93 Feb 8, 2018
5d3165e
updated tests, fixed a bug with changing union mode for clippingPlane…
likangning93 Feb 9, 2018
e2fb890
add gallery image and update changes
likangning93 Feb 9, 2018
cf1b6da
move many clipping planes sandcastle to development
likangning93 Feb 9, 2018
f7d078e
fix issue with clipped models still getting picked
likangning93 Feb 14, 2018
8ba4a65
added support for IE/Edge by fixing a bug in windowToEyeCoordinates.glsl
likangning93 Feb 14, 2018
d484bb3
Merge branch 'master' into clippingPlanesByTexture
likangning93 Feb 14, 2018
c917871
Shader style
lilleyse Feb 14, 2018
b61f98f
PR feedback
likangning93 Feb 15, 2018
c699d4b
merged master into clippingPlanesByTexture
likangning93 Feb 15, 2018
2ccd989
added float texture version of clipping planes by texture
likangning93 Feb 16, 2018
fb69f6a
PR comments
likangning93 Feb 16, 2018
f5512d1
consolidate uniforms for clipping planes
likangning93 Feb 16, 2018
c0a71de
PR comments
likangning93 Feb 16, 2018
e19299a
added ClippingPlane class and streamlined ClippingPlaneCollection upd…
likangning93 Feb 19, 2018
ff3f4a5
wrap normal for ClippingPlane to detect member-of-member changes
likangning93 Feb 20, 2018
ea2d45a
pointcloud and globe now rebuild shaders to match clipping plane count
likangning93 Feb 21, 2018
5d953b5
Model and associated tile content now regenerate shaders for clipping…
likangning93 Feb 23, 2018
2ec99dc
clipping plane textures resize as needed
likangning93 Feb 26, 2018
828a9d1
merged in master
likangning93 Feb 26, 2018
fdca291
retain copies of quantized vertex shaders
likangning93 Feb 26, 2018
f9293e4
bypass float texture size test when not supported
likangning93 Feb 26, 2018
e20d1ec
change float packing to do what BatchTable does
likangning93 Mar 1, 2018
c3c10f0
PR comments
likangning93 Mar 7, 2018
bc8b313
propagate clippingPlanesDirty flag through composite tiles
likangning93 Mar 7, 2018
983585e
merged in master
likangning93 Mar 8, 2018
a05c225
PR feedback
likangning93 Mar 8, 2018
4e705de
Style tweak
lilleyse Mar 9, 2018
5185523
fixed clipping plane edge styling in orthographic
likangning93 Mar 9, 2018
0f04e46
merged in master
likangning93 Mar 9, 2018
31c548b
update CHANGES.md
likangning93 Mar 9, 2018
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
7 changes: 3 additions & 4 deletions Apps/Sandcastle/gallery/3D Tiles Clipping Planes.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@

// Add a clipping plane, a plane geometry to show the representation of the
// plane, and control the magnitude of the plane distance with the mouse.
// Clipping planes are not currently supported in Internet Explorer.

var viewer = new Cesium.Viewer('cesiumContainer', {
infoBox: false,
Expand Down Expand Up @@ -103,7 +102,7 @@
}
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);

var scratchPlane = new Cesium.Plane(Cesium.Cartesian3.UNIT_X, 0.0);
var scratchPlane = new Cesium.ClippingPlane(Cesium.Cartesian3.UNIT_X, 0.0);
function createPlaneUpdateFunction(plane, transform) {
return function () {
plane.distance = targetY;
Expand All @@ -114,7 +113,7 @@
var tileset;
function loadTileset(url) {
var clippingPlanes = [
new Cesium.Plane(new Cesium.Cartesian3(0.0, 0.0, -1.0), -100.0)
new Cesium.ClippingPlane(new Cesium.Cartesian3(0.0, 0.0, -1.0), -100.0)
];

tileset = viewer.scene.primitives.add(new Cesium.Cesium3DTileset({
Expand Down Expand Up @@ -156,7 +155,7 @@
var modelEntityClippingPlanes;
function loadModel(url) {
var clippingPlanes = [
new Cesium.Plane(new Cesium.Cartesian3(0.0, 0.0, -1.0), -100.0)
new Cesium.ClippingPlane(new Cesium.Cartesian3(0.0, 0.0, -1.0), -100.0)
];

modelEntityClippingPlanes = new Cesium.ClippingPlaneCollection({
Expand Down
9 changes: 4 additions & 5 deletions Apps/Sandcastle/gallery/Terrain Clipping Planes.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
'use strict';
//Sandcastle_Begin
// Use clipping planes to selectively hide parts of the globe surface.
// Clipping planes are not currently supported in Internet Explorer.

var viewer = new Cesium.Viewer('cesiumContainer', {
skyAtmosphere: false,
Expand Down Expand Up @@ -74,10 +73,10 @@
globe.clippingPlanes = new Cesium.ClippingPlaneCollection({
modelMatrix : entity.computeModelMatrix(Cesium.JulianDate.now()),
planes : [
new Cesium.Plane(new Cesium.Cartesian3( 1.0, 0.0, 0.0), -700.0),
new Cesium.Plane(new Cesium.Cartesian3(-1.0, 0.0, 0.0), -700.0),
new Cesium.Plane(new Cesium.Cartesian3( 0.0, 1.0, 0.0), -700.0),
new Cesium.Plane(new Cesium.Cartesian3( 0.0, -1.0, 0.0), -700.0)
new Cesium.ClippingPlane(new Cesium.Cartesian3( 1.0, 0.0, 0.0), -700.0),
new Cesium.ClippingPlane(new Cesium.Cartesian3(-1.0, 0.0, 0.0), -700.0),
new Cesium.ClippingPlane(new Cesium.Cartesian3( 0.0, 1.0, 0.0), -700.0),
new Cesium.ClippingPlane(new Cesium.Cartesian3( 0.0, -1.0, 0.0), -700.0)
],
edgeWidth: 1.0,
edgeColor: Cesium.Color.WHITE
Expand Down
285 changes: 285 additions & 0 deletions Apps/Sandcastle/gallery/development/Many Clipping Planes.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,285 @@
<!DOCTYPE html>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency Many Clipping Planes.jpg should be 225x150.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like this demo and feel like it could be incorporated into the main clipping planes demo. If that's annoying to do it could be a standalone demo in the main folder.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mramato recommended moving it to Development since it's more for debugging and performance testing than demonstrating the feature. @pjcozzi also mentioned at one point that we might do actual clipping cylinders, at which point this demo kind of becomes a "wrong" way to achieve the effect.

I really like this demo

Much appreciated though!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about this being in development; I just spent awhile looking for it. At the least, there should be a simple example showing using a lot of clipping planes.

<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="Use Viewer to start building new applications or easily embed Cesium into existing applications.">
<meta name="cesium-sandcastle-labels" content="Beginner, 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">
if(typeof require === "function") {
require.config({
baseUrl : '../../../Source',
waitSeconds : 120
});
}
</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>Distance</td>
<td>
<input type="range" min="-100.0" max="100.0" step="1.0" data-bind="value: cylinderRadius, valueUpdate: 'input'">
<input type="text" size="5" data-bind="value: cylinderRadius">
</td>
<td>Plane Count</td>
<td>
<input type="range" min="1" max="128" step="1" data-bind="value: planeCount, valueUpdate: 'input'">
<input type="text" size="5" data-bind="value: planeCount">
</td>
</tr>
</tbody></table>
<select data-bind="options: exampleTypes, value: currentExampleType"></select>
</div>
<script id="cesium_sandcastle_script">
function startup(Cesium) {
'use strict';
//Sandcastle_Begin
var viewer = new Cesium.Viewer('cesiumContainer', {
infoBox: false,
selectionIndicator: false,
shouldAnimate : true
});

viewer.terrainProvider = new Cesium.CesiumTerrainProvider({
url : 'https://assets.agi.com/stk-terrain/v1/tilesets/world/tiles',
requestWaterMask : true,
requestVertexNormals : true
});
viewer.extend(Cesium.viewerCesium3DTilesInspectorMixin);

var globe = viewer.scene.globe;
globe.depthTestAgainstTerrain = true;

var cylinderRadius = -20.0;
var radiusMultiplier = 1.0;

var steps = 32;
var clippingPlanes = [];
var modelEntityClippingPlanes;
var clippingModeUnion = false;
var enabled = true;

var clipObjects = ['model', 'b3dm', 'pnts', 'i3dm', 'terrain'];
var viewModel = {
cylinderRadius : cylinderRadius,
exampleTypes : clipObjects,
currentExampleType : clipObjects[0],
planeCount : steps
};

Cesium.knockout.track(viewModel);

var toolbar = document.getElementById('toolbar');
Cesium.knockout.applyBindings(viewModel, toolbar);

Cesium.knockout.getObservable(viewModel, 'cylinderRadius').subscribe(
function(newValue) {
cylinderRadius = parseFloat(viewModel.cylinderRadius);
updatePlanes();
}
);

Cesium.knockout.getObservable(viewModel, 'planeCount').subscribe(
function(newValue) {
var newSteps = parseFloat(viewModel.planeCount);
if (newSteps !== steps) {
steps = newSteps;
modelEntityClippingPlanes.removeAll();
computePlanes();
}
}
);

var scene = viewer.scene;
var planeEntities = [];
var selectedPlane;

function updatePlanes() {
for (var i = 0; i < clippingPlanes.length; i++) {
var plane = clippingPlanes[i];
plane.distance = cylinderRadius * radiusMultiplier;
}
}

function computePlanes() {
var stepDegrees = 6.28319 / steps;
clippingPlanes = [];

for (var i = 0; i < steps; i++) {
var angle = i * stepDegrees;
var dir = new Cesium.Cartesian3();
dir.x = 1.0;
dir.y = Math.tan(angle);
if (angle > 1.57079632679) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here and below, avoid hardcoding values. There are PI constants here: https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Source/Core/Math.js#L321

dir.x = -1.0;
dir.y *= -1.0;
}
if (angle > 3.14159265359) {
dir.x = -1.0;
dir.y = dir.y;
}
if (angle > 4.71238898038) {
dir.x = 1.0;
dir.y = -dir.y;
}
Cesium.Cartesian3.normalize(dir, dir);
var newPlane = new Cesium.ClippingPlane(dir, cylinderRadius * radiusMultiplier);
modelEntityClippingPlanes.add(newPlane);
clippingPlanes.push(newPlane);
}
}

function createClippingPlanes(modelMatrix) {
modelEntityClippingPlanes = new Cesium.ClippingPlaneCollection({
modelMatrix : Cesium.defined(modelMatrix) ? modelMatrix : Cesium.Matrix4.IDENTITY,
edgeWidth: 2.0,
edgeColor: Cesium.Color.WHITE,
unionClippingRegions : clippingModeUnion,
enabled : enabled
});
computePlanes();
}

function updateClippingPlanes() {
return modelEntityClippingPlanes;
}

var modelUrl = '../../SampleData/models/CesiumAir/Cesium_Air.glb';
var agiHqUrl = Cesium.IonResource.fromAssetId(3836);
var instancedUrl = Cesium.IonResource.fromAssetId(3876);
var pointCloudUrl = Cesium.IonResource.fromAssetId(3844);

function loadModel(url) {
createClippingPlanes();
var position = Cesium.Cartesian3.fromDegrees(-123.0744619, 44.0503706, 300.0);
var heading = 0.0;
var pitch = 0.0;
var roll = 0.0;
var hpr = new Cesium.HeadingPitchRoll(heading, pitch, roll);
var orientation = Cesium.Transforms.headingPitchRollQuaternion(position, hpr);
var entity = viewer.entities.add({
name : url,
position : position,
orientation : orientation,
model : {
uri : url,
scale : 20,
minimumPixelSize : 100.0,
clippingPlanes : new Cesium.CallbackProperty(updateClippingPlanes, false)
}
});
viewer.trackedEntity = entity;
}

var tileset;
function loadTileset(url) {
createClippingPlanes();
tileset = viewer.scene.primitives.add(new Cesium.Cesium3DTileset({
url : url,
clippingPlanes : modelEntityClippingPlanes
}));

return tileset.readyPromise.then(function() {
var boundingSphere = tileset.boundingSphere;

var cartographic = Cesium.Cartographic.fromCartesian(boundingSphere.center);
var surface = Cesium.Cartesian3.fromRadians(cartographic.longitude, cartographic.latitude, 0.0);
var offset = Cesium.Cartesian3.fromRadians(cartographic.longitude, cartographic.latitude, 100.0);
var translation = Cesium.Cartesian3.subtract(offset, surface, new Cesium.Cartesian3());
tileset.modelMatrix = Cesium.Matrix4.fromTranslation(translation);

var radius = boundingSphere.radius;
viewer.camera.viewBoundingSphere(boundingSphere, new Cesium.HeadingPitchRange(0.5, -0.2, radius * 4.0));
viewer.camera.lookAtTransform(Cesium.Matrix4.IDENTITY);
}).otherwise(function(error) {
throw(error);
});
}

loadModel(modelUrl);

Cesium.knockout.getObservable(viewModel, 'currentExampleType').subscribe(function(newValue) {
reset();

if (newValue === clipObjects[0]) {
// Model
loadModel(modelUrl);
} else if (newValue === clipObjects[1]) {
// B3dm photogrammetry
agiHqUrl.then(function(resource) {
return loadTileset(resource);
});
} else if (newValue === clipObjects[2]) {
// Point clouds
radiusMultiplier = 20.0;
pointCloudUrl.then(function(resource) {
return loadTileset(resource);
}).then(function() {
tileset.pointCloudShading.attenuation = true;
});
} else if (newValue === clipObjects[3]) {
// i3dm
instancedUrl.then(function(resource) {
return loadTileset(resource);
}).then(function() {
tileset.clippingPlanes.modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(tileset.boundingSphere.center);
});
} else if (newValue === clipObjects[4]) {
// Terrain
var position = Cesium.Cartesian3.fromRadians(-2.0872979473351286, 0.6596620013036164, 2380.0);
var entity = viewer.entities.add({
position : position,
model : {
uri : '../../SampleData/models/CesiumMan/Cesium_Man.glb',
minimumPixelSize : 128,
scale : 40
}
});
viewer.trackedEntity = entity;
createClippingPlanes(entity.computeModelMatrix(Cesium.JulianDate.now()));
globe.clippingPlanes = modelEntityClippingPlanes;
}
updatePlanes();
});

function reset() {
radiusMultiplier = 1.0;
viewModel.cylinderRadius = cylinderRadius;
viewer.entities.removeAll();
viewer.scene.primitives.removeAll();
globe.clippingPlanes = undefined; // destroy Globe clipping planes, if any
modelEntityClippingPlanes = undefined;
}

Sandcastle.addToggleButton('union', clippingModeUnion, function(checked) {
clippingModeUnion = checked;
modelEntityClippingPlanes.unionClippingRegions = clippingModeUnion;
});

Sandcastle.addToggleButton('enabled', enabled, function(checked) {
enabled = checked;
modelEntityClippingPlanes.enabled = enabled;
});

//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.
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ Change Log
##### Deprecated :hourglass_flowing_sand:
* The STK World Terrain, ArcticDEM, and PAMAP Terrain tilesets hosted on `assets.agi.com` are deprecated and will be available until September 1, 2018. To continue using them, access them via [Cesium ion](https://cesium.com/blog/2018/03/01/hello-cesium-ion/)
* In the `Resource` class, `addQueryParameters` and `addTemplateValues` have been deprecated and will be removed in Cesium 1.45. Please use `setQueryParameters` and `setTemplateValues` instead.
* `ClippingPlaneCollection` is now supported in Internet Explorer, so `ClippingPlaneCollection.isSupported` has been deprecated and will be removed in Cesium 1.45.
* `ClippingPlaneCollection` should now be used with `ClippingPlane` objects instead of `Plane`. Use of `Plane` objects has been deprecated and will be removed in Cesium 1.47.

##### Additions :tada:
* Added new `Ion`, `IonResource`, and `IonImageryProvider` objects for loading data hosted on [Cesium ion](https://cesium.com/blog/2018/03/01/hello-cesium-ion/).
Expand All @@ -37,6 +39,10 @@ Change Log
* Enable terrain in the `CesiumViewer` demo application [#6198](https://github.com/AnalyticalGraphicsInc/cesium/pull/6198)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this was added accidentally.

* Added `Globe.tilesLoaded` getter property to determine if all terrain and imagery is loaded. [#6194](https://github.com/AnalyticalGraphicsInc/cesium/pull/6194)
* Added `classificationType` property to entities which specifies whether an entity on the ground, like a polygon or rectangle, should be clamped to terrain, 3D Tiles, or both. [#6195](https://github.com/AnalyticalGraphicsInc/cesium/issues/6195)
* `ClippingPlaneCollection` updates [#6201](https://github.com/AnalyticalGraphicsInc/cesium/pull/6201)
* Removed the 6-clipping-plane limit.
* Added support for Internet Explorer.
* Added a `ClippingPlane` object to be used with `ClippingPlaneCollection`.

##### Fixes :wrench:
* Fixed bug where KmlDataSource did not use Ellipsoid to convert coordinates. Use `options.ellipsoid` to pass the ellipsoid to KmlDataSource constructors / loaders. [#6176](https://github.com/AnalyticalGraphicsInc/cesium/pull/6176)
Expand Down
Loading