/*
 * Copyright (c) 2017, Tim Leerhoff <tleerhof@web.de>
 * All rights reserved.
 *
 * See LICENSE-file for further information.
 */
var vecmat = require('lethexa-vecmat');
var meshutils = require('./meshutils');
var materials = require('./materials');


var renderMeshAtVector = function(vCenter, transform) {
    var options = {
        flatNormals: true,
        step: 30,
        transform: transform,
        material: materials.streetlamp,
        profile: [
            vecmat.vector3dFromElements(0.10, 4.0, 0),
            vecmat.vector3dFromElements(0.10, 1.1, 0),
            vecmat.vector3dFromElements(0.15, 1.0, 0),
            vecmat.vector3dFromElements(0.15, 0.0, 0)
        ]
    };
    return meshutils.makeRoundShapeMeshAt(vCenter, options);
};
module.exports.renderMeshAtVector = renderMeshAtVector;


var renderMeshAtLatLonAlt = function(llCenter) {
    var transform = meshutils.getWorldToLocalFromLLA(llCenter);
    var vCenter = meshutils.cvtLLCoordinateToVector(llCenter);
    return renderMeshAtVector(vCenter, transform);
};
module.exports.renderMeshAtLatLonAlt = renderMeshAtLatLonAlt;


var renderMeshAtLLCoordinates = function(llCoordinates) {
    var llCenter = meshutils.getCenterLLFromCoordinates(llCoordinates);
    return renderMeshAtLatLonAlt(llCenter);
};
module.exports.renderMeshAtLLCoordinates = renderMeshAtLLCoordinates;

