diff --git a/CHANGES.md b/CHANGES.md index 90417c021a4f..328593c7aa59 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -19,6 +19,7 @@ Change Log * Fixed a 3D Tiles point cloud bug causing a stray point to appear at the center of the screen on certain hardware. [#5599](https://github.com/AnalyticalGraphicsInc/cesium/issues/5599) * Fixed removing multiple event listeners within event callbacks. [#5827](https://github.com/AnalyticalGraphicsInc/cesium/issues/5827) * Running `buildApps` now creates a built version of Sandcastle which uses the built version of Cesium for better performance. +* Fixed a tileset traversal bug when the `skipLevelOfDetail` optimization is off. [#5869](https://github.com/AnalyticalGraphicsInc/cesium/issues/5869) * Fixed bug with placemarks in imported KML: placemarks with no specified icon would be displayed with default icon. [#5819](https://github.com/AnalyticalGraphicsInc/cesium/issues/5819) ### 1.37 - 2017-09-01 diff --git a/Source/Scene/Cesium3DTilesetTraversal.js b/Source/Scene/Cesium3DTilesetTraversal.js index c40334f96442..5222f3cd41cc 100644 --- a/Source/Scene/Cesium3DTilesetTraversal.js +++ b/Source/Scene/Cesium3DTilesetTraversal.js @@ -509,7 +509,7 @@ define([ if (!tile.hasTilesetContent) { if (tile.refine === Cesium3DTileRefine.ADD) { // Always load additive tiles - loadTile(tileset, tile, this.frameState); + loadTile(tileset, tile, this.frameState, true); if (hasAdditiveContent(tile)) { tileset._desiredTiles.push(tile); } @@ -635,9 +635,16 @@ define([ } } + function checkAdditiveVisibility(tileset, tile, frameState) { + if (defined(tile.parent) && (tile.parent.refine === Cesium3DTileRefine.ADD)) { + return isVisibleAndMeetsSSE(tileset, tile, frameState); + } + return true; + } + function loadTile(tileset, tile, frameState, checkVisibility) { if ((tile.contentUnloaded || tile.contentExpired) && tile._requestedFrame !== frameState.frameNumber) { - if (!checkVisibility || isVisibleAndMeetsSSE(tileset, tile, frameState)) { + if (!checkVisibility || checkAdditiveVisibility(tileset, tile, frameState)) { tile._requestedFrame = frameState.frameNumber; tileset._requestedTiles.push(tile); } diff --git a/Source/ThirdParty/GltfPipeline/addDefaults.js b/Source/ThirdParty/GltfPipeline/addDefaults.js index a7a7228ee23e..a7ccb751e03a 100644 --- a/Source/ThirdParty/GltfPipeline/addDefaults.js +++ b/Source/ThirdParty/GltfPipeline/addDefaults.js @@ -57,13 +57,13 @@ define([ var defaults = { ambient: [0.0, 0.0, 0.0, 1.0], emission: [0.0, 0.0, 0.0, 1.0], - transparency: [1.0] + transparency: 1.0 }; if (technique !== 'CONSTANT') { defaults.diffuse = [0.0, 0.0, 0.0, 1.0]; if (technique !== 'LAMBERT') { defaults.specular = [0.0, 0.0, 0.0, 1.0]; - defaults.shininess = [0.0]; + defaults.shininess = 0.0; } } return { diff --git a/Source/ThirdParty/GltfPipeline/getUniqueId.js b/Source/ThirdParty/GltfPipeline/getUniqueId.js deleted file mode 100644 index 59f7a36cdf5b..000000000000 --- a/Source/ThirdParty/GltfPipeline/getUniqueId.js +++ /dev/null @@ -1,31 +0,0 @@ -define([ - '../../Core/defined' - ], function( - defined) { - 'use strict'; - - /** - * Given a prefix for a new ID, checks the glTF asset for matching prefixes in top-level objects with IDs and returns a unique ID. - * - * @param {Object} gltf A javascript object containing a glTF asset. - * @param {String} prefix The string to try to use as the id. - * @returns {String} A unique id beginning with prefix. - */ - function getUniqueId(gltf, prefix) { - var id = prefix; - var appendIndex = 0; - for (var topLevelGroupId in gltf) { - if (gltf.hasOwnProperty(topLevelGroupId)) { - var topLevelGroup = gltf[topLevelGroupId]; - var match = topLevelGroup[id]; - while (defined(match)) { - id = prefix + '_' + appendIndex; - match = topLevelGroup[id]; - appendIndex++; - } - } - } - return id; - } - return getUniqueId; -}); diff --git a/Source/ThirdParty/GltfPipeline/parseBinaryGltf.js b/Source/ThirdParty/GltfPipeline/parseBinaryGltf.js index ccd7fde98cb4..fd2000d6c8f9 100644 --- a/Source/ThirdParty/GltfPipeline/parseBinaryGltf.js +++ b/Source/ThirdParty/GltfPipeline/parseBinaryGltf.js @@ -105,7 +105,6 @@ define([ } // Load Binary chunk else if (chunkType === 0x004E4942) { - // Clone just the binary chunk so the underlying buffer can be freed binaryBuffer = chunkBuffer; } } diff --git a/Source/ThirdParty/GltfPipeline/processPbrMetallicRoughness.js b/Source/ThirdParty/GltfPipeline/processPbrMetallicRoughness.js index 2f772bef85ea..b9ccf6496c66 100644 --- a/Source/ThirdParty/GltfPipeline/processPbrMetallicRoughness.js +++ b/Source/ThirdParty/GltfPipeline/processPbrMetallicRoughness.js @@ -164,7 +164,7 @@ define([ for (var name in parameterValues) { //generate shader parameters if (parameterValues.hasOwnProperty(name)) { - var valType = getPBRValueType(name, parameterValues[name]); + var valType = getPBRValueType(name); if (!hasTexCoords && (valType === WebGLConstants.SAMPLER_2D)) { hasTexCoords = true; } @@ -373,37 +373,37 @@ define([ fragmentShader += 'const float M_PI = 3.141592653589793;\n'; fragmentShader += 'vec3 lambertianDiffuse(vec3 baseColor) \n' + - '{\n' + - ' return baseColor / M_PI;\n' + - '}\n\n'; + '{\n' + + ' return baseColor / M_PI;\n' + + '}\n\n'; fragmentShader += 'vec3 fresnelSchlick2(vec3 f0, vec3 f90, float VdotH) \n' + - '{\n' + - ' return f0 + (f90 - f0) * pow(clamp(1.0 - VdotH, 0.0, 1.0), 5.0);\n' + - '}\n\n'; + '{\n' + + ' return f0 + (f90 - f0) * pow(clamp(1.0 - VdotH, 0.0, 1.0), 5.0);\n' + + '}\n\n'; fragmentShader += 'vec3 fresnelSchlick(float metalness, float VdotH) \n' + - '{\n' + - ' return metalness + (vec3(1.0) - metalness) * pow(1.0 - VdotH, 5.0);\n' + - '}\n\n'; + '{\n' + + ' return metalness + (vec3(1.0) - metalness) * pow(1.0 - VdotH, 5.0);\n' + + '}\n\n'; fragmentShader += 'float smithVisibilityG1(float NdotV, float roughness) \n' + - '{\n' + - ' float k = (roughness + 1.0) * (roughness + 1.0) / 8.0;\n' + - ' return NdotV / (NdotV * (1.0 - k) + k);\n' + - '}\n\n'; + '{\n' + + ' float k = (roughness + 1.0) * (roughness + 1.0) / 8.0;\n' + + ' return NdotV / (NdotV * (1.0 - k) + k);\n' + + '}\n\n'; fragmentShader += 'float smithVisibilityGGX(float roughness, float NdotL, float NdotV) \n' + - '{\n' + - ' return smithVisibilityG1(NdotL, roughness) * smithVisibilityG1(NdotV, roughness);\n' + - '}\n\n'; + '{\n' + + ' return smithVisibilityG1(NdotL, roughness) * smithVisibilityG1(NdotV, roughness);\n' + + '}\n\n'; fragmentShader += 'float GGX(float roughness, float NdotH) \n' + - '{\n' + - ' float roughnessSquared = roughness * roughness;\n' + - ' float f = (NdotH * roughnessSquared - NdotH) * NdotH + 1.0;\n' + - ' return roughnessSquared / (M_PI * f * f);\n' + - '}\n\n'; + '{\n' + + ' float roughnessSquared = roughness * roughness;\n' + + ' float f = (NdotH * roughnessSquared - NdotH) * NdotH + 1.0;\n' + + ' return roughnessSquared / (M_PI * f * f);\n' + + '}\n\n'; fragmentShader += 'void main(void) \n{\n'; @@ -421,9 +421,9 @@ define([ } else { // Add standard derivatives extension fragmentShader = '#ifdef GL_OES_standard_derivatives\n' + - '#extension GL_OES_standard_derivatives : enable\n' + - '#endif\n' + - fragmentShader; + '#extension GL_OES_standard_derivatives : enable\n' + + '#endif\n' + + fragmentShader; // Compute tangents fragmentShader += '#ifdef GL_OES_standard_derivatives\n'; fragmentShader += ' vec3 pos_dx = dFdx(v_positionEC);\n'; @@ -675,9 +675,7 @@ define([ return techniqueId; } - function getPBRValueType(paramName, paramValue) { - var value; - + function getPBRValueType(paramName) { switch (paramName) { case 'baseColorFactor': return WebGLConstants.FLOAT_VEC4; diff --git a/Source/ThirdParty/GltfPipeline/updateVersion.js b/Source/ThirdParty/GltfPipeline/updateVersion.js index a3b805b604e0..423533993b1a 100644 --- a/Source/ThirdParty/GltfPipeline/updateVersion.js +++ b/Source/ThirdParty/GltfPipeline/updateVersion.js @@ -1,7 +1,6 @@ define([ './addExtensionsRequired', './addToArray', - './findAccessorMinMax', './ForEach', './getAccessorByteStride', '../../Core/Cartesian3', @@ -14,7 +13,6 @@ define([ ], function( addExtensionsRequired, addToArray, - findAccessorMinMax, ForEach, getAccessorByteStride, Cartesian3, @@ -645,17 +643,6 @@ define([ }); } - function makeTechniqueValuesArrays(gltf) { - ForEach.technique(gltf, function(technique) { - ForEach.techniqueParameter(technique, function(parameter) { - var value = parameter.value; - if (defined(value) && !Array.isArray(value)) { - parameter.value = [value]; - } - }); - }); - } - function removeScissorFromTechniques(gltf) { ForEach.technique(gltf, function(technique) { var techniqueStates = technique.states; @@ -754,6 +741,7 @@ define([ var bufferViewShiftMap = {}; var bufferViewRemovalCount = 0; + /* jshint unused:vars */ ForEach.bufferView(gltf, function(bufferView, bufferViewId) { if (defined(bufferViewsToDelete[bufferViewId])) { bufferViewRemovalCount++; @@ -805,16 +793,6 @@ define([ }); } - function requireAccessorMinMax(gltf) { - ForEach.accessor(gltf, function(accessor) { - if (!defined(accessor.min) || !defined(accessor.max)) { - var minMax = findAccessorMinMax(gltf, accessor); - accessor.min = minMax.min; - accessor.max = minMax.max; - } - }); - } - function stripTechniqueAttributeValues(gltf) { ForEach.technique(gltf, function(technique) { ForEach.techniqueAttribute(technique, function(attribute) { @@ -872,8 +850,6 @@ define([ requireAttributeSetIndex(gltf); // Add underscores to application-specific parameters underscoreApplicationSpecificSemantics(gltf); - // technique.parameters.value should be arrays - makeTechniqueValuesArrays(gltf); // remove scissor from techniques removeScissorFromTechniques(gltf); // clamp technique function states to min/max @@ -887,6 +863,5 @@ define([ // add KHR_technique_webgl extension addKHRTechniqueExtension(gltf); } - return updateVersion; }); diff --git a/Specs/Scene/Cesium3DTilesetSpec.js b/Specs/Scene/Cesium3DTilesetSpec.js index a8352aee1dd0..c6f802b8f315 100644 --- a/Specs/Scene/Cesium3DTilesetSpec.js +++ b/Specs/Scene/Cesium3DTilesetSpec.js @@ -720,6 +720,14 @@ defineSuite([ }); }); + it('does not load additive tiles that are out of view', function() { + viewBottomLeft(); + return Cesium3DTilesTester.loadTileset(scene, tilesetUrl).then(function(tileset) { + var statistics = tileset._statistics; + expect(statistics.numberOfTilesWithContentReady).toEqual(2); + }); + }); + it('culls with content box', function() { // Root tile has a content box that is half the extents of its box // Expect to cull root tile and three child tiles