'three js change radius of sphere with dat gui?

http://mrtn.ch/3D/13_06_27_gui_03.html

started analysing example files and now I'm wondering how to properly adress the radius of my sphere with the dat gui slider. I can move the slider but the sphere keeps the initial radius. What's wrong with my code?

Thanks for your help!



Solution 1:[1]

SphereGeometry only uses the radius parameter when it is created. There's no built-in way to change it afterwards. You need to manually modify the geometry vertices, or create a new SphereGeometry with the new radius.

Alternatively, you can just scale the sphere. In your updatesphere() function, try something like:

radius = parameters.radius;
var scale = radius * 0.1; // adjust the multiplier to whatever
sphere.scale.setScalar(scale);

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 e-motiv