Methods

createLoadingOverlay(canvasContainer, enabledopt) → {object|function|function}

Parameters:
NameTypeAttributesDescription
canvasContainerHTMLElement
enabledboolean<optional>
Returns:
  • callbacks

    Type: 
    object
  • callbacks.updateStatusText

    Type: 
    function
  • callbacks.removeOverlay

    Type: 
    function

InactivityCallback(resumeCallback)

Callback passed to setInactivityCallback.

Parameters:
NameTypeDescription
resumeCallbackfunction

Callback that takes no parameters and should be called if the inactive client should not be disconnected. Needs to be called within 30 seconds of the start of InactivityCallback otherwise client will be disconnected anyways.

Type Definitions

AABB

Axis Aligned Bounding Box

Type:
  • object
Properties
NameTypeDescription
minSDK_Vec3

Minimum point of the box.

maxSDK_Vec3

Maximum point of the box.

Example
{ min : [-1,-1,-1], max : [1, 1, 1] }

CameraControllerSettings

Settings used by camera controllers. See camera controller types. They can be updated using updateControllerSettings.

Properties
NameTypeDefaultDescription
speednumber

Speed in meters per second. Default depends on defaultCameraSpeed passed to startSession, joinSession, joinOrStartSession

sensitivitynumber0.1

Input sensitivity, can also be thought of as rotation speed

dampingnumber0.65

Damping factor used to damp, or slow down camera movement

angularDampingnumber0.65

Damping factor used to damp, or slow down camera rotation

lookAtPointSDK_Vec3

For an orbit camera controller, explicity sets the center that the camera orbits around. lookAtPoint is in global space. By default, the lookAtPoint is the clicked point. For other camera controllers, lookAtPoint does nothing

Example
{
    speed: 4.0,
    sensitivity: 0.1,
    damping: 0.65,
    angularDamping: 0.65,
    lookAtPoint: [0, 0, 0]
}

ClientInfo

Info on a client of a session. See SessionInfo.

Type:
  • object
Properties
NameTypeAttributesDescription
client_idstring<optional>

Id of the client

client_type'user' | 'guest'<optional>

Client type, either a user or a guest

user_idstring

Id of 3dverse user that created the client

usernamestring

Username of 3dverse user that created the client

ComponentFilter

Component filter used to filter in mandatory components and filter out forbidden components.

Type:
  • object
Example
{
     mandatoryComponents : ['physics_material', 'rigid_body'],
     forbiddenComponents : ['sphere_geometry']
}

ComponentsMap

Components. A collection of keys and values, where key is the component type and value is an object containing the corresponding component's attributes.

Type:
  • object
Example
{
     euid : { value : <entity uuid>, rtid : <entity rtid> },
     lineage : { parentUUID : <parent uuid>, ordinal : 0 },
     local_transform : { position : [0,0,0], orientation : [0,0,0,1], scale : [1,1,1], eulerOrientation : [0,0,0], globalEulerOrientation : [0,0,0] },
     mesh_ref : { value : <mesh uuid>, submeshIndex : 0 },
     material_ref : { value : <material uuid> }
}

Emitter

Action emitter. Occurs during an entity event.

Properties
NameTypeDescription
clientUUIDstring

Client unique identifier in the session

userUUIDstring

User unique identifier

sessionUUIDstring

Session unique identifier where the action occurs

ExternalComponentState

A string that describes the state of a component belonging to an external entity (i.e. an entity belonging to another scene).
The string can be either:

  • 'unmodified' : the component has not been modified in current scene
  • 'overridden' : the component is overridden in current scene (i.e. its value is modified in comparison to the scene it comes from)
  • 'detached' : the component has been detached in current scene
  • 'new' : the component has been added in current scene
Type:
  • string

ExternalEntityState

A string that describes the state of an external entity (i.e. an entity belonging to another scene).
The string can be either:

  • 'unmodified' : the entity has not been modified in current scene
  • 'overridden' : the entity contains at least one overridden component in current scene
  • 'deleted' : the entity is deleted in current scene
Type:
  • string

mat4

4x4 column-major matrix. The 13th, 14th and 15th elements represent the x, y and z translation components.

Type:
  • Array.<number>
Example
[1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
x, y, z, 0]

PhysicsQueryFilterFlags

Bit flags that contains filter information for physics queries like physicsRaycast. Meant to be set using SDK3DVerse.PhysicsQueryFilterFlag.

Type:
  • number
Example
// This PhysicsQueryFilterFlags specifies dynamic AND static bodies are blocking
SDK3DVerse.PhysicsQueryFilterFlag.dynamic_block | SDK3DVerse.PhysicsQueryFilterFlag.static_block

PhysicsRaycastResult

The return type of physicsRaycast. Object containing information about what the ray hit.

Type:
  • object
Properties
NameTypeDescription
blockPhysicsRayHit | null

Info about the location and physics body that blocked the ray. Can be null if no physics body blocked the ray

touchesArray.<PhysicsRayHit>

Info about the location(s) and physics bod(ies) that the ray passed before being blocked

Example
{
     block : { entity, position, normal },
     touches : [
         { entity, position, normal },
         { entity, position, normal },
     ]
}

PhysicsRayHit

Object containing information about the location that was hit by a physics ray.

Type:
  • object
Properties
NameTypeDescription
entityEntity

Entity that was hit by the ray

positionSDK_Vec3

Global space position that the ray hit

normalSDK_Vec3

Global space normal of the physics geometry at the point where the ray hit

Example
{ entity, position, normal }

SceneSettings

The scene settings of a particular type. See settings types here.

Type:
  • object
Example
// These are the settings of environment type
{
     clearColor : [0,0,0],
     ambientColorTop : [1,1,1],
     ambientColorBottom : [1,1,1]
}

SceneSettingsMap

A map of scene settings type to SceneSettings object.

Type:
  • object
Example
{
     display : { drawDebugLines : true, drawCameraFrustum : true },
     sound : { enabled : true },
     environment : { ambientColorTop : [1, 0, 1], ambientColorBottom : [0, 0, 1] }
}

SDK_Quat

Quaternion. An array of four numbers that correspond to x, y, z, w.

Type:
  • Array.<number>
Example
[0, 0, 0, 1]

SDK_Vec2

Vec2. An array of two numbers that correspond to x, y.

Type:
  • Array.<number>
Example
[0, 0]

SDK_Vec2_uint

Vec2. An array of two unsigned int that correspond to x, y.

Type:
  • Array.<uint>
Example
[0, 0]

SDK_Vec3

Vec3. An array of three numbers that correspond to x, y, z.

Type:
  • Array.<number>
Example
[0, 0, 0]

SessionConstraints

Constraints of a session that can be specified to joinOrStartSession.

Type:
  • object
Properties
NameTypeAttributesDescription
creator_user_idstring<optional>

User id of the user that created the scene

country_codestring<optional>

Country code that session will try to open in

continent_codestring<optional>

Continent code that session will try to open in

SessionInfo

Info on a session that can be retrieved by a call to findSessions.

Type:
  • object
Properties
NameTypeDescription
session_idstring

Id of the session. This id can be passed to joinSession

scene_idstring

UUID of scene that the session has opened

scene_namestring

Name of scene that the session has opened

folder_idstring

Id of the folder that the scene is located in

max_usersnumber

Maximum number of clients allowed in the session

creator_user_idstring

Id of the user that created the scene

created_atstring

Time the user created the scene

country_codestring

Country code that the session is running in

continent_codestring

Continent code that the session is running in

clientsArray.<ClientInfo>

Array of ClientInfo that contains info on all the clients in the session

Transform

Transform containing position, orientation, scale. Equivalent to the transform component.

Type:
  • object
Properties
NameTypeAttributesDescription
positionSDK_Vec3<optional>

Position.

orientationSDK_Quat<optional>

Orientation expressed as quaternion.

scaleSDK_Vec3<optional>

Scale.

eulerOrientationSDK_Vec3<optional>

Local orientation expressed as euler angles.

globalEulerOrientationSDK_Vec3<optional>

Global orientation expressed as euler angles.

Example
{ position : [0, 0. 0], orientation : [0, 0, 0, 1], scale : [1, 1, 1] }

TriggerCallback(emitterEntity, triggerEntity)

Callback function for physics trigger collider events used by:

Parameters:
NameTypeDescription
emitterEntityEntity

The entity that has triggered the collider and has entered or exited it

triggerEntityEntity

The entity that has a trigger collider and was entered or exited

Example
(emitterEntity, triggerEntity) => { console.log(emitterEntity, 'has entered or exited the trigger of', triggerEntity) }

ViewportInfo

Viewport properties used to create a Viewport.

Properties
NameTypeAttributesDefaultDescription
iduint

The identifier of the viewport

widthnumber

Viewport width ratio (from 0.0 to 1.0) within the display area. See setResolution

heightnumber

Viewport height ratio (from 0.0 to 1.0) within the display area. See setResolution

leftnumber

Viewport left border position ratio (from 0.0 to 1.0) within the display area

topnumber

Viewport top border position ratio (from 0.0 to 1.0) within the display area

cameraEntity<optional>
null

An already existing camera entity which will be the camera associated to the created viewport. Otherwise a default camera is created. If specified, then defaultControllerType and onCameraCreation are ignored.

defaultControllerTypeint<optional>
SDK3DVerse.cameraControllerType.editor

The type of controller associated to the default camera. The controller will move camera according to client inputs. Can be omitted if developer wants to implement their own controller, or if no controller is wanted. See SDK3DVerse.cameraControllerType

onCameraCreationfunction<optional>

A function called when the default camera entity of the viewport has been created. The created camera Entity is passed to the function. Please note this function may be called twice for the same viewport and the same camera entity

Examples
// The viewport created from these properties will cover the entire canvas, and a default camera
// with an orbit controller will be created and associated to the viewport.
{
     id: 0,
     width: 1.0,
     height: 1.0,
     left: 0.0,
     top: 0.0,
     defaultControllerType: SDK3DVerse.cameraControllerType.orbit,
     onCameraCreation: (cameraEntity) => { console.log(cameraEntity.getName(), "was created") }
}
// The viewport created from these properties will cover the entire canvas, and the camera
// associated to the viewport will be the cameraEntity passed. No controller is given to the
// camera, the developer may implement one themselves if needed.
{
     id: 0,
     width: 1.0,
     height: 1.0,
     left: 0.0,
     top: 0.0,
     camera: cameraEntity,
}

ViewportMouseEventListener(viewport, event)

Parameters:
NameTypeDescription
viewportViewport

The Viewport object

eventMouseEvent

The MouseEvent object

Events

onAssetsLoadedChanged

Event emitted when the assets loading state changes. The first event emitted with a true value for areAssetsLoaded after a start of the session means all assets are loaded, and consequently all entities of the scene graph are loaded.

Properties
NameTypeDescription
areAssetsLoadedboolean

True if all assets has been loaded. False if some assets are loading.

Example
SDK3DVerse.notifier.on('onAssetsLoadedChanged', (areAssetsLoaded) => {
     console.log('Have assets finished loading?', areAssetsLoaded);
});

onConnectionClosed

Event emitted when the client has disconnected from the session.

Client can be disconnected from the session if the client is idle for too long (see setInactivityCallback for more details), or after an explicit call to disconnectFromSession.

Example
SDK3DVerse.notifier.on('onConnectionClosed', () => {
     console.log('Client disconnected from session.');
});

onEntitiesDeleted

Event emitted when one or more entities have been deleted.

Properties
NameTypeDescription
deletedEntityRTIDsArray.<string>

An array of deleted entity rtids. See example below to convert them to Entity

emitterEmitter

Client emitting the event

Example
SDK3DVerse.notifier.on('onEntitiesDeleted', (deletedEntityRTIDs) => {
     const deletedEntities = deletedEntityRTIDs.map((rtid) => SDK3DVerse.engineAPI.getEntity(rtid));
});

onEntitiesUpdated

Event emitted when entities have been modified or, i.e. their components have been modified. Entity.attachComponent, Entity.setComponent, Entity.setGlobalTransform, and Entity.lookAt are functions that emit this event.

Note: If a component is detached with Entity.detachComponent this event is not fired.

Properties
NameTypeDescription
entitiesArray.<Entity>

Array of updated entities

triggeredBystring

The function or module that triggered this event

euidToUpdatedComponentTypesobject

An object associating entity UUID (or EUID) to its modified component types

updatedParentsArray.<Entity>

Array of parents of updated entities. Empty array unless event emitted by saveEntities

emitterEmitter | null

Client emitting the event. null unless event emitted by saveEntities

Example
SDK3DVerse.notifier.on('onEntitiesUpdated', (entities) => {});

onEntityCreated

Event emitted when entity has been created.

Properties
NameTypeDescription
entityEntity

Entity that was created

emitterEmitter | null

Client emitting the event. Null if the client listening to this event initiated the creation

Example
SDK3DVerse.notifier.on('onEntityCreated', (entity) => { console.log(entity.getName(), 'was created!') });

onEntityReparent

Event emitted when entity has been reparented.

Properties
NameTypeDescription
entityEntity

The re-parented entity

prevParentEntity

Previous parent

newParentEntity

New parent

emitterEmitter

Client emitting the event

Example
SDK3DVerse.notifier.on('onEntityReparent', (entity, prevParent, newParent) => {});

onEntitySelectionChanged

Event emitted when entity selection has changed.

Properties
NameTypeDescription
selectedEntitiesArray.<Entity>

Entities that were selected

unselectedEntitiesArray.<Entity>

Entities that were unselected

triggeredBystring

If entity selection was triggered by castScreenSpaceRay then this will be set to 'picking', otherwise this will be the triggeredBy param passed to selectEntities or selectEntity.

Example
SDK3DVerse.notifier.on('onEntitySelectionChanged', (selectedEntities, unselectedEntities) =>
{
     console.log('Selected', selectedEntities);
     console.log('Unselected', unselectedEntities);
});

onEntityVisibilityChanged

Event emitted when entity visibility has changed.

Properties
NameTypeDescription
entityRTIDstring

Entity rtid

Example
SDK3DVerse.notifier.on('OnEntityVisibilityChanged', (entityRTID) => {
    const entity = SDK3DVerse.engineAPI.getEntity(entityRTID);
});

onFramePostRender

Event emitted after a frame is rendered.

Example
let lastTime = performance.now();
function update()
{
    const deltaTime = performance.now() - lastTime;
    lastTime = performance.now();
}
SDK3DVerse.notifier.on('onFramePostRender', update);

onFramePreRender

Event emitted before a frame is rendered.

Example
let lastTime = performance.now();
function update()
{
    const deltaTime = performance.now() - lastTime;
    lastTime = performance.now();
}
SDK3DVerse.notifier.on('onFramePreRender', update);

onSettingsUpdated

Event emitted when scene settings have been updated.

Properties
NameTypeDescription
sceneSettingTypeToValueobject

Each property of this object corresponds to an updated scene setting

Example
SDK3DVerse.notifier.on('onSettingsUpdated', (sceneSettingTypeToValue) => {});