5

Hi so I have a code as follows for dat.GUI interface.

var gui = new dat.GUI();
var obj1 = { x: 5};
gui.add(obj1, 'x');

How do I get the value of x from the gui into a variable? for example

var xval = (something that returns the value of x from the gui)

If I do var xval = obj1; and I did console.log(xval) then I would get this Object {x=5} Just wondering how to get the value of that 5 out into a variable. Thanks for the help in advance!

WestLangley
  • 102,557
  • 10
  • 276
  • 276
Jason Ma
  • 53
  • 3

2 Answers2

4

You just have to call the x component from the object just like you would with a geometry.

var xval = obj1.x;
Anurag Srivastava
  • 14,077
  • 4
  • 33
  • 43
joe smite
  • 98
  • 7
3

i am not worked with three.js in the past but in plain it would be for example:

var obj1 = { x: 5};
var xval = obj1.x;
console.log(xval);
devjalo
  • 51
  • 5