Interface IScreenSizeCalculator

Contract for screen size and aspect ratio calculation. The SceneManager delegates all screen size measurements to an IScreenSizeCalculator instance.

The calculated screen size is game specific and can return any value fit for a particular game design. Two implementations are provided out of the box: the default DefaultScreenSizeCalculator and NoResizeScreenSizeCalculator. The DefaultScreenSizeCalculator calculates a viewport that horizontally fits on screen and preserves the given aspect rastio while the NoResizeScreenSizeCalculator always returns the full screen size disregarding any aspect ratio constraints.

The IScreenSizeCalculator is used in resize events in the following manner:

const avlSize = this.screenSizeCalculator.GetAvailableSize();
const aspect = this.screenSizeCalculator.GetAspectRatio();
const size = this.screenSizeCalculator.CalculateSize(avlSize, aspect);
this.renderer.resize(size.x, size.y);
interface IScreenSizeCalculator {
    CalculateScale(size: ISize): ISize;
    CalculateSize(): ISize;
}

Implemented by

Methods