ReferenceScripting APIComponent
Component
classA part of a mote, bound to one of its layers (or a 3D layer's item).
| Name | Component |
|---|---|
| Kind | class |
| Script reaches it as | import { Component } from "motion" |
| Since | 0.3 |
Syntax
class Component { … }Properties
| Name | Type | Description |
|---|---|---|
nameproperty | readonly string | Its name on its mote. |
layerproperty | readonly string | Its layer's id. |
visibleproperty | boolean | Whether its layer shows. |
opacityproperty | number | Its layer's opacity, 0 to 1. |
Methods
| Signature | Description |
|---|---|
new Component(name?: string, layer?: string): Componentconstructor | Binds a layer to a mote by hand. A mote's components are made with it, from the layers it's given in Studio, so you rarely need this. |
set(key: string, value: SettingValue): voidmethod | Changes one of its layer's settings. |
animate(key: string, value: string | number, seconds: number, options?: MotionAnimateOptions): Promise<boolean>method | Moves one of its layer's settings. |
stopAnimating(key?: string): voidmethod | Stops its layer's moves. |
get(key: string): SettingValue | undefinedmethod | One of its layer's settings, as scene.get. |
read(key: string): SettingValue | undefinedmethod | One of its layer's settings as last drawn, as scene.read. |
show(visible?: boolean): voidmethod | Shows (or hides) its layer. |
hide(): voidmethod | Hides its layer. |
See also
Notes from the community
Written by creators and checked by the docs' editors. Not part of Motion's official reference.