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

Outline geometry #1021

Merged
merged 31 commits into from
Aug 15, 2013
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
712 changes: 585 additions & 127 deletions Apps/Sandcastle/gallery/Geometry and Appearances.html

Large diffs are not rendered by default.

Binary file modified Apps/Sandcastle/gallery/Geometry and Appearances.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 @@ -8,6 +8,10 @@ Beta Releases

* Breaking changes:
* `DataSourceDisplay` now requires a `DataSourceCollection` to be passed into its constructor.
* Replaced `ExtentGeometry` parameters for extruded extent to make it consistent with other Geometries.
* options.extrudedOptions.height -> options.extrudedHeight
* options.extrudedOptions.closeTop -> options.closeBottom
* options.extrudedOptions.closeBottom -> options.closeTop
* Fixed broken surface rendering in Columbus View when using the `EllipsoidTerrainProvider`.
* Optimized polyline bounding spheres.
* Upgraded Knockout from version 2.2.1 to 2.3.0.
Expand All @@ -17,6 +21,7 @@ Beta Releases
* Added `PolylinePipeline.scaleToGeodeticHeight`.
* `Viewer` now automatically sets its clock to that of the first added `DataSource`, regardless of how it was added to the `DataSourceCollection`. Previously, this was only done for dropped files by `viewerDragDropMixin`.
* Added the ability to specify a `minimumTerrainLevel` and `maximumTerrainLevel` when constructing an `ImageryLayer`. The layer will only be shown for terrain tiles within the specified range.
* Added outline geometry [#1021](https://github.com/AnalyticalGraphicsInc/cesium/pull/1021)

### b19 - 2013-08-01

Expand Down
198 changes: 198 additions & 0 deletions Source/Core/BoxOutlineGeometry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
/*global define*/
define([
'./defined',
'./DeveloperError',
'./Cartesian3',
'./ComponentDatatype',
'./PrimitiveType',
'./defaultValue',
'./BoundingSphere',
'./GeometryAttribute',
'./GeometryAttributes'
], function(
defined,
DeveloperError,
Cartesian3,
ComponentDatatype,
PrimitiveType,
defaultValue,
BoundingSphere,
GeometryAttribute,
GeometryAttributes) {
"use strict";

var diffScratch = new Cartesian3();

/**
* A {@link Geometry} that represents vertices and indices for the edges of a cube centered at the origin.
*
* @alias BoxGeometryOutline
* @constructor
*
* @param {Cartesian3} options.minimumCorner The minimum x, y, and z coordinates of the box.
* @param {Cartesian3} options.maximumCorner The maximum x, y, and z coordinates of the box.
*
* @exception {DeveloperError} options.minimumCorner is required.
* @exception {DeveloperError} options.maximumCorner is required.
*
* @example
* var box = new BoxGeometryOutline({
* maximumCorner : new Cartesian3(250000.0, 250000.0, 250000.0),
* minimumCorner : new Cartesian3(-250000.0, -250000.0, -250000.0)
* });
*/
var BoxGeometryOutline = function(options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);

var min = options.minimumCorner;
var max = options.maximumCorner;

if (!defined(min)) {
throw new DeveloperError('options.minimumCorner is required.');
}

if (!defined(max)) {
throw new DeveloperError('options.maximumCorner is required');
}

var attributes = new GeometryAttributes();
var indices = new Uint16Array(12 * 2);
var positions = new Float64Array(8 * 3);

positions[0] = min.x;
positions[1] = min.y;
positions[2] = min.z;
positions[3] = max.x;
positions[4] = min.y;
positions[5] = min.z;
positions[6] = max.x;
positions[7] = max.y;
positions[8] = min.z;
positions[9] = min.x;
positions[10] = max.y;
positions[11] = min.z;

positions[12] = min.x;
positions[13] = min.y;
positions[14] = max.z;
positions[15] = max.x;
positions[16] = min.y;
positions[17] = max.z;
positions[18] = max.x;
positions[19] = max.y;
positions[20] = max.z;
positions[21] = min.x;
positions[22] = max.y;
positions[23] = max.z;

attributes.position = new GeometryAttribute({
componentDatatype : ComponentDatatype.DOUBLE,
componentsPerAttribute : 3,
values : positions
});

// top
indices[0] = 4;
indices[1] = 5;
indices[2] = 5;
indices[3] = 6;
indices[4] = 6;
indices[5] = 7;
indices[6] = 7;
indices[7] = 4;

// bottom
indices[8] = 0;
indices[9] = 1;
indices[10] = 1;
indices[11] = 2;
indices[12] = 2;
indices[13] = 3;
indices[14] = 3;
indices[15] = 0;

// left
indices[16] = 0;
indices[17] = 4;
indices[18] = 1;
indices[19] = 5;

//right
indices[20] = 2;
indices[21] = 6;
indices[22] = 3;
indices[23] = 7;

var diff = Cartesian3.subtract(max, min, diffScratch);
var radius = diff.magnitude() * 0.5;

/**
* An object containing {@link GeometryAttribute} position property.
*
* @type GeometryAttributes
*
* @see Geometry#attributes
*/
this.attributes = attributes;

/**
* Index data that, along with {@link Geometry#primitiveType}, determines the primitives in the geometry.
*
* @type Array
*/
this.indices = indices;

/**
* The type of primitives in the geometry. For this geometry, it is {@link PrimitiveType.LINES}.
*
* @type PrimitiveType
*/
this.primitiveType = PrimitiveType.LINES;

/**
* A tight-fitting bounding sphere that encloses the vertices of the geometry.
*
* @type BoundingSphere
*/
this.boundingSphere = new BoundingSphere(Cartesian3.ZERO, radius);
};

/**
* Creates vertices and indices for the edges of a cube centered at the origin given its dimensions.
* @memberof BoxGeometryOutline
*
* @param {Cartesian3} options.dimensions The width, depth, and height of the box stored in the x, y, and z coordinates of the <code>Cartesian3</code>, respectively.
*
* @exception {DeveloperError} options.dimensions is required.
* @exception {DeveloperError} All dimensions components must be greater than or equal to zero.
*
* @example
* var box = BoxGeometryOutline.fromDimensions({
* dimensions : new Cartesian3(500000.0, 500000.0, 500000.0)
* });
*/
BoxGeometryOutline.fromDimensions = function(options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);

var dimensions = options.dimensions;
if (!defined(dimensions)) {
throw new DeveloperError('options.dimensions is required.');
}

if (dimensions.x < 0 || dimensions.y < 0 || dimensions.z < 0) {
throw new DeveloperError('All dimensions components must be greater than or equal to zero.');
}

var corner = dimensions.multiplyByScalar(0.5);
var min = corner.negate();
var max = corner;

var newOptions = {
minimumCorner : min,
maximumCorner : max
};
return new BoxGeometryOutline(newOptions);
};

return BoxGeometryOutline;
});
2 changes: 0 additions & 2 deletions Source/Core/CircleGeometry.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
/*global define*/
define([
'./clone',
'./defaultValue',
'./defined',
'./DeveloperError',
'./EllipseGeometry'
], function(
clone,
defaultValue,
defined,
DeveloperError,
Expand Down
98 changes: 98 additions & 0 deletions Source/Core/CircleOutlineGeometry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/*global define*/
define([
'./defaultValue',
'./defined',
'./DeveloperError',
'./EllipseOutlineGeometry'
], function(
defaultValue,
defined,
DeveloperError,
EllipseOutlineGeometry) {
"use strict";

/**
* A {@link Geometry} that represents vertices and indices for the outline of a circle on the ellipsoid.
*
* @alias CircleOutlineGeometry
* @constructor
*
* @param {Cartesian3} options.center The circle's center point in the fixed frame.
* @param {Number} options.radius The radius in meters.
* @param {Ellipsoid} [options.ellipsoid=Ellipsoid.WGS84] The ellipsoid the circle will be on.
* @param {Number} [options.height=0.0] The height above the ellipsoid.
* @param {Number} [options.granularity=0.02] The angular distance between points on the circle in radians.
* @param {Number} [options.extrudedHeight=0.0] The height of the extrusion relative to the ellipsoid.
* @param {Number} [options.numberOfVerticalLines = 16] Number of lines to draw between the top and bottom of an extruded circle.
*
* @exception {DeveloperError} center is required.
* @exception {DeveloperError} radius is required.
* @exception {DeveloperError} radius must be greater than zero.
* @exception {DeveloperError} granularity must be greater than zero.
*
* @example
* // Create a circle.
* var ellipsoid = Ellipsoid.WGS84;
* var circle = new CircleOutlineGeometry({
* ellipsoid : ellipsoid,
* center : ellipsoid.cartographicToCartesian(Cartographic.fromDegrees(-75.59777, 40.03883)),
* radius : 100000.0
* });
*/
var CircleOutlineGeometry = function(options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
var radius = options.radius;

if (!defined(radius)) {
throw new DeveloperError('radius is required.');
}

if (radius <= 0.0) {
throw new DeveloperError('radius must be greater than zero.');
}

var ellipseGeometryOptions = {
center : options.center,
semiMajorAxis : radius,
semiMinorAxis : radius,
ellipsoid : options.ellipsoid,
height : options.height,
extrudedHeight : options.extrudedHeight,
granularity : options.granularity,
numberOfVerticalLines : options.numberOfVerticalLines
};
var ellipseGeometry = new EllipseOutlineGeometry(ellipseGeometryOptions);

/**
* An object containing {@link GeometryAttribute} position property.
*
* @type GeometryAttributes
*
* @see Geometry#attributes
*/
this.attributes = ellipseGeometry.attributes;

/**
* Index data that, along with {@link Geometry#primitiveType}, determines the primitives in the geometry.
*
* @type Array
*/
this.indices = ellipseGeometry.indices;

/**
* The type of primitives in the geometry. For this geometry, it is {@link PrimitiveType.LINES}.
*
* @type PrimitiveType
*/
this.primitiveType = ellipseGeometry.primitiveType;

/**
* A tight-fitting bounding sphere that encloses the vertices of the geometry.
*
* @type BoundingSphere
*/
this.boundingSphere = ellipseGeometry.boundingSphere;
};

return CircleOutlineGeometry;
});
Loading