Skip to content

Commit 05d112a

Browse files
committed
Default sensor selected and creating scene
1 parent a87298c commit 05d112a

File tree

1 file changed

+42
-33
lines changed

1 file changed

+42
-33
lines changed

js/UI/Popup.js

Lines changed: 42 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -581,39 +581,7 @@ class Popup{
581581

582582
//New hardware selection system
583583
document.getElementById("multi-select-sensors").addEventListener('change', () => {
584-
const sensorTextId = document.getElementById("multi-select-sensors").value;
585-
//on click on a sensor, display the scene calculated with this sensor
586-
switch(trackingMode)
587-
{
588-
case 'wall-tracking':
589-
{
590-
const sensor = getLidarsTypes().find(sensorType => sensorType.textId === sensorTextId);
591-
const config = calculateLidarConfig(sensor, givenWidth, givenHeight);
592-
if(!config){
593-
console.error('no config found with this setup');
594-
return;
595-
}
596-
sceneManager.objects.removeSensors();
597-
createSceneFromLidarConfig(config, sceneManager);
598-
break;
599-
}
600-
case 'human-tracking':
601-
case 'hand-tracking':
602-
{
603-
const sensor = getCamerasTypes().find(sensorType => sensorType.textId === sensorTextId);
604-
const overlapHeightDetection = trackingMode === 'human-tracking' ? SceneManager.DEFAULT_DETECTION_HEIGHT : SceneManager.HAND_TRACKING_OVERLAP_HEIGHT;
605-
const config = calculateCameraConfig(trackingMode, sensor, givenWidth, givenLength, givenHeight, overlapHeightDetection);
606-
if(!config){
607-
console.error('no config found with this setup');
608-
return;
609-
}
610-
sceneManager.objects.removeSensors();
611-
createSceneFromCameraConfig(config, trackingMode, givenWidth, givenLength, givenHeight + sceneManager.sceneElevation, sceneManager);
612-
break;
613-
}
614-
default:
615-
break;
616-
}
584+
createSceneFromSelectedSensor();
617585
});
618586

619587
//Old selection system
@@ -666,6 +634,42 @@ class Popup{
666634
// }
667635
}
668636

637+
function createSceneFromSelectedSensor(){
638+
const sensorTextId = document.getElementById("multi-select-sensors").value;
639+
//on click on a sensor, display the scene calculated with this sensor
640+
switch(trackingMode)
641+
{
642+
case 'wall-tracking':
643+
{
644+
const sensor = getLidarsTypes().find(sensorType => sensorType.textId === sensorTextId);
645+
const config = calculateLidarConfig(sensor, givenWidth, givenHeight);
646+
if(!config){
647+
console.error('no config found with this setup');
648+
return;
649+
}
650+
sceneManager.objects.removeSensors();
651+
createSceneFromLidarConfig(config, sceneManager);
652+
break;
653+
}
654+
case 'human-tracking':
655+
case 'hand-tracking':
656+
{
657+
const sensor = getCamerasTypes().find(sensorType => sensorType.textId === sensorTextId);
658+
const overlapHeightDetection = trackingMode === 'human-tracking' ? SceneManager.DEFAULT_DETECTION_HEIGHT : SceneManager.HAND_TRACKING_OVERLAP_HEIGHT;
659+
const config = calculateCameraConfig(trackingMode, sensor, givenWidth, givenLength, givenHeight, overlapHeightDetection);
660+
if(!config){
661+
console.error('no config found with this setup');
662+
return;
663+
}
664+
sceneManager.objects.removeSensors();
665+
createSceneFromCameraConfig(config, trackingMode, givenWidth, givenLength, givenHeight + sceneManager.sceneElevation, sceneManager);
666+
break;
667+
}
668+
default:
669+
break;
670+
}
671+
}
672+
669673
function disableSensorsConsideringEnvironment(environment)
670674
{
671675
let disabledSensorsNumber = 0;
@@ -705,6 +709,11 @@ class Popup{
705709

706710
function selectFirstSensorAvailable()
707711
{
712+
const sensorsDiv = document.getElementById('multi-select-sensors');
713+
if(!sensorsDiv) return;
714+
sensorsDiv.value = sensorsDiv.children[0].value;
715+
createSceneFromSelectedSensor();
716+
//Old way
708717
// const sensorsDiv = document.getElementById('hardware-sensors-selection');
709718
// for(let i = 0; i < sensorsDiv.children.length; i++)
710719
// {

0 commit comments

Comments
 (0)