Global

Methods

# StartWorldcore(options)

This function should be used to start a Worldcore session instead of the normal Croquet Session.join. The reason for this is that some Worldcore services may require installaton or initialization before Croquet starts, and StartWorldcore handles that automatically.

Parameters:
Name Type Description
options Object

The options object to be passed to Session.join

Example
StartWorldcore({
    appId: 'io.croquet.example',
    apiKey: <insert api key>,
    password: 'password',
    name: 'example',
    model: MyModelRoot,
    view: MyViewRoot
})

# GetModelService(name) → {ModelService}

Given the name of a model service, returns a pointer to it.

Parameters:
Name Type Description
name string

The name of a model service.

Returns:
Type
ModelService

# GetViewService(name) → {ViewService}

Given the name of a view service, returns a pointer to it.

Warning: This should not be called inside model code.

Parameters:
Name Type Description
name string

The name of a view service.

Returns:
Type
ViewService

Events

# destroyActor

Fired when an actor is destroyed.

Properties
Name Type Description
scope String

actor.id

event String

"destroyActor"

# translationChanged

Fired when a spatial actor's translation changes.

Properties
Name Type Description
scope String

actor.id

event String

"translationChanged"

translation Array.<number>

3-vector

# rotationChanged

Fired when a spatial actor's rotation changes.

Properties
Name Type Description
scope String

actor.id

event String

"rotationChanged"

rotation Array.<number>

quaternion

# scaleChanged

Fired when a spatial actor's scale changes.

Properties
Name Type Description
scope String

actor.id

event String

"scaleChanged"

scale Array.<number>

3-vector

# localChanged

Fired when a spatial actor's local transform matrix changes.

Properties
Name Type Description
scope String

actor.id

event String

"localChanged"

transform Array.<number>

4x4 transform matrix

# globalChanged

Fired when a spatial actor's global transform matrix changes.

Properties
Name Type Description
scope String

actor.id

event String

"globalChanged"

transform Array.<number>

4x4 transform matrix

# viewGlobalChanged

Fired when a spatial pawn's global transform matrix changes. This is a separate event from globalChanged because a pawn can update its global transform every frame even if its actor updates less frequently. Use this event to drive things like updating the transform matrix of a render model.

Properties
Name Type Description
scope String

actor.id

event String

"viewGlobalChanged"

transform Array.<number>

4x4 transform matrix

Example
this.listen("viewGlobalChanged", m => {console.log(m)}) // Prints the new matrix when it changes