You can turn any 3D object into a button or a switch using the OnTap and OnToggle components.
Existing parameters like sliders, toggles and buttons can be made interactive in mixed reality using the Sync XR Parameters toggles. You can also build 3D UI in Fologram by using the OnHover, OnTap and OnToggle components to detect interactions with geometry. This can be useful for displaying user interfaces in the context where they will be needed, for iterating through material options for a given object, creating popup information panels and more.
Buttons
You can create a new Button from any geometry in your grasshopper component. The Enabled output of the Button is a datatree with boolean values for each input geometry that keep track of whether the button is currently pressed. When a tap is detected on the input geometry, the Pressed output will update as True, then immediately update again as False.
🚧
Note that the button component will update twice for each tap (true then false). This can lead to unexpected behaviour when working with definitions that record values over time so pay close attention to how you are managing data flow in your definition and use a state gate if you need to selectively update components.
Toggles
The OnToggle component creates a button that remembers its state. The Enabled output for the toggle is a boolean that will invert each time a user taps on the input geometry. The Interactor output returns the Interactor object that pressed the toggle. Use the Deconstruct Pointer component to get the device, cursor point or other data.
Â
Hover
The OnHover component outputs True when an interactor (Hand ray, touch ray or gaze) is hovering over the input geometry.