0b5vr / tweakpane-plugin-rotation

3D rotation input plugin for Tweakpane
MIT License
81 stars 5 forks source link

euler is possible to allow prefix params like "_xyz" instead of "xyz" ? #1

Open jonlepage opened 2 years ago

jonlepage commented 2 years ago

hi friend, thanks for this awesome controller ! Its would be awesome if you can found a hack to allow prefixed variable. ex:

  const params = {
    euler: { _x: 0.0, _y: 0.0, _z: 0.0 },
  }
  pane.addInput(params, 'euler', {
    view: 'rotation',
    rotationMode: 'euler',
    order: 'XYZ',
    unit: 'deg',
  });

I suppose if you not allowed this yet is may related to architecture limitation of plugins API ?


My user case is because in usage of a game engine rendering (webgl), we need use a custom update loop with requestAnimationFrame where is run in loop and will apply data like. image


So in this kind of case , the update run like this, and the gui should mutate private "._xyz" value instead of setter values ".xyz".

    update(): void {
        this.proj.scale.set( this._zoom );
        this.proj.euler.set( this.euler._x, this.euler._y, this.euler._z ); // apply _.x and not .x
        this.setPlanes( this._focus, this._near, this._far, this._orthographic );
    }

if the Gui apply euler data on setter in same time as the game update, every math break and go weird. Is there a way to use param like euler: { _x: 0.0, _y: 0.0, _z: 0.0 } instead of euler: { x: 0.0, y: 0.0, z: 0.0 }

I add a dirty temp hack on my side to make this work, but i should not really not hack my engine to make it work with a gui, is really not a good idea 🤣 image so i add a custom object in hight level, where the update use it instead the low level .


i also have another question ,is there a way to reduce the mouse sensibility ? i tried add a very low value in step like step: 0.001 without success !

        folder2.addInput( $, '_eulers', {
            view: 'rotation',
            rotationMode: 'euler',
            order: 'XYZ',
            unit: 'rad', 
            step: 0.0001, // sensivity ? seem not work.
            picker: 'inline',
            expanded: true, 
        } );

Sorry for pock you and for the inconvenience and thanks you @0b5vr for any time you can give :)

0b5vr commented 2 years ago

Sorry for the late reply :bow: Thank you for the detailed description of your circumstance.

I remembered I just followed how the API design goes in the original tweakpane APIs when I implement this but let me check this again. Honestly I'm also bothered by the interface (I want to get the result in Array format).

Also I'm 80% sure that I did no mouse sensitivity stuff when I do this, which is worth considering I believe.

jonlepage commented 2 years ago

you are not alone, I was interested in it to make a plugin and I also found that the API was very restrictive and not very intuitive. I am not a fan of technologies and architecture choosed by the API. Feel free to update if you found a solution, i will update my dirty code on my side :)