1 /** 2 * Copyright (C) 2009-2012 Klaus Reimer <k@ailis.de> 3 * See LICENSE.txt for licensing information 4 * 5 * @require threedee.js 6 * @require threedee/model/Model.js 7 * @use threedee/Vector.js 8 * @use threedee/model/Polygon.js 9 */ 10 11 /** 12 * Constructs a new cube with the specified sizes. 13 * 14 * @param {number} xRadius 15 * The X radius 16 * @param {number=} yRadius 17 * The Y radius. Optional. Defaults to X radius. 18 * @param {number=} zRadius 19 * The Z radius. Optional. Defaults to Y radius. 20 * 21 * @constructor 22 * @extends {threedee.Model} 23 * @class 24 * A cube model. 25 */ 26 threedee.Cube = function(xRadius, yRadius, zRadius) 27 { 28 if (yRadius === undefined) yRadius = xRadius; 29 if (zRadius === undefined) zRadius = xRadius; 30 31 threedee.Model.call(this, [ 32 new threedee.Vector(-xRadius, yRadius, zRadius), 33 new threedee.Vector(-xRadius, yRadius, -zRadius), 34 new threedee.Vector(xRadius, yRadius, -zRadius), 35 new threedee.Vector(xRadius, yRadius, zRadius), 36 new threedee.Vector(-xRadius, -yRadius, zRadius), 37 new threedee.Vector(-xRadius, -yRadius, -zRadius), 38 new threedee.Vector(xRadius, -yRadius, -zRadius), 39 new threedee.Vector(xRadius, -yRadius, zRadius) 40 ], 41 [ 42 new threedee.Polygon([ 0, 1, 2, 3 ]), 43 new threedee.Polygon([ 7, 3, 2, 6 ]), 44 new threedee.Polygon([ 4, 7, 6, 5 ]), 45 new threedee.Polygon([ 1, 0, 4, 5 ]), 46 new threedee.Polygon([ 0, 3, 7, 4 ]), 47 new threedee.Polygon([ 6, 2, 1, 5 ]) 48 ] 49 ); 50 }; 51 threedee.inherit(threedee.Cube, threedee.Model); 52