Skip to content

@fibbojs / core / FCamera

Class: abstract FCamera

The base class for cameras in Fibbo.

Extends

Constructors

new FCamera()

new FCamera(scene): FCamera

Parameters

scene: FScene

Returns

FCamera

Overrides

FComponent.constructor

Defined in

core/src/FCamera.ts:9

Methods

emitCollisionWith()

emitCollisionWith(options): void

Emit a collision event with a given class or object.

Parameters

options

The options for the collision event.

options.class?: any

The class to emit the collision event with.

options.component?: FComponent

The component to emit the collision event with.

Returns

void

Examples

typescript
const player = new Player()
const enemy = new Enemy()
player.emitCollisionWith({
  class: Enemy
})
typescript
const player = new Player()
const enemy = new Enemy()
player.emitCollisionWith({
  object: enemy
})

Inherited from

FComponent.emitCollisionWith

Defined in

core/src/FComponent.ts:201


emitOnLoaded()

emitOnLoaded(): void

Emit the onLoaded callbacks.

Returns

void

Inherited from

FComponent.emitOnLoaded

Defined in

core/src/FComponent.ts:123


frame()

frame(delta): void

Update the component. Should be called every frame. The purpose of this method is to render the component, its mesh/sprite, and its properties.

Parameters

delta: number

The time since the last frame.

Returns

void

Inherited from

FComponent.frame

Defined in

core/src/FComponent.ts:97


onCollisionWith()

onCollisionWith(classOrObject, callback): () => void

Add a callback to be called when a collision occurs.

Parameters

classOrObject: any

The class or object to add the callback to.

callback

The callback to add.

Returns

Function

A function to remove the callback.

Returns

void

Examples

typescript
const player = new Player()
const enemy = new Enemy()
player.onCollisionWith(Enemy, () => {
  console.log('Player collided with an Enemy!')
})
typescript
const player = new Player()
const enemy = new Enemy()
player.onCollisionWith(enemy, () => {
  console.log('Player collided with the enemy!')
})

Inherited from

FComponent.onCollisionWith

Defined in

core/src/FComponent.ts:151


onFrame()

onFrame(callback): void

Add a callback to be called every frame.

Parameters

callback

The callback function.

Returns

void

Inherited from

FComponent.onFrame

Defined in

core/src/FComponent.ts:108


onLoaded()

onLoaded(callback): void

Add a callback to be called when the component is loaded (could be a texture, a 3D model, etc).

Parameters

callback

The callback function.

Returns

void

Inherited from

FComponent.onLoaded

Defined in

core/src/FComponent.ts:116

Properties

__CALLBACKS_ON_COLLISION__

__CALLBACKS_ON_COLLISION__: object = {}

Callbacks for when a collision occurs with a given class or object. It is a dictionary where the key is the class name or object id and the value is an array of callbacks.

Index Signature

[key: string]: (data) => void[]

Inherited from

FComponent.__CALLBACKS_ON_COLLISION__

Defined in

core/src/FComponent.ts:55


__CALLBACKS_ON_FRAME__

__CALLBACKS_ON_FRAME__: () => void[] = []

Callbacks for when a frame is rendered.

Inherited from

FComponent.__CALLBACKS_ON_FRAME__

Defined in

core/src/FComponent.ts:44


__CALLBACKS_ON_LOADED__

__CALLBACKS_ON_LOADED__: () => void[] = []

Callbacks for when the component is loaded (could be a texture, a 3D model, etc).

Inherited from

FComponent.__CALLBACKS_ON_LOADED__

Defined in

core/src/FComponent.ts:49


__ID__

__ID__: number

Unique identifier for the component. It is generated automatically.

Inherited from

FComponent.__ID__

Defined in

core/src/FComponent.ts:39


__IS_2D__

__IS_2D__: boolean = false

Inherited from

FComponent.__IS_2D__

Defined in

core/src/FComponent.ts:33


__IS_3D__

__IS_3D__: boolean = false

Internal flags

Inherited from

FComponent.__IS_3D__

Defined in

core/src/FComponent.ts:32


controller?

optional controller: FController

The controller attached to the component.

Inherited from

FComponent.controller

Defined in

core/src/FComponent.ts:65


scene

scene: FScene

The scene the component is attached to.

Inherited from

FComponent.scene

Defined in

core/src/FComponent.ts:60