Getting started
Vectary DashboardAccount SettingsRolesHow To Get HelpLibraryScene OrientationShortcutsSystem RequirementsStudio Navigation
User InterfaceDesign modeEdit modeLeft bar - Project & Workspaces Right bar - Properties panelCanvas toolsControl BarDesign process
CameraFile ImportingNURBS (CAD)Object EditingColors and MaterialsLighting and EnvironmentsVersion HistoryAnimated MaterialsInteractionsAnimationsFloating UIVariantsHotspotDecalsUV mapping2D to 3DFigma frames import Figma Plugin - Vectary 3D Studio LiteRenderingAdding commentsSharing and embedding
Sharing your projectsFile ExportingClone projects (Sharing Settings)Augmented Reality (WebAR)WebXR (beta)Embedding to other softwareOptimizing a Shared projectLoading screenScene performance analyzerModel API
IntroductionQuick StartEvents & ListenersFloating UI ConfiguratorsEcommerceEvent expressions
Event expressions allow using mathematical functions and operations instead of the final number or text in the input field. This seemingly small feature allows to build a robust system for handling complex data. These data can be used within the same project or connected to the API.
Input differences
It is important to clarify, that In Vectary, there are 4 different Input field (or input box) styles. Accepted values will differ based on which one is used. Event expression only works in 2 of them.
Text input
- uses a text as a source and by nature does not calculate any mathematical operations
- is used for example in object list → name
Number input
- only accepts numbers as a source
- is used for example in design mode → object transformations
Text expression input
- By default, the text expression behaves like regular text input, but special characters
${
are required to trigger the expression and}
to close it - Text expression is currently only supported in the following inputs:
- 3D Text
- Floating UI → Text
- Floating UI → Button
Number expression input
- It works like a regular number input with an option to type expressions inside directly
- does not support text (except variables or functions)
- event name can be typed directly (without a need to enter special characters)
- At this moment, expressions can be used only in a certain number of input fields in Interactions. Here is the list:
- Animated texture → Delay
- Animation → Delay
- Cameras → Duration, Delay
- Download image → Delay
- Interactions → Delay
- Materials → Delay
- Open link → Delay
- Sounds → Delay
- Transformation → all 9 transformation inputs, Duration, Delay
- Upload image → Delay
- Variants → Variants
- Visibility → Delay
Supported expressions
Data types
- Variables
Variables will work only in case, that they already exist in the project. A new variable can be created in Interactions →
Event listener
orSend event
.
- String →
""
''
- Number →
integer
(89) orfloat
(6.45) - Boolean →
true
orfalse
- Template string `text ${} text` → everything is interpreted as a string, except what is inside
${}
. it is an embedded expression
Operators
+
add
-
subtract
*
multiply
/
divide
==
equals (example → 5==6 → false)
!=
not equals (example → 5!=6 → true)
<
less than
>
more than
<=
less than or equal to
>=
more than or equal to
&&
AND
||
OR
??
nullish coalescing operator (example → event ?? “event interaction has not been called yet” → depending on the event, the event value, or the “event not been called yet…” text)
!
negation
Functions
Random value
The random value returns a value between 0 and 1
examples:
RAND()
will output a random value between 0 and 1, e.g.0.625
- to get a different range, use other operators
RAND()*10
will output a random value between 0 and 10, e.g. 6.25
Rounded value
- The first number defines the number to be rounded
- The second number followed by a comma defines decimal numbers
examples:
ROUND(3.14,1)
will output 3.1
ROUND(3.14,0)
will output 3
Length of string
- outputs the length of the string
-
LEN("hello")
will output a value of5
example:
True/False
- first, the condition to evaluate is defined
- second, defines the value returned if the condition is true
- third, defines the value returned if the condition is false
example:
IF ( temperature ≥ 100, “water is boling”, “water is at ${temperature}º, it needs more heat!” )
Features
Event name as text
When expression is activated, typing quotation marks before and after will ignore the event name or any other text and will treat it like regular text.
Spaces are ignored
It does not matter if a space is used in the expression. The system ignores it except if the space is inside a string or template string.
Event name in the expression
It is possible to reference the event name in the expression which means, that if the event name is of a type number
, it will calculate like any other number.
example:
If the value of the number type event “position” is 10, than typing position+100
will output result of 110
.
Colors
Regular text or number — Black
Variables (Event names) — Purple
Functions, true/false — Blue
Operators — Teal
Invalid/incorrect value — Red
Expression — Yellow
String — Green