Skip to main content
Skip table of contents

Writing OKO Scripts - API Bindings

EntitySystem Bindings

Binding name

Description

getEntities

Returns an array of all entities

getObjects

Returns the array of object entities (no avatars)

getAvatars

Returns the array of avatar entities (no objects)

getIndexOfEntity

Returns the index in the array of a given entity

getEntityById

Returns an entity that matches a given Id

getEntityByName

Returns an entity that matches a given name

Entity Bindings

Binding name

Description

subscribeToPropertyChange

Binds a function to fire when a specified property changes

subscribeToMessage

Binds a function to fire when a specified message is received

postMessage

Invokes a message

claimOwnership

Attempts to assign ownership of the entity to the local client

getComponents

Retrieves all components owned by the entity

getAnimatedModelComponents

Retrieves all animated model components owned by the entity

getAudioComponents

Retrieves all audio components owned by the entity

getAvatarComponents

Retrieves all avatar components owned by the entity

getButtonComponents

Retrieves all button components owned by the entity

getCustomComponents

Retrieves all custom components owned by the entity

getECommerceComponents

Retrieves all ecommerce components owned by the entity

getExternalLinkComponents

Retrieves all external link components owned by the entity

getFiducialComponents

Retrieves all fiducial components owned by the entity

getFogComponents

Retrieves all fog components owned by the entity

getImageComponents

Retrieves all image components owned by the entity

getLightComponents

Retrieves all light components owned by the entity

getPortalComponents

Retrieves all portal components owned by the entity

getSplineComponents

Retrieves all spline components owned by the entity

getStaticModelComponents

Retrieves all static model components owned by the entity

getVideoPlayerComponents

Retrieves all video player components owned by the entity

position

The position of the entity

rotation

The rotation of the entity

scale

The scale of the entity

id

The ID of the entity

name

The name of the entity

Component Bindings

  • subscribeToPropertyChange

Animated Model Component

Binding name

Description

externalResourceAssetId

Defines the asset ID for the asset

externalResourceAssetCollectionId

Defines the asset collection ID for the model asset

position

The position of the component

scale

The scale of the component

rotation

The rotation of the component

isLoopPlayback

Whether the animation loops upon reaching the end

isPlaying

Whether the animation is playing

isVisible

Whether the component is visible

animationIndex

Index of the animation that should play

Audio Component

Binding name

Description

position

The position of the component

playbackState

The current playback state [Reset, Pause, Play]

audioType

The type of audio component [Global, Spatial]

audioAssetId

Defines the asset ID for the asset

assetCollectionId

Defines the asset collection ID for the audio asset

attenuationRadius

Distance from the component at which the audio volume attenuates

isLoopPlayback

Whether the audio loops upon reaching the end

timeSincePlay

The time that has elapsed since the audio was last played

volume

The volume of the audio

Avatar Space Component

Binding name

Description

avatarId

Defines the Id of the Avatar

userId

Defines the ID of the user associated with this avatar component

state

The avatar anim state [Idle, Walking, Running, Flying, Jumping, Falling]

avatarMeshIndex

An index denoting which of the baked-in avatars is to be used

agoraUserId

The Agora user ID associated with the avatar

customAvatarUrl

If a custom avatar is being used, the URL for the mesh

isHandIKEnabled

Whether hand IK is enabled for the avatar

targetHandIKTargetLocation

The target hand IK location

handRotation

The current hand orientation

headRotation

The current head orientation

walkRunBlendPercentage

0-1 scalar value controlling the blend between walking and running

torsoTwistAlpha

Value defining the amount of torso twist

avatarPlayMode

The avatar play mode [Default, AR, VR, Creator]

Button Component

Binding name

Description

labelText

The text string to display on the button

iconAssetId

Defines the asset ID for the asset

assetCollectionId

Defines the asset collection ID for the button asset

position

The position of the component

scale

The scale of the component

rotation

The rotation of the component

isVisible

Whether the the component visible

isEnabled

Whether the component enabled

Conversation Component

Binding name

Description

isVisible

Whether the component is visible

isActive

Whether the component is active

position

The position of the component

rotation

The rotation of the component

Custom Component

Binding name

Description

applicationOrigin

A string identifying the author client application

getCustomPropertySubscriptionKey

Get the hash of the of the specified key

hasCustomProperty

Query whether a custom property exists by name

removeCustomProperty

Remove a custom property specified by name

getCustomProperty

Get a custom property specified by name

GetCustomPropertyKeys

Get all set custom property keys

setCustomProperty

Set a custom property specified by name

ECommerce Component

Binding name

Description

position

The position of the component

productId

The Id of the Product associated with the component

External Link Component

Binding name

Description

name

Component name

linkUrl

The external URL associated with the component

displayText

The text to display on the external link in the space

position

The position of the component

scale

The scale of the component

rotation

The rotation of the component

isEnabled

Whether the component is enabled

isVisible

Whether the component is visible

Fiducial Marker Component

Binding name

Description

name

The position of the component

MarkerAssetId

The Id of the Product associated with the component

position

The position of the component

scale

The scale of the component

rotation

The rotation of the component

isVisible

Whether the component is visible

Fog Component

Binding name

Description

fogMode

Component name

position

The position of the component

scale

The scale of the component

rotation

The rotation of the component

startDistance

Distance from the component at which the fog starts

endDistance

Distance from the component at which the fog ends

color

The color of the fog

density

The density of the fog

heightFalloff

The height at which the fog falls off

maxOpacity

The maximum opacity of the fog

isVolumetric

Whether the fog is volumetric

Image Component

Binding name

Binding name

name

Component name

imageAssetId

Defines the asset ID for the asset (retrieved via asset system)

position

The position of the component

scale

The scale of the component

rotation

The rotation of the component

billboardMode

The image billboard mode [Off, Billboard, YawLockedBillboard]

displayMode

The image display mode [SingleSided, DoubleSided, DoubleSidedReversed]

isEmissive

Whether the component is emissive

isVisible

Whether the component is visible

Light Component

Binding name

Description

lightType

What kind of light is this (point, spot)

Intensity

The intensity of the light (units are lumens)

range

The distance over which the light attenuates

innerConeAngle

Spotlight only! Defines the inner cone angle

outerConeAngle

Spotlight only! Defines the outer cone angle

position

The position of the component

rotation

The rotation of the component

color

The RGB color of the light

isVisible

Whether the component is visible

cookieAssetId

Defines the Id of the cookie asset

lightCookieType

The type of cookie you want to use [None, Image]

Portal Component

Binding name

Description

spaceId

Defines the Id of the space the user will travel to

isEnabled

Whether the component is enabled

position

The position of the component

radius

The radius of the portal

Spline Component

Binding name

Description

setWaypoints

Set Vector3 waypoints to generate the spline

getWaypoints

Get Vector3 waypoints used to generate spline

getLocationAlongSpline

Get Vector3 at chosen position along the spline

Static Model Component

Binding name

Description

externalResourceAssetId

Defines the asset ID for the asset

externalResourceAssetCollectionId

Defines the asset collection ID for the model asset

position

The position of the component

scale

The scale of the component

rotation

The rotation of the component

isVisible

Whether the component is visible

Video Player Component

Binding name

Description

position

The position of the component

scale

The scale of the component

rotation

The rotation of the component

videoAssetId

Defines the ID for the asset

videoAssetURL

Instead of uploading a video asset an external URL can be specified

assetCollectionId

Defines the ID for the asset collection for the video asset

isStateShared

Whether playback state is replicated

isAutoPlay

Whether the video should auto play

isLoopPlayback

Whether the video loops upon reaching the end

isAutoResize

Whether the component should resize to match the video aspect ratio

attenutationRadius

Distance from the component at which the audio volume attenuates

playbackState

The current playback state [play, pause, stop]

currentPlayheadPosition

The current timestamp of the video’s play head

timeSincePlay

The time that has elapsed since the video was last played

videoPlayerSourceType

The video source type [URLSource, AssetSource, WowzaStreamSource]

isVisible

Whether the component is visible

isEnabled

Whether the component is enabled

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.