SceneSync

altspace/utilities/behaviors. SceneSync

The SceneSync behavior manages the synchronization of an entire scene.

Constructor

new SceneSync(syncInstance, configopt)

Parameters:
Name Type Attributes Description
syncInstance Firebase

Obtain this by calling altspace.utilities.sync.connect

config Object <optional>
Properties
Name Type Attributes Default 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 a 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.

autoSendRateMS integer <optional>
100

The rate updates are published to other clients, in milliseconds. This can usually be left default.

Extends

Members

isMasterClient :boolean

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

type :string

The string name of this class. This is used for THREE.Object3D#getBehaviorByType.

Overrides:

Methods

destroy(object3d)

Destroy a synced object across instances.

Parameters:
Name Type Description
object3d Object

The object to destroy.

instantiate(syncType, initData, destroyOnDisconnect) → {Object3DSync}

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.