Constructor
new VRSpaceUI()
Creates UI with default LoadProgressIndicator
- Source:
Classes
Members
assetLoader
reference to AssetLoader singleton
- Source:
canAR
AR availability
- Source:
canVR
VR availability
- Source:
contentBase
content base (prefix), default empty (same host)
- Source:
debug
debug output enabled
- Source:
fps
frames per second
- Source:
guiManager
babylon GUI manager - multiple instances may cause issues with transparency
- Source:
hud :HUD
Head-up display
Type:
- Source:
logo
vrspace.org logo mesh
- Source:
logoFile
Logo file name, defaults to logo.glb
- Source:
logoPath
Path to logo, null defaults to contentBase+/babylon (vrspace.org logo)
- Source:
portal
portal mesh
- Source:
portalFile
Portal file name, defaults to scene.gltf
- Source:
portalPath
Path to logo, null defaults to contentBase+/babylon/portal
- Source:
scene
babylon scene
- Source:
scriptLoader
Script loader
- Source:
VRSPACE
reference to VRSpace singleton
- Source:
Methods
copyMesh(mesh, parent, replaceParent)
Utility method to instantiate if possible, or otherwise clone a mesh, including all children recursivelly.
Both instance and clone use the same material, but only the clone has own lightning effects (e.g. shadows, environment).
Parameters:
Name | Type | Description |
---|---|---|
mesh |
to instantiate/clone | |
parent |
optional, copy will have this parent | |
replaceParent |
optional |
- Source:
Returns:
copied mesh
createAnimation(mesh, field, fps)
Utility method - create x,y,z animation of a mesh field.
Parameters:
Name | Type | Description |
---|---|---|
mesh |
to animate | |
field |
name of field to animate, e.g. "position" or "rotation" | |
fps |
frames per second, defaults to fps field value |
- Source:
Returns:
babylonjs AnimationGroup
createQuaternionAnimation(mesh, field, fps)
Utility method - create quaternion animation of a mesh field
Parameters:
Name | Type | Description |
---|---|---|
mesh |
to animate | |
field |
name of field to animate, e.g. "rotationQuaternion" | |
fps |
frames per second, defaults to fps field value |
- Source:
Returns:
babylonjs AnimationGroup
findRootNode()
Utility method - returns the top parent node in hierarchy
- Source:
(async) init(scene)
Creates asset loader, preloads vrspace.org logo and portal for later use.
Parameters:
Name | Type | Description |
---|---|---|
scene |
babylon.js scene to operate with. |
- Source:
listCharacters(dir, callback)
list character folders and their fix files
Parameters:
Name | Type | Description |
---|---|---|
dir |
directory to list | |
callback |
to call |
- Source:
(async) listCharactersAsync(dir)
list character folders and their fix files
Parameters:
Name | Type | Description |
---|---|---|
dir |
directory to list |
- Source:
listDirectory(dir, callback, suffix)
List files in a server folder
Parameters:
Name | Type | Description |
---|---|---|
dir |
directory to list | |
callback |
receives string array with urls | |
suffix |
optional suffix of listed files |
- Source:
listFiles(theUrl, callback)
lists files on a server directory
Parameters:
Name | Type | Description |
---|---|---|
theUrl |
url to load from | |
callback |
to call load, passing it XMLHttpRequest |
- Source:
(async) listFilesAsync(theUrl)
lists files on a server directory
Parameters:
Name | Type | Description |
---|---|---|
theUrl |
url to load from |
- Source:
Returns:
Promise with XMLHttpRequest
listMatchingFiles(dir, callback, suffix)
list server folders along with their matching files
i.e. files with the same name, plus given suffix
Parameters:
Name | Type | Description |
---|---|---|
dir |
directory to list | |
callback |
to call, receives ServerFolder array as argument | |
suffix |
of related file |
- Source:
(async) listMatchingFilesAsync(dir, suffix)
list server folders along with their matching files
i.e. files with the same name, plus given suffix
Parameters:
Name | Type | Description |
---|---|---|
dir |
directory to list | |
suffix |
of related file |
- Source:
Returns:
Promise with ServerFolder array
listThumbnails(dir, callback)
list folders with their jpg thumbnails (files ending with .jpg)
Parameters:
Name | Type | Description |
---|---|---|
dir |
directory to list | |
callback |
to call |
- Source:
(async) loadPortal(scene)
loads the portal
Parameters:
Name | Type | Description |
---|---|---|
scene |
- Source:
loadProgressIndicator()
Pointer to function, defaults to this.loadProgressIndiciatorFactory
- Source:
loadProgressIndicatorFactory(scene, camera)
Creates default LoadProgressIndicator bound to given camera, if one does not already exist.
Parameters:
Name | Type | Description |
---|---|---|
scene |
||
camera |
- Source:
Returns:
load progress indicator
(async) loadScriptsToDocument(urls, parallel)
Utility method - load a script and append it to document head
Parameters:
Name | Type | Description |
---|---|---|
urls |
array containing URLs of scripts | |
parallel |
optionally load in parallel |
- Source:
log(something)
Logs to js console if debug is enabled
Parameters:
Name | Type | Description |
---|---|---|
something |
to log |
- Source:
logoDir()
Used in init, return logPath if exists, or default path to vrspace.org logo
- Source:
optimizeScene()
Optimize the scene for better frame rate
- Source:
portalDir()
Returns portalPath if exists, defaults to contentBase+/babylon/portal
- Source:
receiveShadows(node, shadows)
Utility method, should a node and its children receive shadows.
Parameters:
Name | Type | Description |
---|---|---|
node |
a babylonjs node | |
shadows |
true ofr false |
- Source:
saveFile(filename, content)
Utility method to save a file with given name and file content.
Parameters:
Name | Type | Description |
---|---|---|
filename |
to save | |
content |
of the file, typically some JSON string |
- Source:
saveSceneBabylon(fileName)
Save scene as babylon json file. This only works for very simple scenes,
and is likely to fail for any vrspace world with TypeError: cyclic object value.
Furthermore, it does not save instances.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
fileName |
scene.babylon | defaults to "scene.babylon" |
- Source:
saveSceneGlb(fileName)
Save the entire scene as a GLB file.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
fileName |
scene | defaults to "scene" |
- Source:
saveSceneGltf(fileName)
Save the entire scene as GLTF: fileName.gltf, fileName.bin, textures, etc.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
fileName |
scene | defaults to "scene" |
- Source:
updateAnimation(group, from, to)
Utility method - update x,y,z animation of a mesh field.
If the animation group is playing, it is stopped first. After the update, starts to play, not looping.
Parameters:
Name | Type | Description |
---|---|---|
group |
AnimationGroup to update | |
from |
Vector3 | |
to |
Vector3 |
- Source:
updateQuaternionAnimation(group, from, to)
Utility method - update quaternion animation of a mesh field around Y axis.
Parameters:
Name | Type | Description |
---|---|---|
group |
AnimationGroup to update | |
from |
Quaternion | |
to |
Quaternion |
- Source:
updateQuaternionAnimationFromVec(group, from, to)
Utility method - update quaternion animation of a mesh field around Y axis.
Parameters:
Name | Type | Description |
---|---|---|
group |
AnimationGroup to update | |
from |
Vector3 | |
to |
Vector3 |
- Source: