Class: Viewport
camera/viewport.Viewport
Represents a Camera's viewable area and can be used to perform culling.
Constructors
constructor
โข new Viewport(centre
, width
, height
)
Creates a Viewport instance.
Parameters
Name | Type | Description |
---|---|---|
centre | vec2 | The centre of the viewport in world space |
width | number | The width of the viewport in world space |
height | number | The height of the viewport in world space |
Defined in
src/camera/viewport.ts:23
Properties
centre
โข Private
centre: vec2
Defined in
src/camera/viewport.ts:14
height
โข Private
height: number
Defined in
src/camera/viewport.ts:13
originalHeight
โข Private
originalHeight: number
Defined in
src/camera/viewport.ts:10
originalWidth
โข Private
originalWidth: number
Defined in
src/camera/viewport.ts:9
width
โข Private
width: number
Defined in
src/camera/viewport.ts:12
Methods
containsRectCollider
โธ containsRectCollider(rect
, worldToPixelScale
): boolean
Checks wether the provided rectangle collider is contained within the viewport.
TODO: Change this to use physics collision system so it works with more than just RectCollider
Parameters
Name | Type | Description |
---|---|---|
rect | RectCollider | The rect to check |
worldToPixelScale | vec2 | - |
Returns
boolean
Wether or not the box is withing the viewport
Defined in
src/camera/viewport.ts:50
getHeight
โธ getHeight(): number
Gets the viewport's height.
Returns
number
The viewport's height
Defined in
src/camera/viewport.ts:106
getOriginalHeight
โธ getOriginalHeight(): number
Gets the height the viewport was given when constructed.
Returns
number
The viewport's original height
Defined in
src/camera/viewport.ts:124
getOriginalWidth
โธ getOriginalWidth(): number
Gets the width the viewport was given when constructed.
Returns
number
The viewport's original width
Defined in
src/camera/viewport.ts:115
getWidth
โธ getWidth(): number
Gets the viewport's width.
Returns
number
The viewport's width
Defined in
src/camera/viewport.ts:84
setHeight
โธ setHeight(height
): void
Sets the viewport's height.
throws
When height is <= 0
Parameters
Name | Type | Description |
---|---|---|
height | number | The viewport's new height |
Returns
void
Defined in
src/camera/viewport.ts:95
setWidth
โธ setWidth(width
): void
Sets the viewport's width.
throws
When width is <= 0
Parameters
Name | Type | Description |
---|---|---|
width | number | The viewport's new width |
Returns
void
Defined in
src/camera/viewport.ts:73
update
โธ update(centre
): void
Calculates the viewports bounds around a given centre.
Parameters
Name | Type | Description |
---|---|---|
centre | vec2 | The centre of the viewport |
Returns
void
Defined in
src/camera/viewport.ts:38