Methods
createLoadingOverlay(canvasContainer, enabledopt) → {object|function|function}
Name | Type | Attributes | Description |
---|---|---|---|
canvasContainer | HTMLElement | ||
enabled | boolean | <optional> |
callbacks
- Type:
- object
callbacks.updateStatusText
- Type:
- function
callbacks.removeOverlay
- Type:
- function
InactivityCallback(resumeCallback)
Callback passed to setInactivityCallback.
Name | Type | Description |
---|---|---|
resumeCallback | function | 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
- object
{ min : [-1,-1,-1], max : [1, 1, 1] }
CameraControllerSettings
Settings used by camera controllers. See camera controller types. They can be updated using updateControllerSettings.
Name | Type | Default | Description |
---|---|---|---|
speed | number | Speed in meters per second. Default depends on | |
sensitivity | number | 0.1 | Input sensitivity, can also be thought of as rotation speed |
damping | number | 0.65 | Damping factor used to damp, or slow down camera movement |
angularDamping | number | 0.65 | Damping factor used to damp, or slow down camera rotation |
lookAtPoint | SDK_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 |
{
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.
- object
Name | Type | Attributes | Description |
---|---|---|---|
client_id | string | <optional> | Id of the client |
client_type | 'user' | | <optional> | Client type, either a user or a guest |
user_id | string | Id of 3dverse user that created the client | |
username | string | Username of 3dverse user that created the client |
ComponentFilter
Component filter used to filter in mandatory components and filter out forbidden components.
- object
{
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.
- object
- See
{
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.
Name | Type | Description |
---|---|---|
clientUUID | string | Client unique identifier in the session |
userUUID | string | User unique identifier |
sessionUUID | string | 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
- 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
- string
mat4
4x4 column-major matrix. The 13th, 14th and 15th elements represent the x, y and z translation components.
- Array.<number>
[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.
- number
// 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.
- object
Name | Type | Description |
---|---|---|
block | PhysicsRayHit | | Info about the location and physics body that blocked the ray. Can be null if no physics body blocked the ray |
touches | Array.<PhysicsRayHit> | Info about the location(s) and physics bod(ies) that the ray passed before being blocked |
{
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.
- object
Name | Type | Description |
---|---|---|
entity | Entity | Entity that was hit by the ray |
position | SDK_Vec3 | Global space position that the ray hit |
normal | SDK_Vec3 | Global space normal of the physics geometry at the point where the ray hit |
{ entity, position, normal }
SceneSettings
The scene settings of a particular type. See settings types here.
- object
// 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.
- object
{
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.
- Array.<number>
[0, 0, 0, 1]
SDK_Vec2
Vec2. An array of two numbers that correspond to x, y.
- Array.<number>
[0, 0]
SDK_Vec2_uint
Vec2. An array of two unsigned int that correspond to x, y.
- Array.<uint>
[0, 0]
SDK_Vec3
Vec3. An array of three numbers that correspond to x, y, z.
- Array.<number>
[0, 0, 0]
SessionConstraints
Constraints of a session that can be specified to joinOrStartSession.
- object
Name | Type | Attributes | Description |
---|---|---|---|
creator_user_id | string | <optional> | User id of the user that created the scene |
country_code | string | <optional> | Country code that session will try to open in |
continent_code | string | <optional> | Continent code that session will try to open in |
SessionInfo
Info on a session that can be retrieved by a call to findSessions.
- object
Name | Type | Description |
---|---|---|
session_id | string | Id of the session. This id can be passed to joinSession |
scene_id | string | UUID of scene that the session has opened |
scene_name | string | Name of scene that the session has opened |
folder_id | string | Id of the folder that the scene is located in |
max_users | number | Maximum number of clients allowed in the session |
creator_user_id | string | Id of the user that created the scene |
created_at | string | Time the user created the scene |
country_code | string | Country code that the session is running in |
continent_code | string | Continent code that the session is running in |
clients | Array.<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.
- object
Name | Type | Attributes | Description |
---|---|---|---|
position | SDK_Vec3 | <optional> | Position. |
orientation | SDK_Quat | <optional> | Orientation expressed as quaternion. |
scale | SDK_Vec3 | <optional> | Scale. |
eulerOrientation | SDK_Vec3 | <optional> | Local orientation expressed as euler angles. |
globalEulerOrientation | SDK_Vec3 | <optional> | Global orientation expressed as euler angles. |
{ 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:
(emitterEntity, triggerEntity) => { console.log(emitterEntity, 'has entered or exited the trigger of', triggerEntity) }
ViewportInfo
Viewport properties used to create a Viewport.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
id | uint | The identifier of the viewport | ||
width | number | Viewport width ratio (from 0.0 to 1.0) within the display area. See setResolution | ||
height | number | Viewport height ratio (from 0.0 to 1.0) within the display area. See setResolution | ||
left | number | Viewport left border position ratio (from 0.0 to 1.0) within the display area | ||
top | number | Viewport top border position ratio (from 0.0 to 1.0) within the display area | ||
camera | Entity | <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 | int | <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 |
onCameraCreation | function | <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 |
// 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)
Name | Type | Description |
---|---|---|
viewport | Viewport | The Viewport object |
event | MouseEvent | 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.
Name | Type | Description |
---|---|---|
areAssetsLoaded | boolean | True if all assets has been loaded. False if some assets are loading. |
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.
SDK3DVerse.notifier.on('onConnectionClosed', () => {
console.log('Client disconnected from session.');
});
onEntitiesDeleted
Event emitted when one or more entities have been deleted.
Name | Type | Description |
---|---|---|
deletedEntityRTIDs | Array.<string> | An array of deleted entity rtids. See example below to convert them to Entity |
emitter | Emitter | Client emitting the event |
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.
Name | Type | Description |
---|---|---|
entities | Array.<Entity> | Array of updated entities |
triggeredBy | string | The function or module that triggered this event |
euidToUpdatedComponentTypes | object | An object associating entity UUID (or EUID) to its modified component types |
updatedParents | Array.<Entity> | Array of parents of updated entities. Empty array unless event emitted by saveEntities |
emitter | Emitter | | Client emitting the event. null unless event emitted by saveEntities |
SDK3DVerse.notifier.on('onEntitiesUpdated', (entities) => {});
onEntityCreated
Event emitted when entity has been created.
Name | Type | Description |
---|---|---|
entity | Entity | Entity that was created |
emitter | Emitter | | Client emitting the event. Null if the client listening to this event initiated the creation |
SDK3DVerse.notifier.on('onEntityCreated', (entity) => { console.log(entity.getName(), 'was created!') });
onEntityReparent
Event emitted when entity has been reparented.
Name | Type | Description |
---|---|---|
entity | Entity | The re-parented entity |
prevParent | Entity | Previous parent |
newParent | Entity | New parent |
emitter | Emitter | Client emitting the event |
SDK3DVerse.notifier.on('onEntityReparent', (entity, prevParent, newParent) => {});
onEntitySelectionChanged
Event emitted when entity selection has changed.
Name | Type | Description |
---|---|---|
selectedEntities | Array.<Entity> | Entities that were selected |
unselectedEntities | Array.<Entity> | Entities that were unselected |
triggeredBy | string | If entity selection was triggered by castScreenSpaceRay then this will be set to 'picking', otherwise this will be the |
SDK3DVerse.notifier.on('onEntitySelectionChanged', (selectedEntities, unselectedEntities) =>
{
console.log('Selected', selectedEntities);
console.log('Unselected', unselectedEntities);
});
onEntityVisibilityChanged
Event emitted when entity visibility has changed.
Name | Type | Description |
---|---|---|
entityRTID | string | Entity rtid |
SDK3DVerse.notifier.on('OnEntityVisibilityChanged', (entityRTID) => {
const entity = SDK3DVerse.engineAPI.getEntity(entityRTID);
});
onFramePostRender
Event emitted after a frame is rendered.
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.
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.
Name | Type | Description |
---|---|---|
sceneSettingTypeToValue | object | Each property of this object corresponds to an updated scene setting |
SDK3DVerse.notifier.on('onSettingsUpdated', (sceneSettingTypeToValue) => {});