threejs
threejs
threejs
Would you like to react to this message? Create an account in a few clicks or log in to continue.


WebGL and Three JS dedicated forum. Here we can discuss about Three JS 3D library.
 
HomeGalleryLatest imagesSearchRegisterLog in

 

 Camera controlled with touch

Go down 
2 posters
AuthorMessage
phaidonas




Posts : 24
Points : 32
Reputation : 0
Join date : 2017-02-07

Camera controlled with touch Empty
PostSubject: Camera controlled with touch   Camera controlled with touch Icon_minitimeTue Feb 21, 2017 5:44 pm

For now i am using this code to control the camera and create a scrolling effect, but (1) after a while the speed is increasing and (2) it doesnt work with the touchpad, i have to use the up and down arrows.Here is the code:
(the code is in my render function )

Code:
var scl=0;



$(window).on('DOMMouseScroll mousewheel', function (e) {


if(e.originalEvent.detail > 0 || e.originalEvent.wheelDelta < 0) {

    while(scl==0) {

        scl=0.05;
            camera.position.z+=scl;

    }

} else {

    while(scl==0) {


        scl=0.05;
            camera.position.z-=scl;

    }

}

});
window.addEventListener("keydown", function (event) {


if (window.event.keyCode==38){

   while(scl==0) {

         scl=0.05;
         camera.position.z+=scl;

   }


}else if(window.event.keyCode==40){
   while(scl==0) {


         scl=0.05;
         camera.position.z-=scl;

   }


}


}, true);

window.setInterval(function(){
    scl=0;
}, 10);

http://console.log("4."+" "+scl);

         if(camera.position.z>670){
            camera.position.z=-670;

         }else if (camera.position.z<-670) {
            camera.position.z=670;
         }

http://console.log(camera.position.z);
         camera.updateProjectionMatrix();

Back to top Go down
SamCorny

SamCorny


Posts : 40
Points : 56
Reputation : 0
Join date : 2017-02-06
Location : NYC

Camera controlled with touch Empty
PostSubject: Re: Camera controlled with touch   Camera controlled with touch Icon_minitimeWed Feb 22, 2017 12:20 pm

Its hard to understand exactly why doesnt work just watching this code. But I see you could try to realize the same behaviour thinking about a math algorhythm.
Have you tried using Select Case instead the if conditions?
Back to top Go down
phaidonas




Posts : 24
Points : 32
Reputation : 0
Join date : 2017-02-07

Camera controlled with touch Empty
PostSubject: Re: Camera controlled with touch   Camera controlled with touch Icon_minitimeWed Feb 22, 2017 12:24 pm

it is the same i think,it works with the up and down key and the mouse wheel but not the touchpad,I dont use touch functions in this code
Back to top Go down
SamCorny

SamCorny


Posts : 40
Points : 56
Reputation : 0
Join date : 2017-02-06
Location : NYC

Camera controlled with touch Empty
PostSubject: Re: Camera controlled with touch   Camera controlled with touch Icon_minitimeWed Feb 22, 2017 2:04 pm

ok if it doesnt work with touchpad you should verify if you need some library or drivers for touch pad. What is your OS?
Back to top Go down
phaidonas




Posts : 24
Points : 32
Reputation : 0
Join date : 2017-02-07

Camera controlled with touch Empty
PostSubject: Re: Camera controlled with touch   Camera controlled with touch Icon_minitimeWed Feb 22, 2017 2:39 pm

i have windows 10 and linux ubuntu,but its not that, i use a
Code:
$(window).on('DOMMouseScroll mousewheel', function (e)
, not touch function and for the keycodes i use up and down.Shouldnt i use a mouse touch event?
Back to top Go down
SamCorny

SamCorny


Posts : 40
Points : 56
Reputation : 0
Join date : 2017-02-06
Location : NYC

Camera controlled with touch Empty
PostSubject: Re: Camera controlled with touch   Camera controlled with touch Icon_minitimeThu Feb 23, 2017 2:00 pm

no i think you can use it as well. Touchpad works as mouse as well, so you shouldn't have any problem with it, strange
Back to top Go down
phaidonas




Posts : 24
Points : 32
Reputation : 0
Join date : 2017-02-07

Camera controlled with touch Empty
PostSubject: Re: Camera controlled with touch   Camera controlled with touch Icon_minitimeSat Feb 25, 2017 12:11 pm

Arent the the touchpad the same with touch of mobiles?
Back to top Go down
Sponsored content





Camera controlled with touch Empty
PostSubject: Re: Camera controlled with touch   Camera controlled with touch Icon_minitime

Back to top Go down
 
Camera controlled with touch
Back to top 
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
threejs :: WEBGL and Three JS Library :: Discussions about WebGL coding via Three.js-
Jump to: