Skip to content

Commit 26b4c49

Browse files
committed
Merge pull request #1021 from hpinkos/outlineGeometry
Outline geometry
2 parents 98476c1 + 1781d03 commit 26b4c49

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+4686
-945
lines changed

Apps/Sandcastle/gallery/Geometry and Appearances.html

+585-127
Large diffs are not rendered by default.
Loading

CHANGES.md

+5
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ Beta Releases
88

99
* Breaking changes:
1010
* `DataSourceDisplay` now requires a `DataSourceCollection` to be passed into its constructor.
11+
* Replaced `ExtentGeometry` parameters for extruded extent to make it consistent with other Geometries.
12+
* options.extrudedOptions.height -> options.extrudedHeight
13+
* options.extrudedOptions.closeTop -> options.closeBottom
14+
* options.extrudedOptions.closeBottom -> options.closeTop
1115
* Fixed broken surface rendering in Columbus View when using the `EllipsoidTerrainProvider`.
1216
* Optimized polyline bounding spheres.
1317
* Upgraded Knockout from version 2.2.1 to 2.3.0.
@@ -17,6 +21,7 @@ Beta Releases
1721
* Added `PolylinePipeline.scaleToGeodeticHeight`.
1822
* `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`.
1923
* 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.
24+
* Added outline geometry [#1021](https://github.com/AnalyticalGraphicsInc/cesium/pull/1021)
2025

2126
### b19 - 2013-08-01
2227

Source/Core/BoxOutlineGeometry.js

+198
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
1+
/*global define*/
2+
define([
3+
'./defined',
4+
'./DeveloperError',
5+
'./Cartesian3',
6+
'./ComponentDatatype',
7+
'./PrimitiveType',
8+
'./defaultValue',
9+
'./BoundingSphere',
10+
'./GeometryAttribute',
11+
'./GeometryAttributes'
12+
], function(
13+
defined,
14+
DeveloperError,
15+
Cartesian3,
16+
ComponentDatatype,
17+
PrimitiveType,
18+
defaultValue,
19+
BoundingSphere,
20+
GeometryAttribute,
21+
GeometryAttributes) {
22+
"use strict";
23+
24+
var diffScratch = new Cartesian3();
25+
26+
/**
27+
* A {@link Geometry} that represents vertices and indices for the edges of a cube centered at the origin.
28+
*
29+
* @alias BoxGeometryOutline
30+
* @constructor
31+
*
32+
* @param {Cartesian3} options.minimumCorner The minimum x, y, and z coordinates of the box.
33+
* @param {Cartesian3} options.maximumCorner The maximum x, y, and z coordinates of the box.
34+
*
35+
* @exception {DeveloperError} options.minimumCorner is required.
36+
* @exception {DeveloperError} options.maximumCorner is required.
37+
*
38+
* @example
39+
* var box = new BoxGeometryOutline({
40+
* maximumCorner : new Cartesian3(250000.0, 250000.0, 250000.0),
41+
* minimumCorner : new Cartesian3(-250000.0, -250000.0, -250000.0)
42+
* });
43+
*/
44+
var BoxGeometryOutline = function(options) {
45+
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
46+
47+
var min = options.minimumCorner;
48+
var max = options.maximumCorner;
49+
50+
if (!defined(min)) {
51+
throw new DeveloperError('options.minimumCorner is required.');
52+
}
53+
54+
if (!defined(max)) {
55+
throw new DeveloperError('options.maximumCorner is required');
56+
}
57+
58+
var attributes = new GeometryAttributes();
59+
var indices = new Uint16Array(12 * 2);
60+
var positions = new Float64Array(8 * 3);
61+
62+
positions[0] = min.x;
63+
positions[1] = min.y;
64+
positions[2] = min.z;
65+
positions[3] = max.x;
66+
positions[4] = min.y;
67+
positions[5] = min.z;
68+
positions[6] = max.x;
69+
positions[7] = max.y;
70+
positions[8] = min.z;
71+
positions[9] = min.x;
72+
positions[10] = max.y;
73+
positions[11] = min.z;
74+
75+
positions[12] = min.x;
76+
positions[13] = min.y;
77+
positions[14] = max.z;
78+
positions[15] = max.x;
79+
positions[16] = min.y;
80+
positions[17] = max.z;
81+
positions[18] = max.x;
82+
positions[19] = max.y;
83+
positions[20] = max.z;
84+
positions[21] = min.x;
85+
positions[22] = max.y;
86+
positions[23] = max.z;
87+
88+
attributes.position = new GeometryAttribute({
89+
componentDatatype : ComponentDatatype.DOUBLE,
90+
componentsPerAttribute : 3,
91+
values : positions
92+
});
93+
94+
// top
95+
indices[0] = 4;
96+
indices[1] = 5;
97+
indices[2] = 5;
98+
indices[3] = 6;
99+
indices[4] = 6;
100+
indices[5] = 7;
101+
indices[6] = 7;
102+
indices[7] = 4;
103+
104+
// bottom
105+
indices[8] = 0;
106+
indices[9] = 1;
107+
indices[10] = 1;
108+
indices[11] = 2;
109+
indices[12] = 2;
110+
indices[13] = 3;
111+
indices[14] = 3;
112+
indices[15] = 0;
113+
114+
// left
115+
indices[16] = 0;
116+
indices[17] = 4;
117+
indices[18] = 1;
118+
indices[19] = 5;
119+
120+
//right
121+
indices[20] = 2;
122+
indices[21] = 6;
123+
indices[22] = 3;
124+
indices[23] = 7;
125+
126+
var diff = Cartesian3.subtract(max, min, diffScratch);
127+
var radius = diff.magnitude() * 0.5;
128+
129+
/**
130+
* An object containing {@link GeometryAttribute} position property.
131+
*
132+
* @type GeometryAttributes
133+
*
134+
* @see Geometry#attributes
135+
*/
136+
this.attributes = attributes;
137+
138+
/**
139+
* Index data that, along with {@link Geometry#primitiveType}, determines the primitives in the geometry.
140+
*
141+
* @type Array
142+
*/
143+
this.indices = indices;
144+
145+
/**
146+
* The type of primitives in the geometry. For this geometry, it is {@link PrimitiveType.LINES}.
147+
*
148+
* @type PrimitiveType
149+
*/
150+
this.primitiveType = PrimitiveType.LINES;
151+
152+
/**
153+
* A tight-fitting bounding sphere that encloses the vertices of the geometry.
154+
*
155+
* @type BoundingSphere
156+
*/
157+
this.boundingSphere = new BoundingSphere(Cartesian3.ZERO, radius);
158+
};
159+
160+
/**
161+
* Creates vertices and indices for the edges of a cube centered at the origin given its dimensions.
162+
* @memberof BoxGeometryOutline
163+
*
164+
* @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.
165+
*
166+
* @exception {DeveloperError} options.dimensions is required.
167+
* @exception {DeveloperError} All dimensions components must be greater than or equal to zero.
168+
*
169+
* @example
170+
* var box = BoxGeometryOutline.fromDimensions({
171+
* dimensions : new Cartesian3(500000.0, 500000.0, 500000.0)
172+
* });
173+
*/
174+
BoxGeometryOutline.fromDimensions = function(options) {
175+
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
176+
177+
var dimensions = options.dimensions;
178+
if (!defined(dimensions)) {
179+
throw new DeveloperError('options.dimensions is required.');
180+
}
181+
182+
if (dimensions.x < 0 || dimensions.y < 0 || dimensions.z < 0) {
183+
throw new DeveloperError('All dimensions components must be greater than or equal to zero.');
184+
}
185+
186+
var corner = dimensions.multiplyByScalar(0.5);
187+
var min = corner.negate();
188+
var max = corner;
189+
190+
var newOptions = {
191+
minimumCorner : min,
192+
maximumCorner : max
193+
};
194+
return new BoxGeometryOutline(newOptions);
195+
};
196+
197+
return BoxGeometryOutline;
198+
});

Source/Core/CircleGeometry.js

-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
/*global define*/
22
define([
3-
'./clone',
43
'./defaultValue',
54
'./defined',
65
'./DeveloperError',
76
'./EllipseGeometry'
87
], function(
9-
clone,
108
defaultValue,
119
defined,
1210
DeveloperError,

Source/Core/CircleOutlineGeometry.js

+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
/*global define*/
2+
define([
3+
'./defaultValue',
4+
'./defined',
5+
'./DeveloperError',
6+
'./EllipseOutlineGeometry'
7+
], function(
8+
defaultValue,
9+
defined,
10+
DeveloperError,
11+
EllipseOutlineGeometry) {
12+
"use strict";
13+
14+
/**
15+
* A {@link Geometry} that represents vertices and indices for the outline of a circle on the ellipsoid.
16+
*
17+
* @alias CircleOutlineGeometry
18+
* @constructor
19+
*
20+
* @param {Cartesian3} options.center The circle's center point in the fixed frame.
21+
* @param {Number} options.radius The radius in meters.
22+
* @param {Ellipsoid} [options.ellipsoid=Ellipsoid.WGS84] The ellipsoid the circle will be on.
23+
* @param {Number} [options.height=0.0] The height above the ellipsoid.
24+
* @param {Number} [options.granularity=0.02] The angular distance between points on the circle in radians.
25+
* @param {Number} [options.extrudedHeight=0.0] The height of the extrusion relative to the ellipsoid.
26+
* @param {Number} [options.numberOfVerticalLines = 16] Number of lines to draw between the top and bottom of an extruded circle.
27+
*
28+
* @exception {DeveloperError} center is required.
29+
* @exception {DeveloperError} radius is required.
30+
* @exception {DeveloperError} radius must be greater than zero.
31+
* @exception {DeveloperError} granularity must be greater than zero.
32+
*
33+
* @example
34+
* // Create a circle.
35+
* var ellipsoid = Ellipsoid.WGS84;
36+
* var circle = new CircleOutlineGeometry({
37+
* ellipsoid : ellipsoid,
38+
* center : ellipsoid.cartographicToCartesian(Cartographic.fromDegrees(-75.59777, 40.03883)),
39+
* radius : 100000.0
40+
* });
41+
*/
42+
var CircleOutlineGeometry = function(options) {
43+
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
44+
var radius = options.radius;
45+
46+
if (!defined(radius)) {
47+
throw new DeveloperError('radius is required.');
48+
}
49+
50+
if (radius <= 0.0) {
51+
throw new DeveloperError('radius must be greater than zero.');
52+
}
53+
54+
var ellipseGeometryOptions = {
55+
center : options.center,
56+
semiMajorAxis : radius,
57+
semiMinorAxis : radius,
58+
ellipsoid : options.ellipsoid,
59+
height : options.height,
60+
extrudedHeight : options.extrudedHeight,
61+
granularity : options.granularity,
62+
numberOfVerticalLines : options.numberOfVerticalLines
63+
};
64+
var ellipseGeometry = new EllipseOutlineGeometry(ellipseGeometryOptions);
65+
66+
/**
67+
* An object containing {@link GeometryAttribute} position property.
68+
*
69+
* @type GeometryAttributes
70+
*
71+
* @see Geometry#attributes
72+
*/
73+
this.attributes = ellipseGeometry.attributes;
74+
75+
/**
76+
* Index data that, along with {@link Geometry#primitiveType}, determines the primitives in the geometry.
77+
*
78+
* @type Array
79+
*/
80+
this.indices = ellipseGeometry.indices;
81+
82+
/**
83+
* The type of primitives in the geometry. For this geometry, it is {@link PrimitiveType.LINES}.
84+
*
85+
* @type PrimitiveType
86+
*/
87+
this.primitiveType = ellipseGeometry.primitiveType;
88+
89+
/**
90+
* A tight-fitting bounding sphere that encloses the vertices of the geometry.
91+
*
92+
* @type BoundingSphere
93+
*/
94+
this.boundingSphere = ellipseGeometry.boundingSphere;
95+
};
96+
97+
return CircleOutlineGeometry;
98+
});

0 commit comments

Comments
 (0)