mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-22 20:11:24 +01:00
Labels adapts to height scale
This commit is contained in:
parent
d874f9a3c4
commit
ab61c30e20
1 changed files with 14 additions and 0 deletions
|
|
@ -78,6 +78,14 @@ const stop = function() {
|
||||||
|
|
||||||
const setScale = function(scale) {
|
const setScale = function(scale) {
|
||||||
options.scale = scale;
|
options.scale = scale;
|
||||||
|
|
||||||
|
for (const mesh of textMeshs) {
|
||||||
|
mesh.position.y = getMeshHeight(findGridCell(mesh.base_x, mesh.base_y)) + mesh.base_height;
|
||||||
|
}
|
||||||
|
for (const mesh of iconMeshs) {
|
||||||
|
mesh.position.y = getMeshHeight(findGridCell(mesh.base_x, mesh.base_y));
|
||||||
|
|
||||||
|
}
|
||||||
geometry.vertices.forEach((v, i) => v.z = getMeshHeight(i));
|
geometry.vertices.forEach((v, i) => v.z = getMeshHeight(i));
|
||||||
geometry.verticesNeedUpdate = true;
|
geometry.verticesNeedUpdate = true;
|
||||||
geometry.computeVertexNormals();
|
geometry.computeVertexNormals();
|
||||||
|
|
@ -282,11 +290,13 @@ async function createMesh(width, height, segmentsX, segmentsY) {
|
||||||
|
|
||||||
if (burg.capital) {
|
if (burg.capital) {
|
||||||
text_mesh.position.set(x, y + 15, z);
|
text_mesh.position.set(x, y + 15, z);
|
||||||
|
text_mesh.base_height = 15
|
||||||
text_mesh.animate = function () {
|
text_mesh.animate = function () {
|
||||||
this.rotation.copy(camera.rotation);
|
this.rotation.copy(camera.rotation);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
text_mesh.position.set(x, y + 5, z);
|
text_mesh.position.set(x, y + 5, z);
|
||||||
|
text_mesh.base_height = 5
|
||||||
text_mesh.animate = function () {
|
text_mesh.animate = function () {
|
||||||
if(this.position.distanceTo(camera.position) > 200) {
|
if(this.position.distanceTo(camera.position) > 200) {
|
||||||
this.visible = false;
|
this.visible = false;
|
||||||
|
|
@ -296,6 +306,8 @@ async function createMesh(width, height, segmentsX, segmentsY) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
text_mesh.base_x = burg.x
|
||||||
|
text_mesh.base_y = burg.y
|
||||||
|
|
||||||
textMeshs.push(text_mesh);
|
textMeshs.push(text_mesh);
|
||||||
scene.add(text_mesh);
|
scene.add(text_mesh);
|
||||||
|
|
@ -309,6 +321,8 @@ async function createMesh(width, height, segmentsX, segmentsY) {
|
||||||
icon_material
|
icon_material
|
||||||
);
|
);
|
||||||
icon_mesh.position.set(x, y, z)
|
icon_mesh.position.set(x, y, z)
|
||||||
|
icon_mesh.base_x = burg.x
|
||||||
|
icon_mesh.base_y = burg.y
|
||||||
|
|
||||||
iconMeshs.push(icon_mesh);
|
iconMeshs.push(icon_mesh);
|
||||||
scene.add(icon_mesh);
|
scene.add(icon_mesh);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue