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.
Name | Type | Description |
---|---|---|
options |
Object | The options object to be passed to |
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.
Name | Type | Description |
---|---|---|
name |
string | The name of a model service. |
- 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.
Name | Type | Description |
---|---|---|
name |
string | The name of a view service. |
- Type
- ViewService
Events
# destroyActor
Fired when an actor is destroyed.
Properties
Name | Type | Description |
---|---|---|
scope |
String | actor.id |
event |
String |
|
# translationChanged
Fired when a spatial actor's translation changes.
Properties
Name | Type | Description |
---|---|---|
scope |
String | actor.id |
event |
String |
|
translation |
Array.<number> | 3-vector |
# rotationChanged
Fired when a spatial actor's rotation changes.
Properties
Name | Type | Description |
---|---|---|
scope |
String | actor.id |
event |
String |
|
rotation |
Array.<number> | quaternion |
# scaleChanged
Fired when a spatial actor's scale changes.
Properties
Name | Type | Description |
---|---|---|
scope |
String | actor.id |
event |
String |
|
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 |
|
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 |
|
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 |
|
transform |
Array.<number> | 4x4 transform matrix |
this.listen("viewGlobalChanged", m => {console.log(m)}) // Prints the new matrix when it changes