| | Camera controlled with touch | |
| | Author | Message |
---|
phaidonas
Posts : 24 Points : 32 Reputation : 0 Join date : 2017-02-07
| Subject: 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(); | |
| | | SamCorny
Posts : 40 Points : 56 Reputation : 0 Join date : 2017-02-06 Location : NYC
| Subject: 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? | |
| | | phaidonas
Posts : 24 Points : 32 Reputation : 0 Join date : 2017-02-07
| Subject: 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 | |
| | | SamCorny
Posts : 40 Points : 56 Reputation : 0 Join date : 2017-02-06 Location : NYC
| Subject: 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? | |
| | | phaidonas
Posts : 24 Points : 32 Reputation : 0 Join date : 2017-02-07
| Subject: 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? | |
| | | SamCorny
Posts : 40 Points : 56 Reputation : 0 Join date : 2017-02-06 Location : NYC
| Subject: 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 | |
| | | phaidonas
Posts : 24 Points : 32 Reputation : 0 Join date : 2017-02-07
| Subject: Re: Camera controlled with touch Sat Feb 25, 2017 12:11 pm | |
| Arent the the touchpad the same with touch of mobiles? | |
| | | Sponsored content
| Subject: Re: Camera controlled with touch | |
| |
| | | | Camera controlled with touch | |
|
| Permissions in this forum: | You cannot reply to topics in this forum
| |
| |
| Our first goal | Mon Feb 27, 2017 10:12 am by Admin | More than 20 users,
almost 150 posts,
a new big project is coming,
about …
| Comments: 0 |
Forum changements | Tue Feb 21, 2017 6:10 pm by Admin | Dear members,
I have personally made some changements into the forum, now …
| Comments: 2 |
A new revision of the forum rules | Tue Feb 07, 2017 9:40 pm by Admin | Dear Members,
it is my pleasure to tell you below all the new functions I …
| Comments: 0 |
Top posting users this week | |
|