Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polyline Fixes #711

Merged
merged 4 commits into from
Apr 30, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions Source/Scene/PolylineCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ define([
};

var emptyArray = [];
var scracthBoundingSphere = new BoundingSphere();

/**
* @private
Expand Down Expand Up @@ -449,10 +450,13 @@ define([
if (frameState.mode === SceneMode.SCENE3D) {
boundingVolume = this._boundingVolume;
modelMatrix = this.modelMatrix;
} else if (frameState.mode === SceneMode.COLUMBUS_VIEW || frameState.mode === SceneMode.SCENE2D) {
} else if (frameState.mode === SceneMode.COLUMBUS_VIEW) {
boundingVolume = this._boundingVolume2D;
} else {
boundingVolume = this._boundingVolume && this._boundingVolume2D && this._boundingVolume.union(this._boundingVolume2D);
} else if (frameState.mode === SceneMode.SCENE2D) {
boundingVolume = BoundingSphere.clone(this._boundingVolume2D, scracthBoundingSphere);
boundingVolume.center.x = 0.0;
} else if (typeof this._boundingVolume !== 'undefined' && typeof this._boundingVolume2D !== 'undefined') {
boundingVolume = BoundingSphere.union(this._boundingVolume, this._boundingVolume2D, scracthBoundingSphere);
}

var pass = frameState.passes;
Expand Down Expand Up @@ -1069,7 +1073,7 @@ define([
for ( var i = 0; i < length; ++i) {
var polyline = polylines[i];
var width = polyline.getWidth();
var show = polyline.getShow();
var show = polyline.getShow() && width > 0.0;
var segments = this.getSegments(polyline);
var positions = segments.positions;
var lengths = segments.lengths;
Expand Down Expand Up @@ -1393,7 +1397,7 @@ define([
var position;

var width = polyline.getWidth();
var show = polyline.getShow();
var show = polyline.getShow() && width > 0.0;

positionsLength = positions.length;
for ( var i = 0; i < positionsLength; ++i) {
Expand Down
29 changes: 29 additions & 0 deletions Specs/Scene/PolylineCollectionSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1503,6 +1503,35 @@ defineSuite([
expect(context.readPixels()).toNotEqual([0, 0, 0, 0]);
});

it('does not render with width 0.0', function() {
var positions = [
{
x : -1.0,
y : 1.0,
z : 0.0
},{
x : -1.0,
y : -1.0,
z : 0.0
}];
var line = polylines.add({
positions : positions
});

ClearCommand.ALL.execute(context);
expect(context.readPixels()).toEqual([0, 0, 0, 0]);

render(context, frameState, polylines);
expect(context.readPixels()).toNotEqual([0, 0, 0, 0]);

ClearCommand.ALL.execute(context);
expect(context.readPixels()).toEqual([0, 0, 0, 0]);

line.setWidth(0.0);
render(context, frameState, polylines);
expect(context.readPixels()).toEqual([0, 0, 0, 0]);
});

it('changes polyline position size recreates vertex arrays', function() {
var positions = [];
for(var i = 0; i < 20; ++i){
Expand Down