threejs


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

Share | 
 

 Camera controlled with touch

View previous topic View next topic Go down 
AuthorMessage
phaidonas



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

PostSubject: Camera controlled with touch   Tue 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

avatar

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

PostSubject: Re: Camera controlled with touch   Wed 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

PostSubject: Re: Camera controlled with touch   Wed 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

avatar

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

PostSubject: Re: Camera controlled with touch   Wed 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

PostSubject: Re: Camera controlled with touch   Wed 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

avatar

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

PostSubject: Re: Camera controlled with touch   Thu 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

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

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




PostSubject: Re: Camera controlled with touch   

Back to top Go down
 
Camera controlled with touch
View previous topic View next topic Back to top 
Page 1 of 1
 Similar topics
-
» Messing with camera settings: more Doom Eagles
» Korn "The Brilliant Touch in Chess" (ENG, 1966)
» Keep in Touch [SNS and Calendar Guide]
» Uwe'Boll
» Iliander's Eye-candy

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: