Changing the Spatial Direction

In some use-cases, you may want to provide the ability for the local participant to change the direction they are facing in the virtual world. We will extend the previous example to modify the direction that the local participant is facing.

In the example video below, the listener is changing the direction their head is facing. As you set the Z direction to values slowly from 0 to 90, the head rotates to the right. This rotation about the up direction is call a yaw rotation.

Before you started changing the listener's direction (z-axis rotation is 0 degrees), they could hear another participant on their right hand side from behind, but now after changing direction by rotating 90 degrees about the Z axis, the listener can now hear the other participant still on the right but in front.

Likewise the other participant that used to be right in front of the listener, is now heard directly to the left.

This rotation is the most common type and is called a yaw rotation. In almost all cases except in 3D games and head-tracking you will usually only need to use yaw rotations. There are three different types of direction change rotations. Yaw (rotating about the up direction, z-axis in this example, see up direction in setSpatialEnvironment), pitch (rotating about the right direction, x-axis in this example, see right direction in setSpatialEnvironment), and roll (rotating about the forward direction, negative y-axis in this example, see forward direction in setSpatialEnvironment). You can see example animations of these three rotations in action in the reference documentation for the SpatialDirection model.

The following is the code sample to make the rotation to change the participant's direction:

const spatialDirection = {
 x: 0,
 y: 0,
 z: 90,
};

VoxeetSDK.conference.setSpatialDirection(VoxeetSDK.session.participant, spatialDirection);
let spatialDirection = VTSpatialDirection(x: 0, y: 0, z: 90)!

VoxeetSDK.shared.conference.setSpatialDirection(participant: VoxeetSDK.shared.session.participant!, direction: spatialDirection)
SpatialDirection spatialDirection = new SpatialDirection(0, 0, 90);
VoxeetSDK.conference().setSpatialDirection(spatialDirection);
dolbyio::comms::spatial_audio_batch_update batched_update;
  dolbyio::comms::spatial_direction direction{0, 0, 90};
  batched_update.set_spatial_direction(direction);
  sdk->conference()
      .update_spatial_audio_configuration(std::move(batched_update))
      .then([]() { std::cout << "Spatial Direction Set!\n"; })
      .on_error([](std::exception_ptr&&) {
        std::cerr << "Failed to Set Spatial Direction!";
      });
var direction = new Vector3(0, 90, 0);

await _sdk.Conference.SetSpatialDirectionAsync(_sdk.Session.User.Id, direction);
const spatialDirection = {x: 0, y: 0, z: 90};

await CommsAPI.conference.setSpatialDirection(spatialDirection);
var spatialDirection = SpatialDirection(90, 0, 0);

await dolbyioCommsSdkFlutterPlugin.conference.setSpatialDirection(spatialDirection);