renderTree method

  1. @override
void renderTree(
  1. Canvas canvas
)

Implementation

@override
void renderTree(Canvas canvas) {
  super.renderTree(canvas);
  final camera = CameraComponent3D.currentCamera;
  assert(
    camera != null,
    '''Component is either not part of a World3D or the render is being called outside of the camera rendering''',
  );
  if (!shouldCull(camera!)) {
    world.culled++;
    return;
  }

  // We set the priority to the distance between the camera and the object.
  // This ensures that our rendering is done in a specific order allowing for
  // alpha blending.
  //
  // Note(wolfen): we should optimize this in the long run it currently sucks.
  priority = -(CameraComponent3D.currentCamera!.position - position)
      .length
      .abs()
      .toInt();

  bind(world.graphics);
}