Class: WorldEditor

WorldEditor(world, fileInput)

World editor can be constructed after the world has worldManager attached. Allows for searching through 300,000+ free objects on sketchfab, adding them to the scene, and manipulating own objects. Works on PC, VR devices and mobiles, including mobile VR+gamepad. Or at least it's supposed to;)

Constructor

new WorldEditor(world, fileInput)

Parameters:
Name Type Description
world mandatory world to edit
fileInput optional html file input component, required for load
Source:
Throws:
when world doesn't have WorldManager associated

Classes

WorldEditor

Methods

alignObject(obj)

Align an object using pointer. Casts a ray down, and puts the object on whatever is below it.
Parameters:
Name Type Description
obj selected scene object
Source:

clearForm()

Disposes of search form and displays HUD buttons
Source:

copyObject(obj)

Copy an object: sends a Add command to the server, actual copy (instance) is created when the server responds.
Parameters:
Name Type Description
obj scene object to copy.
Source:

createButtons()

Creates HUD buttons, called from constructor
Source:

createSharedObject(mesh, properties)

Create a shared object, i.e. publish a mesh to the server. The object is marked with a transient property editing set to current user id.
Parameters:
Name Type Description
mesh the object to publish
properties optional properties
Source:

displayButtons(show, …except)

Display or hide all buttons, except.
Parameters:
Name Type Attributes Description
show true or false
except <repeatable>
buttons to skip
Source:

dispose()

Dispose of everything
Source:

doFetch()

Execute Sketchfab search call, and process response. Adds thumbnails of all search results as buttons to the search panel.
Source:

doSearch()

Search form callback, prepares parameters, calls this.search, and clears the form
Source:

download(result)

Search panel selection callback, download selected item. Performs REST API call to VRSpace sketchfab endpoint. Should this call fail with 401 Unauthorized, executes this.sketchfabLogin(). Otherwise, VRSpace server downloads the model from sketchfab, and returns the url, it's added to the scene by calling this.createSharedObject().
Parameters:
Name Type Description
result search result object
Source:

drop(obj)

Drop the object. Cleans change listener, invisible object used track the position, and sends one final position to the server.
Parameters:
Name Type Description
obj VRObject to drop
Source:

dropObject()

Drop the object currently being carried, if any, and display all buttons.
Source:

editObject(obj, editing)

Publishes beggining/end of object manipulation. Sets a transient property of the shared object, editing, to own id, or null.
Parameters:
Name Type Description
obj VRObject
editing true/false
Source:

endManipulation()

End object manipulation: currently carried object is scaled and rotated depending on position and rotation XR controllers. Sends scaling and rotation data to the server, actual change is performed once the server responds.
Source:

handleSqueeze(value, side)

Triggered on squeeze button pres/release. One squeeze pressed activates move button, like grabbing the object under the pointer. Release drops it. Two squeeze buttons activate scaling and rotation. Spread more, scale more, closer is smaller.
Parameters:
Name Type Description
value 0-1
side left or right
Source:

installClickHandler()

Called by constructor, installs onPointerObservable event handler to the scene, executed when something is clicked on (BABYLON.PointerEventTypes.POINTERDOWN event). The handler first determines root object, and fetches the attached VRObject, then executes this.manipulateObject passing it this.activeButton.customAction. Thus, routes the event to appropriate handler method.
Source:

isSelectableMesh(mesh)

XR selection support
Parameters:
Name Type Description
mesh
Source:
Returns:
true if root node of the mesh has VRObject associated

load()

Load saved scene, requires file input html element
Source:

loadingFailed()

WorldManager error callback, installed by constructor.
Source:

makeAButton(text, imageUrl, action)

Creates a HUD button. Adds customAction field to the button, that is executed if a scene object is clicked on.
Parameters:
Name Type Description
text button text
imageUrl image
action callback executed upon clicking on an object in the scene
Source:

makeUI()

Creates the search panel, called from constructor
Source:

manipulateObject(obj, action)

Called when an object is selected, calls the appropriate action e.g. take, resize etc
Parameters:
Name Type Description
obj root scene object
action customAction of whatever button is currently active
Source:

objectLoaded()

WorldManager callback, installed by constructor. Executed every time a shared object has loaded into the scene. If it is own object, rescales it and calls this.takeObject(). This is what happens when selecting a sketchfab object to load.
Source:

pick(obj, direction, length)

Casts a ray from the center of an object into given direction to hit another VRObject in the scene. Used to stack (align) objects one on top of another.
Parameters:
Name Type Default Description
obj object to cast a ray from
direction Vector3
length 100 vector length, default 100
Source:
Returns:
PickingInfo

publish(objects)

Publish all loaded object to the server
Parameters:
Name Type Description
objects VRObject array
Source:

removeObject(obj)

Delete a shared object from the scene.
Parameters:
Name Type Description
obj scene object to delete
Source:

resizeObject(obj)

Resize an object using pointer. Drag up or down to scale up or down, drag more to resize more.
Parameters:
Name Type Description
obj a scene object to resize
Source:

rotateObject(obj)

Rotate an object using pointer. Drag left-right or up-down to rotate, drag more to rotate more.
Parameters:
Name Type Description
obj scene object
Source:

save()

Save current scene: dumps everything using AssetLoader.dump(), and calls VRSPACEUI.saveFile().
Source:
Sketchfab API search call.
Parameters:
Name Type Description
text search string
args search paramters object
Source:

searchForm()

Creates the search form, or destroys if it exists. Search form has virtual keyboard attached if created in XR.
Source:

sendPos(obj)

Send position of the object to the server. Executed by WorldManager after own changes have been published.
Parameters:
Name Type Description
obj a VRObject to update
Source:

setFileInput(fileInput)

Implements load by adding change listener to file input html element. Called from constructor.
Parameters:
Name Type Description
fileInput html file input element
Source:

sketchfabLogin()

Rest API call to VRSpace sketchfab endpoint. If login is required, this opens the login page in the same browser window.
Source:

startManipulation(side)

Start manipulation (scaling,rotating) of currently carried object using XR controllers. Marks current positions and rotations of controllers.
Parameters:
Name Type Description
side left or right
Source:

take(vrObject, position)

Take an object, if not already carrying one. Creates an invisible object, and binds it to current camera, or a VR controller. Invisible object is used to track the position, and actual object position is updated when the server responds. Position of the object is published only after camera position has been published, through WorldManager.addMyChangeListener().
Parameters:
Name Type Description
vrObject VRObject to take
position optional, current object position, default is 2 meters front of the camera
Source:

takeObject(vrObject, position)

Activate this.moveButton and call take()
Parameters:
Name Type Description
vrObject VRObject to take
position current object position
Source:

upright(obj)

Puts an object into original up-down position.
Parameters:
Name Type Description
obj a scene object
Source: