Skip to content

Commit 376a4ec

Browse files
author
Léna Voinchet
committed
Fix "display frustum" button
1 parent 3eb3583 commit 376a4ec

File tree

5 files changed

+26
-16
lines changed

5 files changed

+26
-16
lines changed

js/UI/LidarUI.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,11 +234,10 @@ class LidarUI{
234234
sceneManager.objects.populateStorage();
235235
}
236236

237-
this.changeVisibility = function(visible)
237+
this.changeVisibilityUIOnly = function(visible)
238238
{
239239
const iconElem = document.getElementById('lidar-' + (lidar.id) + '-visible').firstElementChild;
240240
iconElem.dataset.icon = visible ? "akar-icons:eye-open" : "akar-icons:eye-slashed";
241-
sceneManager.objects.updateRaysIcon();
242241
}
243242

244243
this.updatePosition = function(x, z, currentUnitValue)

js/UI/NodeUI.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class NodeUI {
7878

7979
document.getElementById(`node-${node.id}-duplicate`).addEventListener('click', () => sceneManager.objects.duplicateNode(node));
8080
document.getElementById(`node-${node.id}-hide-UI`).addEventListener('click', () => hideUICam());
81-
document.getElementById(`node-${node.id}-visible`).addEventListener('click', () => node.changeFrustumVisibility());
81+
document.getElementById(`node-${node.id}-visible`).addEventListener('click', () => node.changeVisibility());
8282
document.getElementById(`node-${node.id}-delete`).addEventListener('click', () => sceneManager.objects.removeNode(node));
8383

8484
document.getElementById(`cam-type-${node.id}`).addEventListener('change', changeCameraType);

js/scene/objects/SceneObjects.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,9 +291,9 @@ class SceneObjects{
291291
this.displayRays = function()
292292
{
293293
const visibles = lidars.filter(l => l.raysAppear);
294-
lidars.forEach(l => l.changeVisibility(visibles.length != lidars.length));
294+
lidars.forEach(l => l.changeRaysVisibility(visibles.length != lidars.length));
295295
const iconElem = document.getElementById('display-lidars-rays-button-icon');
296-
if(iconElem) iconElem.dataset.icon = visibles.length != nodes.length ? "akar-icons:eye-slashed" : "akar-icons:eye-open";
296+
if(iconElem) iconElem.dataset.icon = visibles.length != lidars.length ? "akar-icons:eye-open" : "akar-icons:eye-slashed";
297297
}
298298

299299
this.updateRaysIcon = function()

js/scene/objects/sensors/Lidar.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,15 +129,21 @@ class Lidar{
129129
}
130130

131131
/* USER'S ACTION */
132-
changeVisibility(display = !this.raysAppear)
132+
changeRaysVisibility(visible = !this.raysAppear)
133133
{
134-
const value = display;
135-
this.raysAppear = value;
136-
this.rays.visible = value;
137-
this.nameText.visible = value;
134+
this.raysAppear = visible;
138135

139-
if (this.uiElement && typeof this.uiElement.changeVisibility === 'function') {
140-
this.uiElement.changeVisibility(value);
136+
if (this.rays) this.rays.visible = visible;
137+
if(this.nameText) this.nameText.visible = visible;
138+
}
139+
140+
changeVisibility(visible = !this.raysAppear)
141+
{
142+
this.changeRaysVisibility(visible);
143+
if (this.mesh) this.mesh.visible = visible;
144+
145+
if (this.uiElement && typeof this.uiElement.changeVisibilityUIOnly === 'function') {
146+
this.uiElement.changeVisibilityUIOnly(visible);
141147
}
142148
}
143149

js/scene/objects/sensors/Node.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ class Node{
172172
this.updateAreaText(sceneManager.currentUnit);
173173

174174
// Update visibility
175-
this.changeFrustumVisibility(this.areaAppear);
175+
this.changeVisibility(this.areaAppear);
176176
}
177177

178178
updateTransformation()
@@ -204,12 +204,12 @@ class Node{
204204
scene.add(this.nameText);
205205
scene.add(this.areaValueText);
206206
this.areaAppear = true;
207-
this.changeFrustumVisibility(true);
207+
this.changeVisibility(true);
208208
}
209209

210210
removeFromScene(scene)
211211
{
212-
this.changeFrustumVisibility(false);
212+
this.changeVisibility(false);
213213
this.areaAppear = false;
214214
scene.remove(this.cameraPerspective);
215215
scene.remove(this.cameraPerspectiveHelper);
@@ -228,9 +228,14 @@ class Node{
228228
this.areaAppear = visible;
229229
if (this.cameraPerspective) this.cameraPerspective.visible = visible;
230230
if (this.cameraPerspectiveHelper) this.cameraPerspectiveHelper.visible = visible;
231-
if (this.mesh) this.mesh.visible = visible;
232231
if (this.nameText) this.nameText.visible = visible;
233232
if (this.areaValueText) this.areaValueText.visible = visible && (this.coveredPointsAbove && this.coveredPointsAbove.length > 2);
233+
}
234+
235+
changeVisibility(visible = !this.areaAppear)
236+
{
237+
this.changeFrustumVisibility(visible);
238+
if (this.mesh) this.mesh.visible = visible;
234239

235240
if (this.uiElement && typeof this.uiElement.changeVisibilityUIOnly === 'function') {
236241
this.uiElement.changeVisibilityUIOnly(visible);

0 commit comments

Comments
 (0)