-
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 16 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,257 @@ | ||
<!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> | ||
</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) { | ||
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); | ||
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() { | ||
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. 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); | ||
}); | ||
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. Usually in Cesium code we condense this to:
|
||
} 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> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) | ||
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. 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) | ||
|
||
|
@@ -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) | ||
|
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.