javascript - Moving an element inside canvas with Leap Motion Leap.Js - How to save a state? -


I'm trying to create LEAP speeds to zoom in and out with a canvas element and it works fine .

Right now when you put your hand in the active area and move vertically or horizontally, then the object moves accordingly. Fine.

When you put your hand on the screen, then the element decreases in size, when you pull it toward yourself, then it increases in size is also good.

Problems start when you want to take your hand away from the area.

Element depends on your peak, which means that it becomes very large (if you pull your hands back yourself). I managed to implement a control, where I remove some fingers (like point it with one finger on one screen), then the image gets accumulated, good.

Now, problem and question: How can I make that when I put my hand back in the control area, then the element starts with the situation where I left it? I was struggling with it all night, and it was difficult and I did not manage it. So if you manage to do this, at least I have to give you beer.

Here is the code (s is my canvas element, the camera [0] has X, Y properties, RATIO Depth):

  var defaultRatio = s.cameras [0]. Arteo; Var firstValidFrame = null; Var start = null; Var Controller = New Leap Controller ({Enable Gesture: True}); Controller.Lop (function (frame) {if (frame heads.langha> gt; 0) {if (first and forefaf; frames.valadi) firstValidFrame = frame; var hand = frame. Hands [0]; var position = Hand (static); palpation; var fingers = arm.finger's; var center = arm. Spanner center; if (position [2] & lt; 60) {start = 1;} if (fingers; length & gt; 2 ; Amp; camera [0] .x = - position [0] * 2; c. Camera [0] .y = position [1] * 2-360; c. Camera [0] .rteo = default raitio - (position [2] * 2/360);}}});   

I

Thank you

P>

I can think of two ways to do this:

  1. bring the user back to the same place Take your hand for where the moving element was "left" before moving it again.

  2. Elements of second hand relative to the position of the hand In issues, when you withdraw your hand in an active area, in that case as to protect and arm motion, moved by the same amount relative to the element.

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -