Class: babylonjs/HostObject

babylonjs/HostObject(optionsopt)

new babylonjs/HostObject(optionsopt)

Parameters:
Name Type Attributes Description
options Object <optional>

Options for the host.

Properties
Name Type Attributes Description
owner Object <optional>

Optional engine-specific owner of the host.

Extends

Members

(readonly) deltaTime :number

Gets the amount of time in milliseconds since update was last called.

Type:
  • number
Overrides:

(readonly) id :string

Gets the string id of the object.

Type:
  • string
Overrides:

(readonly) now :number

Gets the current time in milliseconds.

Type:
  • number
Overrides:

(readonly) owner :Object

Gets the engine owner object of the host.

Type:
  • Object
Overrides:

Methods

(static) addPointOfInterestTracking(host, scene, poiConfig, lookJointName)

Enable point of interest tracking on the host

Parameters:
Name Type Default Description
host HostObject
scene Scene
poiConfig Object
lookJointName string char:jx_c_look

Default: 'char:jx_c_look'

(static) addTextToSpeech(host, scene, voice, engine, language, audioJointName)

Parameters:
Name Type Default Description
host HostObject
scene Scene
voice string
engine string
language string en-US

Default: 'en-US'

audioJointName string char:def_c_neckB

The identifier of the joint to attach the audio to. Default: 'char:def_c_neckB'

(static) assembleHost(assets, scene)

Set up animations on a host - gestures, lipsync, etc - and start rendering them in the scene

Parameters:
Name Type Description
assets SumerianHostLoadedAssets
scene Scene

(async, static) createHost(scene, characterConfig, pollyConfig, lookJoint) → {HostObject}

Creates a new Sumerian Host from the assets listed in the characterConfig
parameter. This can be used to create one of the built-in hosts or your own
custom host.

When creating a custom host, use HOST.HostObject.getCharacterConfig() to
retrieve the appropriate config for that character. (See example below.)

Example:

const characterId = 'Cristine';
const characterConfig = HOST.HostUtils.getCharacterConfig('./assets/character-assets', characterId);
const pollyConfig = { pollyVoice: 'Joanna', pollyEngine: 'neural' };
const host = await HOST.HostUtils.createHost(scene, characterConfig, pollyConfig);
Parameters:
Name Type Description
scene Scene

The scene to add the host to.

characterConfig SumerianCharacterConfig
pollyConfig SumerianPollyConfig
lookJoint string

The name of the joint to use for point-of-interest
tracking. Defaults to 'char:jx_c_look' which is the appropriate value for
the built-in host characters. Custom characters may need to specify a
different joint name.

Returns:

A functioning Sumerian Host

Type
HostObject

(static) getAvailableCharacters() → {Array.<string>}

Returns:

An array of characterId's that can be used with getCharacterConfig

Type
Array.<string>

(static) getCharacterConfig(assetsPath, characterId) → {SumerianCharacterConfig}

Returns a config object describing the assets that comprise one of the
eight built-in Sumerian Host characters.

Available character IDs are:

  • "Cristine"
  • "Fiona"
  • "Grace"
  • "Maya"
  • "Jay"
  • "Luke"
  • "Preston"
  • "Wes"
Parameters:
Name Type Description
assetsPath string

A relative path from the HTML page to the directory containing the
"characters" and "animations" folders for the built-in host characters.

characterId string

The ID of the character to be used.

Returns:
Type
SumerianCharacterConfig

(async, static) initTextToSpeech(pollyopt, presigneropt)

Parameters:
Name Type Attributes Description
polly AWS.Polly <optional>

An AWS Polly service client, assumed to have the proper
credentials and configuration.

presigner AWS.Polly.presigner <optional>

The presigner used for Polly calls

(async, static) loadAnimation(scene, childMeshes, url, clipGroupId) → {Promise.<SumerianLoadedAnimation>}

Loads animations into the provided scene.

Parameters:
Name Type Description
scene Scene
childMeshes Array.<Mesh>
url string

URL of a 3D file containing animations (.gltf or .glb)

clipGroupId string

An ID of your choosing for labeling the group.

Returns:
Type
Promise.<SumerianLoadedAnimation>

(async, static) loadCharacterAnimations(scene, characterMesh, bindPoseOffset, animClipUrls) → {SumerianLoadedAnimations}

Loads the animations for a host character

Parameters:
Name Type Description
scene Scene
characterMesh Mesh

The root mesh of the character model

bindPoseOffset AnimationGroup
animClipUrls SumerianAnimationsConfig
Returns:
Type
SumerianLoadedAnimations

(async, static) loadCharacterMesh(scene, modelUrl) → {AssetContainer}

Loads the gltf file that comprises a character model,
and adds it to the scene to be rendered.

Parameters:
Name Type Description
scene Scene
modelUrl string

The absolute path to the gltf file that contains the model

Returns:

A BabylonJS asset container that contains the loaded meshes

Type
AssetContainer

(async, static) loadJson(url)

Reads JSON file

Parameters:
Name Type Description
url string
Returns:

JSON from file

addFeature(FeatureClass, forceopt, …args) → {boolean}

Instantiate a new Host feature and store it. Features must inherit from
AbstractHostFeature.

Parameters:
Name Type Attributes Default Description
FeatureClass Class

Class that will instantiate the feature. Must
extend AbstractHostFeature.

force boolean <optional>
false

Whether or not to overwrite an existing
feature if one of this type already exists on the object.

args any <repeatable>

Additional arguments to pass to the FeatureClass
constructor. The HostObject will always be passed as the first argument.

Overrides:
Returns:
  • Whether or not a feature was successfully added.
Type
boolean

emit(message, valueopt)

Send a message, causing listener functions for the message on this object
to be executed.

Parameters:
Name Type Attributes Description
message string

The message to emit.

value any <optional>

Optional argument to pass to listener callbacks.

Overrides:

hasFeature(typeName) → {boolean}

Indicate whether a specified feature is installed on the host.

Parameters:
Name Type Description
typeName string

Name of the type of feature to look for.

Overrides:
Returns:
Type
boolean

listenTo(message, callback)

Execute a function when a message is received for this object.

Parameters:
Name Type Description
message string

The message to listen for.

callback function

Function to execute once the message is received.

Overrides:

listFeatures() → {Array.<string>}

List the names of the features installed on the host.

Overrides:
Returns:
Type
Array.<string>

removeFeature(typeName) → {boolean}

Remove a feature from the object.

Parameters:
Name Type Description
typeName string

Name of the type of feature to remove.

Overrides:
Returns:
  • Whether or not a feature was successfully removed.
Type
boolean

stopListening(message, callbackopt)

Prevent a function from being executed when a message is received for this
object.

Parameters:
Name Type Attributes Description
message string

The message to stop listening for.

callback function <optional>

Optional callback to remove. If none is defined,
remove all callbacks for the message.

Overrides:

stopListeningByRegexp(regexp, callbackopt)

De-register callback(s) from being executed when messages matching the given
regular expression are received.

Parameters:
Name Type Attributes Description
regexp Regexp

regexp - The regular expression to filter messages with.

callback function <optional>

Optional callback to remove. If none is defined,
remove all callbacks for messages matching the regular expression.

Overrides:

stopListeningToAll()

Prevent any functions from being executed when any message is received for
this object.

Overrides:

update()

This function should be called in the engine's render loop. Executes update
loops for all features.

Overrides:

wait(secondsopt, optionsopt) → {Deferred}

Return a deferred promise that will wait a given number of seconds before
resolving. The host will continuously update the wait promise during the
update loop until it resolves.

Parameters:
Name Type Attributes Default Description
seconds number <optional>
0

Number of seconds to wait before resolving.

options Object <optional>

Optional options object

Properties
Name Type Attributes Description
onFinish function <optional>

Callback to execute once the wait time
is met.

onProgress function <optional>

Callback to execute each time the wait
time progresses towards the target number of seconds. The amount of progress
as a 0-1 percentage is passed as an argument.

onCancel function <optional>

Callback to execute if the user cancels
the wait before completion.

onError function <optional>

Callback to execute if the wait stops
because an error is encountered. The error message is passed as a parameter.

Overrides:
Returns:
Type
Deferred