Skip to content
Oğuz Eroğlu edited this page Jun 20, 2020 · 5 revisions

Definition

World is an object that contains all the Kompute entities. A World also defines what distance is nearby for entities (What is the maximum distance in order to make an entity close to another entity). World class internally uses Nearby algorithm.

Note that steerables need to be insert into a world in order to move.

A World may have a gravity set via setGravity API. This is necessary for jumping.

Usage

var worldWidth = 1000;
var worldHeight = 1000;
var worldDepth = 1000;

var binSize = 50; // binSize defines what is considered nearby. A greater binSize means objects more far away are considered nearby to a given position

var world = new Kompute.World(worldWidth, worldHeight, worldDepth, binSize);

// This is useful for jumping
world.setGravity(-900);

// Create an entity
var entity = new Kompute.Entity("entity1", new Kompute.Vector3D(), new Kompute.Vector3D(10, 10, 10));

// Insert the entity to the world
world.insertEntity(entity);

// Remove the entity from the world
world.removeEntity(entity);