0
alert(currentObject.position.x);
alert(incrementPositionX);
alert(currentObject.name);
currentObject.position.x += incrementPositionX;
alert(currentObject.position.x);
alert(incrementPositionX);
alert(currentObject.name);

When this Threejs javascript code runs the first 3 alerts are 10 .5 cube1 then after the 1 statement the next 3 alerts are 100.5 .5 cube1

How could the position go from 10 to 100.5 if the increment is .5? This is a sporadic occurrence. after this is run once it works correctly!

Cannot figure this out thanks for the help; Probably something obvious

Martin Levine
  • 27
  • 1
  • 4
  • 1
    `currentObject.position.x` is not a number but a string the first time. – Sebastian Simon Oct 28 '16 at 21:53
  • 1
    FYI: using `console.log(variable)` with a browser's developer tools open is significantly easier to use for debugging than `alert` – Rob M. Oct 28 '16 at 21:58
  • Or just use the developer tools in the inspector. In Chrome you just find your code in the sources menu, click the line to add a breakpoint, (probably reload the page, and then) hover over the variable to see its current value. That way you don't have to remove a bunch of `console.log` lines. – LinuxDisciple Oct 28 '16 at 22:03
  • thanks that was the problem ; appreciate the suggestions! – Martin Levine Oct 28 '16 at 22:54

0 Answers0