program.js
// Binds "on-change" events for the controls on the web page
Binds "on-change" events for the controls on the web page
Binds " on - change " events for the controls on the web page
function initControlEvents() {
    document.getElementById("shape-select").onchange = 
    document.getElementById("superquadric-constant-n1").onchange = 
    document.getElementById("superquadric-constant-n2").onchange = 
    document.getElementById("superquadric-constant-a").onchange =
    document.getElementById("superquadric-constant-b").onchange =
    document.getElementById("superquadric-constant-c").onchange =
    document.getElementById("superquadric-constant-d").onchange =
        function(e) {
            var shape = document.getElementById("shape-select").value;
            if (shape === "supertorus") {
                document.getElementById("superquadric-constant-d").disabled = false;
            }
            else {
                document.getElementById("superquadric-constant-d").disabled = true;
            }
            updateFaces(superquadrics[document.getElementById("shape-select").value],
                getSuperquadricConstants(), SUBDIV_U, SUBDIV_V);
        };
	document.getElementById("material-select").onchange =
		function(e) {
			updateMaterial(document.getElementById("material-select").value);
		};
    document.getElementById("foreground-color").onchange = 
        function(e) {
            updateWireframeColor(getWireframeColor());
        };
    document.getElementById("fov").onchange =
        function(e) {
            updateProjection(perspective(getFOV(), 1, 0.01, 100));
        };
}
function initControlEvents ( ) { document . getElementById ( "shape-select" ) . onchange = document . getElementById ( "superquadric-constant-n1" ) . onchange = document . getElementById ( "superquadric-constant-n2" ) . onchange = document . getElementById ( "superquadric-constant-a" ) . onchange = document . getElementById ( "superquadric-constant-b" ) . onchange = document . getElementById ( "superquadric-constant-c" ) . onchange = document . getElementById ( "superquadric-constant-d" ) . onchange = function ( e ) { var shape = document . getElementById ( "shape-select" ) . value ; if ( shape === "supertorus" ) { document . getElementById ( "superquadric-constant-d" ) . disabled = false ; } else { document . getElementById ( "superquadric-constant-d" ) . disabled = true ; } updateFaces ( superquadrics [ document . getElementById ( "shape-select" ) . value ] , getSuperquadricConstants ( ) , SUBDIV_U , SUBDIV_V ) ; } ; document . getElementById ( "material-select" ) . onchange = function ( e ) { updateMaterial ( document . getElementById ( "material-select" ) . value ) ; } ; document . getElementById ( "foreground-color" ) . onchange = function ( e ) { updateWireframeColor ( getWireframeColor ( ) ) ; } ; document . getElementById ( "fov" ) . onchange = function ( e ) { updateProjection ( perspective ( getFOV ( ) , 1 , 0.01 , 100 ) ) ; } ; }
Binds "on-change" events for the controls on the web page
Binds " on - change " events for the controls on the web page
// Use one event handler for all of the shape controls // Disable the "d" parameter if the shape is not a supertorus // Regenerate the vertex data // Event handler for the material selection // Event handler for the foreground color control // Event handler for the FOV control