From 8d2937a5b636944e04f00de7708850d3cee9825f Mon Sep 17 00:00:00 2001 From: Dan Bagnell Date: Thu, 28 Feb 2013 16:54:18 -0500 Subject: [PATCH] More changes based on review. --- Source/Scene/PerformanceDisplay.js | 2 +- Source/Scene/ViewportQuad.js | 12 ++++++++---- Specs/Scene/ViewportQuadSpec.js | 12 ++++++++++++ 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/Source/Scene/PerformanceDisplay.js b/Source/Scene/PerformanceDisplay.js index 8a746d30a8e..0feaaf4b38c 100644 --- a/Source/Scene/PerformanceDisplay.js +++ b/Source/Scene/PerformanceDisplay.js @@ -134,7 +134,7 @@ define([ } if (typeof this._quad === 'undefined') { - this._quad = new ViewportQuad(Material.fromType(context, Material.ImageType)); + this._quad = new ViewportQuad(undefined, Material.fromType(context, Material.ImageType)); } if (typeof this._texture === 'undefined') { diff --git a/Source/Scene/ViewportQuad.js b/Source/Scene/ViewportQuad.js index 9c29b479a65..8836e1c6c12 100644 --- a/Source/Scene/ViewportQuad.js +++ b/Source/Scene/ViewportQuad.js @@ -41,14 +41,14 @@ define([ * @alias ViewportQuad * @constructor * + * @param {BoundingRectangle} [rectangle] The {@link BoundingRectangle} defining the quad's position within the viewport. * @param {Material} [material] The {@link Material} defining the surface appearance of the viewport quad. * * @example - * var viewportQuad = new ViewportQuad(); - * var viewportQuad = new BoundingRectangle(0, 0, 80, 40); + * var viewportQuad = new ViewportQuad(new BoundingRectangle(0, 0, 80, 40)); * viewportQuad.material.uniforms.color = new Color(1.0, 0.0, 0.0, 1.0); */ - var ViewportQuad = function(material) { + var ViewportQuad = function(rectangle, material) { this._va = undefined; this._overlayCommand = new DrawCommand(); @@ -66,6 +66,10 @@ define([ */ this.show = true; + if (typeof rectangle === 'undefined') { + rectangle = new BoundingRectangle(0, 0, 10, 10); + } + /** * The BoundingRectangle defining the quad's position within the viewport. * @@ -74,7 +78,7 @@ define([ * @example * viewportQuad.rectangle = new BoundingRectangle(0, 0, 80, 40); */ - this.rectangle = new BoundingRectangle(0, 0, 10, 10); + this.rectangle = rectangle; if (typeof material === 'undefined') { material = Material.fromType(undefined, Material.ColorType); diff --git a/Specs/Scene/ViewportQuadSpec.js b/Specs/Scene/ViewportQuadSpec.js index b9e3658f991..24d10b25cd8 100644 --- a/Specs/Scene/ViewportQuadSpec.js +++ b/Specs/Scene/ViewportQuadSpec.js @@ -57,6 +57,18 @@ defineSuite([ us = undefined; }); + it('constructs with a rectangle', function() { + var rectangle = new BoundingRectangle(1.0, 2.0, 3.0, 4.0); + var quad = new ViewportQuad(rectangle); + expect(quad.rectangle).toEqual(rectangle); + }); + + it('constructs with a material', function() { + var material = Material.fromType(undefined, Material.ErosionType); + var quad = new ViewportQuad(undefined, material); + expect(quad.material.type).toEqual(material.type); + }); + it('gets the default color', function() { expect(viewportQuad.material.uniforms.color).toEqual( new Color(1.0, 1.0, 1.0, 1.0));