Skip to content
Josh Stovall edited this page Dec 3, 2020 · 2 revisions

Button()

Create a button, to be used for user interaction.

See the live demo.

Basic Use

var myButton = new XR.Button();

Example

var user = new XR.User({
   input:'gamepad'
});

// setup controllers
new XR.Gamepad();

controller.right.joystick

var rightPointer = new XR.Pointer({
  bind: rightController
});
// create button
var myButton = new XR.Button({
   text: 'hello world',
   color: 0xFF0000,
   action: buttonAction,
});

// action to execute on button click
function buttonAction(){
   console.log('clicked');
}

Parameters

Name Type Default Description
text string text to display
color color button text color
background color button background color
action function function to trigger when button is clicked
href url make the button a link
borderRadius float button border radius

Clone this wiki locally