最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Javascript Getting values from dat.GUI - Stack Overflow

programmeradmin2浏览0评论

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!

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!

Share Improve this question edited Mar 24, 2016 at 21:41 WestLangley 105k11 gold badges287 silver badges283 bronze badges asked Mar 24, 2016 at 21:05 Jason MaJason Ma 533 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 4

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

var xval = obj1.x;

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);
发布评论

评论列表(0)

  1. 暂无评论