-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Use b3dm tilesets for classification #6033
Changes from 29 commits
27972ff
b4f367a
e7ec3be
2b0f52f
f1ab457
33ff56e
7fe3e37
b3993b5
cc7a228
fad8860
a2a1e2f
0d2f1e1
6981a68
e1218d7
9173555
c1ad375
b448116
f15d07f
1f8fb07
9c054da
db85153
124d290
1fe9fc8
8eabdad
67cdf82
15b58e4
0cefab9
3e88765
bc232cd
764267a
00f1792
3ffd232
d377603
eb07e44
ea49b72
12283c4
79ed093
0ab3156
5fdf1ad
772a9c3
9fbc848
612c5f5
618a892
d566de4
045e458
6e57010
15380ef
92709e8
36b2b53
a4c4506
5232f88
029abad
1fa1976
8f389cb
5f4ed4c
2385d20
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,66 @@ | ||
<!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="Sample photogrammetry and classification datasets both rendered with 3D Tiles."> | ||
<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"> | ||
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 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)); | ||
viewer.camera.lookAtTransform(Cesium.Matrix4.IDENTITY); | ||
}).otherwise(function(error) { | ||
throw(error); | ||
}); | ||
|
||
var classification = viewer.scene.primitives.add(new Cesium.Cesium3DTileset({ | ||
url: 'https://beta.cesium.com/api/assets/3486?access_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiIzZjM4MjljZi0xNTAzLTQ0MzctODhlZi0zOTU3Njg5ODA1Y2QiLCJpZCI6OCwiaWF0IjoxNDgxODI5ODMyfQ.dYlV8_PoXcFNlPHGook5kMzuJMS-Bb9DCMzI1mFVvgE', | ||
classificationType : Cesium.ClassificationType.CESIUM_3D_TILE, | ||
skipLevelOfDetail : false | ||
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. Can this be omitted? I thought the plan was to update the documentation for |
||
})); | ||
|
||
classification.readyPromise.then(function() { | ||
classification.style = new Cesium.Cesium3DTileStyle({ | ||
color : 'rgba(255, 0, 0, 0.5)' | ||
}); | ||
}).otherwise(function(error) { | ||
throw(error); | ||
}); | ||
//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 |
---|---|---|
|
@@ -9,6 +9,13 @@ Change Log | |
* Added `Plane.transformPlane` function to apply a transformation to a plane. [#5966](https://github.com/AnalyticalGraphicsInc/cesium/pull/5966) | ||
* Added `PlaneGeometry`, `PlaneOutlineGeometry`, `PlaneGeometryUpdater`, and `PlaneOutlineGeometryUpdater` classes to render plane primitives. [#5996](https://github.com/AnalyticalGraphicsInc/cesium/pull/5996) | ||
* Added `PlaneGraphics` class and `plane` property to `Entity`. [#5996](https://github.com/AnalyticalGraphicsInc/cesium/pull/5996) | ||
* Added `AttributeCompression.zigZagDeltaDecode` which will decode delta and ZigZag encoded buffers in place. | ||
* Added `pack` and `unpack` functions to `OrientedBoundingBox` for packing to and unpacking from a flat buffer. | ||
* Added experimental support for [3D Tiles Vector Data](https://github.com/AnalyticalGraphicsInc/3d-tiles/tree/vector-tiles/TileFormats/VectorData) ([#4665](https://github.com/AnalyticalGraphicsInc/cesium/pull/4665)). The new and modified Cesium APIs are: | ||
* `Cesium3DTileStyle` has expanded for styling point features. See the [styling specification](https://github.com/AnalyticalGraphicsInc/3d-tiles/tree/vector-tiles/Styling#vector-data) for details. | ||
* `Cesium3DTileFeature` can modify `color` and `show` properties for polygon, polyline, geometry, and mesh features. | ||
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. Is this still right? I thought 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. They were removed in the other PR. |
||
* `Cesium3DTilePointFeature` can modify the styling options for a point feature. | ||
* Added `Cesium3DTileset.classificationType` to specify if a tileset classifies terrain, another 3D Tiles tileset, or both. This only applies to vector, geometry and batched 3D model tilesets. See [#6033](https://github.com/AnalyticalGraphicsInc/cesium/pull/6033) for limitations on the glTF contained in the b3dm tile. | ||
|
||
### 1.40 - 2017-12-01 | ||
|
||
|
@@ -29,13 +36,6 @@ Change Log | |
* Added ability to support touch event in Imagery Layers Split Sandcastle example. [#5948](https://github.com/AnalyticalGraphicsInc/cesium/pull/5948) | ||
* Added a new `@experimental` tag to the documentation. A small subset of the Cesium API tagged as such are subject to breaking changes without deprecation. See the [Coding Guide](https://github.com/AnalyticalGraphicsInc/cesium/tree/master/Documentation/Contributors/CodingGuide#deprecation-and-breaking-changes) for further explanation. [#6010](https://github.com/AnalyticalGraphicsInc/cesium/pull/6010) | ||
* Moved terrain and imagery credits to a lightbox that pops up when you click a link in the onscreen credits [#3013](https://github.com/AnalyticalGraphicsInc/cesium/issues/3013) | ||
* Added `AttributeCompression.zigZagDeltaDecode` which will decode delta and ZigZag encoded buffers in place. | ||
* Added `pack` and `unpack` functions to `OrientedBoundingBox` for packing to and unpacking from a flat buffer. | ||
* Added experimental support for [3D Tiles Vector Data](https://github.com/AnalyticalGraphicsInc/3d-tiles/tree/vector-tiles/TileFormats/VectorData) ([#4665](https://github.com/AnalyticalGraphicsInc/cesium/pull/4665)). The new and modified Cesium APIs are: | ||
* `Cesium3DTileset.classificationType` to specify if a vector tileset classifies terrain, another 3D Tiles tileset, or both. | ||
* `Cesium3DTileStyle` has expanded for styling point features. See the [styling specification](https://github.com/AnalyticalGraphicsInc/3d-tiles/tree/vector-tiles/Styling#vector-data) for details. | ||
* `Cesium3DTileFeature` can modify `color` and `show` properties for polygon, polyline, geometry, and mesh features. | ||
* `Cesium3DTilePointFeature` can modify the styling options for a point feature. | ||
|
||
### 1.39 - 2017-11-01 | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ define([ | |
'./Cesium3DTileBatchTable', | ||
'./Cesium3DTileFeature', | ||
'./Cesium3DTileFeatureTable', | ||
'./ClassificationModel', | ||
'./ClippingPlaneCollection', | ||
'./getAttributeOrUniformBySemantic', | ||
'./Model' | ||
|
@@ -37,6 +38,7 @@ define([ | |
Cesium3DTileBatchTable, | ||
Cesium3DTileFeature, | ||
Cesium3DTileFeatureTable, | ||
ClassificationModel, | ||
ClippingPlaneCollection, | ||
getAttributeOrUniformBySemantic, | ||
Model) { | ||
|
@@ -207,8 +209,9 @@ define([ | |
return function(vs) { | ||
var batchTable = content._batchTable; | ||
var gltf = content._model.gltf; | ||
var handleTranslucent = !defined(content._tileset.classificationType); | ||
var batchIdAttributeName = getBatchIdAttributeName(gltf); | ||
var callback = batchTable.getVertexShaderCallback(true, batchIdAttributeName); | ||
var callback = batchTable.getVertexShaderCallback(handleTranslucent, batchIdAttributeName); | ||
return defined(callback) ? callback(vs) : vs; | ||
}; | ||
} | ||
|
@@ -227,12 +230,27 @@ define([ | |
return function(fs) { | ||
var batchTable = content._batchTable; | ||
var gltf = content._model.gltf; | ||
var handleTranslucent = !defined(content._tileset.classificationType); | ||
var diffuseUniformName = getAttributeOrUniformBySemantic(gltf, '_3DTILESDIFFUSE'); | ||
var callback = batchTable.getFragmentShaderCallback(true, diffuseUniformName); | ||
var callback = batchTable.getFragmentShaderCallback(handleTranslucent, diffuseUniformName); | ||
return defined(callback) ? callback(fs) : fs; | ||
}; | ||
} | ||
|
||
function getClassificationFragmentShaderCallback(content) { | ||
return function(fs) { | ||
var batchTable = content._batchTable; | ||
var callback = batchTable.getClassificationFragmentShaderCallback(); | ||
return defined(callback) ? callback(fs) : fs; | ||
}; | ||
} | ||
|
||
function createColorChangedCallback(content) { | ||
return function(batchId, color) { | ||
content._model.updateCommands(batchId, color); | ||
}; | ||
} | ||
|
||
function initialize(content, arrayBuffer, byteOffset) { | ||
var tileset = content._tileset; | ||
var tile = content._tile; | ||
|
@@ -334,7 +352,12 @@ define([ | |
} | ||
} | ||
|
||
var batchTable = new Cesium3DTileBatchTable(content, batchLength, batchTableJson, batchTableBinary); | ||
var colorChangeCallback; | ||
if (defined(tileset.classificationType)) { | ||
colorChangeCallback = createColorChangedCallback(content); | ||
} | ||
|
||
var batchTable = new Cesium3DTileBatchTable(content, batchLength, batchTableJson, batchTableBinary, colorChangeCallback); | ||
content._batchTable = batchTable; | ||
|
||
var gltfByteLength = byteStart + byteLength - byteOffset; | ||
|
@@ -356,35 +379,56 @@ define([ | |
primitive : tileset | ||
}; | ||
|
||
// PERFORMANCE_IDEA: patch the shader on demand, e.g., the first time show/color changes. | ||
// The pick shader still needs to be patched. | ||
content._model = new Model({ | ||
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, | ||
upAxis : tileset._gltfUpAxis, | ||
shadows: tileset.shadows, | ||
debugWireframe: tileset.debugWireframe, | ||
incrementallyLoadTextures : false, | ||
vertexShaderLoaded : getVertexShaderCallback(content), | ||
fragmentShaderLoaded : getFragmentShaderCallback(content), | ||
uniformMapLoaded : batchTable.getUniformMapCallback(), | ||
pickVertexShaderLoaded : getPickVertexShaderCallback(content), | ||
pickFragmentShaderLoaded : batchTable.getPickFragmentShaderCallback(), | ||
pickUniformMapLoaded : batchTable.getPickUniformMapCallback(), | ||
addBatchIdToGeneratedShaders : (batchLength > 0), // If the batch table has values in it, generated shaders will need a batchId attribute | ||
pickObject : pickObject, | ||
clippingPlanes : new ClippingPlaneCollection({ | ||
enabled : false | ||
}) | ||
}); | ||
|
||
if (defined(tileset.clippingPlanes)) { | ||
content._model.clippingPlanes = tileset.clippingPlanes.clone(); | ||
if (!defined(tileset.classificationType)) { | ||
// PERFORMANCE_IDEA: patch the shader on demand, e.g., the first time show/color changes. | ||
// The pick shader still needs to be patched. | ||
content._model = new Model({ | ||
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, | ||
upAxis : tileset._gltfUpAxis, | ||
shadows: tileset.shadows, | ||
debugWireframe: tileset.debugWireframe, | ||
incrementallyLoadTextures : false, | ||
vertexShaderLoaded : getVertexShaderCallback(content), | ||
fragmentShaderLoaded : getFragmentShaderCallback(content), | ||
classificationShaderLoaded : getClassificationFragmentShaderCallback(content), | ||
uniformMapLoaded : batchTable.getUniformMapCallback(), | ||
pickVertexShaderLoaded : getPickVertexShaderCallback(content), | ||
pickFragmentShaderLoaded : batchTable.getPickFragmentShaderCallback(), | ||
pickUniformMapLoaded : batchTable.getPickUniformMapCallback(), | ||
addBatchIdToGeneratedShaders : (batchLength > 0), // If the batch table has values in it, generated shaders will need a batchId attribute | ||
pickObject : pickObject, | ||
clippingPlanes : new ClippingPlaneCollection({ | ||
enabled : false | ||
}) | ||
}); | ||
if (defined(tileset.clippingPlanes)) { | ||
content._model.clippingPlanes = tileset.clippingPlanes.clone(); | ||
} | ||
} else { | ||
// This transcodes glTF to an internal representation for geometry so we can take advantage of the re-batching of vector a geometry data. | ||
// For a list of limitations on the input glTF, see the documentation for classificationType of Cesium3DTileset. | ||
content._model = new ClassificationModel({ | ||
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. Can you add a code comment about how this is a transcode - with limitations on the input glTF - so that we can use the |
||
gltf : gltfView, | ||
cull : false, // The model is already culled by 3D Tiles | ||
basePath : basePath, | ||
modelMatrix : tile.computedTransform, | ||
upAxis : tileset._gltfUpAxis, | ||
debugWireframe : tileset.debugWireframe, | ||
vertexShaderLoaded : getVertexShaderCallback(content), | ||
classificationShaderLoaded : getClassificationFragmentShaderCallback(content), | ||
uniformMapLoaded : batchTable.getUniformMapCallback(), | ||
pickVertexShaderLoaded : getPickVertexShaderCallback(content), | ||
pickFragmentShaderLoaded : batchTable.getPickFragmentShaderCallback(), | ||
pickUniformMapLoaded : batchTable.getPickUniformMapCallback(), | ||
classificationType : tileset._classificationType, | ||
batchTable : batchTable | ||
}); | ||
} | ||
} | ||
|
||
|
@@ -466,7 +510,7 @@ define([ | |
|
||
// If any commands were pushed, add derived commands | ||
var commandEnd = frameState.commandList.length; | ||
if ((commandStart < commandEnd) && frameState.passes.render) { | ||
if ((commandStart < commandEnd) && frameState.passes.render && !(this._model instanceof ClassificationModel)) { | ||
var finalResolution = this._tile._finalResolution; | ||
this._batchTable.addDerivedCommands(frameState, commandStart, finalResolution); | ||
} | ||
|
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.
What does this tileset look like without classification. Is it worth adding a comment to say to comment out the
classificationType
line to see the geometry used to classify?The other option is to create two tilesets, one with and without the classification, and then change their
show
via a checkbox, but that could make the example too complex.