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

Classification primitive #5625

Merged
merged 17 commits into from
Jul 21, 2017
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
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
89 changes: 89 additions & 0 deletions Apps/Sandcastle/gallery/development/ClassificationPrimitive.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1"> <!-- Use Chrome Frame in IE -->
<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.">
<meta name="cesium-sandcastle-labels" content="Development">
Copy link
Contributor

Choose a reason for hiding this comment

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

Are you sure this should go under Development? I would rather it be more prominent.

<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>
<script id="cesium_sandcastle_script">
function startup(Cesium) {
'use strict';
//Sandcastle_Begin
var viewer = new Cesium.Viewer('cesiumContainer');
var scene = viewer.scene;
var camera = scene.camera;

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;
camera.viewBoundingSphere(boundingSphere, new Cesium.HeadingPitchRange(0.0, -0.5, boundingSphere.radius));
camera.lookAtTransform(Cesium.Matrix4.IDENTITY);

var dimensions = new Cesium.Cartesian3(40.0, 30.0, 50.0);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use a slightly different geometry that shows how this is different than a GroundPrimitive? For example, something where the bottom cap is above the ground and/or even something on the underside of a tree, polyline on the roof, etc. It would be fine to have a few short examples here.

var boxModelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(boundingSphere.center);
var boxGeometry = Cesium.BoxGeometry.fromDimensions({
vertexFormat : Cesium.PerInstanceColorAppearance.VERTEX_FORMAT,
dimensions : dimensions
});
var boxGeometryInstance = new Cesium.GeometryInstance({
geometry : boxGeometry,
modelMatrix : boxModelMatrix,
attributes : {
color : Cesium.ColorGeometryInstanceAttribute.fromColor(new Cesium.Color(1.0, 0.0, 0.0, 0.5))
},
id : 'box volume'
});
scene.primitives.add(new Cesium.ClassificationPrimitive({
geometryInstances : boxGeometryInstance
}));
}).otherwise(function(error) {
throw(error);
});

var currentObjectId;
var currentPrimitive;

var handler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
handler.setInputAction(function(movement) {
var pickedObject = scene.pick(movement.endPosition);
if (Cesium.defined(pickedObject) && Cesium.defined(pickedObject.primitive) && Cesium.defined(pickedObject.id) && Cesium.defined(pickedObject.primitive.getGeometryInstanceAttributes)) {
currentObjectId = pickedObject.id;
currentPrimitive = pickedObject.primitive;
currentPrimitive.getGeometryInstanceAttributes(currentObjectId).color = [255, 0, 255, 128];
} else if (Cesium.defined(currentObjectId)) {
currentPrimitive.getGeometryInstanceAttributes(currentObjectId).color = [255, 0, 0, 128];
currentObjectId = undefined;
currentPrimitive = undefined;
}
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
//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.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Change Log

* Added ability to show tile urls in the 3D Tiles Inspector. [#5592](https://github.com/AnalyticalGraphicsInc/cesium/pull/5592)
* Added behavior to `Cesium3DTilesInspector` that selects the first tileset hovered over if no tilest is specified. [#5139](https://github.com/AnalyticalGraphicsInc/cesium/issues/5139)
* Added `ClassificationPrimitive` which defines a volume and draws the intersection of the volume and terrain or 3D Tiles. [#5625](https://github.com/AnalyticalGraphicsInc/cesium/pull/5625)

### 1.35.2 - 2017-07-11

Expand Down
3 changes: 3 additions & 0 deletions Source/Scene/Batched3DModel3DTileContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ define([
'../Core/getStringFromTypedArray',
'../Core/RequestType',
'../Core/RuntimeError',
'../Renderer/Pass',
'./Cesium3DTileBatchTable',
'./Cesium3DTileFeature',
'./Cesium3DTileFeatureTable',
Expand All @@ -33,6 +34,7 @@ define([
getStringFromTypedArray,
RequestType,
RuntimeError,
Pass,
Cesium3DTileBatchTable,
Cesium3DTileFeature,
Cesium3DTileFeatureTable,
Expand Down Expand Up @@ -352,6 +354,7 @@ define([
gltf : gltfView,
cull : false, // The model is already culled by 3D Tiles
releaseGltfJson : true, // Models are unique and will not benefit from caching so save memory
opaquePass : Pass.CESIUM_3D_TILE, // Draw opaque portions of the model during the 3D Tiles pass
basePath : basePath,
requestType : RequestType.TILES3D,
modelMatrix : tile.computedTransform,
Expand Down
4 changes: 0 additions & 4 deletions Source/Scene/Cesium3DTileBatchTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -1305,10 +1305,6 @@ define([
// even though their style is opaque.
var translucentCommand = (derivedCommand.pass === Pass.TRANSLUCENT);

if (!translucentCommand) {
derivedCommand.pass = Pass.CESIUM_3D_TILE;
}

derivedCommand.uniformMap = defined(derivedCommand.uniformMap) ? derivedCommand.uniformMap : {};
derivedCommand.uniformMap.tile_translucentCommand = function() {
return translucentCommand;
Expand Down
Loading