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/updater/NodeUpdater.js 7 */ 8 9 /** 10 * Constructs a new pitch updater. 11 * 12 * @param {number} angle 13 * The angle the node should be rotated around the X axis per 14 * second. Measured in clock-wise RAD. 15 * 16 * @constructor 17 * @extends {threedee.NodeUpdater} 18 * @class 19 * The pitch updater rotates a node around the X axis. 20 */ 21 threedee.PitchUpdater = function(angle) 22 { 23 threedee.NodeUpdater.call(this); 24 this.angle = angle; 25 }; 26 threedee.inherit(threedee.PitchUpdater, threedee.NodeUpdater); 27 28 /** 29 * The rotation speed in clock-wise RAD per second. 30 * @private 31 * @type {number} 32 */ 33 threedee.PitchUpdater.prototype.angle; 34 35 /** 36 * Returns the current angle. 37 * 38 * @return {number} 39 * The angle the node is rotated around the X axis per second. 40 * Measured in clock-wise RAD. 41 */ 42 threedee.PitchUpdater.prototype.getAngle = function() 43 { 44 return this.angle; 45 }; 46 47 /** 48 * Sets the angle. 49 * 50 * @param {number} angle 51 * The angle the node should be rotated around the X axis per 52 * second. Measured in clock-wise RAD. 53 */ 54 threedee.PitchUpdater.prototype.setAngle = function(angle) 55 { 56 this.angle = angle; 57 }; 58 59 /** 60 * @inheritDoc 61 * 62 * @param {!threedee.SceneNode} node 63 * @param {number} delta 64 */ 65 threedee.PitchUpdater.prototype.update = function(node, delta) 66 { 67 // Do nothing if angle is 0 68 if (this.angle == 0) return; 69 70 node.getTransform().rotateX(this.angle * delta / 1000); 71 }; 72