@vaguevoid/fiasco / ecs/components / Camera
Type Alias: Camera
Camera =
Component
<{aspectRatioOverride
:f32
|undefined
;clearColor
: {a
:f32
;b
:f32
;g
:f32
;r
:f32
; };isEnabled
:boolean
;orthographicSize
:f32
;projection
:Mat4
;renderOrder
:i32
;renderTargetTextureId
:u32
|undefined
;view
:Mat4
;viewportRatio
:Viewport
; }>
Defined in: src/ecs/components.ts:568
A component for controlling the game camera.
There is no camera by default, one must be explicitly spawned.
To move the camera, parent it to another entity that moves, or spawn it with a Transform component and move it manually.
ts
import { Query, Transform, Camera, SystemOnce } from '@vaguevoid/fiasco'
import { Components } from '../.fiasco/generated'
function system(): SystemOnce {
engine.spawn([
new Components.Camera(),
new Components.Transform()
])
}
function system2(cameras: Query<[Transform, Camera]>) {
for (const [cameraTransform] of cameras) {
// move every camera's position.x to the right every frame.
cameraTransform.position.x += 1
}
}