function controllerDatGuiOnChange() {

    // When gui values changes then stop animating else won't be able to type with keyboard
    dg_controller_tx.onChange(function(value) {

            // Stop animating
            cancelAnimationFrame( id_animation_frame );

            // update object position
            transform_controls.object.position.x = gui_controls_funs.dg_tx;



            // start animating again
            animate();
        }
    );

    //dg_controller_tx.

        // // Stop animating
        // cancelAnimationFrame( id_animation_frame );
        //
        //
        // // start animating again
        // animate();


    dg_controller_ty.onChange(function(value) {
            cancelAnimationFrame( id_animation_frame );
            transform_controls.object.position.y = gui_controls_funs.dg_ty;
            animate();
        }
    );

    dg_controller_tz.onChange(function(value) {
            cancelAnimationFrame( id_animation_frame );
            transform_controls.object.position.z = gui_controls_funs.dg_tz;
            animate();
        }
    );

    dg_controller_rx.onChange(function(value) {
            cancelAnimationFrame( id_animation_frame );
            transform_controls.object.rotation.x = gui_controls_funs.dg_rx/180*Math.PI;
            animate();
        }
    );

    dg_controller_ry.onChange(function(value) {
            cancelAnimationFrame( id_animation_frame );
            transform_controls.object.rotation.y = gui_controls_funs.dg_ry / 180*Math.PI;
            animate();
        }
    );

    dg_controller_rz.onChange(function(value) {
            cancelAnimationFrame( id_animation_frame );
            transform_controls.object.rotation.z = gui_controls_funs.dg_rz / 180*Math.PI;
            animate();
        }
    );


    dg_controller_sc.onChange(function(value) {

            cancelAnimationFrame( id_animation_frame );

            transform_controls.object.scale.set(gui_controls_funs.dg_scale, gui_controls_funs.dg_scale, gui_controls_funs.dg_scale);

            var dims = findDimensions(transform_controls.object);

            gui_controls_funs.dg_dim_x = dims[0];
            gui_controls_funs.dg_dim_y = dims[1];
            gui_controls_funs.dg_dim_z = dims[2];

            animate();
        }
    );


    // When x length changes from dat gui then change also scale, y and z lengths, and scale the object with transform controls also
    dg_controller_dim_x.onChange( function(value) {

            cancelAnimationFrame( id_animation_frame );

            if (dg_dim_x_prev) {
                gui_controls_funs.dg_scale = gui_controls_funs.dg_scale * value / dg_dim_x_prev;

                transform_controls.object.scale.set(gui_controls_funs.dg_scale, gui_controls_funs.dg_scale, gui_controls_funs.dg_scale);

                var dims = findDimensions(transform_controls.object);

                //gui_controls_funs.dg_dim_x = dims[0];
                gui_controls_funs.dg_dim_y = dims[1];
                gui_controls_funs.dg_dim_z = dims[2];
            }

            dg_dim_x_prev = value;
            animate();


        }
    );


    dg_controller_dim_y.onChange( function(value) {

            cancelAnimationFrame( id_animation_frame );

            if (dg_dim_y_prev) {
                gui_controls_funs.dg_scale = gui_controls_funs.dg_scale * value / dg_dim_y_prev;

                transform_controls.object.scale.set(gui_controls_funs.dg_scale, gui_controls_funs.dg_scale, gui_controls_funs.dg_scale);

                var dims = findDimensions(transform_controls.object);

                gui_controls_funs.dg_dim_x = dims[0];
                //gui_controls_funs.dg_dim_y = dims[1];
                gui_controls_funs.dg_dim_z = dims[2];
            }


            dg_dim_y_prev = value;
            animate();
        }
    );


    dg_controller_dim_z.onChange( function(value) {

            cancelAnimationFrame( id_animation_frame );

            if (dg_dim_z_prev) {
                gui_controls_funs.dg_scale = gui_controls_funs.dg_scale * value / dg_dim_z_prev;

                transform_controls.object.scale.set(gui_controls_funs.dg_scale, gui_controls_funs.dg_scale, gui_controls_funs.dg_scale);

                var dims = findDimensions(transform_controls.object);

                gui_controls_funs.dg_dim_x = dims[0];
                gui_controls_funs.dg_dim_y = dims[1];
                //gui_controls_funs.dg_dim_z = dims[2];
            }


            dg_dim_z_prev = value;
            animate();
        }
    );

    // Make slider-text controllers more interactive
    setKeyPressControllerUnconstrained(dg_controller_tx);
    setKeyPressControllerUnconstrained(dg_controller_ty);
    setKeyPressControllerUnconstrained(dg_controller_tz);
    setKeyPressControllerConstrained(dg_controller_rx);
    setKeyPressControllerConstrained(dg_controller_ry);
    setKeyPressControllerConstrained(dg_controller_rz);
    setKeyPressControllerConstrained(dg_controller_sc);

    setKeyPressControllerConstrained(dg_controller_dim_x);
    setKeyPressControllerConstrained(dg_controller_dim_y);
    setKeyPressControllerConstrained(dg_controller_dim_z);


}
/**
 *  Update php, javascript and transform_controls when dat.gui changes
 */
Update php, javascript and transform_controls when dat.gui changes
Update php javascript and transform_controls when dat . gui changes
function controllerDatGuiOnChange() {
    dg_controller_tx.onChange(function(value) {
            cancelAnimationFrame( id_animation_frame );
            transform_controls.object.position.x = gui_controls_funs.dg_tx;
            animate();
        }
    );
         animate();
    dg_controller_ty.onChange(function(value) {
            cancelAnimationFrame( id_animation_frame );
            transform_controls.object.position.y = gui_controls_funs.dg_ty;
            animate();
        }
    );
    dg_controller_tz.onChange(function(value) {
            cancelAnimationFrame( id_animation_frame );
            transform_controls.object.position.z = gui_controls_funs.dg_tz;
            animate();
        }
    );
    dg_controller_rx.onChange(function(value) {
            cancelAnimationFrame( id_animation_frame );
            transform_controls.object.rotation.x = gui_controls_funs.dg_rx/180*Math.PI;
            animate();
        }
    );
    dg_controller_ry.onChange(function(value) {
            cancelAnimationFrame( id_animation_frame );
            transform_controls.object.rotation.y = gui_controls_funs.dg_ry / 180*Math.PI;
            animate();
        }
    );
    dg_controller_rz.onChange(function(value) {
            cancelAnimationFrame( id_animation_frame );
            transform_controls.object.rotation.z = gui_controls_funs.dg_rz / 180*Math.PI;
            animate();
        }
    );
    dg_controller_sc.onChange(function(value) {
            cancelAnimationFrame( id_animation_frame );
            transform_controls.object.scale.set(gui_controls_funs.dg_scale, gui_controls_funs.dg_scale, gui_controls_funs.dg_scale);
            var dims = findDimensions(transform_controls.object);
            gui_controls_funs.dg_dim_x = dims[0];
            gui_controls_funs.dg_dim_y = dims[1];
            gui_controls_funs.dg_dim_z = dims[2];
            animate();
        }
    );
     When x length changes from dat gui then change also scale, y and z lengths, and scale the object with transform controls also
    dg_controller_dim_x.onChange( function(value) {
            cancelAnimationFrame( id_animation_frame );
            if (dg_dim_x_prev) {
                gui_controls_funs.dg_scale = gui_controls_funs.dg_scale * value / dg_dim_x_prev;
                transform_controls.object.scale.set(gui_controls_funs.dg_scale, gui_controls_funs.dg_scale, gui_controls_funs.dg_scale);
                var dims = findDimensions(transform_controls.object);
                gui_controls_funs.dg_dim_x = dims[0];
                gui_controls_funs.dg_dim_y = dims[1];
                gui_controls_funs.dg_dim_z = dims[2];
            }
            dg_dim_x_prev = value;
            animate();
        }
    );
    dg_controller_dim_y.onChange( function(value) {
            cancelAnimationFrame( id_animation_frame );
            if (dg_dim_y_prev) {
                gui_controls_funs.dg_scale = gui_controls_funs.dg_scale * value / dg_dim_y_prev;
                transform_controls.object.scale.set(gui_controls_funs.dg_scale, gui_controls_funs.dg_scale, gui_controls_funs.dg_scale);
                var dims = findDimensions(transform_controls.object);
                gui_controls_funs.dg_dim_x = dims[0];
                gui_controls_funs.dg_dim_y = dims[1];
                gui_controls_funs.dg_dim_z = dims[2];
            }
            dg_dim_y_prev = value;
            animate();
        }
    );
    dg_controller_dim_z.onChange( function(value) {
            cancelAnimationFrame( id_animation_frame );
            if (dg_dim_z_prev) {
                gui_controls_funs.dg_scale = gui_controls_funs.dg_scale * value / dg_dim_z_prev;
                transform_controls.object.scale.set(gui_controls_funs.dg_scale, gui_controls_funs.dg_scale, gui_controls_funs.dg_scale);
                var dims = findDimensions(transform_controls.object);
                gui_controls_funs.dg_dim_x = dims[0];
                gui_controls_funs.dg_dim_y = dims[1];
                gui_controls_funs.dg_dim_z = dims[2];
            }
            dg_dim_z_prev = value;
            animate();
        }
    );
     Make slider-text controllers more interactive
    setKeyPressControllerUnconstrained(dg_controller_tx);
    setKeyPressControllerUnconstrained(dg_controller_ty);
    setKeyPressControllerUnconstrained(dg_controller_tz);
    setKeyPressControllerConstrained(dg_controller_rx);
    setKeyPressControllerConstrained(dg_controller_ry);
    setKeyPressControllerConstrained(dg_controller_rz);
    setKeyPressControllerConstrained(dg_controller_sc);
    setKeyPressControllerConstrained(dg_controller_dim_x);
    setKeyPressControllerConstrained(dg_controller_dim_y);
    setKeyPressControllerConstrained(dg_controller_dim_z);
}
function controllerDatGuiOnChange ( ) { dg_controller_tx . onChange ( function ( value ) { cancelAnimationFrame ( id_animation_frame ) ; transform_controls . object . position . x = gui_controls_funs . dg_tx ; animate ( ) ; } ) ; dg_controller_ty . onChange ( function ( value ) { cancelAnimationFrame ( id_animation_frame ) ; transform_controls . object . position . y = gui_controls_funs . dg_ty ; animate ( ) ; } ) ; dg_controller_tz . onChange ( function ( value ) { cancelAnimationFrame ( id_animation_frame ) ; transform_controls . object . position . z = gui_controls_funs . dg_tz ; animate ( ) ; } ) ; dg_controller_rx . onChange ( function ( value ) { cancelAnimationFrame ( id_animation_frame ) ; transform_controls . object . rotation . x = gui_controls_funs . dg_rx / 180 * Math . PI ; animate ( ) ; } ) ; dg_controller_ry . onChange ( function ( value ) { cancelAnimationFrame ( id_animation_frame ) ; transform_controls . object . rotation . y = gui_controls_funs . dg_ry / 180 * Math . PI ; animate ( ) ; } ) ; dg_controller_rz . onChange ( function ( value ) { cancelAnimationFrame ( id_animation_frame ) ; transform_controls . object . rotation . z = gui_controls_funs . dg_rz / 180 * Math . PI ; animate ( ) ; } ) ; dg_controller_sc . onChange ( function ( value ) { cancelAnimationFrame ( id_animation_frame ) ; transform_controls . object . scale . set ( gui_controls_funs . dg_scale , gui_controls_funs . dg_scale , gui_controls_funs . dg_scale ) ; var dims = findDimensions ( transform_controls . object ) ; gui_controls_funs . dg_dim_x = dims [ 0 ] ; gui_controls_funs . dg_dim_y = dims [ 1 ] ; gui_controls_funs . dg_dim_z = dims [ 2 ] ; animate ( ) ; } ) ; dg_controller_dim_x . onChange ( function ( value ) { cancelAnimationFrame ( id_animation_frame ) ; if ( dg_dim_x_prev ) { gui_controls_funs . dg_scale = gui_controls_funs . dg_scale * value / dg_dim_x_prev ; transform_controls . object . scale . set ( gui_controls_funs . dg_scale , gui_controls_funs . dg_scale , gui_controls_funs . dg_scale ) ; var dims = findDimensions ( transform_controls . object ) ; gui_controls_funs . dg_dim_y = dims [ 1 ] ; gui_controls_funs . dg_dim_z = dims [ 2 ] ; } dg_dim_x_prev = value ; animate ( ) ; } ) ; dg_controller_dim_y . onChange ( function ( value ) { cancelAnimationFrame ( id_animation_frame ) ; if ( dg_dim_y_prev ) { gui_controls_funs . dg_scale = gui_controls_funs . dg_scale * value / dg_dim_y_prev ; transform_controls . object . scale . set ( gui_controls_funs . dg_scale , gui_controls_funs . dg_scale , gui_controls_funs . dg_scale ) ; var dims = findDimensions ( transform_controls . object ) ; gui_controls_funs . dg_dim_x = dims [ 0 ] ; gui_controls_funs . dg_dim_z = dims [ 2 ] ; } dg_dim_y_prev = value ; animate ( ) ; } ) ; dg_controller_dim_z . onChange ( function ( value ) { cancelAnimationFrame ( id_animation_frame ) ; if ( dg_dim_z_prev ) { gui_controls_funs . dg_scale = gui_controls_funs . dg_scale * value / dg_dim_z_prev ; transform_controls . object . scale . set ( gui_controls_funs . dg_scale , gui_controls_funs . dg_scale , gui_controls_funs . dg_scale ) ; var dims = findDimensions ( transform_controls . object ) ; gui_controls_funs . dg_dim_x = dims [ 0 ] ; gui_controls_funs . dg_dim_y = dims [ 1 ] ; } dg_dim_z_prev = value ; animate ( ) ; } ) ; setKeyPressControllerUnconstrained ( dg_controller_tx ) ; setKeyPressControllerUnconstrained ( dg_controller_ty ) ; setKeyPressControllerUnconstrained ( dg_controller_tz ) ; setKeyPressControllerConstrained ( dg_controller_rx ) ; setKeyPressControllerConstrained ( dg_controller_ry ) ; setKeyPressControllerConstrained ( dg_controller_rz ) ; setKeyPressControllerConstrained ( dg_controller_sc ) ; setKeyPressControllerConstrained ( dg_controller_dim_x ) ; setKeyPressControllerConstrained ( dg_controller_dim_y ) ; setKeyPressControllerConstrained ( dg_controller_dim_z ) ; }
Update php, javascript and transform_controls when dat.gui changes
Update php javascript and transform_controls when dat . gui changes
// When gui values changes then stop animating else won't be able to type with keyboard // Stop animating // update object position // start animating again //dg_controller_tx. // // Stop animating // cancelAnimationFrame( id_animation_frame ); // // // // start animating again // animate(); // When x length changes from dat gui then change also scale, y and z lengths, and scale the object with transform controls also //gui_controls_funs.dg_dim_x = dims[0]; //gui_controls_funs.dg_dim_y = dims[1]; //gui_controls_funs.dg_dim_z = dims[2]; // Make slider-text controllers more interactive