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

Fix 3D Tiles depth picking #5770

Merged
merged 12 commits into from
Aug 29, 2017
94 changes: 94 additions & 0 deletions Apps/Sandcastle/gallery/Classification Types.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<!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="Draw the intersection of a volume and a photgrammetry dataset and terrain.">
<meta name="cesium-sandcastle-labels" content="Tutorials, 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">
require.config({
baseUrl : '../../../Source',
waitSeconds : 60
});
</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');

var tileset = viewer.scene.primitives.add(new Cesium.Cesium3DTileset({
url : 'https://beta.cesium.com/api/assets/1458?access_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiIxYmJiNTAxOC1lOTg5LTQzN2EtODg1OC0zMWJjM2IxNGNlYmMiLCJpZCI6NDQsImFzc2V0cyI6WzE0NThdLCJpYXQiOjE0OTkyNjM4MjB9.1WKijRa-ILkmG6utrhDWX6rDgasjD7dZv-G5ZyCmkKg'
}));

tileset.readyPromise.then(function() {
var boundingSphere = tileset.boundingSphere;
viewer.camera.viewBoundingSphere(boundingSphere, new Cesium.HeadingPitchRange(0.0, -0.5, boundingSphere.radius + 500.0));
viewer.camera.lookAtTransform(Cesium.Matrix4.IDENTITY);
}).otherwise(function(error) {
throw(error);
});

var cartographics = [new Cesium.Cartographic(-1.3194369277314022, 0.6988062530900625),
new Cesium.Cartographic(-1.3193955980204217, 0.6988091578771254),
new Cesium.Cartographic(-1.3193931220959367, 0.698743632490865),
new Cesium.Cartographic(-1.3194358224045408, 0.6987471965556998)];
var rectangle = Cesium.Rectangle.fromCartographicArray(cartographics);
var rectanglePrimitive = viewer.scene.primitives.add(new Cesium.GroundPrimitive({
geometryInstances : new Cesium.GeometryInstance({
geometry : new Cesium.RectangleGeometry({
rectangle : rectangle
}),
attributes: {
color: Cesium.ColorGeometryInstanceAttribute.fromColor(new Cesium.Color(1.0, 0.0, 0.0, 0.5))
}
}),
classificationType : Cesium.ClassificationType.BOTH
}));

var options = [{
text : 'Classify Both',
onselect : function() {
if (Cesium.defined(rectanglePrimitive)) {
rectanglePrimitive.classificationType = Cesium.ClassificationType.BOTH;
}
}
}, {
text : 'Classify Terrain',
onselect : function() {
if (Cesium.defined(rectanglePrimitive)) {
rectanglePrimitive.classificationType = Cesium.ClassificationType.TERRAIN;
}
}
}, {
text : 'Classify 3D Tiles',
onselect : function() {
if (Cesium.defined(rectanglePrimitive)) {
rectanglePrimitive.classificationType = Cesium.ClassificationType.CESIUM_3D_TILE;
}
}
}];
Sandcastle.addToolbarMenu(options);
//Sandcastle_End
Sandcastle.finishedLoading();
}
if (typeof Cesium !== "undefined") {
startup(Cesium);
} else if (typeof require === "function") {
require(["Cesium"], startup);
}
</script>
</body>
</html>
Binary file added Apps/Sandcastle/gallery/Classification Types.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 10 additions & 7 deletions Apps/Sandcastle/gallery/Classification.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
var scene = viewer.scene;
var camera = scene.camera;

scene.globe.depthTestAgainstTerrain = true;

var buildingHighlight;
var treeHighlight1;
var treeHighlight2;
Expand Down Expand Up @@ -73,7 +71,8 @@
color : Cesium.ColorGeometryInstanceAttribute.fromColor(new Cesium.Color(1.0, 0.0, 0.0, 0.5))
},
id : 'volume'
})
}),
classificationType : Cesium.ClassificationType.CESIUM_3D_TILE
}));

camera.setView({
Expand Down Expand Up @@ -106,7 +105,8 @@
color : Cesium.ColorGeometryInstanceAttribute.fromColor(Cesium.Color.fromCssColorString('#F26419').withAlpha(0.5))
},
id : 'volume 1'
})
}),
classificationType : Cesium.ClassificationType.CESIUM_3D_TILE
}));

center = new Cesium.Cartesian3(1216394.3346955755, -4736207.431365568, 4081336.7768881875);
Expand All @@ -125,7 +125,8 @@
color : Cesium.ColorGeometryInstanceAttribute.fromColor(Cesium.Color.fromCssColorString('#F03A47').withAlpha(0.5))
},
id : 'volume 2'
})
}),
classificationType : Cesium.ClassificationType.CESIUM_3D_TILE
}));

center = new Cesium.Cartesian3(1216388.1664430483, -4736210.034324032, 4081332.9324705894);
Expand All @@ -143,7 +144,8 @@
color : Cesium.ColorGeometryInstanceAttribute.fromColor(Cesium.Color.fromCssColorString('#004FFF').withAlpha(0.5))
},
id : 'volume 3'
})
}),
classificationType : Cesium.ClassificationType.CESIUM_3D_TILE
}));

center = new Cesium.Cartesian3(1216383.1478702603, -4736211.716097012, 4081329.551077661);
Expand All @@ -161,7 +163,8 @@
color : Cesium.ColorGeometryInstanceAttribute.fromColor(Cesium.Color.fromCssColorString('#55DDE0').withAlpha(0.5))
},
id : 'volume 4'
})
}),
classificationType : Cesium.ClassificationType.CESIUM_3D_TILE
}));

camera.setView({
Expand Down
30 changes: 20 additions & 10 deletions Apps/Sandcastle/gallery/development/Ground Primitive.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@
color: Cesium.ColorGeometryInstanceAttribute.fromColor(color)
},
id : 'polygon 1'
})
}),
classificationType : Cesium.ClassificationType.TERRAIN
}));

// Same polygon slightly offset and overlapping.
Expand All @@ -89,7 +90,8 @@
color: Cesium.ColorGeometryInstanceAttribute.fromColor(color)
},
id : 'polygon 2'
})
}),
classificationType : Cesium.ClassificationType.TERRAIN
}));

// Same polygon slightly offset and overlapping.
Expand All @@ -110,7 +112,8 @@
color: Cesium.ColorGeometryInstanceAttribute.fromColor(color)
},
id : 'polygon 3'
})
}),
classificationType : Cesium.ClassificationType.TERRAIN
}));
}

Expand Down Expand Up @@ -204,7 +207,8 @@
var show = new Cesium.ShowGeometryInstanceAttribute(true);
var instances = createBatchedInstances(color, show);
scene.groundPrimitives.add(new Cesium.GroundPrimitive({
geometryInstances : instances
geometryInstances : instances,
classificationType : Cesium.ClassificationType.TERRAIN
}));

viewOverlappingPolygons();
Expand All @@ -216,7 +220,8 @@
var instances = createBatchedInstances(color, show);

var primitive = scene.groundPrimitives.add(new Cesium.GroundPrimitive({
geometryInstances : instances
geometryInstances : instances,
classificationType : Cesium.ClassificationType.TERRAIN
}));

color = new Cesium.ColorGeometryInstanceAttribute(1.0, 0.0, 1.0, 0.5);
Expand All @@ -230,7 +235,8 @@
}

var pickPrimitive = scene.groundPrimitives.add(new Cesium.GroundPrimitive({
geometryInstances : instances
geometryInstances : instances,
classificationType : Cesium.ClassificationType.TERRAIN
}));

viewOverlappingPolygons();
Expand Down Expand Up @@ -270,7 +276,8 @@
color : Cesium.ColorGeometryInstanceAttribute.fromColor(new Cesium.Color(1.0, 0.0, 0.0, 0.5))
},
id : 'circle'
})
}),
classificationType : Cesium.ClassificationType.TERRAIN
}));

// Ellipse Geometry
Expand All @@ -285,7 +292,8 @@
color : Cesium.ColorGeometryInstanceAttribute.fromColor(new Cesium.Color(0.0, 1.0, 1.0, 0.5))
},
id : 'ellipse'
})
}),
classificationType : Cesium.ClassificationType.TERRAIN
}));

// Corridor Geometry
Expand All @@ -303,7 +311,8 @@
color : Cesium.ColorGeometryInstanceAttribute.fromColor(new Cesium.Color(0.0, 0.0, 1.0, 0.5))
},
id : 'corridor'
})
}),
classificationType : Cesium.ClassificationType.TERRAIN
}));

// Rectangle geometry
Expand All @@ -317,7 +326,8 @@
color: Cesium.ColorGeometryInstanceAttribute.fromColor(new Cesium.Color(0.0, 1.0, 0.0, 0.5))
},
id : 'rectangle'
})
}),
classificationType : Cesium.ClassificationType.TERRAIN
}));
});

Expand Down
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ Change Log
* Fixed specular computation for certain models using the `KHR_materials_common` extension. [#5773](https://github.com/AnalyticalGraphicsInc/cesium/pull/5773)
* Fixed a bug where developer error was thrown in Sandcastle example [#5703](https://github.com/AnalyticalGraphicsInc/cesium/issues/5703)
* Fixed a 3D Tiles traversal bug for tilesets using additive refinement. [#5766](https://github.com/AnalyticalGraphicsInc/cesium/issues/5766)
* Fixed depth picking on 3D Tiles. [#5676](https://github.com/AnalyticalGraphicsInc/cesium/issues/5676)
* Fixed glTF model translucency bug. [#5731](https://github.com/AnalyticalGraphicsInc/cesium/issues/5731)
* Added `classificationType` to `ClassificationPrimitive` and `GroundPrimitive` to choose whether terrain, 3D Tiles, or both are classified. [#5683](https://github.com/AnalyticalGraphicsInc/cesium/issues/5676)

### 1.36 - 2017-08-01

Expand Down
11 changes: 6 additions & 5 deletions Source/Renderer/Pass.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ define([
COMPUTE : 1,
GLOBE : 2,
CESIUM_3D_TILE : 3,
GROUND : 4,
OPAQUE : 5,
TRANSLUCENT : 6,
OVERLAY : 7,
NUMBER_OF_PASSES : 8
TERRAIN_CLASSIFICATION : 4,
CESIUM_3D_TILE_CLASSIFICATION : 5,
OPAQUE : 6,
TRANSLUCENT : 7,
OVERLAY : 8,
NUMBER_OF_PASSES : 9
};

return freezeObject(Pass);
Expand Down
Loading