JS Math

Use JavaScript to perform mathematical operations on values.

Expression - an area to input mathematical operations/JavaScript expressions.

Result - a read only attribute previewing the result of the Expression.

Add - use this button to add more indices to the UI.

0: Number - the first index in the array

To reference a row in your expression use the syntax n[index number]. For example, to reference the index labelled 0: Number use the syntax n0.

Any strings with n followed by a value will be coloured to help visually identify them within an expression.

Example - adding the values of two attributes together.

  1. Create 3 Shapes.

  2. Create a JS Math Atom.

  3. Connect basicShape1.position.x > jsmath.number0

  4. Connect basicShape2.position.x > jsmath.number1

  5. Enter n0 + n1 into the Expression input.

  6. Connect jsmath.id > basicShape3.position.x to output the result.

Example - move one shape in X at a value of ofAnotherShape\sqrt{ofAnotherShape}

  1. Create 2 Shapes.

  2. Create a JS Math Atom.

  3. Connect basicShape1.position.x > jsmath.number0

  4. Enter Math.sqrt(n0) into the Expression input.

  5. Connect jsmath.id > basicShape2.position.x

See https://htmlcheatsheet.com/js/# for some JavaScript syntax.

To remove indices from the array, select a row or rows, right click and choose Delete Selected Attribute(s).

Last updated