I'm currently developing a WebVR project using Aframe that features multiple miniature 3D scenes (approximately eight) surrounding the viewer. To view each scene, users must rotate their viewpoint accordingly.
Since the number of scenes surpasses what can be accommodated within a 360-degree rotation, I am handling content loading and unloading by monitoring the camera's current rotation. For instance, scene number seven is only visible when the y-axis value of the a-camera falls between 720 and 840 degrees (converted to radians).
This method functions effectively due to the fact that in non-VR mode, the y-axis value of the camera extends from 0 to infinity in both directions.
However, the camera rotation behavior differs in non-VR mode. In VR mode, the y-axis rotation of the camera ranges between 0 and 180 or 0 and -180. When rotating counterclockwise, the y-value transitions from 180 to -180, rendering my previous subscene visibility calculation ineffective.
I am exploring ways to translate the rotation values obtained from the camera in VR mode to align more closely with the non-VR mode operation.
Hopefully, this explanation clarifies things. It indeed presents a bit of a puzzle...
Shown below is my code, which requires significant refactoring but serves its purpose for now:
if (cameraRotY >= 0 && cameraRotY <= degreesToRadians(120) && !self.is('stonehenge')) {
removeAllStates(self);
document.querySelector('#SceneStonehenge').emit('show');
self.addState('stonehenge');
} else if (cameraRotY > degreesToRadians(120) && cameraRotY <= degreesToRadians(240) && !self.is('phoneVines')) {
removeAllStates(self);
document.querySelector('#ScenePhoneVines').emit('show');
self.addState('phoneVines');
} else if (cameraRotY > degreesToRadians(240) && cameraRotY <= degreesToRadians(360) && !self.is('skyFish')) {
removeAllStates(self);
document.querySelector('#SceneSkyfish').emit('show');
self.addState('skyFish');
} else if (cameraRotY > degreesToRadians(360) && cameraRotY <= degreesToRadians(480) && !self.is('rocksPlanets')) {
removeAllStates(self);
document.querySelector('#SceneRocksPlanets').emit('show');
document.querySelector('#SceneRocksPlanetsContents').emit('show');
self.addState('rocksPlanets');
} else if (cameraRotY > degreesToRadians(480) && cameraRotY <= degreesToRadians(600) && !self.is('floatingIslands')) {
removeAllStates(self);
document.querySelector('#SceneFloatingIslands').emit('show');
self.addState('floatingIslands');
} else if (cameraRotY > degreesToRadians(600) && cameraRotY <= degreesToRadians(720) && !self.is('skywhale')) {
removeAllStates(self);
document.querySelector('#SceneSkywhale').emit('show');
self.addState('skywhale');
} else if (cameraRotY > degreesToRadians(720) && cameraRotY <= degreesToRadians(840) && !self.is('crack')) {
removeAllStates(self);
document.querySelector('#SceneCrack').emit('show');
self.addState('crack');
} else if (cameraRotY > degreesToRadians(840) && cameraRotY <= degreesToRadians(960) && !self.is('blackhole')) {
removeAllStates(self);
document.querySelector('#SceneBlackhole').emit('show');
self.addState('blackhole');
}