Sensor.ISensor
A Sensor that detects Sources and provides information about the reading of each.
Extends: IObservable<Sensor.ISensor>
Properties
forward
The world-space "forward" direction describing which direction the sensor is facing.
readings
An observable used to get information about assocated ISources added with ISensor.addSource
{ /** * Start receiving updates about the current set of sources added to this sensor. * @param observer - the observer to receive sensor reading updates */ subscribe(observer: ISensorObserver): ISubscription; }
Methods
addSource
Add a source, to add its readings to the set of readings provided by .subscribe.
| Parameter | Type |
|---|---|
| sources | Sensor.ISource[] the sources to add to this sensor |
showDebug
Show debug visuals for this sensor. Existing visuals are disposed.
| Parameter | Type |
|---|---|
| show | boolean whether to show or hide debug visuals |
subscribe
Start receiving updates when properties of this sensor change, e.g. origin or forward, not its readings.
Subscribe to readings to receive updates about associated ISources
| Parameter | Type |
|---|---|
| observer | IObserver<DataT> | ObserverCallback<DataT> |
Returns: ISubscription
waitUntil
Wait for a specific condition on this object to be met.
When this observable detects a change, the condition provided will be called. When the condition returns true, the returned Promise will be resolved.
// Example: pause execution of code until the app state is in the "playing" phase
await sdk.App.state.waitUntil(
appState => appState.phase == sdk.App.Phase.PLAYING
);
or:
await sdk.App.state.waitUntil({
waitUntil(appState) {
return appState.phase == sdk.App.Phase.PLAYING;
}
});
| Parameter | Type |
|---|---|
| condition | ICondition<Sensor.ISensor> | ConditionCallback<Sensor.ISensor> a condition or callback that returns true when the desired state is met |
Returns: Promise<Sensor.ISensor>
A promise that is resolved when condition returns true.