cesium 0.22.0 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/javascripts/Cesium.js +5 -2
- data/app/assets/javascripts/Core/Cartesian2.js +58 -0
- data/app/assets/javascripts/Core/Cartesian3.js +67 -7
- data/app/assets/javascripts/Core/Cartesian4.js +63 -0
- data/app/assets/javascripts/Core/CatmullRomSpline.js +183 -163
- data/app/assets/javascripts/Core/CorridorGeometry.js +2 -2
- data/app/assets/javascripts/Core/Ellipsoid.js +16 -0
- data/app/assets/javascripts/Core/ExtentGeometry.js +9 -2
- data/app/assets/javascripts/Core/ExtentOutlineGeometry.js +2 -2
- data/app/assets/javascripts/Core/GeometryPipeline.js +23 -23
- data/app/assets/javascripts/Core/HermiteSpline.js +260 -155
- data/app/assets/javascripts/Core/IndexDatatype.js +43 -34
- data/app/assets/javascripts/Core/LinearSpline.js +118 -0
- data/app/assets/javascripts/Core/Math.js +34 -3
- data/app/assets/javascripts/Core/Matrix2.js +26 -0
- data/app/assets/javascripts/Core/Matrix3.js +98 -0
- data/app/assets/javascripts/Core/Matrix4.js +42 -0
- data/app/assets/javascripts/Core/ObjectOrientedBoundingBox.js +396 -0
- data/app/assets/javascripts/Core/PolygonGeometry.js +87 -47
- data/app/assets/javascripts/Core/PolygonGeometryLibrary.js +20 -17
- data/app/assets/javascripts/Core/PolygonOutlineGeometry.js +68 -40
- data/app/assets/javascripts/Core/PolygonPipeline.js +19 -9
- data/app/assets/javascripts/Core/PrimitiveType.js +33 -36
- data/app/assets/javascripts/Core/Quaternion.js +147 -1
- data/app/assets/javascripts/Core/QuaternionSpline.js +160 -0
- data/app/assets/javascripts/Core/Spline.js +121 -0
- data/app/assets/javascripts/Core/Transforms.js +0 -2
- data/app/assets/javascripts/Core/loadArrayBuffer.js +5 -1
- data/app/assets/javascripts/Core/loadBlob.js +5 -1
- data/app/assets/javascripts/Core/loadText.js +4 -1
- data/app/assets/javascripts/Core/loadWithXhr.js +30 -14
- data/app/assets/javascripts/DynamicScene/PolylineOutlineMaterialProperty.js +2 -2
- data/app/assets/javascripts/Renderer/AutomaticUniforms.js +41 -41
- data/app/assets/javascripts/Renderer/Context.js +171 -201
- data/app/assets/javascripts/Renderer/CubeMapFace.js +2 -2
- data/app/assets/javascripts/Renderer/DrawCommand.js +2 -2
- data/app/assets/javascripts/Renderer/PixelFormat.js +22 -28
- data/app/assets/javascripts/Renderer/ShaderProgram.js +65 -46
- data/app/assets/javascripts/Renderer/Texture.js +1 -1
- data/app/assets/javascripts/Renderer/TextureMagnificationFilter.js +7 -9
- data/app/assets/javascripts/Renderer/TextureMinificationFilter.js +19 -25
- data/app/assets/javascripts/Renderer/TextureWrap.js +11 -13
- data/app/assets/javascripts/Renderer/UniformDatatype.js +29 -29
- data/app/assets/javascripts/Renderer/VertexArray.js +43 -35
- data/app/assets/javascripts/Scene/ArcGisMapServerImageryProvider.js +1 -2
- data/app/assets/javascripts/Scene/BillboardCollection.js +10 -1
- data/app/assets/javascripts/Scene/CameraFlightPath.js +58 -101
- data/app/assets/javascripts/Scene/CentralBody.js +1 -4
- data/app/assets/javascripts/Scene/CentralBodySurface.js +1 -2
- data/app/assets/javascripts/Scene/CesiumTerrainProvider.js +1 -2
- data/app/assets/javascripts/Scene/CustomSensorVolume.js +17 -3
- data/app/assets/javascripts/Scene/EllipsoidPrimitive.js +20 -5
- data/app/assets/javascripts/Scene/EllipsoidSurfaceAppearance.js +1 -2
- data/app/assets/javascripts/Scene/FrameState.js +1 -3
- data/app/assets/javascripts/Scene/GoogleEarthImageryProvider.js +2 -5
- data/app/assets/javascripts/Scene/OpenStreetMapImageryProvider.js +1 -2
- data/app/assets/javascripts/Scene/OrthographicFrustum.js +1 -2
- data/app/assets/javascripts/Scene/PerspectiveOffCenterFrustum.js +1 -2
- data/app/assets/javascripts/Scene/Polygon.js +1 -3
- data/app/assets/javascripts/Scene/Polyline.js +5 -2
- data/app/assets/javascripts/Scene/PolylineCollection.js +4 -6
- data/app/assets/javascripts/Scene/Primitive.js +19 -13
- data/app/assets/javascripts/Scene/PrimitivePipeline.js +1 -1
- data/app/assets/javascripts/Scene/Scene.js +7 -10
- data/app/assets/javascripts/Scene/SceneTransforms.js +1 -3
- data/app/assets/javascripts/Scene/SceneTransitioner.js +11 -11
- data/app/assets/javascripts/Scene/SingleTileImageryProvider.js +1 -2
- data/app/assets/javascripts/Scene/TexturePool.js +1 -1
- data/app/assets/javascripts/Scene/TileMapServiceImageryProvider.js +1 -2
- data/app/assets/javascripts/Scene/VRTheWorldTerrainProvider.js +1 -2
- data/app/assets/javascripts/Scene/ViewportQuad.js +1 -3
- data/app/assets/javascripts/Scene/WebMapServiceImageryProvider.js +1 -2
- data/app/assets/javascripts/ThirdParty/knockout-3.0.0.js +6 -3
- data/app/assets/javascripts/Widgets/CesiumWidget/CesiumWidget.js +4 -3
- data/app/assets/javascripts/Widgets/SceneModePicker/SceneModePickerViewModel.js +1 -1
- data/app/assets/javascripts/Widgets/Viewer/Viewer.js +5 -5
- data/app/assets/javascripts/Widgets/Viewer/viewerDragDropMixin.js +13 -13
- data/app/assets/javascripts/Widgets/Viewer/viewerDynamicObjectMixin.js +6 -6
- data/app/assets/javascripts/Widgets/widgets.css +1 -1
- data/lib/cesium/version.rb +1 -1
- metadata +6 -3
- data/app/assets/javascripts/Core/OrientationInterpolator.js +0 -106
|
@@ -229,8 +229,6 @@ define(['Core/defaultValue', 'Core/defined', 'Core/DeveloperError', 'Core/destro
|
|
|
229
229
|
this._defaultCubeMap = undefined;
|
|
230
230
|
|
|
231
231
|
this._us = us;
|
|
232
|
-
this._currentFramebuffer = undefined;
|
|
233
|
-
this._currentSp = undefined;
|
|
234
232
|
this._currentRenderState = rs;
|
|
235
233
|
this._maxFrameTextureUnitIndex = 0;
|
|
236
234
|
|
|
@@ -1138,11 +1136,11 @@ define(['Core/defaultValue', 'Core/defined', 'Core/DeveloperError', 'Core/destro
|
|
|
1138
1136
|
throw new DeveloperError('Invalid indexDatatype.');
|
|
1139
1137
|
}
|
|
1140
1138
|
|
|
1141
|
-
if ((indexDatatype
|
|
1139
|
+
if ((indexDatatype === IndexDatatype.UNSIGNED_INT) && !this.getElementIndexUint()) {
|
|
1142
1140
|
throw new RuntimeError('IndexDatatype.UNSIGNED_INT requires OES_element_index_uint, which is not supported on this system.');
|
|
1143
1141
|
}
|
|
1144
1142
|
|
|
1145
|
-
var bytesPerIndex = indexDatatype
|
|
1143
|
+
var bytesPerIndex = IndexDatatype.getSizeInBytes(indexDatatype);
|
|
1146
1144
|
|
|
1147
1145
|
var gl = this._gl;
|
|
1148
1146
|
var buffer = createBuffer(gl, gl.ELEMENT_ARRAY_BUFFER, typedArrayOrSizeInBytes, usage);
|
|
@@ -1256,41 +1254,41 @@ define(['Core/defaultValue', 'Core/defined', 'Core/DeveloperError', 'Core/destro
|
|
|
1256
1254
|
/**
|
|
1257
1255
|
* DOC_TBA.
|
|
1258
1256
|
*
|
|
1259
|
-
*
|
|
1257
|
+
* options.source can be {ImageData}, {HTMLImageElement}, {HTMLCanvasElement}, or {HTMLVideoElement}.
|
|
1260
1258
|
*
|
|
1261
1259
|
* @memberof Context
|
|
1262
1260
|
*
|
|
1263
1261
|
* @returns {Texture} DOC_TBA.
|
|
1264
1262
|
*
|
|
1265
|
-
* @exception {RuntimeError} When
|
|
1266
|
-
* @exception {RuntimeError} When
|
|
1267
|
-
* @exception {DeveloperError}
|
|
1268
|
-
* @exception {DeveloperError}
|
|
1263
|
+
* @exception {RuntimeError} When options.pixelFormat is DEPTH_COMPONENT or DEPTH_STENCIL, this WebGL implementation must support WEBGL_depth_texture.
|
|
1264
|
+
* @exception {RuntimeError} When options.pixelDatatype is FLOAT, this WebGL implementation must support the OES_texture_float extension.
|
|
1265
|
+
* @exception {DeveloperError} options is required.
|
|
1266
|
+
* @exception {DeveloperError} options requires a source field to create an initialized texture or width and height fields to create a blank texture.
|
|
1269
1267
|
* @exception {DeveloperError} Width must be greater than zero.
|
|
1270
1268
|
* @exception {DeveloperError} Width must be less than or equal to the maximum texture size.
|
|
1271
1269
|
* @exception {DeveloperError} Height must be greater than zero.
|
|
1272
1270
|
* @exception {DeveloperError} Height must be less than or equal to the maximum texture size.
|
|
1273
|
-
* @exception {DeveloperError} Invalid
|
|
1274
|
-
* @exception {DeveloperError} Invalid
|
|
1275
|
-
* @exception {DeveloperError} When
|
|
1276
|
-
* @exception {DeveloperError} When
|
|
1277
|
-
* @exception {DeveloperError} When
|
|
1271
|
+
* @exception {DeveloperError} Invalid options.pixelFormat.
|
|
1272
|
+
* @exception {DeveloperError} Invalid options.pixelDatatype.
|
|
1273
|
+
* @exception {DeveloperError} When options.pixelFormat is DEPTH_COMPONENT, options.pixelDatatype must be UNSIGNED_SHORT or UNSIGNED_INT.
|
|
1274
|
+
* @exception {DeveloperError} When options.pixelFormat is DEPTH_STENCIL, options.pixelDatatype must be UNSIGNED_INT_24_8_WEBGL.
|
|
1275
|
+
* @exception {DeveloperError} When options.pixelFormat is DEPTH_COMPONENT or DEPTH_STENCIL, source cannot be provided.
|
|
1278
1276
|
*
|
|
1279
1277
|
* @see Context#createTexture2DFromFramebuffer
|
|
1280
1278
|
* @see Context#createCubeMap
|
|
1281
1279
|
* @see Context#createSampler
|
|
1282
1280
|
*/
|
|
1283
|
-
Context.prototype.createTexture2D = function(
|
|
1284
|
-
if (!
|
|
1285
|
-
throw new DeveloperError('
|
|
1281
|
+
Context.prototype.createTexture2D = function(options) {
|
|
1282
|
+
if (!defined(options)) {
|
|
1283
|
+
throw new DeveloperError('options is required.');
|
|
1286
1284
|
}
|
|
1287
1285
|
|
|
1288
|
-
var source =
|
|
1289
|
-
var width = defined(source) ? source.width :
|
|
1290
|
-
var height = defined(source) ? source.height :
|
|
1286
|
+
var source = options.source;
|
|
1287
|
+
var width = defined(source) ? source.width : options.width;
|
|
1288
|
+
var height = defined(source) ? source.height : options.height;
|
|
1291
1289
|
|
|
1292
1290
|
if (!defined(width) || !defined(height)) {
|
|
1293
|
-
throw new DeveloperError('
|
|
1291
|
+
throw new DeveloperError('options requires a source field to create an initialized texture or width and height fields to create a blank texture.');
|
|
1294
1292
|
}
|
|
1295
1293
|
|
|
1296
1294
|
if (width <= 0) {
|
|
@@ -1309,43 +1307,43 @@ define(['Core/defaultValue', 'Core/defined', 'Core/DeveloperError', 'Core/destro
|
|
|
1309
1307
|
throw new DeveloperError('Height must be less than or equal to the maximum texture size (' + this._maximumTextureSize + '). Check getMaximumTextureSize().');
|
|
1310
1308
|
}
|
|
1311
1309
|
|
|
1312
|
-
var pixelFormat = defaultValue(
|
|
1310
|
+
var pixelFormat = defaultValue(options.pixelFormat, PixelFormat.RGBA);
|
|
1313
1311
|
if (!PixelFormat.validate(pixelFormat)) {
|
|
1314
|
-
throw new DeveloperError('Invalid
|
|
1312
|
+
throw new DeveloperError('Invalid options.pixelFormat.');
|
|
1315
1313
|
}
|
|
1316
1314
|
|
|
1317
|
-
var pixelDatatype = defaultValue(
|
|
1315
|
+
var pixelDatatype = defaultValue(options.pixelDatatype, PixelDatatype.UNSIGNED_BYTE);
|
|
1318
1316
|
if (!PixelDatatype.validate(pixelDatatype)) {
|
|
1319
|
-
throw new DeveloperError('Invalid
|
|
1317
|
+
throw new DeveloperError('Invalid options.pixelDatatype.');
|
|
1320
1318
|
}
|
|
1321
1319
|
|
|
1322
1320
|
if ((pixelDatatype === PixelDatatype.FLOAT) && !this.getFloatingPointTexture()) {
|
|
1323
|
-
throw new RuntimeError('When
|
|
1321
|
+
throw new RuntimeError('When options.pixelDatatype is FLOAT, this WebGL implementation must support the OES_texture_float extension.');
|
|
1324
1322
|
}
|
|
1325
1323
|
|
|
1326
1324
|
if ((pixelFormat === PixelFormat.DEPTH_COMPONENT) &&
|
|
1327
1325
|
((pixelDatatype !== PixelDatatype.UNSIGNED_SHORT) && (pixelDatatype !== PixelDatatype.UNSIGNED_INT))) {
|
|
1328
|
-
throw new DeveloperError('When
|
|
1326
|
+
throw new DeveloperError('When options.pixelFormat is DEPTH_COMPONENT, options.pixelDatatype must be UNSIGNED_SHORT or UNSIGNED_INT.');
|
|
1329
1327
|
}
|
|
1330
1328
|
|
|
1331
1329
|
if ((pixelFormat === PixelFormat.DEPTH_STENCIL) && (pixelDatatype !== PixelDatatype.UNSIGNED_INT_24_8_WEBGL)) {
|
|
1332
|
-
throw new DeveloperError('When
|
|
1330
|
+
throw new DeveloperError('When options.pixelFormat is DEPTH_STENCIL, options.pixelDatatype must be UNSIGNED_INT_24_8_WEBGL.');
|
|
1333
1331
|
}
|
|
1334
1332
|
|
|
1335
1333
|
if (PixelFormat.isDepthFormat(pixelFormat)) {
|
|
1336
|
-
if (source) {
|
|
1337
|
-
throw new DeveloperError('When
|
|
1334
|
+
if (defined(source)) {
|
|
1335
|
+
throw new DeveloperError('When options.pixelFormat is DEPTH_COMPONENT or DEPTH_STENCIL, source cannot be provided.');
|
|
1338
1336
|
}
|
|
1339
1337
|
|
|
1340
1338
|
if (!this.getDepthTexture()) {
|
|
1341
|
-
throw new RuntimeError('When
|
|
1339
|
+
throw new RuntimeError('When options.pixelFormat is DEPTH_COMPONENT or DEPTH_STENCIL, this WebGL implementation must support WEBGL_depth_texture. Check getDepthTexture().');
|
|
1342
1340
|
}
|
|
1343
1341
|
}
|
|
1344
1342
|
|
|
1345
1343
|
// Use premultiplied alpha for opaque textures should perform better on Chrome:
|
|
1346
1344
|
// http://media.tojicode.com/webglCamp4/#20
|
|
1347
|
-
var preMultiplyAlpha =
|
|
1348
|
-
var flipY = defaultValue(
|
|
1345
|
+
var preMultiplyAlpha = options.preMultiplyAlpha || pixelFormat === PixelFormat.RGB || pixelFormat === PixelFormat.LUMINANCE;
|
|
1346
|
+
var flipY = defaultValue(options.flipY, true);
|
|
1349
1347
|
|
|
1350
1348
|
var gl = this._gl;
|
|
1351
1349
|
var textureTarget = gl.TEXTURE_2D;
|
|
@@ -1354,12 +1352,12 @@ define(['Core/defaultValue', 'Core/defined', 'Core/DeveloperError', 'Core/destro
|
|
|
1354
1352
|
gl.activeTexture(gl.TEXTURE0);
|
|
1355
1353
|
gl.bindTexture(textureTarget, texture);
|
|
1356
1354
|
|
|
1357
|
-
if (source) {
|
|
1355
|
+
if (defined(source)) {
|
|
1358
1356
|
// TODO: _gl.pixelStorei(_gl._UNPACK_ALIGNMENT, 4);
|
|
1359
1357
|
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, preMultiplyAlpha);
|
|
1360
1358
|
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, flipY);
|
|
1361
1359
|
|
|
1362
|
-
if (source.arrayBufferView) {
|
|
1360
|
+
if (defined(source.arrayBufferView)) {
|
|
1363
1361
|
// Source: typed array
|
|
1364
1362
|
gl.texImage2D(textureTarget, 0, pixelFormat, width, height, 0, pixelFormat, pixelDatatype, source.arrayBufferView);
|
|
1365
1363
|
} else {
|
|
@@ -1452,61 +1450,61 @@ define(['Core/defaultValue', 'Core/defined', 'Core/DeveloperError', 'Core/destro
|
|
|
1452
1450
|
*
|
|
1453
1451
|
* @memberof Context
|
|
1454
1452
|
*
|
|
1455
|
-
* @param {PixelFormat} [
|
|
1456
|
-
* @param {Number} [
|
|
1457
|
-
* @param {Cartesian2} [
|
|
1458
|
-
* @param {Array} [
|
|
1459
|
-
* @param {Image} [
|
|
1453
|
+
* @param {PixelFormat} [options.pixelFormat = PixelFormat.RGBA] The pixel format of the texture.
|
|
1454
|
+
* @param {Number} [options.borderWidthInPixels = 1] The amount of spacing between adjacent images in pixels.
|
|
1455
|
+
* @param {Cartesian2} [options.initialSize = new Cartesian2(16.0, 16.0)] The initial side lengths of the texture.
|
|
1456
|
+
* @param {Array} [options.images=undefined] Array of {@link Image} to be added to the atlas. Same as calling addImages(images).
|
|
1457
|
+
* @param {Image} [options.image=undefined] Single image to be added to the atlas. Same as calling addImage(image).
|
|
1460
1458
|
*
|
|
1461
1459
|
* @returns {TextureAtlas} The new texture atlas.
|
|
1462
1460
|
*
|
|
1463
1461
|
* @see TextureAtlas
|
|
1464
1462
|
*/
|
|
1465
|
-
Context.prototype.createTextureAtlas = function(
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
return new TextureAtlas(
|
|
1463
|
+
Context.prototype.createTextureAtlas = function(options) {
|
|
1464
|
+
options = defaultValue(options, {});
|
|
1465
|
+
options.context = this;
|
|
1466
|
+
return new TextureAtlas(options);
|
|
1469
1467
|
};
|
|
1470
1468
|
|
|
1471
1469
|
/**
|
|
1472
1470
|
* DOC_TBA.
|
|
1473
1471
|
*
|
|
1474
|
-
*
|
|
1472
|
+
* options.source can be {ImageData}, {HTMLImageElement}, {HTMLCanvasElement}, or {HTMLVideoElement}.
|
|
1475
1473
|
*
|
|
1476
1474
|
* @memberof Context
|
|
1477
1475
|
*
|
|
1478
1476
|
* @returns {CubeMap} DOC_TBA.
|
|
1479
1477
|
*
|
|
1480
|
-
* @exception {RuntimeError} When
|
|
1481
|
-
* @exception {DeveloperError}
|
|
1482
|
-
* @exception {DeveloperError}
|
|
1483
|
-
* @exception {DeveloperError} Each face in
|
|
1484
|
-
* @exception {DeveloperError}
|
|
1478
|
+
* @exception {RuntimeError} When options.pixelDatatype is FLOAT, this WebGL implementation must support the OES_texture_float extension.
|
|
1479
|
+
* @exception {DeveloperError} options is required.
|
|
1480
|
+
* @exception {DeveloperError} options.source requires positiveX, negativeX, positiveY, negativeY, positiveZ, and negativeZ faces.
|
|
1481
|
+
* @exception {DeveloperError} Each face in options.sources must have the same width and height.
|
|
1482
|
+
* @exception {DeveloperError} options requires a source field to create an initialized cube map or width and height fields to create a blank cube map.
|
|
1485
1483
|
* @exception {DeveloperError} Width must equal height.
|
|
1486
1484
|
* @exception {DeveloperError} Width and height must be greater than zero.
|
|
1487
1485
|
* @exception {DeveloperError} Width and height must be less than or equal to the maximum cube map size.
|
|
1488
|
-
* @exception {DeveloperError} Invalid
|
|
1489
|
-
* @exception {DeveloperError}
|
|
1490
|
-
* @exception {DeveloperError} Invalid
|
|
1486
|
+
* @exception {DeveloperError} Invalid options.pixelFormat.
|
|
1487
|
+
* @exception {DeveloperError} options.pixelFormat cannot be DEPTH_COMPONENT or DEPTH_STENCIL.
|
|
1488
|
+
* @exception {DeveloperError} Invalid options.pixelDatatype.
|
|
1491
1489
|
*
|
|
1492
1490
|
* @see Context#createTexture2D
|
|
1493
1491
|
* @see Context#createTexture2DFromFramebuffer
|
|
1494
1492
|
* @see Context#createSampler
|
|
1495
1493
|
*/
|
|
1496
|
-
Context.prototype.createCubeMap = function(
|
|
1497
|
-
if (!
|
|
1498
|
-
throw new DeveloperError('
|
|
1494
|
+
Context.prototype.createCubeMap = function(options) {
|
|
1495
|
+
if (!defined(options)) {
|
|
1496
|
+
throw new DeveloperError('options is required.');
|
|
1499
1497
|
}
|
|
1500
1498
|
|
|
1501
|
-
var source =
|
|
1499
|
+
var source = options.source;
|
|
1502
1500
|
var width;
|
|
1503
1501
|
var height;
|
|
1504
1502
|
|
|
1505
|
-
if (source) {
|
|
1503
|
+
if (defined(source)) {
|
|
1506
1504
|
var faces = [source.positiveX, source.negativeX, source.positiveY, source.negativeY, source.positiveZ, source.negativeZ];
|
|
1507
1505
|
|
|
1508
1506
|
if (!faces[0] || !faces[1] || !faces[2] || !faces[3] || !faces[4] || !faces[5]) {
|
|
1509
|
-
throw new DeveloperError('
|
|
1507
|
+
throw new DeveloperError('options.source requires positiveX, negativeX, positiveY, negativeY, positiveZ, and negativeZ faces.');
|
|
1510
1508
|
}
|
|
1511
1509
|
|
|
1512
1510
|
width = faces[0].width;
|
|
@@ -1514,16 +1512,16 @@ define(['Core/defaultValue', 'Core/defined', 'Core/DeveloperError', 'Core/destro
|
|
|
1514
1512
|
|
|
1515
1513
|
for ( var i = 1; i < 6; ++i) {
|
|
1516
1514
|
if ((Number(faces[i].width) !== width) || (Number(faces[i].height) !== height)) {
|
|
1517
|
-
throw new DeveloperError('Each face in
|
|
1515
|
+
throw new DeveloperError('Each face in options.source must have the same width and height.');
|
|
1518
1516
|
}
|
|
1519
1517
|
}
|
|
1520
1518
|
} else {
|
|
1521
|
-
width =
|
|
1522
|
-
height =
|
|
1519
|
+
width = options.width;
|
|
1520
|
+
height = options.height;
|
|
1523
1521
|
}
|
|
1524
1522
|
|
|
1525
1523
|
if (!defined(width) || !defined(height)) {
|
|
1526
|
-
throw new DeveloperError('
|
|
1524
|
+
throw new DeveloperError('options requires a source field to create an initialized cube map or width and height fields to create a blank cube map.');
|
|
1527
1525
|
}
|
|
1528
1526
|
|
|
1529
1527
|
if (width !== height) {
|
|
@@ -1540,28 +1538,28 @@ define(['Core/defaultValue', 'Core/defined', 'Core/DeveloperError', 'Core/destro
|
|
|
1540
1538
|
throw new DeveloperError('Width and height must be less than or equal to the maximum cube map size (' + this._maximumCubeMapSize + '). Check getMaximumCubeMapSize().');
|
|
1541
1539
|
}
|
|
1542
1540
|
|
|
1543
|
-
var pixelFormat = defaultValue(
|
|
1541
|
+
var pixelFormat = defaultValue(options.pixelFormat, PixelFormat.RGBA);
|
|
1544
1542
|
if (!PixelFormat.validate(pixelFormat)) {
|
|
1545
|
-
throw new DeveloperError('Invalid
|
|
1543
|
+
throw new DeveloperError('Invalid options.pixelFormat.');
|
|
1546
1544
|
}
|
|
1547
1545
|
|
|
1548
1546
|
if (PixelFormat.isDepthFormat(pixelFormat)) {
|
|
1549
|
-
throw new DeveloperError('
|
|
1547
|
+
throw new DeveloperError('options.pixelFormat cannot be DEPTH_COMPONENT or DEPTH_STENCIL.');
|
|
1550
1548
|
}
|
|
1551
1549
|
|
|
1552
|
-
var pixelDatatype = defaultValue(
|
|
1550
|
+
var pixelDatatype = defaultValue(options.pixelDatatype, PixelDatatype.UNSIGNED_BYTE);
|
|
1553
1551
|
if (!PixelDatatype.validate(pixelDatatype)) {
|
|
1554
|
-
throw new DeveloperError('Invalid
|
|
1552
|
+
throw new DeveloperError('Invalid options.pixelDatatype.');
|
|
1555
1553
|
}
|
|
1556
1554
|
|
|
1557
1555
|
if ((pixelDatatype === PixelDatatype.FLOAT) && !this.getFloatingPointTexture()) {
|
|
1558
|
-
throw new RuntimeError('When
|
|
1556
|
+
throw new RuntimeError('When options.pixelDatatype is FLOAT, this WebGL implementation must support the OES_texture_float extension.');
|
|
1559
1557
|
}
|
|
1560
1558
|
|
|
1561
1559
|
// Use premultiplied alpha for opaque textures should perform better on Chrome:
|
|
1562
1560
|
// http://media.tojicode.com/webglCamp4/#20
|
|
1563
|
-
var preMultiplyAlpha =
|
|
1564
|
-
var flipY = defaultValue(
|
|
1561
|
+
var preMultiplyAlpha = options.preMultiplyAlpha || ((pixelFormat === PixelFormat.RGB) || (pixelFormat === PixelFormat.LUMINANCE));
|
|
1562
|
+
var flipY = defaultValue(options.flipY, true);
|
|
1565
1563
|
|
|
1566
1564
|
var gl = this._gl;
|
|
1567
1565
|
var textureTarget = gl.TEXTURE_CUBE_MAP;
|
|
@@ -1578,7 +1576,7 @@ define(['Core/defaultValue', 'Core/defined', 'Core/DeveloperError', 'Core/destro
|
|
|
1578
1576
|
}
|
|
1579
1577
|
}
|
|
1580
1578
|
|
|
1581
|
-
if (source) {
|
|
1579
|
+
if (defined(source)) {
|
|
1582
1580
|
// TODO: _gl.pixelStorei(_gl._UNPACK_ALIGNMENT, 4);
|
|
1583
1581
|
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, preMultiplyAlpha);
|
|
1584
1582
|
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, flipY);
|
|
@@ -1609,7 +1607,7 @@ define(['Core/defaultValue', 'Core/defined', 'Core/DeveloperError', 'Core/destro
|
|
|
1609
1607
|
*
|
|
1610
1608
|
* @memberof Context
|
|
1611
1609
|
*
|
|
1612
|
-
* @param {Object} [
|
|
1610
|
+
* @param {Object} [options] The initial framebuffer attachments as shown in Example 2. The possible properties are <code>colorTexture</code>, <code>colorRenderbuffer</code>, <code>depthTexture</code>, <code>depthRenderbuffer</code>, <code>stencilRenderbuffer</code>, <code>depthStencilTexture</code>, and <code>depthStencilRenderbuffer</code>.
|
|
1613
1611
|
*
|
|
1614
1612
|
* @returns {Framebuffer} The created framebuffer.
|
|
1615
1613
|
*
|
|
@@ -1655,8 +1653,8 @@ define(['Core/defaultValue', 'Core/defined', 'Core/DeveloperError', 'Core/destro
|
|
|
1655
1653
|
* })
|
|
1656
1654
|
* });
|
|
1657
1655
|
*/
|
|
1658
|
-
Context.prototype.createFramebuffer = function(
|
|
1659
|
-
return new Framebuffer(this._gl,
|
|
1656
|
+
Context.prototype.createFramebuffer = function(options) {
|
|
1657
|
+
return new Framebuffer(this._gl, options);
|
|
1660
1658
|
};
|
|
1661
1659
|
|
|
1662
1660
|
/**
|
|
@@ -1664,7 +1662,7 @@ define(['Core/defaultValue', 'Core/defined', 'Core/DeveloperError', 'Core/destro
|
|
|
1664
1662
|
*
|
|
1665
1663
|
* @memberof Context
|
|
1666
1664
|
*
|
|
1667
|
-
* @param {Object} [
|
|
1665
|
+
* @param {Object} [options] DOC_TBA.
|
|
1668
1666
|
*
|
|
1669
1667
|
* @returns {createRenderbuffer} DOC_TBA.
|
|
1670
1668
|
*
|
|
@@ -1676,13 +1674,13 @@ define(['Core/defaultValue', 'Core/defined', 'Core/DeveloperError', 'Core/destro
|
|
|
1676
1674
|
*
|
|
1677
1675
|
* @see Context#createFramebuffer
|
|
1678
1676
|
*/
|
|
1679
|
-
Context.prototype.createRenderbuffer = function(
|
|
1677
|
+
Context.prototype.createRenderbuffer = function(options) {
|
|
1680
1678
|
var gl = this._gl;
|
|
1681
1679
|
|
|
1682
|
-
|
|
1683
|
-
var format = defaultValue(
|
|
1684
|
-
var width = defined(
|
|
1685
|
-
var height = defined(
|
|
1680
|
+
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
|
|
1681
|
+
var format = defaultValue(options.format, RenderbufferFormat.RGBA4);
|
|
1682
|
+
var width = defined(options.width) ? options.width : gl.drawingBufferWidth;
|
|
1683
|
+
var height = defined(options.height) ? options.height : gl.drawingBufferHeight;
|
|
1686
1684
|
|
|
1687
1685
|
if (!RenderbufferFormat.validate(format)) {
|
|
1688
1686
|
throw new DeveloperError('Invalid format.');
|
|
@@ -1872,10 +1870,10 @@ define(['Core/defaultValue', 'Core/defined', 'Core/DeveloperError', 'Core/destro
|
|
|
1872
1870
|
*/
|
|
1873
1871
|
Context.prototype.createSampler = function(sampler) {
|
|
1874
1872
|
var s = {
|
|
1875
|
-
wrapS : sampler.wrapS
|
|
1876
|
-
wrapT : sampler.wrapT
|
|
1877
|
-
minificationFilter : sampler.minificationFilter
|
|
1878
|
-
magnificationFilter : sampler.magnificationFilter
|
|
1873
|
+
wrapS : defaultValue(sampler.wrapS, TextureWrap.CLAMP_TO_EDGE),
|
|
1874
|
+
wrapT : defaultValue(sampler.wrapT, TextureWrap.CLAMP_TO_EDGE),
|
|
1875
|
+
minificationFilter : defaultValue(sampler.minificationFilter, TextureMinificationFilter.LINEAR),
|
|
1876
|
+
magnificationFilter : defaultValue(sampler.magnificationFilter, TextureMagnificationFilter.LINEAR),
|
|
1879
1877
|
maximumAnisotropy : (defined(sampler.maximumAnisotropy)) ? sampler.maximumAnisotropy : 1.0
|
|
1880
1878
|
};
|
|
1881
1879
|
|
|
@@ -1902,9 +1900,9 @@ define(['Core/defaultValue', 'Core/defined', 'Core/DeveloperError', 'Core/destro
|
|
|
1902
1900
|
return s;
|
|
1903
1901
|
};
|
|
1904
1902
|
|
|
1905
|
-
|
|
1906
|
-
if (
|
|
1907
|
-
var gl =
|
|
1903
|
+
function validateFramebuffer(context, framebuffer) {
|
|
1904
|
+
if (context._validateFB) {
|
|
1905
|
+
var gl = context._gl;
|
|
1908
1906
|
var status = gl.checkFramebufferStatus(gl.FRAMEBUFFER);
|
|
1909
1907
|
|
|
1910
1908
|
if (status !== gl.FRAMEBUFFER_COMPLETE) {
|
|
@@ -1928,7 +1926,7 @@ define(['Core/defaultValue', 'Core/defined', 'Core/DeveloperError', 'Core/destro
|
|
|
1928
1926
|
throw new DeveloperError(message);
|
|
1929
1927
|
}
|
|
1930
1928
|
}
|
|
1931
|
-
}
|
|
1929
|
+
}
|
|
1932
1930
|
|
|
1933
1931
|
function applyRenderState(context, renderState, passState) {
|
|
1934
1932
|
var previousState = context._currentRenderState;
|
|
@@ -1996,7 +1994,7 @@ define(['Core/defaultValue', 'Core/defined', 'Core/DeveloperError', 'Core/destro
|
|
|
1996
1994
|
|
|
1997
1995
|
if (defined(framebuffer)) {
|
|
1998
1996
|
framebuffer._bind();
|
|
1999
|
-
this
|
|
1997
|
+
validateFramebuffer(this, framebuffer);
|
|
2000
1998
|
}
|
|
2001
1999
|
|
|
2002
2000
|
gl.clear(bitmask);
|
|
@@ -2006,6 +2004,78 @@ define(['Core/defaultValue', 'Core/defined', 'Core/DeveloperError', 'Core/destro
|
|
|
2006
2004
|
}
|
|
2007
2005
|
};
|
|
2008
2006
|
|
|
2007
|
+
function beginDraw(context, framebuffer, drawCommand, passState) {
|
|
2008
|
+
var rs = defined(drawCommand.renderState) ? drawCommand.renderState : context._defaultRenderState;
|
|
2009
|
+
|
|
2010
|
+
if (defined(framebuffer) && rs.depthTest) {
|
|
2011
|
+
if (rs.depthTest.enabled && !framebuffer.hasDepthAttachment()) {
|
|
2012
|
+
throw new DeveloperError('The depth test can not be enabled (drawCommand.renderState.depthTest.enabled) because the framebuffer (drawCommand.framebuffer) does not have a depth or depth-stencil renderbuffer.');
|
|
2013
|
+
}
|
|
2014
|
+
}
|
|
2015
|
+
|
|
2016
|
+
///////////////////////////////////////////////////////////////////////
|
|
2017
|
+
|
|
2018
|
+
if (defined(framebuffer)) {
|
|
2019
|
+
framebuffer._bind();
|
|
2020
|
+
validateFramebuffer(context, framebuffer);
|
|
2021
|
+
}
|
|
2022
|
+
|
|
2023
|
+
var sp = drawCommand.shaderProgram;
|
|
2024
|
+
sp._bind();
|
|
2025
|
+
context._maxFrameTextureUnitIndex = Math.max(context._maxFrameTextureUnitIndex, sp.maximumTextureUnitIndex);
|
|
2026
|
+
|
|
2027
|
+
applyRenderState(context, rs, passState);
|
|
2028
|
+
}
|
|
2029
|
+
|
|
2030
|
+
function continueDraw(context, drawCommand) {
|
|
2031
|
+
var primitiveType = drawCommand.primitiveType;
|
|
2032
|
+
var va = drawCommand.vertexArray;
|
|
2033
|
+
var offset = drawCommand.offset;
|
|
2034
|
+
var count = drawCommand.count;
|
|
2035
|
+
|
|
2036
|
+
if (!PrimitiveType.validate(primitiveType)) {
|
|
2037
|
+
throw new DeveloperError('drawCommand.primitiveType is required and must be valid.');
|
|
2038
|
+
}
|
|
2039
|
+
|
|
2040
|
+
if (!defined(va)) {
|
|
2041
|
+
throw new DeveloperError('drawCommand.vertexArray is required.');
|
|
2042
|
+
}
|
|
2043
|
+
|
|
2044
|
+
if (offset < 0) {
|
|
2045
|
+
throw new DeveloperError('drawCommand.offset must be omitted or greater than or equal to zero.');
|
|
2046
|
+
}
|
|
2047
|
+
|
|
2048
|
+
if (count < 0) {
|
|
2049
|
+
throw new DeveloperError('drawCommand.count must be omitted or greater than or equal to zero.');
|
|
2050
|
+
}
|
|
2051
|
+
|
|
2052
|
+
context._us.setModel(defaultValue(drawCommand.modelMatrix, Matrix4.IDENTITY));
|
|
2053
|
+
drawCommand.shaderProgram._setUniforms(drawCommand.uniformMap, context._us, context._validateSP);
|
|
2054
|
+
|
|
2055
|
+
var indexBuffer = va.getIndexBuffer();
|
|
2056
|
+
|
|
2057
|
+
if (defined(indexBuffer)) {
|
|
2058
|
+
offset = offset * indexBuffer.getBytesPerIndex(); // offset in vertices to offset in bytes
|
|
2059
|
+
count = defaultValue(count, indexBuffer.getNumberOfIndices());
|
|
2060
|
+
|
|
2061
|
+
va._bind();
|
|
2062
|
+
context._gl.drawElements(primitiveType, count, indexBuffer.getIndexDatatype(), offset);
|
|
2063
|
+
va._unBind();
|
|
2064
|
+
} else {
|
|
2065
|
+
count = defaultValue(count, va.numberOfVertices);
|
|
2066
|
+
|
|
2067
|
+
va._bind();
|
|
2068
|
+
context._gl.drawArrays(primitiveType, offset, count);
|
|
2069
|
+
va._unBind();
|
|
2070
|
+
}
|
|
2071
|
+
}
|
|
2072
|
+
|
|
2073
|
+
function endDraw(framebuffer) {
|
|
2074
|
+
if (defined(framebuffer)) {
|
|
2075
|
+
framebuffer._unBind();
|
|
2076
|
+
}
|
|
2077
|
+
}
|
|
2078
|
+
|
|
2009
2079
|
/**
|
|
2010
2080
|
* Executes the specified draw command.
|
|
2011
2081
|
*
|
|
@@ -2021,6 +2091,7 @@ define(['Core/defaultValue', 'Core/defined', 'Core/DeveloperError', 'Core/destro
|
|
|
2021
2091
|
* @exception {DeveloperError} drawCommand.shaderProgram is required.
|
|
2022
2092
|
* @exception {DeveloperError} drawCommand.vertexArray is required.
|
|
2023
2093
|
* @exception {DeveloperError} drawCommand.offset must be omitted or greater than or equal to zero.
|
|
2094
|
+
* @exception {DeveloperError} drawCommand.count must be omitted or greater than or equal to zero.
|
|
2024
2095
|
* @exception {DeveloperError} Program validation failed.
|
|
2025
2096
|
* @exception {DeveloperError} Framebuffer is not complete.
|
|
2026
2097
|
*
|
|
@@ -2051,122 +2122,21 @@ define(['Core/defaultValue', 'Core/defined', 'Core/DeveloperError', 'Core/destro
|
|
|
2051
2122
|
* @see Context#createRenderState
|
|
2052
2123
|
*/
|
|
2053
2124
|
Context.prototype.draw = function(drawCommand, passState) {
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
this.continueDraw(drawCommand);
|
|
2057
|
-
this.endDraw();
|
|
2058
|
-
};
|
|
2059
|
-
|
|
2060
|
-
/**
|
|
2061
|
-
* DOC_TBA
|
|
2062
|
-
*
|
|
2063
|
-
* @memberof Context
|
|
2064
|
-
*/
|
|
2065
|
-
Context.prototype.beginDraw = function(command, passState) {
|
|
2066
|
-
if (!defined(command)) {
|
|
2067
|
-
throw new DeveloperError('command is required.');
|
|
2125
|
+
if (!defined(drawCommand)) {
|
|
2126
|
+
throw new DeveloperError('drawCommand is required.');
|
|
2068
2127
|
}
|
|
2069
2128
|
|
|
2070
|
-
if (!defined(
|
|
2071
|
-
throw new DeveloperError('
|
|
2129
|
+
if (!defined(drawCommand.shaderProgram)) {
|
|
2130
|
+
throw new DeveloperError('drawCommand.shaderProgram is required.');
|
|
2072
2131
|
}
|
|
2073
2132
|
|
|
2133
|
+
passState = defaultValue(passState, this._defaultPassState);
|
|
2074
2134
|
// The command's framebuffer takes presidence over the pass' framebuffer, e.g., for off-screen rendering.
|
|
2075
|
-
var framebuffer = defaultValue(
|
|
2076
|
-
var sp = command.shaderProgram;
|
|
2077
|
-
var rs = (defined(command.renderState)) ? command.renderState : this._defaultRenderState;
|
|
2078
|
-
|
|
2079
|
-
if ((defined(framebuffer)) && rs.depthTest) {
|
|
2080
|
-
if (rs.depthTest.enabled && !framebuffer.hasDepthAttachment()) {
|
|
2081
|
-
throw new DeveloperError('The depth test can not be enabled (command.renderState.depthTest.enabled) because the framebuffer (command.framebuffer) does not have a depth or depth-stencil renderbuffer.');
|
|
2082
|
-
}
|
|
2083
|
-
}
|
|
2084
|
-
|
|
2085
|
-
///////////////////////////////////////////////////////////////////////
|
|
2086
|
-
|
|
2087
|
-
applyRenderState(this, rs, passState);
|
|
2088
|
-
|
|
2089
|
-
if (defined(framebuffer)) {
|
|
2090
|
-
framebuffer._bind();
|
|
2091
|
-
this._validateFramebuffer(framebuffer);
|
|
2092
|
-
}
|
|
2093
|
-
sp._bind();
|
|
2094
|
-
|
|
2095
|
-
this._currentFramebuffer = framebuffer;
|
|
2096
|
-
this._currentSp = sp;
|
|
2097
|
-
this._maxFrameTextureUnitIndex = Math.max(this._maxFrameTextureUnitIndex, sp.maximumTextureUnitIndex);
|
|
2098
|
-
};
|
|
2099
|
-
|
|
2100
|
-
/**
|
|
2101
|
-
* DOC_TBA
|
|
2102
|
-
*
|
|
2103
|
-
* @memberof Context
|
|
2104
|
-
*/
|
|
2105
|
-
Context.prototype.continueDraw = function(command) {
|
|
2106
|
-
var sp = this._currentSp;
|
|
2107
|
-
if (!defined(sp)) {
|
|
2108
|
-
throw new DeveloperError('beginDraw must be called before continueDraw.');
|
|
2109
|
-
}
|
|
2110
|
-
|
|
2111
|
-
if (!defined(command)) {
|
|
2112
|
-
throw new DeveloperError('command is required.');
|
|
2113
|
-
}
|
|
2114
|
-
|
|
2115
|
-
var primitiveType = command.primitiveType;
|
|
2116
|
-
if (!PrimitiveType.validate(primitiveType)) {
|
|
2117
|
-
throw new DeveloperError('command.primitiveType is required and must be valid.');
|
|
2118
|
-
}
|
|
2135
|
+
var framebuffer = defaultValue(drawCommand.framebuffer, passState.framebuffer);
|
|
2119
2136
|
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
var va = command.vertexArray;
|
|
2125
|
-
var indexBuffer = va.getIndexBuffer();
|
|
2126
|
-
|
|
2127
|
-
var offset = command.offset;
|
|
2128
|
-
var count = command.count;
|
|
2129
|
-
var hasIndexBuffer = defined(indexBuffer);
|
|
2130
|
-
|
|
2131
|
-
if (hasIndexBuffer) {
|
|
2132
|
-
offset = (offset || 0) * indexBuffer.getBytesPerIndex(); // in bytes
|
|
2133
|
-
count = count || indexBuffer.getNumberOfIndices();
|
|
2134
|
-
} else {
|
|
2135
|
-
offset = offset || 0; // in vertices
|
|
2136
|
-
count = count || va._getNumberOfVertices();
|
|
2137
|
-
}
|
|
2138
|
-
|
|
2139
|
-
if (offset < 0) {
|
|
2140
|
-
throw new DeveloperError('command.offset must be omitted or greater than or equal to zero.');
|
|
2141
|
-
}
|
|
2142
|
-
|
|
2143
|
-
if (count > 0) {
|
|
2144
|
-
this._us.setModel(defaultValue(command.modelMatrix, Matrix4.IDENTITY));
|
|
2145
|
-
sp._setUniforms(command.uniformMap, this._us, this._validateSP);
|
|
2146
|
-
|
|
2147
|
-
va._bind();
|
|
2148
|
-
|
|
2149
|
-
if (hasIndexBuffer) {
|
|
2150
|
-
this._gl.drawElements(primitiveType.value, count, indexBuffer.getIndexDatatype().value, offset);
|
|
2151
|
-
} else {
|
|
2152
|
-
this._gl.drawArrays(primitiveType.value, offset, count);
|
|
2153
|
-
}
|
|
2154
|
-
|
|
2155
|
-
va._unBind();
|
|
2156
|
-
}
|
|
2157
|
-
};
|
|
2158
|
-
|
|
2159
|
-
/**
|
|
2160
|
-
* DOC_TBA
|
|
2161
|
-
*
|
|
2162
|
-
* @memberof Context
|
|
2163
|
-
*/
|
|
2164
|
-
Context.prototype.endDraw = function() {
|
|
2165
|
-
if (defined(this._currentFramebuffer)) {
|
|
2166
|
-
this._currentFramebuffer._unBind();
|
|
2167
|
-
this._currentFramebuffer = undefined;
|
|
2168
|
-
}
|
|
2169
|
-
this._currentSp = undefined;
|
|
2137
|
+
beginDraw(this, framebuffer, drawCommand, passState);
|
|
2138
|
+
continueDraw(this, drawCommand);
|
|
2139
|
+
endDraw(framebuffer);
|
|
2170
2140
|
};
|
|
2171
2141
|
|
|
2172
2142
|
/**
|
|
@@ -2216,7 +2186,7 @@ define(['Core/defaultValue', 'Core/defined', 'Core/DeveloperError', 'Core/destro
|
|
|
2216
2186
|
|
|
2217
2187
|
if (framebuffer) {
|
|
2218
2188
|
framebuffer._bind();
|
|
2219
|
-
this
|
|
2189
|
+
validateFramebuffer(this, framebuffer);
|
|
2220
2190
|
}
|
|
2221
2191
|
|
|
2222
2192
|
gl.readPixels(x, y, width, height, gl.RGBA, gl.UNSIGNED_BYTE, pixels);
|