Skip to content

Commit

Permalink
Don't issue command when alpha is 0
Browse files Browse the repository at this point in the history
  • Loading branch information
lilleyse committed Dec 6, 2016
1 parent 6a60f25 commit 165dd1b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
9 changes: 6 additions & 3 deletions Source/Scene/Model.js
Original file line number Diff line number Diff line change
Expand Up @@ -3505,7 +3505,8 @@ define([

function updateColor(model, frameState) {
var scene3DOnly = frameState.scene3DOnly;
if (model.color.alpha < 1.0) {
var alpha = model.color.alpha;
if ((alpha > 0.0) && (alpha < 1.0)) {
var nodeCommands = model._nodeCommands;
var length = nodeCommands.length;
// Generate translucent commands when the blend color has an alpha less than 1.0
Expand Down Expand Up @@ -3857,8 +3858,9 @@ define([
}
}

var alpha = this.color.alpha;
var displayConditionPassed = defined(this.distanceDisplayCondition) ? distanceDisplayConditionVisible(this, frameState) : true;
var show = this.show && displayConditionPassed && (this.scale !== 0.0);
var show = this.show && displayConditionPassed && (this.scale !== 0.0) && (alpha > 0.0);

if ((show && this._state === ModelState.LOADED) || justLoaded) {
var animated = this.activeAnimations.update(frameState) || this._cesiumAnimationsDirty;
Expand Down Expand Up @@ -3945,11 +3947,12 @@ define([
var idl2D = frameState.mapProjection.ellipsoid.maximumRadius * CesiumMath.PI;
var boundingVolume;


if (passes.render) {
for (i = 0; i < length; ++i) {
nc = nodeCommands[i];
if (nc.show) {
var translucent = (this.color.alpha < 1.0);
var translucent = (alpha < 1.0);
var command = translucent ? nc.translucentCommand : nc.command;
commandList.push(command);
boundingVolume = nc.command.boundingVolume;
Expand Down
8 changes: 7 additions & 1 deletion Specs/Scene/ModelSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1915,13 +1915,19 @@ defineSuite([
expect(sourceColor[1]).toEqual(0);
expect(sourceColor[2]).toEqual(0);

// Check alpha.
// Check alpha
model.colorBlendMode = ColorBlendMode.REPLACE;
model.color = Color.fromAlpha(Color.LIME, 0.5);
color = scene.renderForSpecs();
expect(color[0]).toEqual(0);
expect(color[1]).toBeLessThan(255);
expect(color[1]).toBeGreaterThan(0);

// No commands are issued when the alpha is 0.0
model.color = Color.fromAlpha(Color.LIME, 0.0);
scene.renderForSpecs();
var commands = scene.frameState.commandList;
expect(commands.length).toBe(0);
});
});

Expand Down

0 comments on commit 165dd1b

Please sign in to comment.