flutter3d
Showcase Changelog 38 packages API reference

A lesson through the rig

since 0.7.0 Simulation, audio and XR

A lesson document is the same edu_step entities a step panel already authors: where the stage stands, and which named nodes are visible. Playing it through a stereo rig instead of editing it is a matter of stepping through the same list with a button, since a phone in a holder has no keyboard to reach for.

Step 1: Two steps #

The first hides a detail; the second reveals it.

late final LessonPlayer _player = LessonPlayer(<EntityDef>[
  EntityDef(
    type: 'edu_step',
    position: Vector3(0, 0, 0),
    properties: const <String, Object?>{
      'hidden': <String>['detail'],
    },
  ),
  EntityDef(
    type: 'edu_step',
    position: Vector3(0.5, 0, 0),
    properties: const <String, Object?>{
      'visible': <String>['detail'],
    },
  ),
]);

Step 2: Wrap it in a view #

LessonStereoView puts a StereoSurface around the rig and the player, with Previous and Next buttons doing the stepping.

@override
Widget? customBody(BuildContext buildContext, DemoContext context) =>
    LessonStereoView(
      renderer: context.renderer,
      scene: _scene,
      rig: _rig,
      player: _player,
      nodes: <String, SceneNode>{'detail': _detail},
    );

Step 3: Check what a step actually changes #

// The first step hides the detail node; stepping forward shows it.
_player.applyCurrent(_rig, nodes: <String, SceneNode>{'detail': _detail});
final hiddenAtStart = !_detail.visible;
_player.next();
_player.applyCurrent(_rig, nodes: <String, SceneNode>{'detail': _detail});
final shownAtStepTwo = _detail.visible;

Applying the first step leaves the detail hidden; moving to the second and applying it again shows the detail, because that step names it in its own visible list.