diff --git a/.eslintrc.json b/.eslintrc.json index 5559ce5b6e87..bf1cede7498c 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,6 +1,7 @@ { "extends": "./Tools/eslint-config-cesium/browser.js", "rules": { + "no-lonely-if": "error", "no-unused-vars": ["error", {"vars": "all", "args": "none"}] } } diff --git a/Source/Core/Cartesian3.js b/Source/Core/Cartesian3.js index db2595cbbe35..6fa2ea2b3546 100644 --- a/Source/Core/Cartesian3.js +++ b/Source/Core/Cartesian3.js @@ -674,12 +674,10 @@ define([ } else { result = Cartesian3.clone(Cartesian3.UNIT_Z, result); } + } else if (f.y <= f.z) { + result = Cartesian3.clone(Cartesian3.UNIT_Y, result); } else { - if (f.y <= f.z) { - result = Cartesian3.clone(Cartesian3.UNIT_Y, result); - } else { - result = Cartesian3.clone(Cartesian3.UNIT_Z, result); - } + result = Cartesian3.clone(Cartesian3.UNIT_Z, result); } return result; diff --git a/Source/Core/GoogleEarthEnterpriseMetadata.js b/Source/Core/GoogleEarthEnterpriseMetadata.js index d5ee5dd6185b..a6203bd46069 100644 --- a/Source/Core/GoogleEarthEnterpriseMetadata.js +++ b/Source/Core/GoogleEarthEnterpriseMetadata.js @@ -211,10 +211,8 @@ define([ if (!isBitSet(x, bitmask)) { // Right to left digit |= 1; } - } else { - if (isBitSet(x, bitmask)) { // Left to right - digit |= 1; - } + } else if (isBitSet(x, bitmask)) { // Left to right + digit |= 1; } quadkey += digit; diff --git a/Source/Core/TimeIntervalCollection.js b/Source/Core/TimeIntervalCollection.js index 0dd6e21784aa..711494dff82f 100644 --- a/Source/Core/TimeIntervalCollection.js +++ b/Source/Core/TimeIntervalCollection.js @@ -326,17 +326,15 @@ define([ index = binarySearch(intervals, interval, compareIntervalStartTimes); if (index < 0) { index = ~index; - } else { + } else if (index > 0 && interval.isStartIncluded && intervals[index - 1].isStartIncluded && intervals[index - 1].start.equals(interval.start)) { // interval's start date exactly equals the start date of at least one interval in the collection. // It could actually equal the start date of two intervals if one of them does not actually // include the date. In that case, the binary search could have found either. We need to // look at the surrounding intervals and their IsStartIncluded properties in order to make sure // we're working with the correct interval. - if (index > 0 && interval.isStartIncluded && intervals[index - 1].isStartIncluded && intervals[index - 1].start.equals(interval.start)) { - --index; - } else if (index < intervals.length && !interval.isStartIncluded && intervals[index].isStartIncluded && intervals[index].start.equals(interval.start)) { - ++index; - } + --index; + } else if (index < intervals.length && !interval.isStartIncluded && intervals[index].isStartIncluded && intervals[index].start.equals(interval.start)) { + ++index; } if (index > 0) { diff --git a/Source/Core/loadKTX.js b/Source/Core/loadKTX.js index cd8600b10d14..19be19fb4ce4 100644 --- a/Source/Core/loadKTX.js +++ b/Source/Core/loadKTX.js @@ -195,10 +195,8 @@ define([ if (numberOfMipmapLevels === 0) { throw new RuntimeError('Generating mipmaps for a compressed texture is unsupported.'); } - } else { - if (glBaseInternalFormat !== glFormat) { - throw new RuntimeError('The base internal format must be the same as the format for uncompressed textures.'); - } + } else if (glBaseInternalFormat !== glFormat) { + throw new RuntimeError('The base internal format must be the same as the format for uncompressed textures.'); } if (pixelDepth !== 0) { diff --git a/Source/DataSources/GeometryVisualizer.js b/Source/DataSources/GeometryVisualizer.js index ad62ca0c7be7..7c9b30b568b4 100644 --- a/Source/DataSources/GeometryVisualizer.js +++ b/Source/DataSources/GeometryVisualizer.js @@ -108,20 +108,16 @@ define([ if (updater.fillEnabled) { if (updater.onTerrain) { that._groundColorBatch.add(time, updater); - } else { - if (updater.isClosed) { - if (updater.fillMaterialProperty instanceof ColorMaterialProperty) { - that._closedColorBatches[index].add(time, updater); - } else { - that._closedMaterialBatches[index].add(time, updater); - } + } else if (updater.isClosed) { + if (updater.fillMaterialProperty instanceof ColorMaterialProperty) { + that._closedColorBatches[index].add(time, updater); } else { - if (updater.fillMaterialProperty instanceof ColorMaterialProperty) { - that._openColorBatches[index].add(time, updater); - } else { - that._openMaterialBatches[index].add(time, updater); - } + that._closedMaterialBatches[index].add(time, updater); } + } else if (updater.fillMaterialProperty instanceof ColorMaterialProperty) { + that._openColorBatches[index].add(time, updater); + } else { + that._openMaterialBatches[index].add(time, updater); } } } diff --git a/Source/DataSources/KmlDataSource.js b/Source/DataSources/KmlDataSource.js index 766674a9e4e0..85a36f0240d8 100644 --- a/Source/DataSources/KmlDataSource.js +++ b/Source/DataSources/KmlDataSource.js @@ -1184,25 +1184,23 @@ define([ } else if (defined(polygon)) { wall.outlineColor = defined(polygon.material) ? polygon.material.color : Color.WHITE; } - } else { - if (dataSource._clampToGround && !canExtrude && tessellate) { - var corridor = new CorridorGraphics(); - entity.corridor = corridor; - corridor.positions = coordinates; - if (defined(polyline)) { - corridor.material = defined(polyline.material) ? polyline.material.color.getValue(Iso8601.MINIMUM_VALUE) : Color.WHITE; - corridor.width = defaultValue(polyline.width, 1.0); - } else { - corridor.material = Color.WHITE; - corridor.width = 1.0; - } + } else if (dataSource._clampToGround && !canExtrude && tessellate) { + var corridor = new CorridorGraphics(); + entity.corridor = corridor; + corridor.positions = coordinates; + if (defined(polyline)) { + corridor.material = defined(polyline.material) ? polyline.material.color.getValue(Iso8601.MINIMUM_VALUE) : Color.WHITE; + corridor.width = defaultValue(polyline.width, 1.0); } else { - polyline = defined(polyline) ? polyline.clone() : new PolylineGraphics(); - entity.polyline = polyline; - polyline.positions = createPositionPropertyArrayFromAltitudeMode(coordinates, altitudeMode, gxAltitudeMode); - if (!tessellate || canExtrude) { - polyline.followSurface = false; - } + corridor.material = Color.WHITE; + corridor.width = 1.0; + } + } else { + polyline = defined(polyline) ? polyline.clone() : new PolylineGraphics(); + entity.polyline = polyline; + polyline.positions = createPositionPropertyArrayFromAltitudeMode(coordinates, altitudeMode, gxAltitudeMode); + if (!tessellate || canExtrude) { + polyline.followSurface = false; } } @@ -2052,13 +2050,11 @@ define([ } else { console.log('KML - refreshMode of onExpire requires the NetworkLinkControl to have an expires element'); } + } else if (dataSource._camera) { // Only allow onStop refreshes if we have a camera + networkLinkInfo.refreshMode = RefreshMode.STOP; + networkLinkInfo.time = defaultValue(queryNumericValue(link, 'viewRefreshTime', namespaces.kml), 0); } else { - if (dataSource._camera) { // Only allow onStop refreshes if we have a camera - networkLinkInfo.refreshMode = RefreshMode.STOP; - networkLinkInfo.time = defaultValue(queryNumericValue(link, 'viewRefreshTime', namespaces.kml), 0); - } else { - console.log('A NetworkLink with viewRefreshMode=onStop requires a camera be passed in when creating the KmlDataSource'); - } + console.log('A NetworkLink with viewRefreshMode=onStop requires a camera be passed in when creating the KmlDataSource'); } if (defined(networkLinkInfo.refreshMode)) { diff --git a/Source/Scene/BillboardCollection.js b/Source/Scene/BillboardCollection.js index 7cd3e39fdc92..33f842b1e390 100644 --- a/Source/Scene/BillboardCollection.js +++ b/Source/Scene/BillboardCollection.js @@ -1355,85 +1355,83 @@ define([ } this._billboardsToUpdateIndex = 0; - } else { + } else if (billboardsToUpdateLength > 0) { // Billboards were modified, but none were added or removed. - if (billboardsToUpdateLength > 0) { - var writers = scratchWriterArray; - writers.length = 0; + var writers = scratchWriterArray; + writers.length = 0; - if (properties[POSITION_INDEX] || properties[ROTATION_INDEX] || properties[SCALE_INDEX]) { - writers.push(writePositionScaleAndRotation); - } + if (properties[POSITION_INDEX] || properties[ROTATION_INDEX] || properties[SCALE_INDEX]) { + writers.push(writePositionScaleAndRotation); + } - if (properties[IMAGE_INDEX_INDEX] || properties[PIXEL_OFFSET_INDEX] || properties[HORIZONTAL_ORIGIN_INDEX] || properties[VERTICAL_ORIGIN_INDEX] || properties[SHOW_INDEX]) { - writers.push(writeCompressedAttrib0); - if (this._instanced) { - writers.push(writeEyeOffset); - } + if (properties[IMAGE_INDEX_INDEX] || properties[PIXEL_OFFSET_INDEX] || properties[HORIZONTAL_ORIGIN_INDEX] || properties[VERTICAL_ORIGIN_INDEX] || properties[SHOW_INDEX]) { + writers.push(writeCompressedAttrib0); + if (this._instanced) { + writers.push(writeEyeOffset); } + } - if (properties[IMAGE_INDEX_INDEX] || properties[ALIGNED_AXIS_INDEX] || properties[TRANSLUCENCY_BY_DISTANCE_INDEX]) { - writers.push(writeCompressedAttrib1); - writers.push(writeCompressedAttrib2); - } + if (properties[IMAGE_INDEX_INDEX] || properties[ALIGNED_AXIS_INDEX] || properties[TRANSLUCENCY_BY_DISTANCE_INDEX]) { + writers.push(writeCompressedAttrib1); + writers.push(writeCompressedAttrib2); + } - if (properties[IMAGE_INDEX_INDEX] || properties[COLOR_INDEX]) { - writers.push(writeCompressedAttrib2); - } + if (properties[IMAGE_INDEX_INDEX] || properties[COLOR_INDEX]) { + writers.push(writeCompressedAttrib2); + } - if (properties[EYE_OFFSET_INDEX]) { - writers.push(writeEyeOffset); - } + if (properties[EYE_OFFSET_INDEX]) { + writers.push(writeEyeOffset); + } - if (properties[SCALE_BY_DISTANCE_INDEX]) { - writers.push(writeScaleByDistance); - } + if (properties[SCALE_BY_DISTANCE_INDEX]) { + writers.push(writeScaleByDistance); + } - if (properties[PIXEL_OFFSET_SCALE_BY_DISTANCE_INDEX]) { - writers.push(writePixelOffsetScaleByDistance); - } + if (properties[PIXEL_OFFSET_SCALE_BY_DISTANCE_INDEX]) { + writers.push(writePixelOffsetScaleByDistance); + } - if (properties[DISTANCE_DISPLAY_CONDITION_INDEX] || properties[DISABLE_DEPTH_DISTANCE]) { - writers.push(writeDistanceDisplayConditionAndDepthDisable); - } + if (properties[DISTANCE_DISPLAY_CONDITION_INDEX] || properties[DISABLE_DEPTH_DISTANCE]) { + writers.push(writeDistanceDisplayConditionAndDepthDisable); + } - var numWriters = writers.length; - vafWriters = this._vaf.writers; + var numWriters = writers.length; + vafWriters = this._vaf.writers; - if ((billboardsToUpdateLength / billboardsLength) > 0.1) { - // If more than 10% of billboard change, rewrite the entire buffer. + if ((billboardsToUpdateLength / billboardsLength) > 0.1) { + // If more than 10% of billboard change, rewrite the entire buffer. - // PERFORMANCE_IDEA: I totally made up 10% :). + // PERFORMANCE_IDEA: I totally made up 10% :). - for (var m = 0; m < billboardsToUpdateLength; ++m) { - var b = billboardsToUpdate[m]; - b._dirty = false; + for (var m = 0; m < billboardsToUpdateLength; ++m) { + var b = billboardsToUpdate[m]; + b._dirty = false; - for ( var n = 0; n < numWriters; ++n) { - writers[n](this, context, textureAtlasCoordinates, vafWriters, b); - } - } - this._vaf.commit(getIndexBuffer(context)); - } else { - for (var h = 0; h < billboardsToUpdateLength; ++h) { - var bb = billboardsToUpdate[h]; - bb._dirty = false; - - for ( var o = 0; o < numWriters; ++o) { - writers[o](this, context, textureAtlasCoordinates, vafWriters, bb); - } - - if (this._instanced) { - this._vaf.subCommit(bb._index, 1); - } else { - this._vaf.subCommit(bb._index * 4, 4); - } + for ( var n = 0; n < numWriters; ++n) { + writers[n](this, context, textureAtlasCoordinates, vafWriters, b); } - this._vaf.endSubCommits(); } + this._vaf.commit(getIndexBuffer(context)); + } else { + for (var h = 0; h < billboardsToUpdateLength; ++h) { + var bb = billboardsToUpdate[h]; + bb._dirty = false; + + for ( var o = 0; o < numWriters; ++o) { + writers[o](this, context, textureAtlasCoordinates, vafWriters, bb); + } - this._billboardsToUpdateIndex = 0; + if (this._instanced) { + this._vaf.subCommit(bb._index, 1); + } else { + this._vaf.subCommit(bb._index * 4, 4); + } + } + this._vaf.endSubCommits(); } + + this._billboardsToUpdateIndex = 0; } // If the number of total billboards ever shrinks considerably diff --git a/Source/Scene/GroundPrimitive.js b/Source/Scene/GroundPrimitive.js index ff898956dc1a..236bafc3ef38 100644 --- a/Source/Scene/GroundPrimitive.js +++ b/Source/Scene/GroundPrimitive.js @@ -1065,10 +1065,8 @@ define([ var instanceRectangle = getRectangle(frameState, geometry); if (!defined(rectangle)) { rectangle = instanceRectangle; - } else { - if (defined(instanceRectangle)) { - Rectangle.union(rectangle, instanceRectangle, rectangle); - } + } else if (defined(instanceRectangle)) { + Rectangle.union(rectangle, instanceRectangle, rectangle); } var id = instance.id; diff --git a/Source/Scene/LabelCollection.js b/Source/Scene/LabelCollection.js index 817306b0974c..7875c7115436 100644 --- a/Source/Scene/LabelCollection.js +++ b/Source/Scene/LabelCollection.js @@ -219,12 +219,10 @@ define([ // no texture, and therefore no billboard, for this glyph. // so, completely unbind glyph. unbindGlyph(labelCollection, glyph); - } else { + } else if (defined(glyph.textureInfo)) { // we have a texture and billboard. If we had one before, release // our reference to that texture info, but reuse the billboard. - if (defined(glyph.textureInfo)) { - glyph.textureInfo = undefined; - } + glyph.textureInfo = undefined; } } else { // create a glyph object diff --git a/Source/Scene/ModelAnimationCollection.js b/Source/Scene/ModelAnimationCollection.js index 40f49ff34a03..0c5c3a1c94e1 100644 --- a/Source/Scene/ModelAnimationCollection.js +++ b/Source/Scene/ModelAnimationCollection.js @@ -415,17 +415,15 @@ define([ frameState.afterRender.push(scheduledAnimation._raiseUpdateEvent); } animationOccured = true; - } else { + } else if (pastStartTime && (scheduledAnimation._state === ModelAnimationState.ANIMATING)) { // ANIMATING -> STOPPED state transition? - if (pastStartTime && (scheduledAnimation._state === ModelAnimationState.ANIMATING)) { - scheduledAnimation._state = ModelAnimationState.STOPPED; - if (scheduledAnimation.stop.numberOfListeners > 0) { - frameState.afterRender.push(scheduledAnimation._raiseStopEvent); - } + scheduledAnimation._state = ModelAnimationState.STOPPED; + if (scheduledAnimation.stop.numberOfListeners > 0) { + frameState.afterRender.push(scheduledAnimation._raiseStopEvent); + } - if (scheduledAnimation.removeOnStop) { - animationsToRemove.push(scheduledAnimation); - } + if (scheduledAnimation.removeOnStop) { + animationsToRemove.push(scheduledAnimation); } } } diff --git a/Source/Scene/PointPrimitiveCollection.js b/Source/Scene/PointPrimitiveCollection.js index 9dd0d4bd690c..2045f48fa58e 100644 --- a/Source/Scene/PointPrimitiveCollection.js +++ b/Source/Scene/PointPrimitiveCollection.js @@ -784,65 +784,63 @@ define([ } this._pointPrimitivesToUpdateIndex = 0; - } else { + } else if (pointPrimitivesToUpdateLength > 0) { // PointPrimitives were modified, but none were added or removed. - if (pointPrimitivesToUpdateLength > 0) { - var writers = scratchWriterArray; - writers.length = 0; + var writers = scratchWriterArray; + writers.length = 0; - if (properties[POSITION_INDEX] || properties[OUTLINE_WIDTH_INDEX] || properties[PIXEL_SIZE_INDEX]) { - writers.push(writePositionSizeAndOutline); - } + if (properties[POSITION_INDEX] || properties[OUTLINE_WIDTH_INDEX] || properties[PIXEL_SIZE_INDEX]) { + writers.push(writePositionSizeAndOutline); + } - if (properties[COLOR_INDEX] || properties[OUTLINE_COLOR_INDEX]) { - writers.push(writeCompressedAttrib0); - } + if (properties[COLOR_INDEX] || properties[OUTLINE_COLOR_INDEX]) { + writers.push(writeCompressedAttrib0); + } - if (properties[SHOW_INDEX] || properties[TRANSLUCENCY_BY_DISTANCE_INDEX]) { - writers.push(writeCompressedAttrib1); - } + if (properties[SHOW_INDEX] || properties[TRANSLUCENCY_BY_DISTANCE_INDEX]) { + writers.push(writeCompressedAttrib1); + } - if (properties[SCALE_BY_DISTANCE_INDEX]) { - writers.push(writeScaleByDistance); - } + if (properties[SCALE_BY_DISTANCE_INDEX]) { + writers.push(writeScaleByDistance); + } - if (properties[DISTANCE_DISPLAY_CONDITION_INDEX] || properties[DISABLE_DEPTH_DISTANCE_INDEX]) { - writers.push(writeDistanceDisplayConditionAndDepthDisable); - } + if (properties[DISTANCE_DISPLAY_CONDITION_INDEX] || properties[DISABLE_DEPTH_DISTANCE_INDEX]) { + writers.push(writeDistanceDisplayConditionAndDepthDisable); + } - var numWriters = writers.length; + var numWriters = writers.length; - vafWriters = this._vaf.writers; + vafWriters = this._vaf.writers; - if ((pointPrimitivesToUpdateLength / pointPrimitivesLength) > 0.1) { - // If more than 10% of pointPrimitive change, rewrite the entire buffer. + if ((pointPrimitivesToUpdateLength / pointPrimitivesLength) > 0.1) { + // If more than 10% of pointPrimitive change, rewrite the entire buffer. - // PERFORMANCE_IDEA: I totally made up 10% :). + // PERFORMANCE_IDEA: I totally made up 10% :). - for (var m = 0; m < pointPrimitivesToUpdateLength; ++m) { - var b = pointPrimitivesToUpdate[m]; - b._dirty = false; + for (var m = 0; m < pointPrimitivesToUpdateLength; ++m) { + var b = pointPrimitivesToUpdate[m]; + b._dirty = false; - for ( var n = 0; n < numWriters; ++n) { - writers[n](this, context, vafWriters, b); - } + for ( var n = 0; n < numWriters; ++n) { + writers[n](this, context, vafWriters, b); } - this._vaf.commit(); - } else { - for (var h = 0; h < pointPrimitivesToUpdateLength; ++h) { - var bb = pointPrimitivesToUpdate[h]; - bb._dirty = false; - - for ( var o = 0; o < numWriters; ++o) { - writers[o](this, context, vafWriters, bb); - } - this._vaf.subCommit(bb._index, 1); - } - this._vaf.endSubCommits(); } + this._vaf.commit(); + } else { + for (var h = 0; h < pointPrimitivesToUpdateLength; ++h) { + var bb = pointPrimitivesToUpdate[h]; + bb._dirty = false; - this._pointPrimitivesToUpdateIndex = 0; + for ( var o = 0; o < numWriters; ++o) { + writers[o](this, context, vafWriters, bb); + } + this._vaf.subCommit(bb._index, 1); + } + this._vaf.endSubCommits(); } + + this._pointPrimitivesToUpdateIndex = 0; } // If the number of total pointPrimitives ever shrinks considerably diff --git a/Source/Scene/Polyline.js b/Source/Scene/Polyline.js index 9572cd0e8152..b7f8ce5f6390 100644 --- a/Source/Scene/Polyline.js +++ b/Source/Scene/Polyline.js @@ -260,13 +260,11 @@ define([ } positions.push(Cartesian3.clone(positions[0])); } - } else { - if (positions.length > 2 && Cartesian3.equals(positions[0], positions[positions.length - 1])) { - if (positions.length - 1 === this._positions.length) { - this._actualPositions = this._positions; - } else { - positions.pop(); - } + } else if (positions.length > 2 && Cartesian3.equals(positions[0], positions[positions.length - 1])) { + if (positions.length - 1 === this._positions.length) { + this._actualPositions = this._positions; + } else { + positions.pop(); } } diff --git a/Source/Scene/PolylineCollection.js b/Source/Scene/PolylineCollection.js index 815f95d93dc7..ddbc799db2b7 100644 --- a/Source/Scene/PolylineCollection.js +++ b/Source/Scene/PolylineCollection.js @@ -758,14 +758,12 @@ define([ } else { bufferUsage.frameCount = 100; } - } else { - if (bufferUsage.bufferUsage !== BufferUsage.STATIC_DRAW) { - if (bufferUsage.frameCount === 0) { - usageChanged = true; - bufferUsage.bufferUsage = BufferUsage.STATIC_DRAW; - } else { - bufferUsage.frameCount--; - } + } else if (bufferUsage.bufferUsage !== BufferUsage.STATIC_DRAW) { + if (bufferUsage.frameCount === 0) { + usageChanged = true; + bufferUsage.bufferUsage = BufferUsage.STATIC_DRAW; + } else { + bufferUsage.frameCount--; } } diff --git a/Source/Scene/QuadtreePrimitive.js b/Source/Scene/QuadtreePrimitive.js index faab9989d1fa..150e6fecba83 100644 --- a/Source/Scene/QuadtreePrimitive.js +++ b/Source/Scene/QuadtreePrimitive.js @@ -587,20 +587,18 @@ define([ queueChildTileLoad(primitive, northeast); queueChildTileLoad(primitive, southeast); } + } else if (cameraPosition.latitude < southwest.north) { + // Camera southeast quadrant + queueChildTileLoad(primitive, southeast); + queueChildTileLoad(primitive, southwest); + queueChildTileLoad(primitive, northeast); + queueChildTileLoad(primitive, northwest); } else { - if (cameraPosition.latitude < southwest.north) { - // Camera southeast quadrant - queueChildTileLoad(primitive, southeast); - queueChildTileLoad(primitive, southwest); - queueChildTileLoad(primitive, northeast); - queueChildTileLoad(primitive, northwest); - } else { - // Camera in northeast quadrant - queueChildTileLoad(primitive, northeast); - queueChildTileLoad(primitive, northwest); - queueChildTileLoad(primitive, southeast); - queueChildTileLoad(primitive, southwest); - } + // Camera in northeast quadrant + queueChildTileLoad(primitive, northeast); + queueChildTileLoad(primitive, northwest); + queueChildTileLoad(primitive, southeast); + queueChildTileLoad(primitive, southwest); } } @@ -635,20 +633,18 @@ define([ visitIfVisible(primitive, northeast, tileProvider, frameState, occluders); visitIfVisible(primitive, southeast, tileProvider, frameState, occluders); } + } else if (cameraPosition.latitude < southwest.rectangle.north) { + // Camera southeast quadrant + visitIfVisible(primitive, southeast, tileProvider, frameState, occluders); + visitIfVisible(primitive, southwest, tileProvider, frameState, occluders); + visitIfVisible(primitive, northeast, tileProvider, frameState, occluders); + visitIfVisible(primitive, northwest, tileProvider, frameState, occluders); } else { - if (cameraPosition.latitude < southwest.rectangle.north) { - // Camera southeast quadrant - visitIfVisible(primitive, southeast, tileProvider, frameState, occluders); - visitIfVisible(primitive, southwest, tileProvider, frameState, occluders); - visitIfVisible(primitive, northeast, tileProvider, frameState, occluders); - visitIfVisible(primitive, northwest, tileProvider, frameState, occluders); - } else { - // Camera in northeast quadrant - visitIfVisible(primitive, northeast, tileProvider, frameState, occluders); - visitIfVisible(primitive, northwest, tileProvider, frameState, occluders); - visitIfVisible(primitive, southeast, tileProvider, frameState, occluders); - visitIfVisible(primitive, southwest, tileProvider, frameState, occluders); - } + // Camera in northeast quadrant + visitIfVisible(primitive, northeast, tileProvider, frameState, occluders); + visitIfVisible(primitive, northwest, tileProvider, frameState, occluders); + visitIfVisible(primitive, southeast, tileProvider, frameState, occluders); + visitIfVisible(primitive, southwest, tileProvider, frameState, occluders); } } diff --git a/Source/Scene/TweenCollection.js b/Source/Scene/TweenCollection.js index 79ae4a6ecc84..e9359fa64f88 100644 --- a/Source/Scene/TweenCollection.js +++ b/Source/Scene/TweenCollection.js @@ -535,13 +535,11 @@ define([ if (tween.needsStart) { tween.needsStart = false; tweenjs.start(time); + } else if (tweenjs.update(time)) { + i++; } else { - if (tweenjs.update(time)) { - i++; - } else { - tweenjs.stop(); - tweens.splice(i, 1); - } + tweenjs.stop(); + tweens.splice(i, 1); } } }; diff --git a/Source/Scene/modelMaterialsCommon.js b/Source/Scene/modelMaterialsCommon.js index 27875e305d3f..a84ba464a711 100644 --- a/Source/Scene/modelMaterialsCommon.js +++ b/Source/Scene/modelMaterialsCommon.js @@ -496,13 +496,11 @@ define([ finalColorComputation = ' gl_FragColor = vec4(color * diffuse.a, diffuse.a);\n'; } } + else if (defined(techniqueParameters.transparency)) { + finalColorComputation = ' gl_FragColor = vec4(color, u_transparency);\n'; + } else { - if (defined(techniqueParameters.transparency)) { - finalColorComputation = ' gl_FragColor = vec4(color, u_transparency);\n'; - } - else { - finalColorComputation = ' gl_FragColor = vec4(color, 1.0);\n'; - } + finalColorComputation = ' gl_FragColor = vec4(color, 1.0);\n'; } if (defined(techniqueParameters.emission)) { diff --git a/Source/Widgets/Animation/AnimationViewModel.js b/Source/Widgets/Animation/AnimationViewModel.js index 6409bf9d9250..6e8031e97ffd 100644 --- a/Source/Widgets/Animation/AnimationViewModel.js +++ b/Source/Widgets/Animation/AnimationViewModel.js @@ -202,21 +202,19 @@ define([ var multiplier = angleToMultiplier(angle, ticks); if (that.snapToTicks) { multiplier = ticks[getTypicalMultiplierIndex(multiplier, ticks)]; - } else { - if (multiplier !== 0) { - var positiveMultiplier = Math.abs(multiplier); - - if (positiveMultiplier > 100) { - var numDigits = positiveMultiplier.toFixed(0).length - 2; - var divisor = Math.pow(10, numDigits); - multiplier = (Math.round(multiplier / divisor) * divisor) | 0; - } else if (positiveMultiplier > realtimeShuttleRingAngle) { - multiplier = Math.round(multiplier); - } else if (positiveMultiplier > 1) { - multiplier = +multiplier.toFixed(1); - } else if (positiveMultiplier > 0) { - multiplier = +multiplier.toFixed(2); - } + } else if (multiplier !== 0) { + var positiveMultiplier = Math.abs(multiplier); + + if (positiveMultiplier > 100) { + var numDigits = positiveMultiplier.toFixed(0).length - 2; + var divisor = Math.pow(10, numDigits); + multiplier = (Math.round(multiplier / divisor) * divisor) | 0; + } else if (positiveMultiplier > realtimeShuttleRingAngle) { + multiplier = Math.round(multiplier); + } else if (positiveMultiplier > 1) { + multiplier = +multiplier.toFixed(1); + } else if (positiveMultiplier > 0) { + multiplier = +multiplier.toFixed(2); } } clockViewModel.multiplier = multiplier; diff --git a/Source/Widgets/Viewer/Viewer.js b/Source/Widgets/Viewer/Viewer.js index 0203645386bd..4eb4adfe3895 100644 --- a/Source/Widgets/Viewer/Viewer.js +++ b/Source/Widgets/Viewer/Viewer.js @@ -1256,11 +1256,9 @@ Either specify options.terrainProvider instead or set options.baseLayerPicker to if (defined(selectionIndicatorViewModel)) { selectionIndicatorViewModel.animateAppear(); } - } else { + } else if (defined(selectionIndicatorViewModel)) { // Leave the info text in place here, it is needed during the exit animation. - if (defined(selectionIndicatorViewModel)) { - selectionIndicatorViewModel.animateDepart(); - } + selectionIndicatorViewModel.animateDepart(); } this._selectedEntityChanged.raiseEvent(value); } diff --git a/Specs/addDefaultMatchers.js b/Specs/addDefaultMatchers.js index bd47573d648a..c33eb353d95a 100644 --- a/Specs/addDefaultMatchers.js +++ b/Specs/addDefaultMatchers.js @@ -594,16 +594,14 @@ define([ message : 'Expected context to render ' + expected + ', but rendered: ' + rgba }; } - } else { - if (CesiumMath.equalsEpsilon(rgba[0], expected[0], 0, epsilon) && - CesiumMath.equalsEpsilon(rgba[1], expected[1], 0, epsilon) && - CesiumMath.equalsEpsilon(rgba[2], expected[2], 0, epsilon) && - CesiumMath.equalsEpsilon(rgba[3], expected[3], 0, epsilon)) { - return { - pass : false, - message : 'Expected context not to render ' + expected + ', but rendered: ' + rgba - }; - } + } else if (CesiumMath.equalsEpsilon(rgba[0], expected[0], 0, epsilon) && + CesiumMath.equalsEpsilon(rgba[1], expected[1], 0, epsilon) && + CesiumMath.equalsEpsilon(rgba[2], expected[2], 0, epsilon) && + CesiumMath.equalsEpsilon(rgba[3], expected[3], 0, epsilon)) { + return { + pass : false, + message : 'Expected context not to render ' + expected + ', but rendered: ' + rgba + }; } } diff --git a/Specs/pollToPromise.js b/Specs/pollToPromise.js index ae6588632785..f7e0bcba2493 100644 --- a/Specs/pollToPromise.js +++ b/Specs/pollToPromise.js @@ -32,12 +32,10 @@ define([ if (result) { deferred.resolve(); + } else if (getTimestamp() > endTimestamp) { + deferred.reject(); } else { - if (getTimestamp() > endTimestamp) { - deferred.reject(); - } else { - setTimeout(poller, pollInterval); - } + setTimeout(poller, pollInterval); } }