LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-13-2013, 09:18 PM   #1
ButterflyMelissa
Senior Member
 
Registered: Nov 2007
Location: Somewhere on my hard drive...
Distribution: Manjaro
Posts: 2,766
Blog Entries: 23

Rep: Reputation: 411Reputation: 411Reputation: 411Reputation: 411Reputation: 411
Post Three.js and camera rollover


Hey Gang!
Okay, I'm making (duh) a something, using Three.js. So far, I've been able to import a landscape (collada) and set up a skybox. With he mouse I control the rotation of the player, this angle gets stored. I use that to calculate the next X/Y position of the player as (s)he moves forward, using Trigonometry.
As I move the mouse, I read the angle of the camera, it's in Radians, so I convert it. That all seems to work, however, the camera either keeps adding the angle (to 700° - that's not even an angle anymore) or comes up with negative numbers. At one try, it even only counted up to 180 and reset its count...
I use the perspective camera in Three.js...
This is the function I use to read the camera's angle...

Quote:
function MouseMove(evt)
{
if(mousestatus == "down")
{
//console.log("cammove");
var deltaX = evt.clientX - intMousePosX;
var deltaY = evt.clientY - intMousePosY;
TheCamera.rotation.y += deltaX / 100;
fltCamAngle = RadToDeg(TheCamera.rotation.y);
if(fltCamAngle>360)
{
fltCamAngle = fltCamAngle - 360;
}
if(fltCamAngle<0)
{
fltCamAngle = Math.abs(fltCamAngle);
}
intMousePosX = evt.clientX;
intMousePosY = evt.clientY;
}
}
Thanks for any help.
Maybe I'd better use the trackball controlls or so, but I was'nt able to get that working...
Thunder
 
Old 11-09-2015, 12:39 PM   #2
ButterflyMelissa
Senior Member
 
Registered: Nov 2007
Location: Somewhere on my hard drive...
Distribution: Manjaro
Posts: 2,766

Original Poster
Blog Entries: 23

Rep: Reputation: 411Reputation: 411Reputation: 411Reputation: 411Reputation: 411
Solved...
Simply had to figure out the quadrants...
Works like a charm now...
More than two years now... wow...
Melissa
(what? I singed with..."thunder"??? LOL)
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Consistent Reproducing of DayLightSavings rollover jak4 Linux - Newbie 0 06-21-2012 06:12 AM
[SOLVED] javascript rollover issue frieza Programming 1 06-06-2011 01:25 PM
Web Browser Mouse Rollover Effect Woodsman Linux - Software 4 02-06-2011 04:15 PM
mouse cursor edge rollover effect exodist Linux - Software 3 09-22-2008 12:28 AM
Rollover to db9 rkemp Linux - Networking 0 12-20-2004 12:43 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:50 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration