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

Support for loading 3D Tiles via CZML and Entity API #8580

Merged
merged 4 commits into from
Feb 7, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/Build
/Cesium-*.zip
/cesium-*.tgz
.directory
.DS_Store
Thumbs.db
.eslintcache
Expand Down
57 changes: 57 additions & 0 deletions Apps/Sandcastle/gallery/CZML 3D Tiles.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<!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="CZML Model">
<meta name="cesium-sandcastle-labels" content="CZML">
<title>Cesium Demo</title>
<script type="text/javascript" src="../Sandcastle-header.js"></script>
<script type="text/javascript" src="../../../Build/CesiumUnminified/Cesium.js" nomodule></script>
<script type="module" src="../load-cesium-es6.js"></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 czml = [{
"id" : "document",
"version" : "1.0"
}, {
"id" : "BatchedColors",
"name" : "BatchedColors",
"tileset": {
"uri" : "../../SampleData/Cesium3DTiles/Batched/BatchedColors/tileset.json"
}
}];

var viewer = new Cesium.Viewer('cesiumContainer', {
shouldAnimate : true
});

var dataSourcePromise = viewer.dataSources.add(Cesium.CzmlDataSource.load(czml));

dataSourcePromise.then(function(dataSource){
viewer.flyTo(dataSource.entities.getById('BatchedColors'));
}).otherwise(function(error){
window.alert(error);
});
//Sandcastle_End
Sandcastle.finishedLoading();
}
if (typeof Cesium !== 'undefined') {
window.startupCalled = true;
startup(Cesium);
}
</script>
</body>
</html>
Binary file added Apps/Sandcastle/gallery/CZML 3D Tiles.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ Change Log

### 1.67.0 - 2020-03-02

##### Additions :tada:

* Added `Entity.tileset` for loading a 3D Tiles tileset via the Entity API using the new `Cesium3DTilesetGraphics` class.
* Added `tileset.uri`, `tileset.show`, and `tileset.maximumScreenSpaceError` properties to CZML processing for loading 3D Tiles.

##### Fixes :wrench:

* Fixed a bug where tiles would not load if the camera was tracking a moving tileset. [#8598](https://github.com/AnalyticalGraphicsInc/cesium/pull/8598)
Expand Down
104 changes: 104 additions & 0 deletions Source/DataSources/Cesium3DTilesetGraphics.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import defaultValue from '../Core/defaultValue.js';
import defined from '../Core/defined.js';
import defineProperties from '../Core/defineProperties.js';
import DeveloperError from '../Core/DeveloperError.js';
import Event from '../Core/Event.js';
import createPropertyDescriptor from './createPropertyDescriptor.js';

/**
* A 3D Tiles tileset represented by an {@link Entity}.
* The tileset modelMatrix is determined by the containing Entity position and orientation
* or is left unset if position is undefined.
*
* @alias Cesium3DTilesetGraphics
* @constructor
*
* @param {Object} [options] Object with the following properties:
* @param {Property} [options.show=true] A boolean Property specifying the visibility of the tileset.
* @param {Property} [options.uri] A string or Resource Property specifying the URI of the tileset.
* @param {Property} [options.maximumScreenSpaceError] A number or Property specifying the maximum screen space error used to drive level of detail refinement.
*/
function Cesium3DTilesetGraphics(options) {
this._definitionChanged = new Event();
this._show = undefined;
this._showSubscription = undefined;
this._uri = undefined;
this._uriSubscription = undefined;
this._maximumScreenSpaceError = undefined;
this._maximumScreenSpaceErrorSubscription = undefined;

this.merge(defaultValue(options, defaultValue.EMPTY_OBJECT));
}

defineProperties(Cesium3DTilesetGraphics.prototype, {
/**
* Gets the event that is raised whenever a property or sub-property is changed or modified.
* @memberof Cesium3DTilesetGraphics.prototype
* @type {Event}
* @readonly
*/
definitionChanged: {
get: function() {
return this._definitionChanged;
}
},

/**
* Gets or sets the boolean Property specifying the visibility of the model.
* @memberof Cesium3DTilesetGraphics.prototype
* @type {Property}
* @default true
*/
show: createPropertyDescriptor('show'),

/**
* Gets or sets the string Property specifying the URI of the glTF asset.
Copy link
Contributor

Choose a reason for hiding this comment

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

This shouldn't refer to a glTF asset. Copy/paste error from ModelGraphics?

* @memberof Cesium3DTilesetGraphics.prototype
* @type {Property}
*/
uri: createPropertyDescriptor('uri'),

/**
* Gets or sets the maximum screen space error used to drive level of detail refinement.
* @memberof Cesium3DTilesetGraphics.prototype
* @type {Property}
*/
maximumScreenSpaceError: createPropertyDescriptor('maximumScreenSpaceError')
});

/**
* Duplicates this instance.
*
* @param {Cesium3DTilesetGraphics} [result] The object onto which to store the result.
* @returns {Cesium3DTilesetGraphics} The modified result parameter or a new instance if one was not provided.
*/
Cesium3DTilesetGraphics.prototype.clone = function(result) {
if (!defined(result)) {
return new Cesium3DTilesetGraphics(this);
}
result.show = this.show;
result.uri = this.uri;
result.maximumScreenSpaceError = this.maximumScreenSpaceError;

return result;
};

/**
* Assigns each unassigned property on this object to the value
* of the same property on the provided source object.
*
* @param {Cesium3DTilesetGraphics} source The object to be merged into this object.
*/
Cesium3DTilesetGraphics.prototype.merge = function(source) {
//>>includeStart('debug', pragmas.debug);
if (!defined(source)) {
throw new DeveloperError('source is required.');
}
//>>includeEnd('debug');

this.show = defaultValue(this.show, source.show);
this.uri = defaultValue(this.uri, source.uri);
this.maximumScreenSpaceError = defaultValue(this.maximumScreenSpaceError, source.maximumScreenSpaceError);
};

export default Cesium3DTilesetGraphics;
Loading