Set value to circle slider directly

北城余情 提交于 2020-06-01 04:47:37

问题


As a continuation of this question:

Set value to slider directly

I have the very same problem updating the circle slider.

My problem is that I set the values of the circle with the mouse click and drag, but I cannot set the values directly. I want to set the rotation of the circle to a determined value.

The full code I am working with is here:

https://webgl2fundamentals.org/webgl/lessons/webgl-2d-rotation.html

I tried to create a function that updates the value, calling the updateValue function in:

https://webgl2fundamentals.org/webgl/resources/jquery-gman-circle.js

function updateSlider(slider, value) {slider.updateValue(value)}

But it is not a function present in the UI element funtionality as in the slider case.

I tried then to call the drawCircle(ctx) function that can be found as used in the code:

function drawCircle(ctx)

But it is inside the _create: function() { and I dont know how to call it for my circle.

I also considered extendin the funcionality of the cicle created to set a value with the setSlider value function, but I dont know how to vinculate my click button event with this function to update the value.

rotCircle = $('#rotation').gmanUnitCircle({
      width: 200,
      height: 200,
      value: 0,
      slide: (e, u) => {
        this.rotation[0] = u.x;
        this.rotation[1] = u.y;
        this.drawScene(shader);
      },
      setSliderValue: (e, u) => { // <- I would want to call this function to set the values I desire in u
        this.rotation[0] = u.x;
        this.rotation[1] = u.y;
        this.drawScene(shader);
      },
    });

To sum up, I just want to set the value of the circle rotation slider directly. I am not familar with the Javascript event approach so that is why I guess I find this harder that expected.

Thanks in advance

来源:https://stackoverflow.com/questions/62118060/set-value-to-circle-slider-directly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!