Constructor
(abstract) new World(params)
    Constructor takes parems that allow to override default values.
    Parameters:
| Name | Type | Description | 
|---|---|---|
params | 
            
            object to override world defaults - all properties are copied to world properties | 
- Source:
 
Classes
Members
arHelper
    AR helper @type { VRHelper }
- Source:
 
avatar
    Reference to own Avatar or VideoAvatar, set by AvatarController during initialization @type { Avatar }
- Source:
 
avatarController
    Reference to AvatarController, set by AvatarController during initialization @type { AvatarController }
- Source:
 
baseUrl
    Base URL of related content, default "" (current location)
- Source:
 
camera
    Main world camera
- Source:
 
camera1p
    First person camera, defaults to main camera
- Source:
 
camera3p
    Main 3rd person world camera
- Source:
 
collisionsEnabled
    Wheter collisions are enabled, default true
- Source:
 
collisionsEnabledInXR
    Wheter collisions are enabled in XR, default true
- Source:
 
file
    World scene file name to load, default scene.gltf
- Source:
 
gravityEnabled
    Wheter gravity is enabled, default true
- Source:
 
hasXR
    WebXR capability indicator, set by VRHelper
- Source:
 
inAR
    AR mode indicator, set by VRHelper
- Source:
 
indicator
    Progress indicator
- Source:
 
inVR
    VR mode indicator, set by VRHelper
- Source:
 
lastInstance :World
    World instance that was created last.
    Type:
- Source:
 
name
    World name, default null
- Source:
 
objectsFile
    World objects json file, as saved by WorldEditor and AssetLoader, default null
- Source:
 
onProgress
    Progress indicator functon
- Source:
 
sceneMeshes
    Scene meshes, available once the world loads (in loaded, loadingStop, collisions methods)
- Source:
 
sharedSkybox
    Background VRObject
- Source:
 
sharedTerrain
    Terrain VRObject
- Source:
 
skyBox
    Skybox, optionally created in createSkybox() @type {Skybox}
- Source:
 
terrain
    Terrain, optionally created in createTerrain() @type {Terrain}
- Source:
 
vrHelper
    VR helper @type { VRHelper }
- Source:
 
VRSPACEUI :VRSpaceUI
    Handy reference to VRSpaceUI
    Type:
- Source:
 
worldListeners
    List of world listeners. 
    WorldManager executes enter(Welcome) method once user enters the world, after World.enter() method. 
    Methods added(VRObject) and removed(VRObject) are executed whenever the scene changes.
    Method loaded(VRObject) is called once the asset loads.
- Source:
 
worldManager
    Reference to worldManager, set by WorldManager once that user goes online @type { WorldManager }
- Source:
 
worldObjects
    World objects to load, default null
- Source:
 
xrHelper
    Currently active VR/AR helper
- Source:
 
Methods
_collisions(meshes, state)
    Utility method, enables or disables collisions on the given set of meshes.
    Parameters:
| Name | Type | Description | 
|---|---|---|
meshes | 
            
            array of meshes | |
state | 
            
            true or false | 
- Source:
 
addListener(worldListener, processAlreadyAdded)
    Add a world listener to listen for world events.
By default, added() event will not trigger for objects already present in the scene at the moment of adding the listener.
    Parameters:
| Name | Type | Description | 
|---|---|---|
worldListener | 
            
            WorldListener | |
processAlreadyAdded | 
            
            boolean | to call added() method for objects that added previously | 
- Source:
 
addSelectionPredicate()
    Add a selection predicate. It takes a mesh and returns true if it can be selected by the pointer.
- Source:
 
assetPath(relativePath)
    Utility method, returns baseUrl+relativePath
    Parameters:
| Name | Type | Description | 
|---|---|---|
relativePath | 
            
            path relative to current world directory | 
- Source:
 
attachControl()
    Attach the control to the camera, called from createScene.
- Source:
 
collisions(state)
    Enables or disables collisions in the world. This includes floorMeshes, sceneMeshes, and also applying gravity to camera.
    Parameters:
| Name | Type | Description | 
|---|---|---|
state | 
            
            true or false | 
- Source:
 
(async) createCamera()
    An implementation must override this method and define at least one camera.
Returned camera, if any, is set as main camera (this.camera), and also as 1st person
camera (this.camera1p) if one is not set.
- Source:
 
createChatlog()
    Creates a ChatLog and binds it to the HUD, then it registers remoteEvent() method
  as a change listener with WorldManager to process remote events.
- Source:
 
(async) createEffects()
    Optional, empty implementation, called from createScene
- Source:
 
(async) createGround()
    Optional, empty implementation, called from createScene. Should return a mesh.
- Source:
 
(async) createLights()
    Optional, empty implementation, called from createScene. May return a Light
- Source:
 
(async) createPhysics()
    Optional, called from createScene. Creates Havok physics engine and plugin, with this.scene.gravity.
Generally, to enable physics in the scene, just set gravity and call super.createPhysics().
Or to disable gravity, simply do not call super.
- Source:
 
(async) createScene()
    Called from init.
  If the scene does not exist, creates the scene first.
  Then calls methods in this order: 
  createCamera, attachControl, createLights, createShadows, createSkybox, createGround, createEffects, createPhysics.
- Source:
 
(async) createShadows()
    Optional, empty implementation, called from createScene. Should return a ShadowGenerator.
- Source:
 
(async) createSkyBox()
    Optional, empty implementation, called from createScene. Should return a sky Box.
- Source:
 
(async) createTerrain()
    Optional, empty implementation, called from createScene
- Source:
 
(async) createUI()
    Optional, empty implementation, called from createScene
- Source:
 
(async) dispose()
    Disposes of all objects returned by createLights, createCamera, createShadows, createSkybox
- Source:
 
enableBackground()
    Called when entering world in AR mode, or entering/exiting AR.
VRHelper disables the skybox and terrain, but this method should dissable all other nodes that shouldn't be visible in AR.
- Source:
 
enableFloorSelection(enable)
    Enable/disable floor/ground selection, includes manipulation and teleportation
    Parameters:
| Name | Type | Description | 
|---|---|---|
enable | 
            
            boolean | 
- Source:
 
(async) entered(welcome)
    Called by WorldManager after the user has entered a multiuser world.
  Default implementation calls this.createChatlog().
  Note that at this point world geometry may not have been loaded.
    Parameters:
| Name | Type | Description | 
|---|---|---|
welcome | 
            
            message containing users Client object and array of permanent objects | 
- Source:
 
(async) enterWith(avatarUrl, userNameopt)
    Quick enter, with avatar url and optionally user name.
    Parameters:
| Name | Type | Attributes | Description | 
|---|---|---|---|
avatarUrl | 
            
            string | URL to load avatar from | |
userName | 
            
            string | 
                
                    <optional> | 
            
            
            login name of the user | 
- Source:
 
enterXR()
    Called by VR helper after entering XR mode. Default implementation enables virtual keyboard in ChatLog.
- Source:
 
exitXR()
    Called by VR helper after exiting XR. Default implementation turns off ChatLog virtual keyboard.
- Source:
 
firstPerson()
    Activate first person camera (this.camera1p), if available.
Makes a call to AvatarController method that applies camera rotation and takes care of everything else.
- Source:
 
firstPersonCamera()
    Creates first person camera and sets this.camera1p.
- Source:
 - See:
 - 
        
- CameraHelper.firstPersonCamera
 
 
getFloorMeshes()
    Returns this.floorMeshes or this.ground if exist, or empty array.
  Used for movement in XR.
- Source:
 
(async) init(engine, name, scene, callback, baseUrl, file)
    Create, load and and show the world.
  Enables gravity and collisions, then executes createScene method, optionally creates load indicator,
  registers render loop, crates terrain, and finally, executes load method. Every method executed can be overridden.
    Parameters:
| Name | Type | Description | 
|---|---|---|
engine | 
            
            babylonjs engine | |
name | 
            
            world name | |
scene | 
            
            babylonjs scene, optional | |
callback | 
            
            to execute after the world has loaded | |
baseUrl | 
            
            folder to load scene from, default "", used only if not defined in constructor | |
file | 
            
            scene file to load, default scene.gltf, used only if not defined in constructor | 
- Source:
 
Returns:
    final scene
    
        
            
    
    
    initXR(vrHelper, arHelper, activeHelper)
    Creates a VRHelper if needed, and initializes it with the current world.
  Normally called after world is loaded, safe to call elsewhere, or call multiple times, 
  but only after World.init() has finished. (world.scene must be initialized)
    Parameters:
| Name | Type | Description | 
|---|---|---|
vrHelper | 
            
            optional existing vrHelper | |
arHelper | 
            
            optional existing arHelper | |
activeHelper | 
            
            optional, if given both helpers, one that's currently active (e.g. passed while in VR or AR mode) | 
- Source:
 
inXR()
    Returns true if either VR or AR mode is currently active
- Source:
 
isOnline()
    Utility method, returns true if the world is online, i.e. the client is connected to the server.
- Source:
 
isSelectableMesh()
    Used in mesh selection predicate in XR, for world elements only. 
  Default implementation returns true for members of this.floorMeshes.
- Source:
 
(async) load(callback)
    Load the world, then execute given callback passing self as argument.
  Loads an AssetContainer from file specified by this.file, if any (by default scene.gltf), and adds it to the scene.
  Then loads all world objects specified in this.objectsFile or this.worldObjects, if any - file takes precedence.
  Takes care of loading progress.
  Calls loadingStart, loaded, loadingStop, collisions - each may be overridden.
    Parameters:
| Name | Type | Description | 
|---|---|---|
callback | 
            
            to execute after the content has loaded | 
- Source:
 
Returns:
    world object
    
        
            
    
    
    (async) loadAsset(relativePath, file)
    Utility method to fix the path and load the file, executes LoadAssetContainerAsync.
    Parameters:
| Name | Type | Description | 
|---|---|---|
relativePath | 
            
            path relative to current world directory | |
file | 
            
            file name to load | 
- Source:
 
loaded(file, mesh)
    Called after assets are loaded. By default calls initXR().
  Subclasses typically override this with some spatial manipulations, e.g. scaling the world.
  Subclasses may, but are not required, call super.loaded()
    Parameters:
| Name | Type | Description | 
|---|---|---|
file | 
            
            world file that has loaded | |
mesh | 
            
            root mesh of the world | 
- Source:
 
loadFailed(exception)
    Called if loading the world fails. Passes the exception to this.onFailure handler if it exists,
  otherwise logs it to the console.
    Parameters:
| Name | Type | Description | 
|---|---|---|
exception | 
            
            whatever caused loading to fail | 
- Source:
 
loadingStart(name)
    Called when loading starts. Calls this.indicator.add if available.
    Parameters:
| Name | Type | Description | 
|---|---|---|
name | 
            
            
- Source:
 
loadingStop(name)
    Called when loading finishes. Calls this.indicator.remove if available.
    Parameters:
| Name | Type | Description | 
|---|---|---|
name | 
            
            
- Source:
 
loadProgress(evt, name)
    Called on loading progress, executes whatever this.onProgress contains, by default LoadProgressListener.
    Parameters:
| Name | Type | Description | 
|---|---|---|
evt | 
            
            ||
name | 
            
            
- Source:
 
registerRenderLoop()
    Register render loop.
- Source:
 
remoteEvent(obj, field, node)
    Receives a remote event. Default implementation handles only 'wrote' event, and sends it to the ChatLog.
    Parameters:
| Name | Type | Description | 
|---|---|---|
obj | 
            
            a VRObject that has changed | |
field | 
            
            a field that has changed, obj[field] contains the actual value | |
node | 
            
            root node in the scene that has received event, may be null | 
- Source:
 
removeListener()
    Remove a world listener
- Source:
 
removeSelectionPredicate()
    Remove a selection predicate function
- Source:
 
setAvatar(avatar)
    Set own avatar, valid only while online. Makes a call to AvatarController method, if available.
    Parameters:
| Name | Type | Description | 
|---|---|---|
avatar | 
            
            Avatar | 
- Source:
 
setMeshCollisions(mesh, state)
    Enable or disable collisions for a mesh. Override to fine-tune collisions.
    Parameters:
| Name | Type | Description | 
|---|---|---|
mesh | 
            
            ||
state | 
            
            
- Source:
 
thirdPerson()
    Activate third person camera  (this.camera3p), if available.
Makes a call to AvatarController method that applies camera rotation and takes care of everything else.
- Source:
 
thirdPersonCamera()
    Utility method, creates 3rd person camera and sets this.camera3p.
- Source:
 - See:
 - 
        
- CameraHelper.thirdPersonCamera
 
 
trackXrDevices()
    Called by VRHelper once XR devices are initialized. Default implementation does nothing.
- Source:
 
write(text, link)
    Write some text to world chat. Usually text appears above avatar's head and/or in chat log,
  but this method only sends own 'wrote' event.
    Parameters:
| Name | Type | Description | 
|---|---|---|
text | 
            
            string | something to say | 
link | 
            
            string | optional url to link the text with | 
- Source: