Skip to content

@fibbojs / 3d / FFBX

Class: FFBX

A FBX model in Fibbo.

Example

ts
import { FFBX, FScene } from '@fibbojs/3d'

const scene = new FScene()

const fbx = new FFBX(scene, {
  path: 'model.fbx',
})
scene.addComponent(fbx)

Extends

Constructors

new FFBX()

new FFBX(scene, options): FFBX

Parameters

scene: FScene

options: FModelOptions

Returns

FFBX

Overrides

FModel.constructor

Defined in

3d/src/model/FFBX.ts:24

Methods

__SET_POSITION__()

__SET_POSITION__(position): void

Parameters

position: FVector3

Returns

void

Inherited from

FModel.__SET_POSITION__

Defined in

3d/src/core/FComponent.ts:243


__SET_ROTATION__()

__SET_ROTATION__(rotation): void

Parameters

rotation: FVector3

Returns

void

Inherited from

FModel.__SET_ROTATION__

Defined in

3d/src/core/FComponent.ts:251


__SET_SCALE__()

__SET_SCALE__(scale): void

Parameters

scale: FVector3

Returns

void

Overrides

FModel.__SET_SCALE__

Defined in

3d/src/model/FFBX.ts:79


__UPDATE_POSITION__()

__UPDATE_POSITION__(initiator): void

Update the position of the component according to the transform. This method should be called after updating the transform properties.

Parameters

initiator: boolean = false

By default (false), the component won't be considered as the initiator of the position update. Set this to true to propagate the position update to the rigidBody, collider and sensor.

Returns

void

Inherited from

FModel.__UPDATE_POSITION__

Defined in

3d/src/core/FComponent.ts:123


__UPDATE_ROTATION__()

__UPDATE_ROTATION__(initiator): void

Update the rotation of the component according to the transform. This method should be called after updating the transform properties.

Parameters

initiator: boolean = false

By default (false), the component won't be considered as the initiator of the rotation update. Set this to true to propagate the rotation update to the rigidBody, collider and sensor.

Returns

void

Inherited from

FModel.__UPDATE_ROTATION__

Defined in

3d/src/core/FComponent.ts:165


__UPDATE_SCALE__()

__UPDATE_SCALE__(initiator): void

Update the scale of the component according to the transform. This method should be called after updating the transform properties.

Parameters

initiator: boolean = false

By default (false), the component won't be considered as the initiator of the scale update. Set this to true to propagate the scale update to the rigidBody, collider and sensor.

Returns

void

Inherited from

FModel.__UPDATE_SCALE__

Defined in

3d/src/core/FComponent.ts:207


defineMeshTransforms()

defineMeshTransforms(): void

Define mesh transforms (used after loading the model).

Returns

void

Overrides

FModel.defineMeshTransforms

Defined in

3d/src/model/FFBX.ts:66


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

FModel.emitCollisionWith

Defined in

core/dist/index.d.ts:293


emitOnLoaded()

emitOnLoaded(): void

Emit the onLoaded callbacks. It was overridden to add shadow support.

Returns

void

Inherited from

FModel.emitOnLoaded

Defined in

3d/src/model/FModel.ts:104


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

Returns

void

Inherited from

FModel.frame

Defined in

3d/src/core/FComponent.ts:113


initCollider()

initCollider(options?): void

Parameters

options?: FColliderOptions

Returns

void

Inherited from

FModel.initCollider

Defined in

3d/src/core/FComponent.ts:286


initRigidBody()

initRigidBody(options?): void

Parameters

options?: FRigidBodyOptions

Returns

void

Inherited from

FModel.initRigidBody

Defined in

3d/src/core/FComponent.ts:295


initSensor()

initSensor(options?): void

Parameters

options?: FRigidBodyOptions

Returns

void

Inherited from

FModel.initSensor

Defined in

3d/src/core/FComponent.ts:304


loadTextureForMesh()

loadTextureForMesh(mesh): void

Load the texture for a given mesh.

Parameters

mesh: Mesh<BufferGeometry<NormalBufferAttributes>, Material | Material[], Object3DEventMap>

The mesh.

Returns

void

Example

ts
model.loadTextureFor(material)

Inherited from

FModel.loadTextureForMesh

Defined in

3d/src/model/FModel.ts:147


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

FModel.onCollisionWith

Defined in

3d/src/core/FComponent.ts:276


onFrame()

onFrame(callback): void

Add a callback to be called every frame.

Parameters

callback

The callback function.

Returns

void

Inherited from

FModel.onFrame

Defined in

core/dist/index.d.ts:238


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

FModel.onLoaded

Defined in

core/dist/index.d.ts:243

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

FModel.__CALLBACKS_ON_COLLISION__

Defined in

core/dist/index.d.ts:216


__CALLBACKS_ON_FRAME__

__CALLBACKS_ON_FRAME__: () => void[]

Callbacks for when a frame is rendered.

Inherited from

FModel.__CALLBACKS_ON_FRAME__

Defined in

core/dist/index.d.ts:207


__CALLBACKS_ON_LOADED__

__CALLBACKS_ON_LOADED__: () => void[]

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

Inherited from

FModel.__CALLBACKS_ON_LOADED__

Defined in

core/dist/index.d.ts:211


__ID__

__ID__: number

Unique identifier for the component. It is generated automatically.

Inherited from

FModel.__ID__

Defined in

core/dist/index.d.ts:203


__IS_2D__

__IS_2D__: boolean

Inherited from

FModel.__IS_2D__

Defined in

core/dist/index.d.ts:198


__IS_3D__

__IS_3D__: boolean = true

Internal flags

Inherited from

FModel.__IS_3D__

Defined in

3d/src/core/FComponent.ts:30


__MESH__?

optional __MESH__: Mesh<BufferGeometry<NormalBufferAttributes>, Material | Material[], Object3DEventMap> | Group<Object3DEventMap>

Mesh

Inherited from

FModel.__MESH__

Defined in

3d/src/core/FComponent.ts:44


collider?

optional collider: FCollider

Collider

Inherited from

FModel.collider

Defined in

3d/src/core/FComponent.ts:59


controller?

optional controller: FController

The controller attached to the component.

Inherited from

FModel.controller

Defined in

3d/src/core/FComponent.ts:39


fileExtension

fileExtension: string

The file extension of the model. Default is 'obj'.

Inherited from

FModel.fileExtension

Defined in

3d/src/model/FModel.ts:47


name

name: string

The name of the model. Shouldn't contain file extensions.

Inherited from

FModel.name

Defined in

3d/src/model/FModel.ts:22


path

path: string

The path to the model file. Will be interpreted as a URL if it starts with http. Will be interpreted as an absolute path if it starts with /. Otherwise, it will be treated as a relative path to the models folder.

Inherited from

FModel.path

Defined in

3d/src/model/FModel.ts:30


rigidBody?

optional rigidBody: FRigidBody

RigidBody

Inherited from

FModel.rigidBody

Defined in

3d/src/core/FComponent.ts:55


scene

scene: FScene

The scene which the component is in.

Inherited from

FModel.scene

Defined in

3d/src/core/FComponent.ts:35


sensor?

optional sensor: FRigidBody

Sensor (a collider that doesn't collide with other colliders, but still triggers events)

Inherited from

FModel.sensor

Defined in

3d/src/core/FComponent.ts:63


textures

textures: Record<string, string>

A record containing texture path for each material.

Example

json
{
  "default": "/models/my-model/my-model.png"
}

Inherited from

FModel.textures

Defined in

3d/src/model/FModel.ts:41


transform

transform: FTransform

Transforms

Inherited from

FModel.transform

Defined in

3d/src/core/FComponent.ts:49