flutter3d
Showcase Changelog 38 packages API reference

The stereo rig

since 0.1.0 Simulation, audio and XR

A headset reports where the head is inside a room, which leaves nowhere to put walking, riding a vehicle, or a level that starts somewhere other than the origin. StereoRig is three nodes for that reason: a stage the application moves, a head the tracker points, and two eyes under it, a fixed distance apart.

Step 1: Build the rig #

final StereoRig _rig = StereoRig();

Step 2: Draw it as a pair #

StereoSurface renders both eyes into one frame, left half and right, and applies the settings a stereo pair needs — RenderSettings.forStereo() — so a caller does not have to remember to.

return StereoSurface(
  renderer: context.renderer,
  scene: _scene,
  rig: _rig,
  settings: () => const RenderSettings().forStereo(),
  onBeforeFrame: () {},
);

Step 3: Check the split #

// Two views, side by side, half the frame's width apart.
if (_rig.views.length != 2) {
  throw StateError('a stereo rig draws exactly two views');
}
final left = _rig.views[0].viewportFraction;
final right = _rig.views[1].viewportFraction;

The rig always draws exactly two views, the left filling the left half of the frame and the right filling the right half, whatever runtime is driving the head.