renderTree method
void
renderTree(
- Canvas canvas
)
Implementation
@override
void renderTree(Canvas 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 ancestor is inside, so are we, otherwise test.
final cullResult = _ancestorFullyInside
? CullResult.inside
: aabb.frustumCullTest(camera!.frustum);
// Result is fully outside, skip children and self.
if (cullResult == CullResult.outside) {
world.culled++;
return;
}
// Render children. If fully inside, children can skip frustum tests.
final wasAncestorFullyInside = _ancestorFullyInside;
if (cullResult == CullResult.inside) {
_ancestorFullyInside = true;
}
super.renderTree(canvas);
_ancestorFullyInside = wasAncestorFullyInside;
if (cullResult == CullResult.inside || shouldCull(camera!)) {
// 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(wolfenrain): we should optimize this in the long run it currently
// sucks.
priority = -(CameraComponent3D.currentCamera!.position - position).length
.abs()
.toInt();
bind(world.device);
} else {
world.culled++;
}
}