Lens Scripting API

    Class ScriptComponent

    Used to bind custom JavaScript or TypeScript code to specific Lens events for dynamic interactivity.

    These Script Components are attached to SceneObjects, providing the ability to modify properties and behaviors of those objects or others within the scene. Script Components expose input fields in the Inspector panel, allowing for customization of script behavior without altering code. Any script can access the ScriptComponent executing them through the variable script.

    // Bind a function to the MouthOpened event
    function onMouthOpen(eventData)
    {
    print("mouth was opened");
    }
    var event = script.createEvent("MouthOpenedEvent");
    event.bind(onMouthOpen);

    Hierarchy (View Summary, Expand)

    Implemented by

    Indexable

    • [index: string]: any
    Index

    Constructors

    Properties

    api: Record<string, any>

    Generic object accessible by other instances of ScriptComponent. Use this object to store references to properties and methods that need to be accessible from other ScriptComponents.

    enabled: boolean

    If disabled, the Component will stop enacting its behavior.

    sceneObject: SceneObject

    The scene object this component is on.

    uniqueIdentifier: string

    Methods

    • Destroys the component.

      Returns void

    • Returns the name of this object's type.

      Returns string

    • Returns true if the object matches or derives from the passed in type.

      Parameters

      • type: string

      Returns boolean

    • Returns true if this object is the same as other. Useful for checking if two references point to the same thing.

      Parameters

      Returns boolean

    • Removes a previously added SceneEvent from the ScriptComponent.

      Parameters

      Returns void

    MMNEPVFCICPMFPCPTTAAATR