Constructor
new WorldManager(world, fps)
Creates world manager with default values and connection, scene, camera listeners.
Parameters:
Name | Type | Description |
---|---|---|
world |
||
fps |
network framerate, default 5 (send up to 5 events per second) |
- Source:
Classes
Members
avatarLoader
Avatar loader
- Source:
createAnimations
Create animations for movement of avatars, default true. Recommended for low fps.
- Source:
customAnimations
Custom avatar animations
- Source:
customOptions
Custom avatar options, applied to avatars after loading. Currently video avatars only
- Source:
debug
Enable debug output
- Source:
fps
Network frames per second, default 5
- Source:
instance
Current WorldManager instance @type {WorldManager}
- Source:
leftArmPos
Current left arm position
- Source:
leftArmRot
Current left arm rotation
- Source:
loadCallback
Optionally called after an avatar has loaded. Callback is passed VRObject and avatar object as parameters.
Avatar object can be either Avatar or VideoAvatar instance, or an AssetContainer.
TODO this needs to go away, but is used in WorldEditor.
- Source:
loadErrorHandler
Called when loading fails, default null.
TODO used in WorldEditor, replace with WorldListener
- Source:
mediaStreams
This is set once we connect to streaming server @type {MediaStreams}
- Source:
myChangeListeners
Listeners notified after own avatar property (e.g. position) has changed and published
- Source:
pos
Current position
- Source:
remoteLogging
Mobile browsers don't have javascript console, and USB debugging is next to useless.
Enable to redirect all console output to the server log. Sure, it starts only after connection to the server is established.
- Source:
resolution
Movement resolution, default 1 cm/3.6 deg. Any movement less than this will be ignored.
- Source:
rightArmPos
Current right arm position
- Source:
rightArmRot
Current right arm rotation
- Source:
rot
Current rotation
- Source:
scene
the scene
- Source:
tokens
client tokens
- Source:
trackedMesh
In 3rd person view, we're not tracking and publishing position and orientation camera, but of this mesh
- Source:
trackRotation
Whether to track user rotation, default true.
- Source:
userHeight
User height in real world, default 1.8
- Source:
world
the world @type {World}
- Source:
Methods
(static) myId()
Returns VRSPACE.me if available, null otherwise
- Source:
addMyChangeListener()
Add a listener to own events
- Source:
bBoxMax()
Utility method, calculates bounding box for an AssetContainer and returns maximum of x,y,z.
Works only for meshes already rendered
- Source:
boundingBox()
Utility method, calculates bounding box for an AssetContainer.
- Source:
Returns:
Vector3 bounding box
checkChange()
Check if a value has changed, and update change array if so.
- Source:
(async) enter(properties) → {Promise.<Welcome>}
Enter the world specified by world.name. If not already connected,
first connect to world.serverUrl and set own properties, then start the session.
World and WorldListeners are notified by calling entered methods.
Parameters:
Name | Type | Description |
---|---|---|
properties |
Object | own properties to set before starting the session |
- Source:
Returns:
promise resolved after enter
- Type
- Promise.<Welcome>
(async) enterAs(avatar) → {Promise.<Welcome>}
Enter the world as avatar.
Creates propererties by taking user name, height and avatar url from given Avatar,
then calls enter( properties ).
Parameters:
Name | Type | Description |
---|---|---|
avatar |
Avatar | User's avatar |
- Source:
Returns:
promise resolved after enter
- Type
- Promise.<Welcome>
entered()
Called after user enters a world, calls world.entered() wrapped in try/catch
- Source:
(async) enterWith(avatarUrl, userName) → {Avatar}
Quick enter, with avatar url and optionally user name.
Parameters:
Name | Type | Description |
---|---|---|
avatarUrl |
string | URL to load avatar from |
userName |
string | login name of the user |
- Source:
Returns:
own Avatar instance
- Type
- Avatar
isChanged()
Return true if a value is ouside of given range.
- Source:
isOnline()
Returns true if connected to the server and session is active
- Source:
loadScript()
Load a script, call it's constructor with the VRObject, then calls init(), and adds the listener.
See basic-script.js and web-portal.js.
- Source:
publishChanges(changes)
Publish changes to the server (if online) and local change listeners
Parameters:
Name | Type | Description |
---|---|---|
changes |
array of objects with field-value pairs |
- Source:
pubSub(user, autoPublishVideo)
Publish and subscribe
Parameters:
Name | Type | Description |
---|---|---|
user |
Client | Client object of the local user |
autoPublishVideo |
boolean | should webcam video be published as soon as possible |
- Source:
removeMyChangeListener()
Remove listener to own events
- Source:
removeObject()
Remove an object: remove the mesh from the scene (scene listener), and dispose of everything.
- Source:
sceneChanged(e)
Called when scene has changed (scene listener).
If an object was added, calls appropriate loader method.
If an object was removed, calls removeObject.
Any WorldListeners on the world are notified after changes are performed, by calling added and removed methods.
Parameters:
Name | Type | Description |
---|---|---|
e |
SceneEvent | SceneEvent containing the change |
- Source:
sendMy(obj)
Send own event.
Parameters:
Name | Type | Description |
---|---|---|
obj |
object containing changes to be sent, i.e. name-value pair(s). |
- Source:
setSessionStatus()
Called when connection to the server is established (connection listener)
- Source:
trackCamera()
Tracks active camera
- Source:
trackChanges()
Periodically executed, as specified by fps.
Tracks changes to camera and XR controllers.
Calls checkChange, and if anything has changed, changes are sent to server,
and to myChangeListeners.
- Source:
trackMesh()
Track a mesh, used in 3rd person view
- Source:
write()
Local user wrote something - send it over and notify local listener(s)
- Source: