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

Misc changes and helpers from 3d-tiles #5249

Merged
merged 3 commits into from
May 8, 2017
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
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
var primitives = scene.primitives;
var solidWhite = Cesium.ColorGeometryInstanceAttribute.fromColor(Cesium.Color.WHITE);

// Combine instances for an rectangle, polygon, ellipse, and circle into a single primitive.
// Combine instances for a rectangle, polygon, ellipse, and circle into a single primitive.

var rectangle = Cesium.Rectangle.fromDegrees(-92.0, 20.0, -86.0, 27.0);
var rectangleInstance = new Cesium.GeometryInstance({
Expand Down
26 changes: 13 additions & 13 deletions Documentation/Contributors/CodingGuide/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -290,12 +290,12 @@ Cesium3DTileset.prototype.update = function(frameState) {
updateTiles(this, frameState);
};

function processTiles(tiles3D, frameState) {
var tiles = tiles3D._processingQueue;
function processTiles(tileset, frameState) {
var tiles = tileset._processingQueue;
var length = tiles.length;

for (var i = length - 1; i >= 0; --i) {
tiles[i].process(tiles3D, frameState);
tiles[i].process(tileset, frameState);
}
}
```
Expand Down Expand Up @@ -571,12 +571,12 @@ Cesium3DTileset.prototype.update = function(frameState) {
// ...
};

Cesium3DTileset.prototype._processTiles(tiles3D, frameState) {
Cesium3DTileset.prototype._processTiles(tileset, frameState) {
var tiles = this._processingQueue;
var length = tiles.length;

for (var i = length - 1; i >= 0; --i) {
tiles[i].process(tiles3D, frameState);
tiles[i].process(tileset, frameState);
}
}
```
Expand All @@ -587,12 +587,12 @@ Cesium3DTileset.prototype.update = function(frameState) {
// ...
};

function processTiles(tiles3D, frameState) {
var tiles = tiles3D._processingQueue;
function processTiles(tileset, frameState) {
var tiles = tileset._processingQueue;
var length = tiles.length;

for (var i = length - 1; i >= 0; --i) {
tiles[i].process(tiles3D, frameState);
tiles[i].process(tileset, frameState);
}
}
```
Expand Down Expand Up @@ -672,13 +672,13 @@ Model.prototype.update = function(frameState) {

It is convenient for the constructor function to be at the top of the file even if it requires that helper functions rely on **hoisting**, for example, `Cesium3DTileset.js`,
```javascript
function loadTilesJson(tileset, tilesJson, done) {
function loadTileset(tileset, tilesJson, done) {
// ...
}

function Cesium3DTileset(options) {
// ...
loadTilesJson(this, options.url, function(data) {
loadTileset(this, options.url, function(data) {
// ...
});
};
Expand All @@ -687,16 +687,16 @@ is better written as
```javascript
function Cesium3DTileset(options) {
// ...
loadTilesJson(this, options.url, function(data) {
loadTileset(this, options.url, function(data) {
// ...
});
};

function loadTilesJson(tileset, tilesJson, done) {
function loadTileset(tileset, tilesJson, done) {
// ...
}
```
even though it relies on implicitly hoisting the `loadTilesJson` function to the top of the file.
even though it relies on implicitly hoisting the `loadTileset` function to the top of the file.

## Design

Expand Down
2 changes: 1 addition & 1 deletion Documentation/Contributors/TestingGuide/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ it('can create a billboard using a URL', function() {
return pollToPromise(function() {
return b.ready;
}).then(function() {
expect(scene.renderForSpecs()).toEqual([0, 255, 0, 255]);
expect(scene).toRender([0, 255, 0, 255]);
});
});
```
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/BoundingRectangle.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ define([
var fromRectangleLowerLeft = new Cartographic();
var fromRectangleUpperRight = new Cartographic();
/**
* Computes a bounding rectangle from an rectangle.
* Computes a bounding rectangle from a rectangle.
*
* @param {Rectangle} rectangle The valid rectangle used to create a bounding rectangle.
* @param {Object} [projection=GeographicProjection] The projection used to project the rectangle into 2D.
Expand Down
6 changes: 3 additions & 3 deletions Source/Core/BoundingSphere.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ define([
var fromRectangle2DNortheast = new Cartographic();

/**
* Computes a bounding sphere from an rectangle projected in 2D.
* Computes a bounding sphere from a rectangle projected in 2D.
*
* @param {Rectangle} rectangle The rectangle around which to create a bounding sphere.
* @param {Object} [projection=GeographicProjection] The projection used to project the rectangle into 2D.
Expand All @@ -233,7 +233,7 @@ define([
};

/**
* Computes a bounding sphere from an rectangle projected in 2D. The bounding sphere accounts for the
* Computes a bounding sphere from a rectangle projected in 2D. The bounding sphere accounts for the
* object's minimum and maximum heights over the rectangle.
*
* @param {Rectangle} rectangle The rectangle around which to create a bounding sphere.
Expand Down Expand Up @@ -279,7 +279,7 @@ define([
var fromRectangle3DScratch = [];

/**
* Computes a bounding sphere from an rectangle in 3D. The bounding sphere is created using a subsample of points
* Computes a bounding sphere from a rectangle in 3D. The bounding sphere is created using a subsample of points
* on the ellipsoid and contained in the rectangle. It may not be accurate for all rectangles on all types of ellipsoids.
*
* @param {Rectangle} rectangle The valid rectangle used to create a bounding sphere.
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/EllipsoidalOccluder.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ define([
var subsampleScratch = [];

/**
* Computes a point that can be used for horizon culling of an rectangle. If the point is below
* Computes a point that can be used for horizon culling of a rectangle. If the point is below
* the horizon, the ellipsoid-conforming rectangle is guaranteed to be below the horizon as well.
* The returned point is expressed in the ellipsoid-scaled space and is suitable for use with
* {@link EllipsoidalOccluder#isScaledSpacePointVisible}.
Expand Down
4 changes: 2 additions & 2 deletions Source/Core/GeographicTilingScheme.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ define([
};

/**
* Transforms an rectangle specified in geodetic radians to the native coordinate system
* Transforms a rectangle specified in geodetic radians to the native coordinate system
* of this tiling scheme.
*
* @param {Rectangle} rectangle The rectangle to transform.
Expand Down Expand Up @@ -137,7 +137,7 @@ define([
};

/**
* Converts tile x, y coordinates and level to an rectangle expressed in the native coordinates
* Converts tile x, y coordinates and level to a rectangle expressed in the native coordinates
* of the tiling scheme.
*
* @param {Number} x The integer x coordinate of the tile.
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/HeightmapTessellator.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ define([
* @param {Number} options.width The width of the heightmap, in height samples.
* @param {Number} options.height The height of the heightmap, in height samples.
* @param {Number} options.skirtHeight The height of skirts to drape at the edges of the heightmap.
* @param {Rectangle} options.nativeRectangle An rectangle in the native coordinates of the heightmap's projection. For
* @param {Rectangle} options.nativeRectangle A rectangle in the native coordinates of the heightmap's projection. For
* a heightmap with a geographic projection, this is degrees. For the web mercator
* projection, this is meters.
* @param {Number} [options.exaggeration=1.0] The scale used to exaggerate the terrain.
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/IndexDatatype.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ define([
* or <code>Uint32Array</code> depending on the number of vertices.
*
* @param {Number} numberOfVertices Number of vertices that the indices will reference.
* @param {Any} indicesLengthOrArray Passed through to the typed array constructor.
* @param {*} indicesLengthOrArray Passed through to the typed array constructor.
* @returns {Uint16Array|Uint32Array} A <code>Uint16Array</code> or <code>Uint32Array</code> constructed with <code>indicesLengthOrArray</code>.
*
* @example
Expand Down
8 changes: 4 additions & 4 deletions Source/Core/Occluder.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ define([
* var occluder = new Cesium.Occluder(littleSphere, cameraPosition);
* var point = new Cesium.Cartesian3(0, 0, -3);
* occluder.isPointVisible(point); //returns true
*
*
* @see Occluder#computeVisibility
*/
Occluder.prototype.isPointVisible = function(occludee) {
Expand Down Expand Up @@ -206,7 +206,7 @@ define([
* var occluder = new Cesium.Occluder(littleSphere, cameraPosition);
* var bigSphere = new Cesium.BoundingSphere(new Cesium.Cartesian3(0, 0, -3), 1);
* occluder.isBoundingSphereVisible(bigSphere); //returns true
*
*
* @see Occluder#computeVisibility
*/
Occluder.prototype.isBoundingSphereVisible = function(occludee) {
Expand Down Expand Up @@ -265,7 +265,7 @@ define([
* var cameraPosition = new Cesium.Cartesian3(0, 0, 0);
* var occluder = new Cesium.Occluder(sphere1, cameraPosition);
* occluder.computeVisibility(sphere2); //returns Visibility.NONE
*
*
* @see Occluder#isVisible
*/
Occluder.prototype.computeVisibility = function(occludeeBS) {
Expand Down Expand Up @@ -406,7 +406,7 @@ define([

var computeOccludeePointFromRectangleScratch = [];
/**
* Computes a point that can be used as the occludee position to the visibility functions from an rectangle.
* Computes a point that can be used as the occludee position to the visibility functions from a rectangle.
*
* @param {Rectangle} rectangle The rectangle used to create a bounding sphere.
* @param {Ellipsoid} [ellipsoid=Ellipsoid.WGS84] The ellipsoid used to determine positions of the rectangle.
Expand Down
35 changes: 34 additions & 1 deletion Source/Core/PixelFormat.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
/*global define*/
define([
'../Renderer/PixelDatatype',
'./freezeObject',
'./WebGLConstants'
], function(
PixelDatatype,
freezeObject,
WebGLConstants) {
'use strict';
Expand Down Expand Up @@ -141,6 +143,26 @@ define([
*/
RGB_ETC1 : WebGLConstants.COMPRESSED_RGB_ETC1_WEBGL,

/**
* @private
*/
componentsLength : function(pixelFormat) {
switch (pixelFormat) {
// Many GPUs store RGB as RGBA internally
// https://devtalk.nvidia.com/default/topic/699479/general-graphics-programming/rgb-auto-converted-to-rgba/post/4142379/#4142379
case PixelFormat.RGB:
case PixelFormat.RGBA:
return 4;
case PixelFormat.LUMINANCE_ALPHA:
return 2;
case PixelFormat.ALPHA:
case PixelFormat.LUMINANCE:
return 1;
default:
return 1;
}
},

/**
* @private
*/
Expand Down Expand Up @@ -227,7 +249,7 @@ define([
/**
* @private
*/
compressedTextureSize : function(pixelFormat, width, height) {
compressedTextureSizeInBytes : function(pixelFormat, width, height) {
switch (pixelFormat) {
case PixelFormat.RGB_DXT1:
case PixelFormat.RGBA_DXT1:
Expand All @@ -249,6 +271,17 @@ define([
default:
return 0;
}
},

/**
* @private
*/
textureSizeInBytes : function(pixelFormat, pixelDatatype, width, height) {
var componentsLength = PixelFormat.componentsLength(pixelFormat);
if (PixelDatatype.isPacked(pixelDatatype)) {
componentsLength = 1;
}
return componentsLength * PixelDatatype.sizeInBytes(pixelDatatype) * width * height;
}
};

Expand Down
16 changes: 8 additions & 8 deletions Source/Core/Rectangle.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ define([
};

/**
* Creates an rectangle given the boundary longitude and latitude in degrees.
* Creates a rectangle given the boundary longitude and latitude in degrees.
*
* @param {Number} [west=0.0] The westernmost longitude in degrees in the range [-180.0, 180.0].
* @param {Number} [south=0.0] The southernmost latitude in degrees in the range [-90.0, 90.0].
Expand Down Expand Up @@ -208,7 +208,7 @@ define([
};

/**
* Creates an rectangle given the boundary longitude and latitude in radians.
* Creates a rectangle given the boundary longitude and latitude in radians.
*
* @param {Number} [west=0.0] The westernmost longitude in radians in the range [-Math.PI, Math.PI].
* @param {Number} [south=0.0] The southernmost latitude in radians in the range [-Math.PI/2, Math.PI/2].
Expand Down Expand Up @@ -458,7 +458,7 @@ define([
};

/**
* Computes the southwest corner of an rectangle.
* Computes the southwest corner of a rectangle.
*
* @param {Rectangle} rectangle The rectangle for which to find the corner
* @param {Cartographic} [result] The object onto which to store the result.
Expand All @@ -479,7 +479,7 @@ define([
};

/**
* Computes the northwest corner of an rectangle.
* Computes the northwest corner of a rectangle.
*
* @param {Rectangle} rectangle The rectangle for which to find the corner
* @param {Cartographic} [result] The object onto which to store the result.
Expand All @@ -500,7 +500,7 @@ define([
};

/**
* Computes the northeast corner of an rectangle.
* Computes the northeast corner of a rectangle.
*
* @param {Rectangle} rectangle The rectangle for which to find the corner
* @param {Cartographic} [result] The object onto which to store the result.
Expand All @@ -521,7 +521,7 @@ define([
};

/**
* Computes the southeast corner of an rectangle.
* Computes the southeast corner of a rectangle.
*
* @param {Rectangle} rectangle The rectangle for which to find the corner
* @param {Cartographic} [result] The object onto which to store the result.
Expand All @@ -542,7 +542,7 @@ define([
};

/**
* Computes the center of an rectangle.
* Computes the center of a rectangle.
*
* @param {Rectangle} rectangle The rectangle for which to find the center
* @param {Cartographic} [result] The object onto which to store the result.
Expand Down Expand Up @@ -776,7 +776,7 @@ define([

var subsampleLlaScratch = new Cartographic();
/**
* Samples an rectangle so that it includes a list of Cartesian points suitable for passing to
* Samples a rectangle so that it includes a list of Cartesian points suitable for passing to
* {@link BoundingSphere#fromPoints}. Sampling is necessary to account
* for rectangles that cover the poles or cross the equator.
*
Expand Down
4 changes: 2 additions & 2 deletions Source/Core/RectangleGeometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ define([
* @demo {@link http://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=Rectangle.html|Cesium Sandcastle Rectangle Demo}
*
* @example
* // 1. create an rectangle
* // 1. create a rectangle
* var rectangle = new Cesium.RectangleGeometry({
* ellipsoid : Cesium.Ellipsoid.WGS84,
* rectangle : Cesium.Rectangle.fromDegrees(-80.0, 39.0, -74.0, 42.0),
Expand Down Expand Up @@ -809,7 +809,7 @@ define([
var quaternionScratch = new Quaternion();
var centerScratch = new Cartographic();
/**
* Computes the geometric representation of an rectangle, including its vertices, indices, and a bounding sphere.
* Computes the geometric representation of a rectangle, including its vertices, indices, and a bounding sphere.
*
* @param {RectangleGeometry} rectangleGeometry A description of the rectangle.
* @returns {Geometry|undefined} The computed vertices and indices.
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/RectangleOutlineGeometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ define([

var nwScratch = new Cartographic();
/**
* Computes the geometric representation of an outline of an rectangle, including its vertices, indices, and a bounding sphere.
* Computes the geometric representation of an outline of a rectangle, including its vertices, indices, and a bounding sphere.
*
* @param {RectangleOutlineGeometry} rectangleGeometry A description of the rectangle outline.
* @returns {Geometry|undefined} The computed vertices and indices.
Expand Down
4 changes: 2 additions & 2 deletions Source/Core/TilingScheme.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ define([
TilingScheme.prototype.getNumberOfYTilesAtLevel = DeveloperError.throwInstantiationError;

/**
* Transforms an rectangle specified in geodetic radians to the native coordinate system
* Transforms a rectangle specified in geodetic radians to the native coordinate system
* of this tiling scheme.
* @function
*
Expand All @@ -88,7 +88,7 @@ define([
TilingScheme.prototype.rectangleToNativeRectangle = DeveloperError.throwInstantiationError;

/**
* Converts tile x, y coordinates and level to an rectangle expressed in the native coordinates
* Converts tile x, y coordinates and level to a rectangle expressed in the native coordinates
* of the tiling scheme.
* @function
*
Expand Down
Loading