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 16 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
257 changes: 257 additions & 0 deletions Apps/Sandcastle/gallery/development/Many Clipping Planes.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,257 @@
<!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>
</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,
skyAtmosphere: false,
shouldAnimate : true
});

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

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

var cylinderRadius = -20.0;
var radiusMultiplier = 1.0;

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

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();
}
);

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

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

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

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

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);
clippingPlanes.push(new Cesium.Plane(dir, cylinderRadius));
}
modelEntityClippingPlanes = new Cesium.ClippingPlaneCollection({
modelMatrix : Cesium.defined(modelMatrix) ? modelMatrix : Cesium.Matrix4.IDENTITY,
planes : clippingPlanes,
edgeWidth: 2.0,
edgeColor: Cesium.Color.WHITE,
unionClippingRegions : clippingModeUnion
});
}

function updateClippingPlanes() {
return modelEntityClippingPlanes;
}

var modelUrl = '../../SampleData/models/CesiumAir/Cesium_Air.glb';
var agiHqUrl = Cesium.CesiumIon.createResource(1458, { accessToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiIxYmJiNTAxOC1lOTg5LTQzN2EtODg1OC0zMWJjM2IxNGNlYmMiLCJpZCI6NDQsImFzc2V0cyI6WzE0NThdLCJpYXQiOjE0OTkyNjM4MjB9.1WKijRa-ILkmG6utrhDWX6rDgasjD7dZv-G5ZyCmkKg' });
var instancedUrl = Cesium.CesiumIon.createResource(3876, { accessToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJjYjNlMTg5Zi1hMzc2LTRmZjktOGEwZC00NGEzNTM0MTAzZGUiLCJpZCI6MjU5LCJpYXQiOjE1MTgxOTE2NTV9.qaP8-_Ej6AihGnv5iB990Hm6lHr8F_rrC3_EPxdT6MQ' });
var pointCloudUrl = Cesium.CesiumIon.createResource(3742, { accessToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiIxOGZjMjlhZC03MDE1LTQ3ZTAtODEyNy05YTU3M2MwYzQ0YmEiLCJpZCI6NDQsImFzc2V0cyI6WzM3NDJdLCJpYXQiOjE1MTcyNDI3NDJ9.TJAJctFXC1UyFMpxkA3cyKVAmnh72cLtfY1yKbaQsyk' });

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() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Update code style here too.

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);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Usually in Cesium code we condense this to:

        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
}

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

//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 @@ -3,6 +3,9 @@ Change Log

### 1.43 - 2018-03-01

##### Deprecated :hourglass_flowing_sand:
* `ClippingPlaneCollection` is now supported in Internet Explorer, so `ClippingPlaneCollection.isSupported` always returns `true`. [#6201](https://github.com/AnalyticalGraphicsInc/cesium/pull/6201)
Copy link
Contributor

Choose a reason for hiding this comment

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

Mention that the deprecated function will be removed in 1.43.


##### Additions :tada:
* Added support for a promise to a resource for `CesiumTerrainProvider`, `createTileMapServiceImageryProvider` and `Cesium3DTileset` [#6204](https://github.com/AnalyticalGraphicsInc/cesium/pull/6204)

Expand All @@ -14,6 +17,9 @@ Change Log
##### Additions :tada:
* Enable terrain in the `CesiumViewer` demo application [#6198](https://github.com/AnalyticalGraphicsInc/cesium/pull/6198)

##### Additions :tada:
* Increased maximum number of clipping planes from 6 to 2048, added support for Internet Explorer. [#6201](https://github.com/AnalyticalGraphicsInc/cesium/pull/6201)

### 1.42.1 - 2018-02-01
_This is an npm-only release to fix an issue with using Cesium in Node.js.__
* Fixed a bug where Cesium would fail to load under Node.js. [#6177](https://github.com/AnalyticalGraphicsInc/cesium/pull/6177)
Expand Down
Loading