-
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
Increase max clipping planes using textures #6201
Changes from 33 commits
0317622
44a2662
3f40dc2
4b7b0ea
15e3a1e
a0a9706
a5e6ff4
a42261a
5d3165e
e2fb890
cf1b6da
f7d078e
8ba4a65
d484bb3
c917871
b61f98f
c699d4b
2ccd989
fb69f6a
f5512d1
c0a71de
e19299a
ff3f4a5
ea2d45a
5d953b5
2ec99dc
828a9d1
fdca291
f9293e4
e20d1ec
c3c10f0
bc8b313
983585e
a05c225
4e705de
5185523
0f04e46
31c548b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,285 @@ | ||
<!DOCTYPE html> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Much appreciated though! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure about this being in |
||
<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) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here and below, avoid hardcoding values. There are |
||
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> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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/). | ||
|
@@ -37,6 +39,10 @@ Change Log | |
* Enable terrain in the `CesiumViewer` demo application [#6198](https://github.com/AnalyticalGraphicsInc/cesium/pull/6198) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
|
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.
For consistency
Many Clipping Planes.jpg
should be 225x150.