How can I pass values dynamically generated from dat.gui sliders into the p and q properties of TorusKnotGeometry, like in this example? http://threejs.org/docs/#Reference/Extras.Geometries/TorusKnotGeometry
I tried looking through the source code but didn't understand how to apply it: http://threejs.org/docs/scenes/js/geometry.js
Here's what I tried. I have cube rotation rendering properly, but torus is not rendering with the values from sliders.
var p = guiControl.p;
var q = guiControl.q;
// setup torus and add to scene
var torusGeometry = new THREE.TorusKnotGeometry(0.64, 0.25, 25, 6, p, q);
var torusMaterial = new THREE.MeshLambertMaterial({color: 0xff00ff});
var torus = new THREE.Mesh(torusGeometry, torusMaterial);
torus.position.set(1,1,1);
torus.castShadow = true;
scene.add(torus);
function render(){
requestAnimationFrame(render);
// controls.update();
cube.rotation.x += guiControl.rotationX;
cube.rotation.y += guiControl.rotationY;
cube.rotation.z += guiControl.rotationZ;
torusGeometry.parameters.p += guiControl.p;
torusGeometry.parameters.q += guiControl.q;
renderer.render(scene,camera);
};
render();
Thanks for your help! I'm new to this.