SceneSync

altspace/utilities/behaviors. SceneSync

new SceneSync(syncInstance, configopt)

The SceneSync behavior manages the synchronization of an entire scene.

Parameters:
Name Type Attributes Description
syncInstance Firebase
config Object <optional>
Properties
Name Type Attributes Description
instantiators Object <optional>

A dictionary of instantiation callbacks by syncType. Instantiators are called on every client whenever an instantiation call is made. Instantiators are passed an initialization data object and the syncType. They should return an Object3D with an Object3DSync behavior.

destroyers Object <optional>

(Optional) A dictionary of destroy callbacks by syncType. Destroyers are called on every client whenever an destroy call is made. If no destroyer is provided, a default one will be use which will remove the object from its parent and dispose its geometry, material, and texture. If you return true from a custom destroyer, the default destroyer will also be called.

ready function <optional>

A callback that is called after checking to see if the instance has already been initialized. The callback is passed a boolean that is true if this is the first callback that has been called for this sync instance. This is primarily useful for setting up any objects that should only be created once for an instance, and is not necessary otherwise.

Members

(readonly) autoSendRateMS :number

Interval at which an object's position/rotation/scale data is sent to Firebase, in milliseconds.

(readonly) clientId :string

UUID of the current client.

(readonly) clientsRef :Firebase

Firebase reference for the 'clients' child location. Can be used by app to listen to clients entering and leaving the room (but generally should not be modified by apps).

(readonly) isMasterClient :boolean

True if this client is the master, false otherwise. Master is generally the client that has been in the room the longest.

Methods

destroy(object3d)

Destroy a synced object across instances.

Parameters:
Name Type Description
object3d Object

The object to destroy.

instantiate(syncType, initData, destroyOnDisconnect)

Instantiate an object by syncType.

Parameters:
Name Type Description
syncType String

Type of object to instantiate.

initData Object

An object containing initialization data, passed to the instantiator.

destroyOnDisconnect Boolean

If the object should be destroyed across all synced instance when the instantiating instance disconnects.