Skip to content

Commit

Permalink
Added support for RGBA
Browse files Browse the repository at this point in the history
  • Loading branch information
lilleyse committed Jul 13, 2016
1 parent 8387119 commit 1393820
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 4 deletions.
8 changes: 6 additions & 2 deletions Source/Core/PointGeometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -82,8 +86,8 @@ define([

attributes.color = new GeometryAttribute({
componentDatatype : ComponentDatatype.UNSIGNED_BYTE,
componentsPerAttribute : 3,
values : pointGeometry._colorsTypedArray,
componentsPerAttribute : colorComponentsPerAttribute,
values : colors,
normalize : true
});

Expand Down
6 changes: 4 additions & 2 deletions Source/Scene/Points3DTileContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
Binary file not shown.
21 changes: 21 additions & 0 deletions Specs/Data/Cesium3DTiles/Points/PointsRGBA/tileset.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
5 changes: 5 additions & 0 deletions Specs/Scene/Points3DTileContentSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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);
});
Expand Down

0 comments on commit 1393820

Please sign in to comment.