exports

exports

The A-Frame Renderer

Constructor

new exports(gameEngine, clientEngine)

Constructor of the Renderer singleton.

Parameters:
Name Type Description
gameEngine GameEngine

Reference to the GameEngine instance.

clientEngine ClientEngine

Reference to the ClientEngine instance.

Source:

Members

acceleration :Number

acceleration per step

Source:

affectedByGravity :Boolean

Whether this object is affected by gravity.

Source:

angle :Number

object orientation angle in degrees

Source:

friction :TwoVector

The friction coefficient. Velocity is multiplied by this for each step. Default is (1,1)

Source:

gameEngine :GameEngine

reference to game engine

Source:

height :Number

Object Height for collision detection purposes. Default is 1

Source:

isAccelerating :Boolean

should accelerate by DynamicObject#acceleration on next step

Source:

isRotatingLeft :Boolean

should rotate left by DynamicObject#rotationSpeed on next step

Source:

isRotatingRight :Boolean

should rotate right by DynamicObject#rotationSpeed on next step

Source:

playerId :String

client's player ID, as a string. If running on the client, this is set at runtime by the clientEngine

Source:

playerId :Number

ID of player who created this object

Source:

rotationSpeed :Number

angle rotation per step

Source:

serializer :Serializer

reference to serializer

Source:

serializer :GameEngine

reference to game engine

Source:

width :Number

Object width for collision detection purposes. Default is 1

Source:

exports

A Quaternion is a geometric object which can be used to represent a three-dimensional rotation.

Constructor

new exports(w, x, y, z)

Creates an instance of a Quaternion.

Parameters:
Name Type Description
w Number

first value

x Number

second value

y Number

third value

z Number

fourth value

Source:

Members

acceleration :Number

acceleration per step

Source:

affectedByGravity :Boolean

Whether this object is affected by gravity.

Source:

angle :Number

object orientation angle in degrees

Source:

friction :TwoVector

The friction coefficient. Velocity is multiplied by this for each step. Default is (1,1)

Source:

gameEngine :GameEngine

reference to game engine

Source:

height :Number

Object Height for collision detection purposes. Default is 1

Source:

isAccelerating :Boolean

should accelerate by DynamicObject#acceleration on next step

Source:

isRotatingLeft :Boolean

should rotate left by DynamicObject#rotationSpeed on next step

Source:

isRotatingRight :Boolean

should rotate right by DynamicObject#rotationSpeed on next step

Source:

playerId :String

client's player ID, as a string. If running on the client, this is set at runtime by the clientEngine

Source:

playerId :Number

ID of player who created this object

Source:

rotationSpeed :Number

angle rotation per step

Source:

serializer :Serializer

reference to serializer

Source:

serializer :GameEngine

reference to game engine

Source:

width :Number

Object width for collision detection purposes. Default is 1

Source:

exports

A ThreeVector is a geometric object which is completely described by three values.

Constructor

new exports(x, y, z)

Creates an instance of a ThreeVector.

Parameters:
Name Type Description
x Number

first value

y Number

second value

z Number

second value

Source:

Members

acceleration :Number

acceleration per step

Source:

affectedByGravity :Boolean

Whether this object is affected by gravity.

Source:

angle :Number

object orientation angle in degrees

Source:

friction :TwoVector

The friction coefficient. Velocity is multiplied by this for each step. Default is (1,1)

Source:

gameEngine :GameEngine

reference to game engine

Source:

height :Number

Object Height for collision detection purposes. Default is 1

Source:

isAccelerating :Boolean

should accelerate by DynamicObject#acceleration on next step

Source:

isRotatingLeft :Boolean

should rotate left by DynamicObject#rotationSpeed on next step

Source:

isRotatingRight :Boolean

should rotate right by DynamicObject#rotationSpeed on next step

Source:

playerId :String

client's player ID, as a string. If running on the client, this is set at runtime by the clientEngine

Source:

playerId :Number

ID of player who created this object

Source:

rotationSpeed :Number

angle rotation per step

Source:

serializer :Serializer

reference to serializer

Source:

serializer :GameEngine

reference to game engine

Source:

width :Number

Object width for collision detection purposes. Default is 1

Source:

exports

A TwoVector is a geometric object which is completely described by two values.

Constructor

new exports(x, y)

Creates an instance of a TwoVector.

Parameters:
Name Type Description
x Number

first value

y Number

second value

Source:

Members

acceleration :Number

acceleration per step

Source:

affectedByGravity :Boolean

Whether this object is affected by gravity.

Source:

angle :Number

object orientation angle in degrees

Source:

friction :TwoVector

The friction coefficient. Velocity is multiplied by this for each step. Default is (1,1)

Source:

gameEngine :GameEngine

reference to game engine

Source:

height :Number

Object Height for collision detection purposes. Default is 1

Source:

isAccelerating :Boolean

should accelerate by DynamicObject#acceleration on next step

Source:

isRotatingLeft :Boolean

should rotate left by DynamicObject#rotationSpeed on next step

Source:

isRotatingRight :Boolean

should rotate right by DynamicObject#rotationSpeed on next step

Source:

playerId :String

client's player ID, as a string. If running on the client, this is set at runtime by the clientEngine

Source:

playerId :Number

ID of player who created this object

Source:

rotationSpeed :Number

angle rotation per step

Source:

serializer :Serializer

reference to serializer

Source:

serializer :GameEngine

reference to game engine

Source:

width :Number

Object width for collision detection purposes. Default is 1

Source:

exports

ServerEngine is the main server-side singleton code. Extend this class with your own server-side logic, and start a single instance.

This class should not be used to contain the actual game logic. That belongs in the GameEngine class, where the mechanics of the gameplay are actually implemented. The ServerEngine singleton is typically a lightweight implementation, logging gameplay statistics and registering user activity and user data.

The base class implementation is responsible for starting the server, initiating each game step, accepting new connections and dis-connections, emitting periodic game-state updates, and capturing remote user inputs.

Constructor

new exports(io, gameEngine, options)

create a ServerEngine instance

Parameters:
Name Type Description
io SocketIO

the SocketIO server

gameEngine GameEngine

instance of GameEngine

options Object

server options

Properties
Name Type Default Description
stepRate Number

number of steps per second

updateRate Number

number of steps in each update (sync)

tracesPath String

path where traces should go

updateOnObjectCreation Boolean

should send update immediately when new object is created

timeoutInterval Number 40

number of seconds after which a player is automatically disconnected if no input is received. Set to 0 for no timeout

Source:

Members

acceleration :Number

acceleration per step

Source:

affectedByGravity :Boolean

Whether this object is affected by gravity.

Source:

angle :Number

object orientation angle in degrees

Source:

friction :TwoVector

The friction coefficient. Velocity is multiplied by this for each step. Default is (1,1)

Source:

gameEngine :GameEngine

reference to game engine

Source:

height :Number

Object Height for collision detection purposes. Default is 1

Source:

isAccelerating :Boolean

should accelerate by DynamicObject#acceleration on next step

Source:

isRotatingLeft :Boolean

should rotate left by DynamicObject#rotationSpeed on next step

Source:

isRotatingRight :Boolean

should rotate right by DynamicObject#rotationSpeed on next step

Source:

playerId :String

client's player ID, as a string. If running on the client, this is set at runtime by the clientEngine

Source:

playerId :Number

ID of player who created this object

Source:

rotationSpeed :Number

angle rotation per step

Source:

serializer :Serializer

reference to serializer

Source:

serializer :GameEngine

reference to game engine

Source:

width :Number

Object width for collision detection purposes. Default is 1

Source:

exports

The Serializer is responsible for serializing the game world and its objects on the server, before they are sent to each client. On the client side the Serializer deserializes these objects.

The Serializer defines the data types which can be serialized.

Constructor

new exports()

Source:

Members

acceleration :Number

acceleration per step

Source:

affectedByGravity :Boolean

Whether this object is affected by gravity.

Source:

angle :Number

object orientation angle in degrees

Source:

friction :TwoVector

The friction coefficient. Velocity is multiplied by this for each step. Default is (1,1)

Source:

gameEngine :GameEngine

reference to game engine

Source:

height :Number

Object Height for collision detection purposes. Default is 1

Source:

isAccelerating :Boolean

should accelerate by DynamicObject#acceleration on next step

Source:

isRotatingLeft :Boolean

should rotate left by DynamicObject#rotationSpeed on next step

Source:

isRotatingRight :Boolean

should rotate right by DynamicObject#rotationSpeed on next step

Source:

playerId :String

client's player ID, as a string. If running on the client, this is set at runtime by the clientEngine

Source:

playerId :Number

ID of player who created this object

Source:

rotationSpeed :Number

angle rotation per step

Source:

serializer :Serializer

reference to serializer

Source:

serializer :GameEngine

reference to game engine

Source:

width :Number

Object width for collision detection purposes. Default is 1

Source:

exports

The Renderer is the component which must draw the game on the client. It will be instantiated once on each client, and must implement the draw method. The draw method will be invoked on every iteration of the browser's render loop.

Constructor

new exports(gameEngine, clientEngine)

Constructor of the Renderer singleton.

Parameters:
Name Type Description
gameEngine GameEngine

Reference to the GameEngine instance.

clientEngine ClientEngine

Reference to the ClientEngine instance.

Source:

Members

acceleration :Number

acceleration per step

Source:

affectedByGravity :Boolean

Whether this object is affected by gravity.

Source:

angle :Number

object orientation angle in degrees

Source:

friction :TwoVector

The friction coefficient. Velocity is multiplied by this for each step. Default is (1,1)

Source:

gameEngine :GameEngine

reference to game engine

Source:

height :Number

Object Height for collision detection purposes. Default is 1

Source:

isAccelerating :Boolean

should accelerate by DynamicObject#acceleration on next step

Source:

isRotatingLeft :Boolean

should rotate left by DynamicObject#rotationSpeed on next step

Source:

isRotatingRight :Boolean

should rotate right by DynamicObject#rotationSpeed on next step

Source:

playerId :String

client's player ID, as a string. If running on the client, this is set at runtime by the clientEngine

Source:

playerId :Number

ID of player who created this object

Source:

rotationSpeed :Number

angle rotation per step

Source:

serializer :Serializer

reference to serializer

Source:

serializer :GameEngine

reference to game engine

Source:

width :Number

Object width for collision detection purposes. Default is 1

Source:

exports

The client engine is the singleton which manages the client-side process, starting the game engine, listening to network messages, starting client steps, and handling world updates which arrive from the server.

Constructor

new exports(gameEngine, inputOptions, Renderer)

Create a client engine instance.

Parameters:
Name Type Description
gameEngine GameEngine

a game engine

inputOptions Object

options object

Properties
Name Type Description
autoConnect Boolean

if true, the client will automatically attempt connect to server.

standaloneMode Boolean

if true, the client will never try to connect to a server

delayInputCount Number

if set, inputs will be delayed by this many steps before they are actually applied on the client.

healthCheckInterval Number

health check message interval (millisec). Default is 1000.

healthCheckRTTSample Number

health check RTT calculation sample size. Default is 10.

syncOptions Object

an object describing the synchronization method. If not set, will be set to extrapolate, with local object bending set to 0.0 and remote object bending set to 0.6. If the query-string parameter "sync" is defined, then that value is passed to this object's sync attribute.

scheduler String

When set to "render-schedule" the game step scheduling is controlled by the renderer and step time is variable. When set to "fixed" the game step is run independently with a fixed step time. Default is "fixed".

syncOptions.sync String

chosen sync option, can be interpolate, extrapolate, or frameSync

syncOptions.localObjBending Number

amount of bending towards original client position, after each sync, for local objects

syncOptions.remoteObjBending Number

amount of bending towards original client position, after each sync, for remote objects

Renderer Renderer

the Renderer class constructor

Source:

Members

acceleration :Number

acceleration per step

Source:

affectedByGravity :Boolean

Whether this object is affected by gravity.

Source:

angle :Number

object orientation angle in degrees

Source:

friction :TwoVector

The friction coefficient. Velocity is multiplied by this for each step. Default is (1,1)

Source:

gameEngine :GameEngine

reference to game engine

Source:

height :Number

Object Height for collision detection purposes. Default is 1

Source:

isAccelerating :Boolean

should accelerate by DynamicObject#acceleration on next step

Source:

isRotatingLeft :Boolean

should rotate left by DynamicObject#rotationSpeed on next step

Source:

isRotatingRight :Boolean

should rotate right by DynamicObject#rotationSpeed on next step

Source:

playerId :String

client's player ID, as a string. If running on the client, this is set at runtime by the clientEngine

Source:

playerId :Number

ID of player who created this object

Source:

rotationSpeed :Number

angle rotation per step

Source:

serializer :Serializer

reference to serializer

Source:

serializer :GameEngine

reference to game engine

Source:

width :Number

Object width for collision detection purposes. Default is 1

Source:

exports

Tracing Services. Use the trace functions to trace game state. Turn on tracing by specifying the minimum trace level which should be recorded. For example, setting traceLevel to Trace.TRACE_INFO will cause info, warn, and error traces to be recorded.

Constructor

new exports()

Source:

Members

acceleration :Number

acceleration per step

Source:

affectedByGravity :Boolean

Whether this object is affected by gravity.

Source:

angle :Number

object orientation angle in degrees

Source:

friction :TwoVector

The friction coefficient. Velocity is multiplied by this for each step. Default is (1,1)

Source:

gameEngine :GameEngine

reference to game engine

Source:

height :Number

Object Height for collision detection purposes. Default is 1

Source:

isAccelerating :Boolean

should accelerate by DynamicObject#acceleration on next step

Source:

isRotatingLeft :Boolean

should rotate left by DynamicObject#rotationSpeed on next step

Source:

isRotatingRight :Boolean

should rotate right by DynamicObject#rotationSpeed on next step

Source:

playerId :String

client's player ID, as a string. If running on the client, this is set at runtime by the clientEngine

Source:

playerId :Number

ID of player who created this object

Source:

rotationSpeed :Number

angle rotation per step

Source:

serializer :Serializer

reference to serializer

Source:

serializer :GameEngine

reference to game engine

Source:

width :Number

Object width for collision detection purposes. Default is 1

Source:

exports

DynamicObject is the base class of the game's objects, for games which rely on SimplePhysicsEngine. It defines the base object which can move around in the game world. The extensions of this object (the subclasses) will be periodically synchronized from the server to every client.

The dynamic objects have pseudo-physical properties, which allow the client to extrapolate the position of dynamic objects in-between server updates.

Constructor

new exports(gameEngine, options, props)

Creates an instance of a dynamic object. NOTE: all subclasses of this class must comply with this constructor signature. This is required because the engine will create temporary instances when syncs arrive on the clients.

Parameters:
Name Type Description
gameEngine GameEngine

the gameEngine this object will be used in

options Object

options for the new object. See GameObject

props Object

properties to be set in the new object

Properties
Name Type Description
position TwoVector

position vector

velocity TwoVector

velocity vector

Source:

Members

acceleration :Number

acceleration per step

Source:

affectedByGravity :Boolean

Whether this object is affected by gravity.

Source:

angle :Number

object orientation angle in degrees

Source:

friction :TwoVector

The friction coefficient. Velocity is multiplied by this for each step. Default is (1,1)

Source:

gameEngine :GameEngine

reference to game engine

Source:

height :Number

Object Height for collision detection purposes. Default is 1

Source:

isAccelerating :Boolean

should accelerate by DynamicObject#acceleration on next step

Source:

isRotatingLeft :Boolean

should rotate left by DynamicObject#rotationSpeed on next step

Source:

isRotatingRight :Boolean

should rotate right by DynamicObject#rotationSpeed on next step

Source:

playerId :String

client's player ID, as a string. If running on the client, this is set at runtime by the clientEngine

Source:

playerId :Number

ID of player who created this object

Source:

rotationSpeed :Number

angle rotation per step

Source:

serializer :Serializer

reference to serializer

Source:

serializer :GameEngine

reference to game engine

Source:

width :Number

Object width for collision detection purposes. Default is 1

Source:

exports

The GameEngine contains the game logic. Extend this class to implement game mechanics. The GameEngine derived instance runs once on the server, where the final decisions are always taken, and one instance will run on each client as well, where the client emulates what it expects to be happening on the server.

The game engine's logic must listen to user inputs and act on these inputs to change the game state. For example, the game engine listens to controller/keyboard inputs to infer movement for the player/ship/first-person. The game engine listens to clicks, button-presses to infer firing, etc..

Note that the game engine runs on both the server and on the clients - but the server decisions always have the final say, and therefore clients must resolve server updates which conflict with client-side predictions.

Constructor

new exports(options)

Create a game engine instance. This needs to happen once on the server, and once on each client.

Parameters:
Name Type Description
options Object

options object

Properties
Name Type Description
traceLevel Number

the trace level from 0 to 5. Lower value traces more.

delayInputCount Number

client side only. Introduce an artificial delay on the client to better match the time it will occur on the server. This value sets the number of steps the client will wait before applying the input locally

Source:

Members

acceleration :Number

acceleration per step

Source:

affectedByGravity :Boolean

Whether this object is affected by gravity.

Source:

angle :Number

object orientation angle in degrees

Source:

friction :TwoVector

The friction coefficient. Velocity is multiplied by this for each step. Default is (1,1)

Source:

gameEngine :GameEngine

reference to game engine

Source:

height :Number

Object Height for collision detection purposes. Default is 1

Source:

isAccelerating :Boolean

should accelerate by DynamicObject#acceleration on next step

Source:

isRotatingLeft :Boolean

should rotate left by DynamicObject#rotationSpeed on next step

Source:

isRotatingRight :Boolean

should rotate right by DynamicObject#rotationSpeed on next step

Source:

playerId :String

client's player ID, as a string. If running on the client, this is set at runtime by the clientEngine

Source:

playerId :Number

ID of player who created this object

Source:

rotationSpeed :Number

angle rotation per step

Source:

serializer :Serializer

reference to serializer

Source:

serializer :GameEngine

reference to game engine

Source:

width :Number

Object width for collision detection purposes. Default is 1

Source:

exports

The PhysicalObject is the base class for physical game objects

Constructor

new exports(gameEngine, options, props)

Creates an instance of a physical object. Override to provide starting values for position, velocity, quaternion and angular velocity. The object ID should be the next value provided by world.idCount NOTE: all subclasses of this class must comply with this constructor signature. This is required because the engine will create temporary instances when syncs arrive on the clients.

Parameters:
Name Type Description
gameEngine GameEngine

the gameEngine this object will be used in

options Object

options for the new object. See GameObject

props Object

properties to be set in the new object

Properties
Name Type Description
position ThreeVector

position vector

velocity ThreeVector

velocity vector

quaternion Quaternion

orientation quaternion

angularVelocity ThreeVector

3-vector representation of angular velocity

Source:

Members

acceleration :Number

acceleration per step

Source:

affectedByGravity :Boolean

Whether this object is affected by gravity.

Source:

angle :Number

object orientation angle in degrees

Source:

friction :TwoVector

The friction coefficient. Velocity is multiplied by this for each step. Default is (1,1)

Source:

gameEngine :GameEngine

reference to game engine

Source:

height :Number

Object Height for collision detection purposes. Default is 1

Source:

isAccelerating :Boolean

should accelerate by DynamicObject#acceleration on next step

Source:

isRotatingLeft :Boolean

should rotate left by DynamicObject#rotationSpeed on next step

Source:

isRotatingRight :Boolean

should rotate right by DynamicObject#rotationSpeed on next step

Source:

playerId :String

client's player ID, as a string. If running on the client, this is set at runtime by the clientEngine

Source:

playerId :Number

ID of player who created this object

Source:

rotationSpeed :Number

angle rotation per step

Source:

serializer :Serializer

reference to serializer

Source:

serializer :GameEngine

reference to game engine

Source:

width :Number

Object width for collision detection purposes. Default is 1

Source: