Global

Members

(constant) _actions

(constant) ADD_ACTION_OPTIONS

The option used when adding script actions to the state machine.

(constant) DracoModuleLoader

Load the draco module to decode draco format. It may download the
webasm version or the asm.js version. it default to webasm if supported
else it download the asm.js version.

(constant) imagePostfix :string

Postfix for image anchorIds

nextActionId :number

Used to construct action ids.

size

Wraps Set.size.

size

Wraps Map.size.

(constant) tmpTransform

Adds Ammo physics to a Sumerian entity.
Ammo is a powerful physics engine converted from the C language project Bullet.
Use Ammo.js if you need to support any 3D shape (trimesh).
Also see AmmoSystem.

Deprecated:
  • Deprecated as of v0.11.x and scheduled for removal in v0.13.0; consider using the Cannon system/component instead.

Example
var entity = world.createEntity(new Box(20, 10, 1));
entity.setComponent(new AmmoComponent({ mass: 5 }));

(constant) version :string

The engine version.

Methods

_cleanup(args, ctx)

Calls all cleanup callbacks, stops the context, and then deletes the root context.

Parameters:
Name Type Description
args Object

Script's parameters

ctx Context

Script's context

_notifyListeners(key, entity)

Notifies listeners for a particular key/entity combination, if any exist.

Parameters:
Name Type Description
key string

The key that was updated.

entity Entity

The entity associated with the key that was either added or removed.

_pathElementsFromModuleUrl(url) → {Array.<string>}

Resolves a module URL (e.g. "module://sumerian-common/A/B/C") to an array of path elements (e.g ["common", "A", "B", "C"]).

Parameters:
Name Type Description
url string

The string representing the full object path to the specified URL.

_pause(args, ctx)

Calls pause on the context

Parameters:
Name Type Description
args Object

Script's parameters

ctx Context

Script's context

_pauseEntity(entity)

Called when an entity should be paused. This happens either when the
world is paused or if the entity is added while the world is paused. The
default implemenation does nothing.

Parameters:
Name Type Description
entity Entity

The entity that should be paused.

_preProcessScript(source) → {string}

Replaces the default export statement in a script, inserting a placeholder name for the export if:

  1. The default exported class is un-named.
  2. The default exported class inherits from another class.

ex: "export default class extends s.Action {" => "export default class defaultexport extends s.Action {"

This is necessary to work around a transpilation issue in Babel, which causes the class declaration to execute
before dependencies (potentially including the base class definition) are loaded.

Parameters:
Name Type Description
source string

The original script source.

_resume(args, ctx)

Calls resume on the context

Parameters:
Name Type Description
args Object

Script's parameters

ctx Context

Script's context

_resumeEntity(entity)

Called when an entity should be resumed. This happens the world is
resumed. The default implemenation does nothing.

Parameters:
Name Type Description
entity Entity

The entity that should be resumed.

_startEntity(entity)

Called when an entity should be started. This happens either when the
world is started or if the entity is added while the world is running
or paused. The default implemenation does nothing.

Parameters:
Name Type Description
entity Entity

The entity that should be started.

_stopEntity(entity)

Called when an entity should be stopped. This happens either when the
world is stopped or if the entity is removed while the world is running
or paused. The default implemenation does nothing.

Parameters:
Name Type Description
entity Entity

The entity that should be stopped.

_updateLoadStatus()

Updates the current load status state and calls all registered callbacks
if a change from unloaded to loaded occurs.

_waitForLoad()

Returns a promise that resolves when all assets required for
module resolution have been loaded.

add(value)

Wraps Set.add(), notifying listeners on addition.

Parameters:
Name Type Description
value any

Value to add to the set.

add(…functions)

Adds functions to the stack.

Parameters:
Name Type Attributes Description
functions function <repeatable>

The functions to add.

add(key, entity)

Adds an entry to the index if it doesn't already exist and
notifies listeners.

Parameters:
Name Type Description
key string

The index key.

entity Entity

The entity to associate.

addListener(key, listener)

Adds a listener for changes associated with a specified key.

Parameters:
Name Type Description
key string

The key to track.

listener function

The function to call when an entry related to the key changes.

ARCameraScript()

Engine built in script to enable the AR Camera

AxisAlignedCamControlScript() → {Object}

Axis aligned camera control script

ButtonScript()

Attaches mouse events to an entity.

callAll(…params)

Calls all callbacks in the reverse order from which they were added.

Parameters:
Name Type Attributes Description
params any <repeatable>

Parameters to pass to the callbacks.

canRender() → {boolean}

Returns true if the Viewer is ready to render.

canRender()

canRender()

cleanup()

Calls System#stop if the world has been started, then calls
super.cleanup.

cleanup()

Sets System@passive to true then calls super.cleanup.

clear()

Clears the index and removes all listeners.

clear()

Removes all previously added functions.

clear()

Wraps Set.clear, notifying listeners for each removed element.

clear()

Wraps Map.clear, notifying listeners for each removed element.

clearAssetDirectory()

Informs the module registry that the asset directory has been cleared.

clearListeners()

Removes all listeners.

codeAssetRefInPackWithName(packRef, name) → {Promise.<string>}

Searches for a code asset in and asset pack and returns its id.

Parameters:
Name Type Description
packRef string

The id of the asset pack to seach.

name string

The name of the code asset.

contains()

contains(bound) → {Number}

Checks a bounding volume against the planes of this camera's frustum and returns if it is completely inside of, outside of, or intersecting.
Example returns are Camera.Inside, Camera.Outside or Camera.Intersects.

Parameters:
Name Type Description
bound BoundingVolume

The BoundingVolume to check for culling.

delete(key) → {boolean}

Wraps Map.delete, notifying listeners if the element is removed.

Parameters:
Name Type Description
key any

The element to remove.

delete(value) → {boolean}

Wraps Set.delete, notifying listeners if the element is removed.

Parameters:
Name Type Description
value any

The element to remove.

deleted(entity)

Calls AutoPassiveSystemMixin#_stopEntity if the world has been
started, then calls super.deleted.

Parameters:
Name Type Description
entity Entity

The removed entity.

entries() → {Iterator}

Wraps Set.entries.

entries() → {Iterator}

Wraps Map.entries.

flatten(obj, …props) → {object}

Moves nested properties up into an object. Used to remove levels from an
internal namespace to maintain backward compatiblity in the global
namespace.

Parameters:
Name Type Attributes Description
obj object

The object where the nested poperties will be put.

props string <repeatable>

Names of properties in obj that will be
flattened.

forEach(callback, thisArg)

Wraps Map.forEach.

Parameters:
Name Type Description
callback function

Function to call on each member.

thisArg any

Value to use as this on each function call.

forEach(callback, thisArg)

Wraps Set.forEach.

Parameters:
Name Type Description
callback function

Function to call on each member.

thisArg any

Value to use as this on each function call.

get(key)

Wraps Map.get.

Parameters:
Name Type Description
key any

The key to query.

getFarPlaneDepth()

getFarPlaneDepth() → {Number}

Returns the View's far plane depth.

getNearPlaneDepth() → {Number}

Returns the View's near plane depth.

getNearPlaneDepth()

getNextActionId() → {string}

Constructs a new action id.

getProjectionMatrix()

getProjectionMatrix() → {Matrix4}

Returns the View's projection matrix.

getScaleMaxMinRatio(scale) → {number}

get the ratio of max absolute scale value over min absolute scale value

Parameters:
Name Type Description
scale Vector3

getSystemRegisterModule(id) → {Promise.<string>}

Gets the System.register module for the specified module id.

Parameters:
Name Type Description
id string

id of the module.

getViewInverseMatrix()

getViewInverseMatrix() → {Matrix4}

Returns the View's inverse view matrix.

getViewMatrix() → {Matrix4}

Returns the View's view matrix.

getViewMatrix()

getViewport()

getViewport(store, targetWidth, targetHeight)

Returns the View's viewport relative to a render target.

Parameters:
Name Type Description
store Object

The object to fill with the viewport values.

targetWidth Number

The render target's width.

targetHeight Number

The render target's height.

getViewProjectionInverseMatrix()

getViewProjectionInverseMatrix() → {Matrix4}

Returns the View's inverse view-projection matrix.

getViewProjectionMatrix() → {Matrix4}

Returns the View's view-projection matrix.

getViewProjectionMatrix()

getViews() → {Array.<View>}

Returns an array of View objects representing each eye.

getViews()

getViews()

getWorldTransform()

getWorldTransform()

getWorldTransform()

getWorldTransform() → {Transform}

Returns the View's world space transform.

getWorldTransform() → {Transform}

Returns the Viewer's world space transform.
There is no implied spatial relationship between the Viewer's transform
and the transforms of its Views.

has(key) → {boolean}

Wraps Map.has.

Parameters:
Name Type Description
key any

Key to search for.

has(value) → {boolean}

Wraps Set.has.

Parameters:
Name Type Description
value any

Value to search for.

inserted(entity)

Calls super.inserted, then calls AutoPassiveSystemMixin#_startEntity
if the world is running or paused, and AutoPassiveSystemMixin#_pauseEntity
if the world is paused.

Parameters:
Name Type Description
entity Entity

The inserted entity.

interrupt()

Causes callAll() to return immediately after executing its current callback.

isTransformUpdateValid(transformComponent, parentWorldTransformInvertMatrix) → {boolean}

Check if the new transform is decomposable. Also check if its children's new transform is decomposable

Parameters:
Name Type Description
transformComponent TransformComponent

target component

parentWorldTransformInvertMatrix Matrix4

target's parent world transform invert

keys() → {Iterable}

Wraps Map.keys.

LensFlareScript()

This script makes an entity shine with some lensflare effect.

LogicNodeVec3()

Logic node that provides a Vec3.

makeSuccinctLogger()

Creates a function that wraps console.log to prevent logging the same
content over and over.

Example
const myLogA = DebugUtils.makeSuccinctLogger();
const myLogB = DebugUtils.makeSuccinctLogger();

moduleFromModuleUrl() → {object}

Resolves a module URL (e.g. "module://sumerian/A/B/C") to the corresponding sumerian object
object (e.g. window.sumerian.api.A.B.C).

Throws:

If an invalid URL is provided.

Type
Error

packRefContainingAsset(assetRef) → {Promise.<string>}

Returns the id of the asset pack that contains an asset with the specified id.

Parameters:
Name Type Description
assetRef string

Asset id to find.

packRefForPackName(name) → {Promise.<string>}

Returns the id of the asset pack with the specified name.

Parameters:
Name Type Description
name string

Asset pack name to find.

pause()

Sets System#passive to true then calls super.pause.

pause()

Calls AutoPassiveSystemMixin#_pauseEntity for all the system's
active entities then calls super.pause.

PromiseUtils()

Provides promise-related utility methods

Deprecated:
  • Yes

ReflectionProbeRenderer(settingsopt)

Handles pre-rendering of reflection probes. Attach this to the rendersystem pre-renderers.

Parameters:
Name Type Attributes Description
settings Object <optional>

Reflection probe settings (JSON object).

Properties
Name Type Attributes Description
translation Vector3 <optional>

Probe's translation.

rotation Matrix3 <optional>

Probe's rotation.

positiveXFar number <optional>

Positive X Camera Far Plane.

negativeXFar number <optional>

Negative X Camera Far Plane.

positiveYFar number <optional>

Positive Y Camera Far Plane.

negativeYFar number <optional>

Negative Y Camera Far Plane.

positiveZFar number <optional>

Positive Z Camera Far Plane.

negativeZFar number <optional>

Negative Z Camera Far Plane.

resolution number <optional>

Probe's cubemap resolution.

register(factoryFunction)

Registers an engine script factory function.

Parameters:
Name Type Description
factoryFunction function

A function that returns an object as
described by Script.

register(name, options)

Makes a module available for import and adds its contents to the sumerian
global.

Parameters:
Name Type Description
name string

The name of the module being registered.

options object

Data used when registering.

Properties
Name Type Attributes Description
internal object <optional>

The module's internal namespace. If
not defined then the module has no internal api.

api object <optional>

The module's public namespace. If not
defined then the module has no public api.

global object <optional>

The module's global namespaces. If
not defined then the module's internal namespace is used, if any.

registerOrUpdate(id, source)

Adds or updates a module in the registry. Added modules are converted to the System.register format
via Babel. Existing modules will be updated and their version incremented.

Parameters:
Name Type Description
id string

id of the module.

source source

source for the module.

Throws:

if the Babel translation throws.

Type
Error

remove(fnToRemove)

Removes a previously added function.

Parameters:
Name Type Description
fnToRemove function

The function to remove.

remove(key, entity)

Removes and entry from the index if it exists and
notifies listeners.

Parameters:
Name Type Description
key string

The index key.

entity Entity

The entity to remove.

removeCodeAsset(codeAssetRef)

Informs the module registry that the specified code asset ref has been removed.

Parameters:
Name Type Description
codeAssetRef string

The code asset ref that was removed.

removeListener(key, listener)

Removes a previously added listener.

Parameters:
Name Type Description
key string

The key associated with the listener.

listener function

The function previously registered.

resume()

Calls super.resume, then calls AutoPassiveSystemMixin#_resumeEntity
for all the system's active entities.

resume()

Calls super.resume then sets System#passive to false.

scriptIsCompatible(config)

Checks a script for compatibility with the runtime. Currently just
checks for the presence of an 'export default class' statement.

Parameters:
Name Type Description
config

Script config.

set(key, value)

Wraps Map.set, notifying listeners on successful addition.

Parameters:
Name Type Description
key any

Key to set.

value any

Value to associate with the key.

setup(world)

Calls super.setup, then calls System#start if the world has been
started, then calls System#pause if the world is currently pause.

Parameters:
Name Type Description
world World

The world to which the system has been attached.

setup()

Calls super.setup, then sets System#passive to false if the world
is running, or true if the world is stopped or paused.

size() → {number}

Returns the number of functions in the stack.

start()

Calls super.start, then calls AutoPassiveSystemMixin#_startEntity
or all the system's active entities.

start()

Calls super.start then sets System#passive to false.

stop()

Calls AutoPassiveSystemMixin#_stopEntity for all the system's
active entities, then calls super.stop.

stop()

Sets System#passive to true then calls super.stop.

updateAssetDirectory(assetDirectory)

Informs the module registry that the asset directory has loaded or has been modified.

Parameters:
Name Type Description
assetDirectory Object

The new asset directory.

updateCodeAsset(codeAsset)

Informs the module registry that the specified code asset has been added or modified.

Parameters:
Name Type Description
codeAsset CodeAsset

The code asset that was changed.

updateConfig(config)

Updates the code asset from the provided config.

Parameters:
Name Type Description
config object
Properties
Name Type Attributes Description
name string

The name of the code asset.

type string

The type of file linked to the code asset.

id string

The id of the code asset.

linkedFileName string

The name of the file linked to the code asset.

codeRef string

The unique id of the file linked to the code asset.

content string <optional>

The string representation of the file contents associated with the code asset.

values() → {Iterator}

Wraps Set.values.

values() → {Iterator}

Wraps Map.values.

Type Definitions

Collidable :Object

An object with a bounding polygon on the XZ-plane, a top and a bottom Y coordinate.

Properties:
Name Type Description
poly Array.<Number>

An array of XZ coordinates representing the bounding polygon of the collidable

bottom number

The bottom Y coordinate of the collidable

top number

The top Y coordinate of the collidable

config :Object

Updates the component values according to a config.

Properties:
Name Type Description
config.volume number

A number between 0 and 1 representing the playback volume.

config.voice string

The name of the polly voice to use for playback.

config.spatial boolean

Indicate if the component is a spatial speech component

config :Object

Updates the component valueas according to config

Properties:
Name Type Attributes Description
config.volume number <optional>

A number between 0 and 1.

config.reverb number <optional>

A number between 0 and 1.

config :Object

Update the environmental audio properties. The settings are applied on the next process().

Properties:
Name Type Attributes Description
config.rolloffFactor number <optional>

How fast the sound fades with distance.

config.maxDistance number <optional>

After this distance, sound will keep its volume.

config.volume number <optional>

Will be clamped between 0 and 1.

config.reverb number <optional>

Will be clamped between 0 and 1.

config.muted boolean <optional>

config :Object

Updates the configuration of the Speech object.

Properties:
Name Type Description
config.entity Entity

The entity this speech is attached to

config.id string

The id of the speech object

config.name string

The name of the speech object

config.body string

The text content of the speech object.

config.type string

The type of content contained in Speech.body (text or ssml).

config.volume number

The volume used for playback (0 - 1.0)

config.voice string

The voice id used by polly to synthesize the speech.

config :Object

Updates host component properties from a config

Properties:
Name Type Description
pointOfInterestType string

'None' || 'LookAtEntity'

lookAtTargetEntityId string

entity Id of the lookAt target entity, used if pointOfInterestType is 'LookAtEntity'

animateLipSync boolean

flag to enable Lip Sync animation

animateGestures boolean

flag to enable Gesture animation

gestureMinPeriod number

time in seconds below which successive gesture are dropped.

gestureHoldTime number

time in seconds to play each gesture animation,

hostConfig Object

Host Config object (see HostComponentHandler.js for properties of this object).

DialogueConfig :Object

The configuration object for the DialogueComponent.

Properties:
Name Type Description
name string
alias string

nodes :Object

Connect output of component to audio nodes if not provided disconnect all

Properties:
Name Type Attributes Description
nodes.dry AudioNode <optional>
nodes.wet AudioNode <optional>

options :Object

Attempts to connect to the child Host Entity and it's components used for Gestures

Properties:
Name Type Description
version number

0 for legacy hosts (pre-gestureConfig), > 0 otherwise

animLayerName string

Name of the animation layer with gesture animation states

fromIdleSuffix string

Suffix for the animation state which transitions from the idle state to the gesture state

toIdleSuffix string

Suffix for the animation state which transitions from the gesture state to the idle state

toGestureSuffix string

Suffix for the animation state which transitions from the gesture state to another gesture state

toGestureTransitionOffset number

Normalized percentage (0-1) of the 'from idle' transition to use as the start the 'to gesture' transition if an explicit 'to gesture' state is not found.

hostComponentEntity Entity

the entity with the host component

hostEntity Entity

child entity with the host mesh, skeleton and animation components

gestureMinPeriod number

time in seconds below which successive Gestures Events will be dropped

gestureHoldTime number

time in seconds to play each gesture

progressCallback(progress)

Callback used to report scene load progress.

Parameters:
Name Type Description
progress number

Load progress in interval [0.0, 1.0].

ReplaceRefFunction

Parameters:
Name Type Description
replacementRef string

The ref that will replace the existing ref.

SpeechManagerConfig :Object

Properties:
Name Type Description
voiceId string
body string

StateContext :Object

Provides access to the state when calling action functions.

SumerianRunnerCallback(tpf)

Parameters:
Name Type Description
tpf number

Time elapsed for the frame.