-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3203 from AnalyticalGraphicsInc/point-geometry-ap…
…pearance Added PointGeometry and PointAppearance
- Loading branch information
Showing
14 changed files
with
679 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
/*global define*/ | ||
define([ | ||
'./BoundingSphere', | ||
'./ComponentDatatype', | ||
'./defaultValue', | ||
'./defined', | ||
'./DeveloperError', | ||
'./Geometry', | ||
'./GeometryAttribute', | ||
'./GeometryAttributes', | ||
'./PrimitiveType' | ||
], function( | ||
BoundingSphere, | ||
ComponentDatatype, | ||
defaultValue, | ||
defined, | ||
DeveloperError, | ||
Geometry, | ||
GeometryAttribute, | ||
GeometryAttributes, | ||
PrimitiveType) { | ||
"use strict"; | ||
|
||
/** | ||
* Describes a collection of points made up of positions and colors. | ||
* | ||
* @alias PointGeometry | ||
* @constructor | ||
* | ||
* @param {Object} options Object with the following properties: | ||
* @param {TypedArray} options.positionsTypedArray The position values of the points stored in a typed array. Positions are stored as packed (x, y, z) floats. | ||
* @param {TypedArray} options.colorsTypedArray The color values of the points stored in a typed array. Colors are stored as packed (r, g, b) unsigned bytes. | ||
* @param {BoundingSphere} [options.boundingSphere] Optional precomputed bounding sphere to save computation time. | ||
* | ||
* @example | ||
* // Create a PointGeometry with two points | ||
* var points = new Cesium.PointGeometry({ | ||
* positionsTypedArray : new Float32Array([0.0, 0.0, 0.0, 1.0, 1.0, 1.0]), | ||
* colorsTypedArray : new Uint8Array([255, 0, 0, 127, 127, 127]), | ||
* boundingSphere : boundingSphere | ||
* }); | ||
* var geometry = Cesium.PointGeometry.createGeometry(points); | ||
* | ||
* @private | ||
*/ | ||
var PointGeometry = function(options) { | ||
options = defaultValue(options, defaultValue.EMPTY_OBJECT); | ||
|
||
//>>includeStart('debug', pragmas.debug); | ||
if (!defined(options.positionsTypedArray)) { | ||
throw new DeveloperError('options.positionsTypedArray is required.'); | ||
} | ||
if (!defined(options.colorsTypedArray)) { | ||
throw new DeveloperError('options.colorsTypedArray is required'); | ||
} | ||
//>>includeEnd('debug'); | ||
|
||
this._positionsTypedArray = options.positionsTypedArray; | ||
this._colorsTypedArray = options.colorsTypedArray; | ||
this._boundingSphere = BoundingSphere.clone(options.boundingSphere); | ||
|
||
this._workerName = 'createPointGeometry'; | ||
}; | ||
|
||
/** | ||
* Computes the geometric representation a point collection, including its vertices and a bounding sphere. | ||
* | ||
* @param {PointGeometry} pointGeometry A description of the points. | ||
* @returns {Geometry} The computed vertices. | ||
*/ | ||
PointGeometry.createGeometry = function(pointGeometry) { | ||
var positions = pointGeometry._positionsTypedArray; | ||
var componentByteLength = positions.byteLength / positions.length; | ||
var componentDatatype = componentByteLength === 4 ? ComponentDatatype.FLOAT : ComponentDatatype.DOUBLE; | ||
|
||
var attributes = new GeometryAttributes(); | ||
attributes.position = new GeometryAttribute({ | ||
componentDatatype : componentDatatype, | ||
componentsPerAttribute : 3, | ||
values : positions | ||
}); | ||
|
||
attributes.color = new GeometryAttribute({ | ||
componentDatatype : ComponentDatatype.UNSIGNED_BYTE, | ||
componentsPerAttribute : 3, | ||
values : pointGeometry._colorsTypedArray, | ||
normalize : true | ||
}); | ||
|
||
// User provided bounding sphere to save computation time. | ||
var boundingSphere = pointGeometry._boundingSphere; | ||
if (!defined(boundingSphere)) { | ||
boundingSphere = BoundingSphere.fromVertices(positions); | ||
} | ||
|
||
return new Geometry({ | ||
attributes : attributes, | ||
primitiveType : PrimitiveType.POINTS, | ||
boundingSphere : boundingSphere | ||
}); | ||
}; | ||
|
||
return PointGeometry; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.