API Docs for: 0.3
Show:

World Class

Defined in: src\sim\World.js:9
Module: World
Parent Module: CrowdSim

The world where al entities live

Constructor

World

(
  • parent
  • options
)

Defined in src\sim\World.js:9

Parameters:

Methods

_getEntityList

(
  • entity
)

Returns the property that holds the entity list, used internally.

Parameters:

  • entity Entity

    Context, Group, Wall or Path

_onCreate

(
  • entity
)

Callback trigger when an entity is created

Parameters:

  • entity Entity

    Context, Group, Wall or Path

_onDestroy

(
  • entity
)

Callback trigger when an entity is destroyed

Parameters:

  • entity Entity

    Context, Group, Wall or Path

_saveHelper

(
  • o
)
String

Save helper to remove loops and agents from world data.

Parameters:

  • o Object

    the world.entities property

Returns:

String:

JSON data that represents the world.entities

addAgents

(
  • agents
)

Add an array of Agents from the world.

Parameters:

addContext

(
  • context
)

Add a Context to the world.

Parameters:

addEntity

(
  • entity
)

Add an entity from the world. Called by entities on constructor.

Parameters:

  • entity Entity

    Context, Group, Wall or Path

addGroup

(
  • group
)

Add a Group to the world.

Parameters:

addPath

(
  • path
)

Add a Path to the world.

Parameters:

addWall

(
  • wall
)

Add a Wall to the world.

Parameters:

agentsInContext

(
  • context
)
Array

Get the list of agents in a given Context

Parameters:

Returns:

Array:

all entities

changesNumber

() Number

Defined in src\sim\World.js:37

Gets and resets the number of steps executed since last call

Returns:

Number:

changes

freeze

(
  • freeze
)
Boolean

Defined in src\sim\World.js:48

Get/set if the world is not running (Frozen). This is set from the Engine

Parameters:

Returns:

Boolean:

true if world is static

getAgents

() Array

Defined in src\sim\World.js:70

Get the list of Agents.

Returns:

Array:

agents

getContextById

(
  • id
)
Array

Search an context in the world by its id.

Parameters:

Returns:

Array:

contexts

getContexts

() Array

Defined in src\sim\World.js:90

Get the list of contexts.

Returns:

Array:

contexts

getDefaultGroup

() Object

Defined in src\sim\World.js:60

Returns the first group created.

Returns:

Object:

group

getEntitiesIterator

() Object

Defined in src\sim\World.js:80

Gets a iterator for all entities.

Returns:

Object:

Lazy iterator

getEntityById

(
  • id
)
Entity

Search an entity in the world by its id.

Parameters:

Returns:

getGroups

() Array

Get the list of groups.

Returns:

Array:

groups

getNearAgents

(
  • agent
)
Array

Returns the agents near to another. The near property is given in the options constructor parameter

Parameters:

Returns:

Array:

agents

getNearWalls

(
  • agent
)
Array

Returns the agents near to another.

The near property is given in the options constructor parameter

Parameters:

Returns:

Array:

walls

getPathById

(
  • id
)
Array

Search an path in the world by its id.

Parameters:

Returns:

Array:

paths

getPaths

() Array

Get the list of paths.

Returns:

Array:

paths

getWalls

() Array

Get the list of walls.

Returns:

Array:

walls

load

(
  • loader
  • loadDefault
)

Load the world state from a loader.

Parameters:

removeAgents

(
  • agents
)

Remove an array of agents from the World.

Parameters:

removeEntity

(
  • entity
)

Remove an entity from the world. Called by entities on destroy.

Parameters:

  • entity Entity

    Context, Group, Wall or Path

save

(
  • save
)

Save the world state without agents.

Parameters:

  • save Boolean

    true to store internally; false to return the JSON data

step

(
  • stepSize
)
Context | Null

Advances the simulation of the world entities one stepSize. If one contexts configured to nofify when agentsIn === 0

Parameters:

  • stepSize Number

    defined by the simulation step size

Returns:

Context | Null:

contextEmpty that triggers step