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

Clamp to 3D Tiles most detailed #7115

Merged
merged 44 commits into from
Nov 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
eb4b83d
Move common code into Cesium3DTile
lilleyse Sep 18, 2018
75d297c
Pass statistics around in preparation for offscreen statistics
lilleyse Sep 19, 2018
96143eb
Merge branch 'pick-ray-2' into offscreen-picking
lilleyse Sep 21, 2018
5392ed7
Merge branch 'master' into offscreen-picking
lilleyse Oct 1, 2018
c389629
Offscreen picking
lilleyse Oct 1, 2018
8b88951
Added Sandcastle demo
lilleyse Oct 3, 2018
8273d8e
Cleaned up Ray.clone
lilleyse Oct 5, 2018
eaa858b
Update frame number and time in main render loop so changes are refle…
lilleyse Oct 5, 2018
93061df
Fix #7120 by picking through primitives that don't write depth for sa…
lilleyse Oct 15, 2018
336bf3a
Merge branch 'master' into offscreen-picking
lilleyse Oct 15, 2018
b950f17
Merge branch 'master' into offscreen-picking
lilleyse Oct 15, 2018
af109b2
Added #7120 to CHANGES
lilleyse Oct 15, 2018
320bf99
Modify arrays in place
lilleyse Oct 15, 2018
751b138
Rename demo
lilleyse Oct 16, 2018
003baa5
Merge branch 'master' into offscreen-picking
lilleyse Oct 16, 2018
b605450
Fix tests
lilleyse Oct 16, 2018
bdd2d78
Added pick tests
lilleyse Oct 18, 2018
67d2a86
Remove updateAsync and use normal update
lilleyse Oct 19, 2018
26a1a66
Fix tests
lilleyse Oct 19, 2018
a75ddf3
Merge branch 'master' into offscreen-picking
lilleyse Oct 19, 2018
db53e33
Minor Scene edits
lilleyse Oct 19, 2018
a8710ff
Undo statistics changes in Cesium3DTileset
lilleyse Oct 19, 2018
ebd65d9
Cleanup and fixes from #7115
lilleyse Oct 19, 2018
955b098
Merge branch 'offscreen-picking-prep' into offscreen-picking
lilleyse Oct 19, 2018
9e89108
Renamed Cesium3DTilesetOffscreenTraversal to Cesium3DTilesetAsyncTrav…
lilleyse Oct 19, 2018
0a805d5
eslint fix
lilleyse Oct 19, 2018
8d1159c
Merge branch 'offscreen-picking-prep' into offscreen-picking
lilleyse Oct 19, 2018
504988a
Merge branch 'offscreen-picking-prep' into offscreen-picking
lilleyse Oct 19, 2018
ab58195
Remove unused include
lilleyse Oct 19, 2018
12e92b5
Ignore async commands in different place
lilleyse Oct 22, 2018
a406d3a
Fix WebGL stub tests
lilleyse Oct 22, 2018
66e626c
Added tileset tests
lilleyse Nov 5, 2018
a5078f5
Added updateAsync function to Cesium3DTileset
lilleyse Nov 5, 2018
470bd0f
Add terrain to Sandcastle demo
lilleyse Nov 5, 2018
d0c16e3
Remove minimumGeometricError
lilleyse Nov 5, 2018
e457213
Formatting
lilleyse Nov 5, 2018
9a2e7eb
Renamed asyncLoaders to asyncRayPicks
lilleyse Nov 5, 2018
3d64294
Scene updates
lilleyse Nov 5, 2018
ac9a986
Merge branch 'master' into offscreen-picking
lilleyse Nov 5, 2018
b5cafd7
Add to doc
lilleyse Nov 5, 2018
3876766
Merge conflict fix
lilleyse Nov 6, 2018
f461329
Merge branch 'master' into offscreen-picking
lilleyse Nov 7, 2018
d115e17
Updated CHANGES.md
lilleyse Nov 7, 2018
9956a08
Merge branch 'master' into offscreen-picking
lilleyse Nov 7, 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
106 changes: 106 additions & 0 deletions Apps/Sandcastle/gallery/Sample Height from 3D Tiles.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
<!DOCTYPE html>
<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="Sample the most detailed heights of a 3D Tileset.">
<meta name="cesium-sandcastle-labels" content="Showcases, 3D Tiles">
<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"></div>
<script id="cesium_sandcastle_script">
function startup(Cesium) {
'use strict';
//Sandcastle_Begin
var viewer = new Cesium.Viewer('cesiumContainer', {
terrainProvider : Cesium.createWorldTerrain()
});
var scene = viewer.scene;

var tileset = scene.primitives.add(
new Cesium.Cesium3DTileset({
url: Cesium.IonResource.fromAssetId(6074)
})
);

scene.camera.setView({
destination: new Cesium.Cartesian3(1216411.0748779264, -4736313.10747583, 4081359.5125561724),
orientation: new Cesium.HeadingPitchRoll(4.239925103568368, -0.4911293834802475, 6.279849292088564),
endTransform : Cesium.Matrix4.IDENTITY
});

Sandcastle.addToolbarButton('Sample heights', function() {
sampleHeights();
});

function sampleHeights() {
if (!scene.clampToHeightSupported) {
console.log('This browser does not support clampToHeightMostDetailed.');
}

viewer.entities.removeAll();

var cartesian1 = new Cesium.Cartesian3(1216390.063324395, -4736314.814479433, 4081341.9787972216);
var cartesian2 = new Cesium.Cartesian3(1216329.5413318684, -4736272.029009798, 4081407.9342479417);

var count = 30;
var cartesians = new Array(count);
for (var i = 0; i < count; ++i) {
var offset = i / (count - 1);
cartesians[i] = Cesium.Cartesian3.lerp(cartesian1, cartesian2, offset, new Cesium.Cartesian3());
}

scene.clampToHeightMostDetailed(cartesians).then(function(clampedCartesians) {
for (var i = 0; i < count; ++i) {
viewer.entities.add({
position: clampedCartesians[i],
ellipsoid : {
radii : new Cesium.Cartesian3(0.2, 0.2, 0.2),
material : Cesium.Color.RED
}
});
}

viewer.entities.add({
polyline : {
positions : clampedCartesians,
followSurface : false,
width : 2,
material : new Cesium.PolylineOutlineMaterialProperty({
color : Cesium.Color.YELLOW
}),
depthFailMaterial : new Cesium.PolylineOutlineMaterialProperty({
color : Cesium.Color.YELLOW
})
}
});
});
}
//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.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ Change Log
### 1.52 - 2018-12-03

##### Additions :tada:
* Added functions to get the most detailed height of 3D Tiles on-screen or off-screen. [#7115](https://github.com/AnalyticalGraphicsInc/cesium/pull/7115)
* Added `Scene.sampleHeightMostDetailed`, an asynchronous version of `Scene.sampleHeight` that uses the maximum level of detail for 3D Tiles.
* Added `Scene.clampToHeightMostDetailed`, an asynchronous version of `Scene.clampToHeight` that uses the maximum level of detail for 3D Tiles.
* Added `Scene.invertClassificationSupported` for checking if invert classification is supported.
* Added `computeLineSegmentLineSegmentIntersection` to `Intersections2D`. [#7228](https://github.com/AnalyticalGraphicsInc/Cesium/pull/7228)

Expand Down
78 changes: 52 additions & 26 deletions Source/Scene/Cesium3DTileset.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ define([
'./Cesium3DTileContentState',
'./Cesium3DTileOptimizations',
'./Cesium3DTileRefine',
'./Cesium3DTilesetAsyncTraversal',
'./Cesium3DTilesetCache',
'./Cesium3DTilesetStatistics',
'./Cesium3DTilesetTraversal',
Expand Down Expand Up @@ -73,6 +74,7 @@ define([
Cesium3DTileContentState,
Cesium3DTileOptimizations,
Cesium3DTileRefine,
Cesium3DTilesetAsyncTraversal,
Cesium3DTilesetCache,
Cesium3DTilesetStatistics,
Cesium3DTilesetTraversal,
Expand Down Expand Up @@ -204,6 +206,7 @@ define([
this._statistics = new Cesium3DTilesetStatistics();
this._statisticsLastRender = new Cesium3DTilesetStatistics();
this._statisticsLastPick = new Cesium3DTilesetStatistics();
this._statisticsLastAsync = new Cesium3DTilesetStatistics();

this._tilesLoaded = false;
this._initialTilesLoaded = false;
Expand Down Expand Up @@ -1707,9 +1710,9 @@ define([
function updateTiles(tileset, frameState) {
tileset._styleEngine.applyStyle(tileset, frameState);

var statistics = tileset._statistics;
var passes = frameState.passes;
var isRender = passes.render;
var statistics = tileset._statistics;
var commandList = frameState.commandList;
var numberOfInitialCommands = commandList.length;
var selectedTiles = tileset._selectedTiles;
Expand Down Expand Up @@ -1899,69 +1902,76 @@ define([

///////////////////////////////////////////////////////////////////////////

/**
* @private
*/
Cesium3DTileset.prototype.update = function(frameState) {
function update(tileset, frameState) {
if (frameState.mode === SceneMode.MORPHING) {
return;
return false;
}

if (!this.show || !this.ready) {
return;
if (!tileset.show || !tileset.ready) {
return false;
}

if (!defined(this._loadTimestamp)) {
this._loadTimestamp = JulianDate.clone(frameState.time);
if (!defined(tileset._loadTimestamp)) {
tileset._loadTimestamp = JulianDate.clone(frameState.time);
}

// Update clipping planes
var clippingPlanes = this._clippingPlanes;
this._clippingPlanesOriginMatrixDirty = true;
var clippingPlanes = tileset._clippingPlanes;
tileset._clippingPlanesOriginMatrixDirty = true;
if (defined(clippingPlanes) && clippingPlanes.enabled) {
clippingPlanes.update(frameState);
}

this._timeSinceLoad = Math.max(JulianDate.secondsDifference(frameState.time, this._loadTimestamp) * 1000, 0.0);
tileset._timeSinceLoad = Math.max(JulianDate.secondsDifference(frameState.time, tileset._loadTimestamp) * 1000, 0.0);

this._skipLevelOfDetail = this.skipLevelOfDetail && !defined(this._classificationType) && !this._disableSkipLevelOfDetail && !this._allTilesAdditive;
tileset._skipLevelOfDetail = tileset.skipLevelOfDetail && !defined(tileset._classificationType) && !tileset._disableSkipLevelOfDetail && !tileset._allTilesAdditive;

// Do out-of-core operations (new content requests, cache removal,
// process new tiles) only during the render pass.
var passes = frameState.passes;
var isRender = passes.render;
var isPick = passes.pick;
var isAsync = passes.async;

var statistics = this._statistics;
var statistics = tileset._statistics;
statistics.clear();

if (this.dynamicScreenSpaceError) {
updateDynamicScreenSpaceError(this, frameState);
if (tileset.dynamicScreenSpaceError) {
updateDynamicScreenSpaceError(tileset, frameState);
}

if (isRender) {
this._cache.reset();
tileset._cache.reset();
}

var ready;

if (isAsync) {
ready = Cesium3DTilesetAsyncTraversal.selectTiles(tileset, frameState);
} else {
ready = Cesium3DTilesetTraversal.selectTiles(tileset, frameState);
}

Cesium3DTilesetTraversal.selectTiles(this, frameState);
if (isRender || isAsync) {
requestTiles(tileset);
}

if (isRender) {
requestTiles(this);
processTiles(this, frameState);
processTiles(tileset, frameState);
}

updateTiles(this, frameState);
updateTiles(tileset, frameState);

if (isRender) {
unloadTiles(this);
unloadTiles(tileset);

// Events are raised (added to the afterRender queue) here since promises
// may resolve outside of the update loop that then raise events, e.g.,
// model's readyPromise.
raiseLoadProgressEvent(this, frameState);
raiseLoadProgressEvent(tileset, frameState);

if (statistics.selected !== 0) {
var credits = this._credits;
var credits = tileset._credits;
if (defined(credits)) {
var length = credits.length;
for (var i = 0; i < length; i++) {
Expand All @@ -1972,8 +1982,24 @@ define([
}

// Update last statistics
var statisticsLast = isPick ? this._statisticsLastPick : this._statisticsLastRender;
var statisticsLast = isAsync ? tileset._statisticsLastAsync : (isPick ? tileset._statisticsLastPick : tileset._statisticsLastRender);
Cesium3DTilesetStatistics.clone(statistics, statisticsLast);

return ready;
}

/**
* @private
*/
Cesium3DTileset.prototype.update = function(frameState) {
update(this, frameState);
};

/**
* @private
*/
Cesium3DTileset.prototype.updateAsync = function(frameState) {
return update(this, frameState);
};

/**
Expand Down
Loading