Labels now follow camera

This commit is contained in:
Robert Levesque 2016-08-23 22:21:53 -04:00
parent 2036ebf6d0
commit abd78b0269

View File

@ -90,6 +90,7 @@ for (var key in jsonEmpire) {
l_text.material.alphaTest = 0.5; l_text.material.alphaTest = 0.5;
l_text.position.set(border.x,border.y,border.z); l_text.position.set(border.x,border.y,border.z);
l_text.scale.set(0.75,0.75,0.75); l_text.scale.set(0.75,0.75,0.75);
l_text.name = border.name + "_label";
scene.add(l_text); scene.add(l_text);
} }
} }
@ -111,7 +112,7 @@ for (var key in jsonEmpire) {
l_text.material.alphaTest = 0.0; l_text.material.alphaTest = 0.0;
l_text.position.set(planet.x,planet.y,planet.z); l_text.position.set(planet.x,planet.y,planet.z);
l_text.scale.set(0.25,0.25,0.25); l_text.scale.set(0.25,0.25,0.25);
l_text.name = escapeHTML(planet.name); l_text.name = escapeHTML(planet.name + "_label");
scene.add(l_text); scene.add(l_text);
} }
@ -131,7 +132,7 @@ for (var key in jsonEmpire) {
l_text.material.alphaTest = 0.0; l_text.material.alphaTest = 0.0;
l_text.position.set(base.x,base.y+3,base.z); l_text.position.set(base.x,base.y+3,base.z);
l_text.scale.set(0.20,0.20,0.20); l_text.scale.set(0.20,0.20,0.20);
l_text.name = escapeHTML(base.name); l_text.name = escapeHTML(base.name + "_label");
scene.add(l_text); scene.add(l_text);
} }
@ -191,9 +192,16 @@ function animate() {
function render () { function render () {
//requestAnimationFrame( render ); //requestAnimationFrame( render );
var objectlist = Object.keys(listobjects("stations"));
objectlist.forEach (function(station) { var obj = scene.getObjectByName(escapeHTML(station + "_label")); obj.lookAt(camera.position) }) ;
objectlist = Object.keys(listobjects("planets"));
objectlist.forEach (function(planet) { var obj = scene.getObjectByName(escapeHTML(planet + "_label")); obj.lookAt(camera.position) }) ;
objectlist = Object.keys(listobjects("borders"));
objectlist.forEach (function(border) { var obj = scene.getObjectByName(border + "_label"); if (obj != undefined) { obj.lookAt(camera.position)} }) ;
renderer.render( scene, camera ); renderer.render( scene, camera );
}
}
function listobjects(type) { function listobjects(type) {
@ -211,6 +219,7 @@ function listobjects(type) {
return objects; return objects;
} }
function zoomfocus(name) { function zoomfocus(name) {