ViewService

ViewService

A singleton with a well-known name that provides a view-side global service.

Extends

Members

# (readonly) time :number

Returns the system time in milliseconds at the last frame update.

Type:
  • number
Inherited From:

# (readonly) delta :number

Returns the time in milliseconds between the last frame update and the previous one.

Type:
  • number
Inherited From:

Methods

# (async, static) asyncStart()

This method is called before the Croquet session starts. If you're writing a custom service that requires some sort of installation or initization before Croquet runs Session.join that code should go here.

# update(time, delta)

Any ViewService with an update method will have it called on every frame. Classes that inherit from this base class should overload update if they need to refresh every frame.

Parameters:
Name Type Description
time number

The system time in milliseconds at the last frame.

delta number

The elapsed time in milliseconds since the last frame.

Example
class MyViewService extends ViewService {
        update(time, delta) {
            console.log(delta + " ms have elapsed since previous frame");
        }
    }

# service(name) → {ViewService}

Returns a pointer to the named view service.

Parameters:
Name Type Description
name string

The public name of the view service.

Inherited From:
Returns:
Type
ViewService

# modelService(name) → {ModelService}

Returns a pointer to the named model service.

Note: The view should only read from the model service. Do not write to it, or call methods that modify it.

Parameters:
Name Type Description
name string

The public name of the model service.

Inherited From:
Returns:
Type
ModelService