'use strict';

/**
 * Objects to draw and interact with the planet Earth
 * @class Earth
 * @requires jsfps/Game
 */
var Earth = function() {
    var self=this;

    /**
     * Mass, heavier means more gravity
     * @name Planet#mass
     * @type Number
    */
    this.mass = 1<<14;

    /**
     * ThreeJS Texture
     * @name texture
     * @type Texture
    */
    var texture = game.texture_loader.load('textures/grass.png');
	texture.wrapS = THREE.RepeatWrapping;
	texture.wrapT = THREE.RepeatWrapping;
	texture.repeat.set( 1<<10, 1<<10 );

    /**
     * ThreeJS Mesh
     * @name Earth#mesh
     * @type Mesh
    */
    this.mesh = new THREE.Mesh(
		new THREE.PlaneGeometry(
            1<<15, // width
            1<<15 // height
            //1, // widthSegments
            //1 // heightSegments
        ),
		new THREE.MeshBasicMaterial( { map: texture } )
	);
	this.mesh.rotation.x = -Math.PI / 2;

    /**
     * Function to update camera position and orientation
     * @name Camera#update
     * @type function
    */
    this.update = 'function'===typeof onUpdate ? onUpdate : function() {};

}


/**
 * Express the Earth as a string
 * @returns {string} Earth's info
 */
Earth.prototype.toString = function() {
    return ''
        +'Earth'
        +'('
        +' '
        +'q: '+quat.str(this.q)
        +' '
        +')';
};
