Skip to content

@emile/engine


@emile/engine / physics/world / PhysicsWorld

Class: PhysicsWorld

Defined in: src/physics/world.ts:29

Represents a physics world.

The physics world has a system priority of 0. You can give your systems a higher priority to run before the physics world.

Extends

Constructors

new PhysicsWorld()

new PhysicsWorld(options): PhysicsWorld

Defined in: src/physics/world.ts:57

Creates a new physics world.

Parameters

options

PhysicsWorldOptions

The options for the physics world.

Returns

PhysicsWorld

Overrides

System.constructor

Properties

dispose()?

readonly optional dispose: (data) => void

Defined in: src/ecs/system.ts:95

The function to run when the system is disposed.

Parameters

data

SystemUpdateData

The data for the disposal.

Returns

void

Inherited from

System.dispose


priority

readonly priority: number

Defined in: src/ecs/system.ts:44

The priority of the system.

Systems with a higher priority will run before systems with a lower priority.

Inherited from

System.priority


query

readonly query: EntityQuery

Defined in: src/ecs/system.ts:28

The query to match entities.

An empty query will match all entities.

This should not be changed after the system is created.

Inherited from

System.query


queryKey

readonly queryKey: string

Defined in: src/ecs/system.ts:37

The key of the query.

This is used internally by the registry.

Do not change this value.

Inherited from

System.queryKey


stateUpdate()?

readonly optional stateUpdate: (data) => void

Defined in: src/ecs/system.ts:88

The function to run on state updates.

Parameters

data

SystemUpdateData

The data for the update.

Returns

void

Inherited from

System.stateUpdate


type

readonly type: SystemType

Defined in: src/ecs/system.ts:53

The type of the system.

This should not be changed after the system is created.

Note

This is used to determine if the system should run on the client, server, or both.

Inherited from

System.type


update()?

readonly optional update: (data) => void

Defined in: src/ecs/system.ts:74

The function to run on updates.

Parameters

data

SystemUpdateData

The data for the update.

Returns

void

Inherited from

System.update

Methods

fixedUpdate()

fixedUpdate(__namedParameters): void

Defined in: src/physics/world.ts:73

The function to run on fixed updates.

Parameters

__namedParameters

SystemUpdateData

Returns

void

Overrides

System.fixedUpdate


getGravity()

getGravity(): Vec2

Defined in: src/physics/world.ts:230

Gets the gravity of the physics world.

Returns

Vec2

The gravity of the physics world.


queryRay()

Call Signature

queryRay(start, end): RayCol[]

Defined in: src/physics/world.ts:242

Queries the world for bodies that intersect with a ray.

Parameters
start

Vec2

The start of the ray.

end

Vec2

The end of the ray.

Returns

RayCol[]

The bodies that intersect with the ray.

Call Signature

queryRay(origin, dir, len): RayCol[]

Defined in: src/physics/world.ts:253

Queries the world for bodies that intersect with a ray.

Parameters
origin

Vec2

The origin of the ray.

dir

Vec2

The direction of the ray.

len

number

The length of the ray.

Returns

RayCol[]

The bodies that intersect with the ray.


setGravity()

setGravity(gravity): void

Defined in: src/physics/world.ts:220

Sets the gravity of the physics world.

Parameters

gravity

Vec2

The gravity to set.

Returns

void


getCollider()

static getCollider(entity): null | Collider

Defined in: src/physics/world.ts:30

Parameters

entity

Entity

Returns

null | Collider