mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 01:41:22 +01:00
optimization as suggested by Rayzeq
This commit is contained in:
parent
7b506fc6d8
commit
76bc07e3e2
1 changed files with 6 additions and 2 deletions
|
|
@ -202,11 +202,12 @@
|
||||||
|
|
||||||
function textureToSprite(texture, width, height) {
|
function textureToSprite(texture, width, height) {
|
||||||
const map = new THREE.TextureLoader().load(texture);
|
const map = new THREE.TextureLoader().load(texture);
|
||||||
|
map.anisotropy = Renderer.getMaxAnisotropy();
|
||||||
const material = new THREE.SpriteMaterial({map});
|
const material = new THREE.SpriteMaterial({map});
|
||||||
material.depthTest = false;
|
|
||||||
|
|
||||||
const sprite = new THREE.Sprite(material);
|
const sprite = new THREE.Sprite(material);
|
||||||
sprite.scale.set(width, height, 1);
|
sprite.scale.set(width, height, 1);
|
||||||
|
sprite.renderOrder = 1;
|
||||||
return sprite;
|
return sprite;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -334,6 +335,9 @@
|
||||||
scene.add(stateSprite);
|
scene.add(stateSprite);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// apply visibility setting
|
||||||
|
doWorkOnRender();
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteLabels() {
|
function deleteLabels() {
|
||||||
|
|
@ -528,7 +532,7 @@
|
||||||
function doWorkOnRender() {
|
function doWorkOnRender() {
|
||||||
for (const [i, label] of labels.entries()) {
|
for (const [i, label] of labels.entries()) {
|
||||||
const dist = label.position.distanceTo(camera.position);
|
const dist = label.position.distanceTo(camera.position);
|
||||||
const isVisible = dist < 80 * label.size && dist > label.size * 6;
|
const isVisible = dist < 100 * label.size && dist > label.size * 6;
|
||||||
label.visible = isVisible;
|
label.visible = isVisible;
|
||||||
if (lines[i]) lines[i].visible = isVisible;
|
if (lines[i]) lines[i].visible = isVisible;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue