Skip to content

oguzeroglu/Kompute

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kompute

Kompute is a lightweight and efficient steering library for AI movement. It's not a visual library and generates numbers (velocity & position data), that's why it may easily be plugged into any codebase.

Kompute is originally designed to be used by the ROYGBIV engine, however may be easily used in any other project as well.

See the documentation.

Demos

Getting Started

Include it in your project.

For browser:

<script src="PATH_TO_kompute.min.js"></script>

For NodeJS:

var Kompute = require("kompute");

Create a World:

var worldWidth = 1000;
var worldHeight = 1000;
var worldDepth = 1000;
var binSize = 50;

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

Create a Steerable:

var steerableID = "steerable1";
var steerableCenterPosition = new Kompute.Vector3D(0, 50, 0);
var steerableSize = new Kompute.Vector3D(25, 25, 25);

var steerable = new Kompute.Steerable(steerableID, steerableCenterPosition, steerableSize);

Insert the steerable into the world:

world.insertEntity(steerable);

Create a new Steering Behavior:

// this could be any type of Steering behavior
var behavior = new Kompute.SteeringBehavior();

Set the behavior:

steerable.setBehavior(behavior);

Update the steerable (ideally 60 times per second):

function update() {
  steerable.update();

  // steerable.position -> the updated position of the steerable
  // steerable.velocity -> the updated velocity of the steerable
  // You may visualise the steerable with any rendering library
  // You may use the velocity with a physics engine

  requestAnimationFrame(update);
}

update();

License

Kompute uses MIT license.