PatchesModule

The PatchesModule module allows interop between JS scripting and the AR Studio patches visual scripting system.

Example

//==============================================================================
// The following example demonstrates how to send and receive values between the
// Patch Editor and script.
//
// Project setup:
// - Insert text
// - With your script selected in the Assets, in the Inspector:
//   - Select 'Boolean' from the + menu of 'From Script' and name it 'myBoolean'
//   - Select 'Read varibles from script' from the + menu of 'Actions'
//   - Select 'String' from the + menu of 'To Script' and name it 'myString'
//   - Select the circle next to 'myString' to add it to the Patch Editor
// - Add an 'If Then Else' patch setting it's 'Type' to 'Text'
// - Add two strings to the 'Then' and 'Else' values of the 'If Then Else' patch
// - Connect the 'myBoolean' value to the 'Condidition' value
// - Connect the 'If Then Else' patch output value to the 'myString' value
//==============================================================================

// Load in the required modules
const Patches = require('Patches');
const Scene = require('Scene');

// Locate the text in the Scene
const text = Scene.root.find('text0');

// Create a boolean variable
const myBoolean = true;

// Send the boolean value to the Patch Editor under the name 'myBoolean'
Patches.setBooleanValue('myBoolean', myBoolean);

// Get the 'myString' string value from the Patch Editor
const myString = Patches.getStringValue('myString');

// Update the text with the string value
text.text = myString;

Properties

This module exposes no properties.

Methods

MethodDescription

getBooleanValue

getBooleanValue(name: String): BoolSignal

Returns a BoolSignal that is exported with name from the Patch Editor.

getColorValue

getColorValue(name: String): ColorSignal

Returns a ColorSignal that is exported with name from the Patch Editor.

getPoint2DValue

getPoint2DValue(name: String): PixelPointSignal

Returns a PixelPointSignal that is exported with name from the Patch Editor.

getPointValue

getPointValue(name: String): PointSignal

Returns a PointSignal that is exported with name from the Patch Editor.

getPulseValue

getPulseValue(name: String): EventSource

Returns a pulse EventSource that wrapps a pulse that is exported with name from the Patch Editor.

getScalarValue

getScalarValue(name: String): ScalarSignal

Returns a ScalarSignal that is exported with name from the Patch Editor.

getStringValue

getStringValue(name: String): StringSignal

Returns a StringSignal that is exported with name from the Patch Editor.

getVectorValue

getVectorValue(name: String): VectorSignal

Returns a VectorSignal that is exported with name from the Patch Editor.

setBooleanValue

setBooleanValue(name: String, signal: BoolSignal): void

Sends a BoolSignal that is imported with name into the Patch Editor.

setColorValue

setColorValue(name: String, signal: ColorSignal): void

Sends a ColorSignal that is imported with name into the Patch Editor.

setPoint2DValue

setPoint2DValue(name: String, signal: PixelPointSignal): void

Sends a PixelPointSignal that is imported with name into the Patch Editor.

setPointValue

setPointValue(name: String, signal: PointSignal): void

Sends a PointSignal that is imported with name into the Patch Editor.

setPulseValue

setPulseValue(name: String, signal: EventSource): void

Sends a EventSource that is imported with name into the Patch Editor.

setScalarValue

setScalarValue(name: String, signal: ScalarSignal): void

Sends a ScalarSignal that is imported with name into the Patch Editor.

setStringValue

setStringValue(name: String, signal: StringSignal): void

Sends a StringSignal that is imported with name into the Patch Editor.

setVectorValue

setVectorValue(name: String, signal: VectorSignal): void

Sends a VectorSignal that is imported with name into the Patch Editor.

Classes

This module exposes no classes.