diff --git a/Source/Core/PointGeometry.js b/Source/Core/PointGeometry.js index a0336fee833a..4538bae4d930 100644 --- a/Source/Core/PointGeometry.js +++ b/Source/Core/PointGeometry.js @@ -73,6 +73,10 @@ define([ var componentByteLength = positions.byteLength / positions.length; var componentDatatype = componentByteLength === 4 ? ComponentDatatype.FLOAT : ComponentDatatype.DOUBLE; + // Check if the colors are provided as rgb or rgba + var colors = pointGeometry._colorsTypedArray; + var colorComponentsPerAttribute = (colors.length === positions.length) ? 3 : 4; + var attributes = new GeometryAttributes(); attributes.position = new GeometryAttribute({ componentDatatype : componentDatatype, @@ -82,8 +86,8 @@ define([ attributes.color = new GeometryAttribute({ componentDatatype : ComponentDatatype.UNSIGNED_BYTE, - componentsPerAttribute : 3, - values : pointGeometry._colorsTypedArray, + componentsPerAttribute : colorComponentsPerAttribute, + values : colors, normalize : true }); diff --git a/Source/Scene/Points3DTileContent.js b/Source/Scene/Points3DTileContent.js index beaba14e9085..c338f190f7ba 100644 --- a/Source/Scene/Points3DTileContent.js +++ b/Source/Scene/Points3DTileContent.js @@ -195,9 +195,11 @@ define([ // Get the point colors var tiles3DRGB = batchTableJSON.TILES3D_RGB; + var tiles3DRGBA = batchTableJSON.TILES3D_RGBA; if (defined(tiles3DRGB)) { - var binaryByteOffset = tiles3DRGB.byteOffset; - colors = new Uint8Array(batchTableBinary, binaryByteOffset, pointsLength * 3); + colors = new Uint8Array(batchTableBinary, tiles3DRGB.byteOffset, pointsLength * 3); + } else if (defined(tiles3DRGBA)) { + colors = new Uint8Array(batchTableBinary, tiles3DRGBA.byteOffset, pointsLength * 4); } } diff --git a/Specs/Data/Cesium3DTiles/Points/PointsRGBA/pointsRGBA.pnts b/Specs/Data/Cesium3DTiles/Points/PointsRGBA/pointsRGBA.pnts new file mode 100644 index 000000000000..50197734882d Binary files /dev/null and b/Specs/Data/Cesium3DTiles/Points/PointsRGBA/pointsRGBA.pnts differ diff --git a/Specs/Data/Cesium3DTiles/Points/PointsRGBA/tileset.json b/Specs/Data/Cesium3DTiles/Points/PointsRGBA/tileset.json new file mode 100644 index 000000000000..c6a10c023a4e --- /dev/null +++ b/Specs/Data/Cesium3DTiles/Points/PointsRGBA/tileset.json @@ -0,0 +1,21 @@ +{ + "asset": { + "version": "0.0" + }, + "geometricError": 346.4, + "refine": "add", + "root": { + "boundingVolume": { + "sphere": [ + 1215011.9317263428, + -4736309.3434217675, + 4081602.0044800863, + 100 + ] + }, + "geometricError": 0, + "content": { + "url": "pointsRGBA.pnts" + } + } +} diff --git a/Specs/Scene/Points3DTileContentSpec.js b/Specs/Scene/Points3DTileContentSpec.js index 02223b9ed6e9..082ab9ef54af 100644 --- a/Specs/Scene/Points3DTileContentSpec.js +++ b/Specs/Scene/Points3DTileContentSpec.js @@ -18,6 +18,7 @@ defineSuite([ var centerLatitude = 0.698874; var pointsRGBUrl = './Data/Cesium3DTiles/Points/PointsRGB'; + var pointsRGBAUrl = './Data/Cesium3DTiles/Points/PointsRGBA'; var pointsNoColorUrl = './Data/Cesium3DTiles/Points/PointsNoColor'; beforeAll(function() { @@ -82,6 +83,10 @@ defineSuite([ return Cesium3DTilesTester.loadTileset(scene, pointsRGBUrl).then(expectRenderPoints); }); + it('renders points with rgba colors', function() { + return Cesium3DTilesTester.loadTileset(scene, pointsRGBAUrl).then(expectRenderPoints); + }); + it('renders points with no colors', function() { return Cesium3DTilesTester.loadTileset(scene, pointsNoColorUrl).then(expectRenderPoints); });