Skip to content

Commit

Permalink
Merge pull request #4769 from lasalvavida/3d-tiles-prefix-underscore
Browse files Browse the repository at this point in the history
Added deprecation warning for BATCHID without a prefixed underscore
  • Loading branch information
pjcozzi authored Dec 21, 2016
2 parents 13fa726 + 0b49d0f commit b06a306
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
15 changes: 13 additions & 2 deletions Source/Scene/Batched3DModel3DTileContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand All @@ -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;
};
Expand Down
10 changes: 10 additions & 0 deletions Specs/Scene/Batched3DModel3DTileContentSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
defineSuite([
'Scene/Batched3DModel3DTileContent',
'Core/Cartesian3',
'Core/deprecationWarning',
'Core/HeadingPitchRange',
'Core/Transforms',
'Specs/Cesium3DTilesTester',
'Specs/createScene'
], function(
Batched3DModel3DTileContent,
Cartesian3,
deprecationWarning,
HeadingPitchRange,
Transforms,
Cesium3DTilesTester,
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit b06a306

Please sign in to comment.