High Fidelity API Reference
Tools Used: JavaScript, JSDoc, GitHub Pages, Markdown, HTML, CSS
Entities
The Entities API provides facilities to create and interact with entities. Entities are 2D or 3D objects displayed in-world. Depending on their EntityHostType, they may persist in the domain as "domain" entities, travel to different domains with a user as "avatar" entities, or be visible only to an individual user as "local" entities (a.k.a. "overlays").
Note: For Interface, avatar, and client entity scripts, the entities available to scripts are those that Interface has displayed and so knows about. For assignment client scripts, the entities available are those that are "seen" by the EntityViewer. For entity server scripts, all entities are available.
Entity Methods
Some of the API's signals correspond to entity methods that are called, if present, in the entity being interacted with. The client or server entity script must expose them as a property. However, unlike Entities.callEntityMethod, server entity scripts do not need to list them in an remotelyCallable property. The entity methods are called with parameters per their corresponding signal.
| Method Name | Corresponding Signal |
|---|---|
| |
| |
| |
| |
|
Supported Script Types: Interface Scripts • Client Entity Scripts • Avatar Scripts • Server Entity Scripts • Assignment Client Scripts
Properties
| Name | Type | Summary |
|---|---|---|
| keyboardFocusEntity | The Web entity that has keyboard focus. If no Web entity has keyboard focus, returns |
Methods
| Name | Return Value | Summary |
|---|---|---|
Adds an action to an entity. An action is registered with the physics engine and is applied every physics simulation step. | ||
Adds a new domain, avatar, or local entity. | ||
boolean | Appends a point to a Line entity. Deprecated: This function is deprecated and will be removed. Use PolyLine entities instead. | |
None | Calls a method in a specific user's client entity script from a server entity script. | |
None | Calls a method in a client entity script from an Interface, avatar, or client entity script, or calls a method in a server entity script from a server entity script. | |
None | Calls a method in a server entity script from an Interface, avatar, or client entity script. | |
boolean | Checks whether or not the script can get and set the | |
Creates a clone of an entity. | ||
boolean | Deletes an action from an entity. | |
None | Deletes an entity. | |
Edits an entity, changing one or more of its property values. | ||
None | Sends a message to a Web entity's HTML page. | |
Finds the domain or avatar entity with a position closest to a specified point and within a specified radius. | ||
Gets the arguments of an action. | ||
Array.<Uuid> | Gets the IDs of the actions that are associated with an entity. | |
object | Gets an entity's script object. | |
Gets an entity's property values. | ||
Gets an entity's type. | ||
boolean | Reloads an entity's server entity script such that the latest version re-downloaded. | |
None | Emits a clickDownOnEntity event. | |
None | Emits a clickReleaseOnEntity event. | |
boolean | Checks whether servers exist for the client to send entity packets to, i.e., whether you are connected to a domain and its entity server is working. | |
None | Sets the maximum number of entity packets that the client can send per second. | |
Calculates the size of some text in a Text entity. The entity need not be set visible. | ||
boolean | Updates an entity action. |
Signals
| Name | Summary |
|---|---|
Triggered when an entity is added to Interface's local in-memory tree of entities it knows about. This may occur when entities are loaded upon visiting a domain, when the user rotates their view so that more entities become visible, and when any type of entity is created (e.g., by addEntity). | |
Triggered when your ability to get and set private user data changes. | |
Triggered when you disconnect from a domain, at which time Interface's local in-memory tree of entities that it knows about is cleared. | |
Triggered when a mouse button is clicked while the mouse cursor is on an entity. Note: Not triggered by controllers. | |
Triggered when a mouse button is released after clicking on an entity, even if the mouse cursor has moved off the entity. Note: Not triggered by controllers. | |
Triggered on the client that is the physics simulation owner during the collision of two entities. Note: Isn't triggered for a collision with an avatar. | |
Triggered when an entity is deleted. | |
Triggered when an avatar enters an entity, but only if the entity has an entity method exposed for this event. | |
Triggered when an avatar leaves an entity, but only if the entity has an entity method exposed for this event. | |
Triggered when the script starts for a user. See also, Script.entityScriptPreloadFinished. | |
Triggered when the script terminates for a user. | |
Triggered when a script in a Web entity's HTML sends an event over the entity's HTML event bridge. |
Type Definitions
ActionArgumentsActionArguments Type: object | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Different entity action types have different arguments: some common to all actions (listed in the table) and some specific to each ActionType (linked to below). Properties
|
ActionArguments-OffsetActionArguments-Offset Type: object | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
The Properties
|
ActionArguments-SliderActionArguments-Slider Type: object | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
The Properties
|
ActionArguments-TravelOrientedActionArguments-TravelOriented Type: object | |||||||||
|---|---|---|---|---|---|---|---|---|---|
The Properties
|
ActionTypeActionType Type: string | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
An entity action may be one of the following types: Properties
|
AmbientLightAmbientLight Type: object | ||||||
|---|---|---|---|---|---|---|
Ambient light is defined by its intensity. Properties
|
EntityHostTypeEntityHostType Type: string | ||||||||
|---|---|---|---|---|---|---|---|---|
How an entity is hosted and sent to others for display. Properties
|
EntityPropertiesEntityProperties Type: object | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Every EntityType will have these properties, in addition to those properties specific to the type. Properties
|
EntityProperties-LightEntityProperties-Light Type: object | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
The Properties
Example: Create a spotlight pointing at the ground |
EntityProperties-LineEntityProperties-Line Type: object |
|---|
The Deprecated: Use PolyLine entities instead. |
EntityProperties-ModelEntityProperties-Model Type: object | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
The Properties
|
EntityProperties-PolyLineEntityProperties-PolyLine Type: object | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
The Properties
Example: Draw a textured "V" |
EntityProperties-ShapeEntityProperties-Shape Type: object | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
The Properties
Example: Create a cylinder |
EntityProperties-TextEntityProperties-Text Type: object | |||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
The Properties
Example: Create a text entity |
EntityProperties-WebEntityProperties-Web Type: object | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
The Properties
Example: Create a Web entity displaying at 1920 x 1080 resolution |
EntityPropertyInfoEntityPropertyInfo Type: object | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
Information about an entity property. Properties
|
EntityTypeEntityType Type: string | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
An entity may be one of the following types: Properties
|
PhysicsMotionTypePhysicsMotionType Type: string | ||||||||
|---|---|---|---|---|---|---|---|---|
Properties
|
RenderInfoRenderInfo Type: object | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Information on how an entity is rendered. Properties are only filled in for Properties
|
RenderLayerRenderLayer Type: string | ||||||||
|---|---|---|---|---|---|---|---|---|
A layer in which an entity may be rendered. Properties
|
ShapeShape Type: string | |||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A Properties
|
TextEffectTextEffect Type: string | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|
A Text entity may use one of the following effects: Properties
|
Method Details
addAction(static) addAction( actionType, entityID, arguments ) → { Uuid } Returns: The ID of the action if successfully added, otherwise | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
Adds an action to an entity. An action is registered with the physics engine and is applied every physics simulation step. Any entity may have more than one action associated with it, but only as many as will fit in an entity's Parameters
Example: Constrain a cube to move along a vertical line |
addEntity(static) addEntity( properties, entityHostTypeopt ) → { Uuid } Returns: The ID of the entity if successfully created, otherwise Uuid.NULL. | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Adds a new domain, avatar, or local entity. Parameters
Example: Create a box domain entity in front of your avatar |
appendPoint(static) appendPoint( entityID, point ) → { boolean } Returns: |
|---|
Appends a point to a Line entity. Deprecated: This function is deprecated and will be removed. Use PolyLine entities instead. |
callEntityClientMethod(static) callEntityClientMethod( clientSessionID, entityID, method, parametersopt ) | |||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Calls a method in a specific user's client entity script from a server entity script. The entity script method must be exposed as a property in the target client entity script. Additionally, the client entity script must include the method's name in an exposed property called Parameters
Example: Call a method in a client entity script from a server entity script |
callEntityMethod(static) callEntityMethod( entityID, method, parametersopt ) | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Calls a method in a client entity script from an Interface, avatar, or client entity script, or calls a method in a server entity script from a server entity script. The entity script method must be exposed as a property in the target entity script. Additionally, if calling a server entity script, the server entity script must include the method's name in an exposed property called Parameters
Example: Call a method in a client entity script from an Interface script |
callEntityServerMethod(static) callEntityServerMethod( entityID, method, parametersopt ) | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Calls a method in a server entity script from an Interface, avatar, or client entity script. The server entity script method must be exposed as a property in the target server entity script. Additionally, the server entity script must include the method's name in an exposed property called Parameters
Example: Call a method in a server entity script from an Interface script |
canGetAndSetPrivateUserData(static) canGetAndSetPrivateUserData( ) → { boolean } Returns: |
|---|
Checks whether or not the script can get and set the |
canReplaceContent(static) canReplaceContent( ) → { boolean } Returns: |
|---|
Checks whether or not the script can replace the domain's content set. |
canWriteAssets(static) canWriteAssets( ) → { boolean } Returns: |
|---|
Checks whether or not the script can make changes to the asset server's assets. |
cloneEntity(static) cloneEntity( entityID ) → { Uuid } Returns: The ID of the new entity if successfully cloned, otherwise Uuid.NULL. | ||||||
|---|---|---|---|---|---|---|
Creates a clone of an entity. The clone has the same properties as the original except that: it has a modified Domain entities must have their Avatar entities must have their Parameters
|
deleteAction(static) deleteAction( entityID, actionID ) → { boolean } Returns: | |||||||||
|---|---|---|---|---|---|---|---|---|---|
Deletes an action from an entity. Parameters
|
deleteEntity(static) deleteEntity( entityID ) | ||||||
|---|---|---|---|---|---|---|
Deletes an entity. Parameters
Example: Delete an entity a few seconds after creating it |
editEntity(static) editEntity( entityID, properties ) → { Uuid } Returns: The ID of the entity if the edit was successful, otherwise | |||||||||
|---|---|---|---|---|---|---|---|---|---|
Edits an entity, changing one or more of its property values. Parameters
Example: Change the color of an entity |
emitScriptEvent(static) emitScriptEvent( entityID, message ) | |||||||||
|---|---|---|---|---|---|---|---|---|---|
Sends a message to a Web entity's HTML page. To receive the message, the web page's script must connect to the Use Entities.webEventReceived to receive messages from the Web entity's HTML page. Alternatively, use Entities.getEntityObject to exchange messages over a Web entity's HTML event bridge. Parameters
Example: Exchange messages with a Web entity |
findClosestEntity(static) findClosestEntity( center, radius ) → { Uuid } Returns: The ID of the entity that is closest to the | |||||||||
|---|---|---|---|---|---|---|---|---|---|
Finds the domain or avatar entity with a position closest to a specified point and within a specified radius. Parameters
Example: Find the closest entity within 10m of your avatar |
findEntities(static) findEntities( center, radius ) → { Array.<Uuid> } Returns: An array of entity IDs that intersect the search sphere. The array is empty if no entities could be found. | |||||||||
|---|---|---|---|---|---|---|---|---|---|
Finds all domain and avatar entities that intersect a sphere. Parameters
Example: Report how many entities are within 10m of your avatar |
getActionArguments(static) getActionArguments( entityID, actionID ) → { Entities.ActionArguments } Returns: The arguments of the action if found, otherwise an empty object. | |||||||||
|---|---|---|---|---|---|---|---|---|---|
Gets the arguments of an action. Parameters
|
getActionIDs(static) getActionIDs( entityID ) → { Array.<Uuid> } Returns: The action IDs if any are found, otherwise an empty array. | ||||||
|---|---|---|---|---|---|---|
Gets the IDs of the actions that are associated with an entity. Parameters
|
getEntityObject(static) getEntityObject( id ) → { object } Returns: The script object for the entity if found. | ||||||
|---|---|---|---|---|---|---|
Gets an entity's script object. In particular, this is useful for accessing a Web entity's HTML To send a message from an Interface script to a Web entity over its event bridge: To receive a message from a Web entity over its event bridge in an Interface script: Alternatively, use Entities.emitScriptEvent and Entities.webEventReceived to exchange messages with a Web entity over its event bridge. Parameters
Example: Exchange messages with a Web entity |
getEntityProperties(static) getEntityProperties( entityID, desiredPropertiesopt ) → Returns: The specified properties of the entity if the entity can be found, otherwise an empty object. If no properties are specified, then all properties are returned. | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Gets an entity's property values. Parameters
Example: Report the color of a new box entity |
getEntityType(static) getEntityType( id ) → { Entities.EntityType } Returns: The type of the entity. | ||||||
|---|---|---|---|---|---|---|
Gets an entity's type. Parameters
|
reloadServerScripts(static) reloadServerScripts( entityID ) → { boolean } Returns: | ||||||
|---|---|---|---|---|---|---|
Reloads an entity's server entity script such that the latest version re-downloaded. Parameters
|
sendClickDownOnEntity(static) sendClickDownOnEntity( entityID, event ) | |||||||||
|---|---|---|---|---|---|---|---|---|---|
Emits a clickDownOnEntity event. Parameters
|
sendClickReleaseOnEntity(static) sendClickReleaseOnEntity( entityID, event ) | |||||||||
|---|---|---|---|---|---|---|---|---|---|
Emits a clickReleaseOnEntity event. Parameters
|
serversExist(static) serversExist( ) → { boolean } Returns: |
|---|
Checks whether servers exist for the client to send entity packets to, i.e., whether you are connected to a domain and its entity server is working. |
setPacketsPerSecond(static) setPacketsPerSecond( packetsPerSecond ) | ||||||
|---|---|---|---|---|---|---|
Sets the maximum number of entity packets that the client can send per second. Parameters
|
textSize(static) textSize( id, text ) → { Size } Returns: The size of the | |||||||||
|---|---|---|---|---|---|---|---|---|---|
Calculates the size of some text in a Text entity. The entity need not be set visible. Note: The size of text in a Text entity cannot be calculated immediately after the entity is created; a short delay is required while the entity finishes being created. Parameters
|
updateAction(static) updateAction( entityID, actionID, arguments ) → { boolean } Returns: | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
Updates an entity action. Parameters
|
Signal Details
addingEntityaddingEntity( entityID ) Returns: Signal | ||||||
|---|---|---|---|---|---|---|
Triggered when an entity is added to Interface's local in-memory tree of entities it knows about. This may occur when entities are loaded upon visiting a domain, when the user rotates their view so that more entities become visible, and when any type of entity is created (e.g., by addEntity). Parameters
Example: Report when an entity is added |
canGetAndSetPrivateUserDataChangedcanGetAndSetPrivateUserDataChanged( canGetAndSetPrivateUserData ) Returns: Signal | ||||||
|---|---|---|---|---|---|---|
Triggered when your ability to get and set private user data changes. Parameters
|
clearingEntitiesclearingEntities( ) Returns: Signal |
|---|
Triggered when you disconnect from a domain, at which time Interface's local in-memory tree of entities that it knows about is cleared. Example: Report when Interfaces's entity tree is cleared |
clickDownOnEntityclickDownOnEntity( entityID, event ) Returns: Signal | |||||||||
|---|---|---|---|---|---|---|---|---|---|
Triggered when a mouse button is clicked while the mouse cursor is on an entity. Note: Not triggered by controllers. Parameters
Example: Compare clickDownOnEntity signal and entity script method |
clickReleaseOnEntityclickReleaseOnEntity( entityID, event ) Returns: Signal | |||||||||
|---|---|---|---|---|---|---|---|---|---|
Triggered when a mouse button is released after clicking on an entity, even if the mouse cursor has moved off the entity. Note: Not triggered by controllers. Parameters
|
collisionWithEntitycollisionWithEntity( idA, idB, collision ) Returns: Signal | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
Triggered on the client that is the physics simulation owner during the collision of two entities. Note: Isn't triggered for a collision with an avatar. See also, Entity Methods and Script.addEventHandler. Parameters
Example: Change the color of an entity when it collides with another entity |
deletingEntitydeletingEntity( entityID ) Returns: Signal | ||||||
|---|---|---|---|---|---|---|
Triggered when an entity is deleted. Parameters
Example: Report when an entity is deleted |
enterEntityenterEntity( entityID ) Returns: Signal | ||||||
|---|---|---|---|---|---|---|
Triggered when an avatar enters an entity, but only if the entity has an entity method exposed for this event. See also, Entity Methods and Script.addEventHandler. Parameters
|
leaveEntityleaveEntity( entityID ) Returns: Signal | ||||||
|---|---|---|---|---|---|---|
Triggered when an avatar leaves an entity, but only if the entity has an entity method exposed for this event. Parameters
|
preloadpreload( entityID ) Returns: Signal | ||||||
|---|---|---|---|---|---|---|
Triggered when the script starts for a user. See also, Script.entityScriptPreloadFinished. Note: Can only be connected to via Supported Script Types: Client Entity Scripts • Server Entity Scripts Parameters
Example: Get the ID of the entity that a client entity script is running in |
unloadunload( entityID ) Returns: Signal | ||||||
|---|---|---|---|---|---|---|
Triggered when the script terminates for a user. Note: Can only be connected to via Supported Script Types: Client Entity Scripts • Server Entity Scripts Parameters
|
webEventReceivedwebEventReceived( entityID, message ) Returns: Signal | |||||||||
|---|---|---|---|---|---|---|---|---|---|
Triggered when a script in a Web entity's HTML sends an event over the entity's HTML event bridge. The HTML web page can send a message by calling Use Entities.emitScriptEvent to send messages to the Web entity's HTML page. Alternatively, use Entities.getEntityObject to exchange messages over a Web entity's HTML event bridge. Parameters
|