Skip to content
This repository was archived by the owner on Oct 5, 2022. It is now read-only.

Element

David Peicho edited this page Sep 8, 2017 · 1 revision

Introduction

You already saw how to apply a style to any Element. You will see in depth what every element in VRUI has access to. If you checked the diagram in the first part of the wiki, you could have seen that everything is an Element. Consequently, every attributes and method that we will described here are accessible in views and layouts.

Class In Depth

Below are listed the attributes and methods of all elements. You can modify them as you want. However, it is not advised to modify any field beginning with an underscore (e.g: _myField). You must also use setters if they exist, as they may do some preprocessing.

Object method

  • refresh(): refreshes the element, and all its children if it has some. Refresh will recompute the bounds of the hierarchy and scale/position the elements accordingly.
  • set(style): sets every style properties listed in the style object. You can have a description of all the properties in this section
  • onChange(callback): adds callback callback triggered when the element change. The callback is triggered depending on the type of object it is on. For instance, on ImageButton, onChange is triggered when the button is pressed / released, but on SliderView, it is triggered when the slider value is updated.
  • onHoverEnter(callback): adds callback callback triggered when the input enter the element area.
  • onHoverExit(callback): adds callback callback triggered when the input exit the element area.

Object attributes

  • group: THREE.Group object, containing every THREE.Object3D. For instance, the background is a mesh with a material (potentially with a texture), and this mesh is added to the group. If you want to move an element and its children, for instance to animate something, it is the best way!
  • parent: reference to the parent element, if any. It is used inside the library, but could be useful in some cases.
  • style: contains a copy of the given style.
  • hover: true if the input is hover the element, false otherwise.
  • userData: if you want to extend VRUI with custom data, use this object!
  • _background: mesh containing representing the background.

Examples

Clone this wiki locally