diff --git a/Source/Scene/Batched3DModel3DTileContent.js b/Source/Scene/Batched3DModel3DTileContent.js index b380e568978f..678e4050b48d 100644 --- a/Source/Scene/Batched3DModel3DTileContent.js +++ b/Source/Scene/Batched3DModel3DTileContent.js @@ -178,11 +178,22 @@ define([ return true; }; + function getBatchIdAttributeName(gltf) { + var batchIdAttributeName = getAttributeOrUniformBySemantic(gltf, '_BATCHID'); + if (!defined(batchIdAttributeName)) { + batchIdAttributeName = getAttributeOrUniformBySemantic(gltf, 'BATCHID'); + if (defined(batchIdAttributeName)) { + deprecationWarning('b3dm-legacy-batchid', 'The glTF in this b3dm uses the semantic `BATCHID`. Application-specific semantics should be prefixed with an underscore: `_BATCHID`.'); + } + } + return batchIdAttributeName; + } + function getVertexShaderCallback(content) { return function(vs) { var batchTable = content.batchTable; var gltf = content._model.gltf; - var batchIdAttributeName = getAttributeOrUniformBySemantic(gltf, 'BATCHID'); + var batchIdAttributeName = getBatchIdAttributeName(gltf); var callback = batchTable.getVertexShaderCallback(true, batchIdAttributeName); return defined(callback) ? callback(vs) : vs; }; @@ -192,7 +203,7 @@ define([ return function(vs) { var batchTable = content.batchTable; var gltf = content._model.gltf; - var batchIdAttributeName = getAttributeOrUniformBySemantic(gltf, 'BATCHID'); + var batchIdAttributeName = getBatchIdAttributeName(gltf); var callback = batchTable.getPickVertexShaderCallback(batchIdAttributeName); return defined(callback) ? callback(vs) : vs; }; diff --git a/Specs/Scene/Batched3DModel3DTileContentSpec.js b/Specs/Scene/Batched3DModel3DTileContentSpec.js index c7e9e5da1a84..182e05286be5 100644 --- a/Specs/Scene/Batched3DModel3DTileContentSpec.js +++ b/Specs/Scene/Batched3DModel3DTileContentSpec.js @@ -2,6 +2,7 @@ defineSuite([ 'Scene/Batched3DModel3DTileContent', 'Core/Cartesian3', + 'Core/deprecationWarning', 'Core/HeadingPitchRange', 'Core/Transforms', 'Specs/Cesium3DTilesTester', @@ -9,6 +10,7 @@ defineSuite([ ], function( Batched3DModel3DTileContent, Cartesian3, + deprecationWarning, HeadingPitchRange, Transforms, Cesium3DTilesTester, @@ -100,6 +102,14 @@ defineSuite([ expect(tile.batchTable.featuresLength).toEqual(1); }); + it('logs deprecation warning for use of BATCHID without prefixed underscore', function() { + var deprecationWarningSpy = jasmine.createSpy(deprecationWarning); + return Cesium3DTilesTester.loadTileset(scene, withBatchTableUrl).then(function(tileset) { + expect(deprecationWarningSpy).toHaveBeenCalled(); + Cesium3DTilesTester.expectRenderTileset(scene, tileset); + }); + }); + it('throws with empty gltf', function() { // Expect to throw DeveloperError in Model due to invalid gltf magic var arrayBuffer = Cesium3DTilesTester.generateBatchedTileBuffer();