Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin' into sphere-from-oriented-box
Browse files Browse the repository at this point in the history
  • Loading branch information
lilleyse committed Nov 5, 2015
2 parents ebb8f60 + ee68e6b commit e084434
Show file tree
Hide file tree
Showing 22 changed files with 317 additions and 26 deletions.
3 changes: 2 additions & 1 deletion Apps/Sandcastle/gallery/3D Models.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
orientation : orientation,
model : {
uri : url,
minimumPixelSize : 128
minimumPixelSize : 128,
maximumScale : 20000
}
});
viewer.trackedEntity = entity;
Expand Down
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ Change Log
* Fixed a bug in the deprecated `jsonp` that prevented it from returning a promise. Its replacement, `loadJsonp`, was unaffected.
* Fixed glTF implementation to read the version as a string as per the specification and to correctly handle backwards compatibility for axis-angle rotations in glTF 0.8 models.
* Added `BoundingSphere.fromOrientedBoundingBox` function.
* Fixed a bug that caused setting `Entity.parent` to `undefined` to throw an exception. [#3169](https://github.com/AnalyticalGraphicsInc/cesium/issues/3169)
* Added `Model.maximumScale` and `ModelGraphics.maximumScale` properties, giving an upper limit for minimumPixelSize.
* Entities have a reference to their entity collection.
* Entity collections have a reference to their owner (usually a data source, but can be a `CompositeEntityCollection`).
* `GeoJsonDataSource.load` now takes an optional `describeProperty` function for generating feature description properties. [#3140](https://github.com/AnalyticalGraphicsInc/cesium/pull/3140)

### 1.15 - 2015-11-02

Expand Down
2 changes: 2 additions & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to Cesiu
* [Kevin Ring](https://github.com/kring)
* [Keith Grochow](https://github.com/kgrochow)
* [Chloe Chen](https://github.com/chloeleichen)
* [Arthur Street](https://github.com/RacingTadpole)
* [EU Edge](http://euedge.com/)
* [Ákos Maróy](https://github.com/akosmaroy)
* [Raytheon Intelligence and Information Systems](http://www.raytheon.com/)
Expand Down Expand Up @@ -73,5 +74,6 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to Cesiu
* [Cole Murphy](https://github.com/fantasticole)
* [Keat Tang](https://github.com/keattang)
* [Denver Pierce](https://github.com/denverpierce)
* [Tucker Tibbetts](https://github.com/cttibbetts)

Also see [our contributors page](http://cesiumjs.org/contributors.html) for more information.
4 changes: 2 additions & 2 deletions Source/DataSources/CompositeEntityCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ define([
var iEntities;
var collection;
var composite = that._composite;
var newEntities = new EntityCollection();
var newEntities = new EntityCollection(that);
var eventHash = that._eventHash;
var collectionId;

Expand Down Expand Up @@ -127,7 +127,7 @@ define([
* @param {EntityCollection[]} [collections] The initial list of EntityCollection instances to merge.
*/
var CompositeEntityCollection = function(collections) {
this._composite = new EntityCollection();
this._composite = new EntityCollection(this);
this._suspendCount = 0;
this._collections = defined(collections) ? collections.slice() : [];
this._collectionsCopy = [];
Expand Down
2 changes: 1 addition & 1 deletion Source/DataSources/CustomDataSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ define([
this._error = new Event();
this._isLoading = false;
this._loading = new Event();
this._entityCollection = new EntityCollection();
this._entityCollection = new EntityCollection(this);
};

defineProperties(CustomDataSource.prototype, {
Expand Down
2 changes: 1 addition & 1 deletion Source/DataSources/CzmlDataSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -1531,7 +1531,7 @@ define([
this._clock = undefined;
this._documentPacket = new DocumentPacket();
this._version = undefined;
this._entityCollection = new EntityCollection();
this._entityCollection = new EntityCollection(this);
};

/**
Expand Down
10 changes: 9 additions & 1 deletion Source/DataSources/Entity.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,12 @@ define([
this._wallSubscription = undefined;
this._children = [];

/**
* Gets or sets the entity collection that this entity belongs to.
* @type {EntityCollection}
*/
this.entityCollection = undefined;

this.parent = options.parent;
this.merge(options);
};
Expand Down Expand Up @@ -297,7 +303,9 @@ define([
}

this._parent = value;
value._children.push(this);
if (defined(value)) {
value._children.push(this);
}

var isShowing = this.isShowing;

Expand Down
17 changes: 16 additions & 1 deletion Source/DataSources/EntityCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,11 @@ define([
* An observable collection of {@link Entity} instances where each entity has a unique id.
* @alias EntityCollection
* @constructor
*
* @param {DataSource|CompositeEntityCollection} [owner] The data source (or composite entity collection) which created this collection.
*/
var EntityCollection = function() {
var EntityCollection = function(owner) {
this._owner = owner;
this._entities = new AssociativeArray();
this._addedEntities = new AssociativeArray();
this._removedEntities = new AssociativeArray();
Expand Down Expand Up @@ -136,6 +139,17 @@ define([
get : function() {
return this._entities.values;
}
},
/**
* Gets the owner of this entity collection, ie. the data source or composite entity collection which created it.
* @memberof EntityCollection.prototype
* @readonly
* @type {DataSource|CompositeEntityCollection}
*/
owner : {
get : function() {
return this._owner;
}
}
});

Expand Down Expand Up @@ -202,6 +216,7 @@ define([
throw new RuntimeError('An entity with id ' + id + ' already exists in this collection.');
}

entity.entityCollection = this;
entities.set(id, entity);

var removedEntities = this._removedEntities;
Expand Down
34 changes: 24 additions & 10 deletions Source/DataSources/GeoJsonDataSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ define([

var stringifyScratch = new Array(4);

function describe(properties, nameProperty) {
function defaultDescribe(properties, nameProperty) {
var html = '';
for ( var key in properties) {
if (properties.hasOwnProperty(key)) {
Expand All @@ -99,7 +99,7 @@ define([
var value = properties[key];
if (definedNotNull(value)) {
if (typeof value === 'object') {
html += '<tr><th>' + key + '</th><td>' + describe(value) + '</td></tr>';
html += '<tr><th>' + key + '</th><td>' + defaultDescribe(value) + '</td></tr>';
} else {
html += '<tr><th>' + key + '</th><td>' + value + '</td></tr>';
}
Expand All @@ -114,7 +114,7 @@ define([
return html;
}

function createDescriptionCallback(properties, nameProperty) {
function createDescriptionCallback(describe, properties, nameProperty) {
var description;
return function(time, result) {
if (!defined(description)) {
Expand All @@ -124,10 +124,14 @@ define([
};
}

function defaultDescribeProperty(properties, nameProperty) {
return new CallbackProperty(createDescriptionCallback(defaultDescribe, properties, nameProperty), true);
}

//GeoJSON specifies only the Feature object has a usable id property
//But since "multi" geometries create multiple entity,
//we can't use it for them either.
function createObject(geoJson, entityCollection) {
function createObject(geoJson, entityCollection, describe) {
var id = geoJson.id;
if (!definedNotNull(id) || geoJson.type !== 'Feature') {
id = createGuid();
Expand Down Expand Up @@ -189,7 +193,7 @@ define([

var description = properties.description;
if (!defined(description)) {
entity.description = new CallbackProperty(createDescriptionCallback(properties, nameProperty), true);
entity.description = describe(properties, nameProperty);
} else if (description !== null) {
entity.description = new ConstantProperty(description);
}
Expand All @@ -213,7 +217,7 @@ define([

if (feature.geometry === null) {
//Null geometry is allowed, so just create an empty entity instance for it.
createObject(feature, dataSource._entityCollection);
createObject(feature, dataSource._entityCollection, options.describe);
} else {
var geometryType = feature.geometry.type;
var geometryHandler = geometryTypes[geometryType];
Expand Down Expand Up @@ -284,7 +288,7 @@ define([
billboard.verticalOrigin = new ConstantProperty(VerticalOrigin.BOTTOM);
billboard.image = new ConstantProperty(dataUrl);

var entity = createObject(geoJson, dataSource._entityCollection);
var entity = createObject(geoJson, dataSource._entityCollection, options.describe);
entity.billboard = billboard;
entity.position = new ConstantPositionProperty(crsFunction(coordinates));
}));
Expand Down Expand Up @@ -334,7 +338,7 @@ define([
polyline.width = widthProperty;
polyline.positions = new ConstantProperty(coordinatesArrayToCartesianArray(coordinates, crsFunction));

var entity = createObject(geoJson, dataSource._entityCollection);
var entity = createObject(geoJson, dataSource._entityCollection, options.describe);
entity.polyline = polyline;
}

Expand Down Expand Up @@ -417,7 +421,7 @@ define([
polygon.perPositionHeight = new ConstantProperty(true);
}

var entity = createObject(geoJson, dataSource._entityCollection);
var entity = createObject(geoJson, dataSource._entityCollection, options.describe);
entity.polygon = polygon;
}

Expand Down Expand Up @@ -496,7 +500,7 @@ define([
this._error = new Event();
this._isLoading = false;
this._loading = new Event();
this._entityCollection = new EntityCollection();
this._entityCollection = new EntityCollection(this);
this._promises = [];
this._pinBuilder = new PinBuilder();
};
Expand Down Expand Up @@ -732,6 +736,8 @@ define([
* @param {String|Object} data A url, GeoJSON object, or TopoJSON object to be loaded.
* @param {Object} [options] An object with the following properties:
* @param {String} [options.sourceUri] Overrides the url to use for resolving relative links.
* @param {GeoJsonDataSource~describe} [options.describe=GeoJsonDataSource.defaultDescribeProperty] A function which returns a Property object (or just a string),
* which converts the properties into an html description.
* @param {Number} [options.markerSize=GeoJsonDataSource.markerSize] The default size of the map pin created for each point, in pixels.
* @param {String} [options.markerSymbol=GeoJsonDataSource.markerSymbol] The default symbol of the map pin created for each point.
* @param {Color} [options.markerColor=GeoJsonDataSource.markerColor] The default color of the map pin created for each point.
Expand Down Expand Up @@ -761,6 +767,7 @@ define([
}

options = {
describe: defaultValue(options.describe, defaultDescribeProperty),
markerSize : defaultValue(options.markerSize, defaultMarkerSize),
markerSymbol : defaultValue(options.markerSymbol, defaultMarkerSymbol),
markerColor : defaultValue(options.markerColor, defaultMarkerColor),
Expand Down Expand Up @@ -846,5 +853,12 @@ define([
});
}

/**
* This callback is displayed as part of the GeoJsonDataSource class.
* @callback GeoJsonDataSource~describe
* @param {Object} properties The properties of the feature.
* @param {String} nameProperty The property key that Cesium estimates to have the name of the feature.
*/

return GeoJsonDataSource;
});
4 changes: 2 additions & 2 deletions Source/DataSources/KmlDataSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -1539,7 +1539,7 @@ define([
name = getFilenameFromUri(sourceUri);
}

var styleCollection = new EntityCollection();
var styleCollection = new EntityCollection(dataSource);
return when.all(processStyles(dataSource, kml, styleCollection, sourceUri, false, uriResolver), function() {
var element = kml.documentElement;
if (element.localName === 'kml') {
Expand Down Expand Up @@ -1681,7 +1681,7 @@ define([
this._error = new Event();
this._loading = new Event();
this._clock = undefined;
this._entityCollection = new EntityCollection();
this._entityCollection = new EntityCollection(this);
this._name = undefined;
this._isLoading = false;
this._proxy = proxy;
Expand Down
14 changes: 14 additions & 0 deletions Source/DataSources/ModelGraphics.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ define([
* @param {Property} [options.show=true] A boolean Property specifying the visibility of the model.
* @param {Property} [options.scale=1.0] A numeric Property specifying a uniform linear scale.
* @param {Property} [options.minimumPixelSize=0.0] A numeric Property specifying the approximate minimum pixel size of the model regardless of zoom.
* @param {Property} [options.maximumScale] The maximum scale size of a model. An upper limit for minimumPixelSize.
*
* @see {@link http://cesiumjs.org/2014/03/03/Cesium-3D-Models-Tutorial/|3D Models Tutorial}
* @demo {@link http://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=3D%20Models.html|Cesium Sandcastle 3D Models Demo}
Expand All @@ -42,6 +43,8 @@ define([
this._scaleSubscription = undefined;
this._minimumPixelSize = undefined;
this._minimumPixelSizeSubscription = undefined;
this._maximumScale = undefined;
this._maximumScaleSubscription = undefined;
this._uri = undefined;
this._uriSubscription = undefined;
this._definitionChanged = new Event();
Expand Down Expand Up @@ -91,6 +94,15 @@ define([
*/
minimumPixelSize : createPropertyDescriptor('minimumPixelSize'),

/**
* Gets or sets the numeric Property specifying the maximum scale
* size of a model. This property is used as an upper limit for
* {@link ModelGraphics#minimumPixelSize}.
* @memberof ModelGraphics.prototype
* @type {Property}
*/
maximumScale : createPropertyDescriptor('maximumScale'),

/**
* Gets or sets the string Property specifying the URI of the glTF asset.
* @memberof ModelGraphics.prototype
Expand All @@ -112,6 +124,7 @@ define([
result.show = this.show;
result.scale = this.scale;
result.minimumPixelSize = this.minimumPixelSize;
result.maximumScale = this.maximumScale;
result.uri = this.uri;
return result;
};
Expand All @@ -132,6 +145,7 @@ define([
this.show = defaultValue(this.show, source.show);
this.scale = defaultValue(this.scale, source.scale);
this.minimumPixelSize = defaultValue(this.minimumPixelSize, source.minimumPixelSize);
this.maximumScale = defaultValue(this.maximumScale, source.maximumScale);
this.uri = defaultValue(this.uri, source.uri);
};

Expand Down
1 change: 1 addition & 0 deletions Source/DataSources/ModelVisualizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ define([
model.show = true;
model.scale = Property.getValueOrDefault(modelGraphics._scale, time, defaultScale);
model.minimumPixelSize = Property.getValueOrDefault(modelGraphics._minimumPixelSize, time, defaultMinimumPixelSize);
model.maximumScale = Property.getValueOrUndefined(modelGraphics._maximumScale, time);
model.modelMatrix = Matrix4.clone(modelMatrix, model.modelMatrix);
}
return true;
Expand Down
Loading

0 comments on commit e084434

Please sign in to comment.