diff --git a/CHANGES.md b/CHANGES.md index aac3d79a4d13..39280ad6db17 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -29,6 +29,7 @@ Change Log * Fixed a bug when creating billboard and model entities without a globe. [#6109](https://github.com/AnalyticalGraphicsInc/cesium/pull/6109) * Updated documentation links to reflect new locations on cesiumjs.org and cesium.com. * Added support for vertex shader uniforms when `tileset.colorBlendMode` is `MIX` or `REPLACE`. [#5874](https://github.com/AnalyticalGraphicsInc/cesium/pull/5874) +* Fixed applying a translucent style to a point cloud tileset. [#6113](https://github.com/AnalyticalGraphicsInc/cesium/pull/6113) ### 1.41 - 2018-01-02 diff --git a/Source/Scene/Cesium3DTileStyle.js b/Source/Scene/Cesium3DTileStyle.js index f1649ab830a7..941f431b6e2c 100644 --- a/Source/Scene/Cesium3DTileStyle.js +++ b/Source/Scene/Cesium3DTileStyle.js @@ -94,6 +94,8 @@ define([ this._showShaderFunctionReady = false; this._pointSizeShaderFunctionReady = false; + this._colorShaderTranslucent = false; + var promise; if (typeof style === 'string') { promise = loadJson(style); @@ -1453,12 +1455,14 @@ define([ */ Cesium3DTileStyle.prototype.getColorShaderFunction = function(functionName, attributePrefix, shaderState) { if (this._colorShaderFunctionReady) { + shaderState.translucent = this._colorShaderTranslucent; // Return the cached result, may be undefined return this._colorShaderFunction; } this._colorShaderFunctionReady = true; this._colorShaderFunction = defined(this.color) ? this.color.getShaderFunction(functionName, attributePrefix, shaderState, 'vec4') : undefined; + this._colorShaderTranslucent = shaderState.translucent; return this._colorShaderFunction; }; diff --git a/Specs/Data/Cesium3DTiles/Tilesets/TilesetPoints/0.pnts b/Specs/Data/Cesium3DTiles/Tilesets/TilesetPoints/0.pnts new file mode 100644 index 000000000000..3622fbf0fb4d Binary files /dev/null and b/Specs/Data/Cesium3DTiles/Tilesets/TilesetPoints/0.pnts differ diff --git a/Specs/Data/Cesium3DTiles/Tilesets/TilesetPoints/1.pnts b/Specs/Data/Cesium3DTiles/Tilesets/TilesetPoints/1.pnts new file mode 100644 index 000000000000..c9f9698361ff Binary files /dev/null and b/Specs/Data/Cesium3DTiles/Tilesets/TilesetPoints/1.pnts differ diff --git a/Specs/Data/Cesium3DTiles/Tilesets/TilesetPoints/2.pnts b/Specs/Data/Cesium3DTiles/Tilesets/TilesetPoints/2.pnts new file mode 100644 index 000000000000..30a52479f575 Binary files /dev/null and b/Specs/Data/Cesium3DTiles/Tilesets/TilesetPoints/2.pnts differ diff --git a/Specs/Data/Cesium3DTiles/Tilesets/TilesetPoints/3.pnts b/Specs/Data/Cesium3DTiles/Tilesets/TilesetPoints/3.pnts new file mode 100644 index 000000000000..b913eeab1893 Binary files /dev/null and b/Specs/Data/Cesium3DTiles/Tilesets/TilesetPoints/3.pnts differ diff --git a/Specs/Data/Cesium3DTiles/Tilesets/TilesetPoints/4.pnts b/Specs/Data/Cesium3DTiles/Tilesets/TilesetPoints/4.pnts new file mode 100644 index 000000000000..1da4e463dbc4 Binary files /dev/null and b/Specs/Data/Cesium3DTiles/Tilesets/TilesetPoints/4.pnts differ diff --git a/Specs/Data/Cesium3DTiles/Tilesets/TilesetPoints/5.pnts b/Specs/Data/Cesium3DTiles/Tilesets/TilesetPoints/5.pnts new file mode 100644 index 000000000000..d99fa39f8c77 Binary files /dev/null and b/Specs/Data/Cesium3DTiles/Tilesets/TilesetPoints/5.pnts differ diff --git a/Specs/Data/Cesium3DTiles/Tilesets/TilesetPoints/6.pnts b/Specs/Data/Cesium3DTiles/Tilesets/TilesetPoints/6.pnts new file mode 100644 index 000000000000..f7cc21a99750 Binary files /dev/null and b/Specs/Data/Cesium3DTiles/Tilesets/TilesetPoints/6.pnts differ diff --git a/Specs/Data/Cesium3DTiles/Tilesets/TilesetPoints/7.pnts b/Specs/Data/Cesium3DTiles/Tilesets/TilesetPoints/7.pnts new file mode 100644 index 000000000000..b8e4f9ea9a1c Binary files /dev/null and b/Specs/Data/Cesium3DTiles/Tilesets/TilesetPoints/7.pnts differ diff --git a/Specs/Data/Cesium3DTiles/Tilesets/TilesetPoints/parent.pnts b/Specs/Data/Cesium3DTiles/Tilesets/TilesetPoints/parent.pnts new file mode 100644 index 000000000000..da80bf879a88 Binary files /dev/null and b/Specs/Data/Cesium3DTiles/Tilesets/TilesetPoints/parent.pnts differ diff --git a/Specs/Data/Cesium3DTiles/Tilesets/TilesetPoints/tileset.json b/Specs/Data/Cesium3DTiles/Tilesets/TilesetPoints/tileset.json new file mode 100644 index 000000000000..5c933b8efedd --- /dev/null +++ b/Specs/Data/Cesium3DTiles/Tilesets/TilesetPoints/tileset.json @@ -0,0 +1,225 @@ +{ + "asset": { + "version": "0.0" + }, + "geometricError": 17.32, + "root": { + "boundingVolume": { + "box": [ + 0, + 0, + 0, + 5, + 0, + 0, + 0, + 5, + 0, + 0, + 0, + 5 + ] + }, + "transform": [ + 0.968635634376879, + 0.24848542777253735, + 0, + 0, + -0.15986460794399626, + 0.6231776137472074, + 0.7655670897127491, + 0, + 0.190232265775849, + -0.7415555636019701, + 0.6433560687121489, + 0, + 1215012.8828876738, + -4736313.051199594, + 4081605.22126042, + 1 + ], + "geometricError": 8.66, + "refine": "ADD", + "content": { + "url": "parent.pnts" + }, + "children": [ + { + "boundingVolume": { + "box": [ + -2.5, + -2.5, + -2.5, + 2.5, + 0, + 0, + 0, + 2.5, + 0, + 0, + 0, + 2.5 + ] + }, + "geometricError": 0, + "content": { + "url": "0.pnts" + } + }, + { + "boundingVolume": { + "box": [ + -2.5, + 2.5, + 2.5, + 2.5, + 0, + 0, + 0, + 2.5, + 0, + 0, + 0, + 2.5 + ] + }, + "geometricError": 0, + "content": { + "url": "1.pnts" + } + }, + { + "boundingVolume": { + "box": [ + -2.5, + -2.5, + 2.5, + 2.5, + 0, + 0, + 0, + 2.5, + 0, + 0, + 0, + 2.5 + ] + }, + "geometricError": 0, + "content": { + "url": "2.pnts" + } + }, + { + "boundingVolume": { + "box": [ + -2.5, + 2.5, + -2.5, + 2.5, + 0, + 0, + 0, + 2.5, + 0, + 0, + 0, + 2.5 + ] + }, + "geometricError": 0, + "content": { + "url": "3.pnts" + } + }, + { + "boundingVolume": { + "box": [ + 2.5, + -2.5, + -2.5, + 2.5, + 0, + 0, + 0, + 2.5, + 0, + 0, + 0, + 2.5 + ] + }, + "geometricError": 0, + "content": { + "url": "4.pnts" + } + }, + { + "boundingVolume": { + "box": [ + 2.5, + 2.5, + -2.5, + 2.5, + 0, + 0, + 0, + 2.5, + 0, + 0, + 0, + 2.5 + ] + }, + "geometricError": 0, + "content": { + "url": "5.pnts" + } + }, + { + "boundingVolume": { + "box": [ + 2.5, + -2.5, + 2.5, + 2.5, + 0, + 0, + 0, + 2.5, + 0, + 0, + 0, + 2.5 + ] + }, + "geometricError": 0, + "content": { + "url": "6.pnts" + } + }, + { + "boundingVolume": { + "box": [ + 2.5, + 2.5, + 2.5, + 2.5, + 0, + 0, + 0, + 2.5, + 0, + 0, + 0, + 2.5 + ] + }, + "geometricError": 0, + "content": { + "url": "7.pnts" + } + } + ] + } +} diff --git a/Specs/Scene/PointCloud3DTileContentSpec.js b/Specs/Scene/PointCloud3DTileContentSpec.js index 45521ea9ecce..89a368150578 100644 --- a/Specs/Scene/PointCloud3DTileContentSpec.js +++ b/Specs/Scene/PointCloud3DTileContentSpec.js @@ -11,6 +11,7 @@ defineSuite([ 'Core/PerspectiveFrustum', 'Core/Plane', 'Core/Transforms', + 'Renderer/Pass', 'Scene/Cesium3DTileStyle', 'Scene/Expression', 'Specs/Cesium3DTilesTester', @@ -29,6 +30,7 @@ defineSuite([ PerspectiveFrustum, Plane, Transforms, + Pass, Cesium3DTileStyle, Expression, Cesium3DTilesTester, @@ -53,6 +55,7 @@ defineSuite([ var pointCloudBatchedUrl = './Data/Cesium3DTiles/PointCloud/PointCloudBatched'; var pointCloudWithPerPointPropertiesUrl = './Data/Cesium3DTiles/PointCloud/PointCloudWithPerPointProperties'; var pointCloudWithTransformUrl = './Data/Cesium3DTiles/PointCloud/PointCloudWithTransform'; + var pointCloudTilesetUrl = './Data/Cesium3DTiles/Tilesets/TilesetPoints'; function setCamera(longitude, latitude) { // Point the camera to the center of the tile @@ -539,7 +542,7 @@ defineSuite([ }); it('rebuilds shader style when expression changes', function() { - return Cesium3DTilesTester.loadTileset(scene, pointCloudWithPerPointPropertiesUrl).then(function(tileset) { + return Cesium3DTilesTester.loadTileset(scene, pointCloudTilesetUrl).then(function(tileset) { // Solid red color tileset.style = new Cesium3DTileStyle({ color : 'color("red")' @@ -549,6 +552,28 @@ defineSuite([ tileset.style.color = new Expression('color("lime")'); tileset.makeStyleDirty(); expect(scene).toRender([0, 255, 0, 255]); + + tileset.style.color = new Expression('color("blue", 0.5)'); + tileset.makeStyleDirty(); + expect(scene).toRender([0, 0, 255, 255]); + + var i; + var commands = scene.frameState.commandList; + var commandsLength = commands.length; + expect(commandsLength).toBeGreaterThan(1); // Just check that at least some children are rendered + for (i = 0; i < commandsLength; ++i) { + expect(commands[i].pass).toBe(Pass.TRANSLUCENT); + } + + tileset.style.color = new Expression('color("yellow")'); + tileset.makeStyleDirty(); + expect(scene).toRender([255, 255, 0, 255]); + + commands = scene.frameState.commandList; + commandsLength = commands.length; + for (i = 0; i < commandsLength; ++i) { + expect(commands[i].pass).not.toBe(Pass.TRANSLUCENT); + } }); });