Global

Methods

add(other) → {ThreeVector}

Add other vector to this vector

Parameters:
Name Type Description
other ThreeVector

the other vector

Source:
Returns:

returns self

Type
ThreeVector

addCustomType(customType)

Adds a custom primitive to the serializer instance. This will enable you to use it in an object's netScheme

Parameters:
Name Type Description
customType
Source:

addObject(obj)

Handle the addition of a new object to the world.

Parameters:
Name Type Description
obj Object

The object to be added.

Source:

addObjectToWorld(object) → {Object}

Add object to the game world. On the client side, the object may not be created, if the server copy of this object is already in the game world. This could happen when the client is using delayed-input, and the RTT is very low.

Parameters:
Name Type Description
object Object

the object.

Source:
Returns:

object - the final object.

Type
Object

bendingToString() → {String}

Formatted textual description of the game object's current bending properties.

Source:
Returns:

description - a string description

Type
String

conjugate() → {Quaternion}

conjugate the quaternion, in-place

Source:
Returns:

returns self

Type
Quaternion

connect(optionsopt) → {Promise}

Makes a connection to the game server

Parameters:
Name Type Attributes Description
options Object <optional>

additional socket.io options

Source:
Returns:

Resolved when the connection is made to the server

Type
Promise

copy(sourceObj) → {ThreeVector}

Copy values from another ThreeVector into this ThreeVector

Parameters:
Name Type Description
sourceObj ThreeVector

the other vector

Source:
Returns:

returns self

Type
ThreeVector

copy(sourceObj) → {Quaternion}

copy values from another quaternion into this quaternion

Parameters:
Name Type Description
sourceObj Quaternion

the quaternion to copy from

Source:
Returns:

returns self

Type
Quaternion

draw()

In AFrame, we set the draw method (which is called at requestAnimationFrame) to a NO-OP. See tick() instead

Source:

draw(t, dt)

The main draw function. This method is called at high frequency, at the rate of the render loop. Typically this is 60Hz, in WebVR 90Hz. If the client engine has been configured to render-schedule, then this method must call the clientEngine's step method.

Parameters:
Name Type Description
t Number

current time (only required in render-schedule mode)

dt Number

time elapsed since last draw (only required in render-schedule mode)

Source:

gameStatus() → {String}

Report game status This method is only relevant if the game uses MatchMaker functionality. This method must return the game status.

Source:
Returns:

Stringified game status object.

Type
String

init() → {Promise}

Initialize the renderer.

Source:
Returns:

Resolves when renderer is ready.

Type
Promise

init() → {Promise}

Initialize the renderer.

Source:
Returns:

Resolves when renderer is ready.

Type
Promise

isOwnedByPlayer(object) → {Boolean}

Check if a given object is owned by the player on this client

Parameters:
Name Type Description
object Object

the game object to check

Source:
Returns:

true if the game object is owned by the player on this client

Type
Boolean

length() → {Number}

Get vector length

Source:
Returns:

length of this vector

Type
Number

lerp(target, p) → {ThreeVector}

Apply in-place lerp (linear interpolation) to this ThreeVector towards another ThreeVector

Parameters:
Name Type Description
target ThreeVector

the target vector

p Number

The percentage to interpolate

Source:
Returns:

returns self

Type
ThreeVector

multiply(other) → {Quaternion}

multiply this quaternion by another, in-place

Parameters:
Name Type Description
other Quaternion

The other quaternion

Source:
Returns:

returns self

Type
Quaternion

multiplyScalar(s) → {ThreeVector}

Multiply this ThreeVector by a scalar

Parameters:
Name Type Description
s Number

the scale

Source:
Returns:

returns self

Type
ThreeVector

normalize() → {ThreeVector}

Normalize this vector, in-place

Source:
Returns:

returns self

Type
ThreeVector

processInput(inputMsg, playerId, isServer)

Override this function to implement input handling. This method will be called on the specific client where the input was received, and will also be called on the server when the input reaches the server. The client does not call this method directly, rather the client calls ClientEngine#sendInput so that the input is sent to both server and client, and so that the input is delayed artificially if so configured.

The input is described by a short string, and is given an index. The index is used internally to keep track of inputs which have already been applied on the client during synchronization. The input is also associated with the ID of a player.

Parameters:
Name Type Description
inputMsg Object

input descriptor object

Properties
Name Type Description
input String

describe the input (e.g. "up", "down", "fire")

messageIndex Number

input identifier

playerId Number

the player ID

isServer Boolean

indicate if this function is being called on the server side

Source:

registerClass(classObj, classId)

Registers a new class with the serializer, so it may be deserialized later

Parameters:
Name Type Description
classObj function

reference to the class (not an instance!)

classId String

Unit specifying a class ID

Source:

registerClasses(serializer)

Register Game Object Classes

Parameters:
Name Type Description
serializer Serializer

the serializer

Source:
Example
registerClasses(serializer) {
  serializer.registerClass(require('../common/Paddle'));
  serializer.registerClass(require('../common/Ball'));
}

removeObject(obj)

Handle the removal of an old object from the world.

Parameters:
Name Type Description
obj Object

The object to be removed.

Source:

removeObjectFromWorld(id)

Remove an object from the game world.

Parameters:
Name Type Description
id String

the object ID

Source:

runClientStep(t, dt)

The main draw function. This method is called at high frequency, at the rate of the render loop. Typically this is 60Hz, in WebVR 90Hz.

Parameters:
Name Type Description
t Number

current time

dt Number

time elapsed since last draw

Source:

sendInput(input, inputOptions)

This function should be called by the client whenever a user input occurs. This function will emit the input event, forward the input to the client's game engine (with a delay if so configured) and will transmit the input to the server as well.

This function can be called by the extended client engine class, typically at the beginning of client-side step processing (see event client__preStep)

Parameters:
Name Type Description
input Object

string representing the input

inputOptions Object

options for the input

Source:

set(x, y, z) → {ThreeVector}

Set ThreeVector values

Parameters:
Name Type Description
x Number

x-value

y Number

y-value

z Number

z-value

Source:
Returns:

returns self

Type
ThreeVector

set(w, x, y, z) → {Quaternion}

set quaternion values

Parameters:
Name Type Description
w Number

w-value

x Number

x-value

y Number

y-value

z Number

z-value

Source:
Returns:

returns self

Type
Quaternion

setFromAxisAngle(axis, angle) → {Quaternion}

set the values of this quaternion from an axis/angle representation

Parameters:
Name Type Description
axis ThreeVector

The axis

angle Number

angle in radians

Source:
Returns:

returns self

Type
Quaternion

slerp(target, bending) → {Quaternion}

Apply in-place slerp (spherical linear interpolation) to this quaternion, towards another quaternion.

Parameters:
Name Type Description
target Quaternion

The target quaternion

bending Number

The percentage to interpolate

Source:
Returns:

returns self

Type
Quaternion

start()

Start the game. This method runs on both server and client. Extending the start method is useful for setting up the game's worldSettings attribute, and registering methods on the event handler.

Source:

start() → {Promise}

Start the client engine, setting up the game loop, rendering loop and renderer.

Source:
Returns:

Resolves once the Renderer has been initialized, and the game is ready to connect

Type
Promise

step(isReenact, t, dt, physicsOnly)

Single game step.

Parameters:
Name Type Description
isReenact Boolean

is this step a re-enactment of the past.

t Number

the current time (optional)

dt Number

elapsed time since last step was called. (optional)

physicsOnly Boolean

do a physics step only, no game logic

Source:

subtract(other) → {ThreeVector}

Subtract other vector from this vector

Parameters:
Name Type Description
other ThreeVector

the other vector

Source:
Returns:

returns self

Type
ThreeVector

toAxisAngle() → {Object}

return an axis-angle representation of this quaternion

Source:
Returns:

contains two attributes: axis (ThreeVector) and angle.

Type
Object

toString() → {String}

Formatted textual description of the ThreeVector.

Source:
Returns:

description

Type
String

toString() → {String}

Formatted textual description of the TwoVector.

Source:
Returns:

description

Type
String

toString() → {String}

Formatted textual description of the Quaternion.

Source:
Returns:

description

Type
String

toString() → {String}

Formatted textual description of the dynamic object. The output of this method is used to describe each instance in the traces, which significantly helps in debugging.

Source:
Returns:

description - a string describing the DynamicObject

Type
String

toString() → {String}

Formatted textual description of the dynamic object. The output of this method is used to describe each instance in the traces, which significantly helps in debugging.

Source:
Returns:

description - a string describing the DynamicObject

Type
String

typeCanAssign(type) → {Boolean}

Checks if type can be assigned by value.

Parameters:
Name Type Description
type String

Type to Checks

Source:
Returns:

True if type can be assigned

Type
Boolean