Jump to content
  • Advertisement
Sign in to follow this  
ChrisHemmens

Working out angles and perspective with JavaScript

This topic is 2634 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi I'm stuck stuck with something and am just hoping that someone actually paid attention in math.

I'm making a 3D camera/map system 100% DOM/CSS/JavaScript, no Canvas needed. The plan is to work out x,y,z coordinates and the way the camera views the map, but I just can't get my head around it.

Here's how it works.

I have a player. The player has an x, y and z coordinate. He also has a viewing distance setting that allows him to see less or more depending on system performance. With this information I then set his camera on the map. The camera is basically the screen that he is looking though. Like in any other game.

The camera has to be able to change pitch and rotate around.

To create a 3D effect I have a few options:
Either use WebGL (uses canvas)
use http://wxs.ca/js3d/ (sort of the direction I'm going in but only uses flat surfaces)
or make an object generator that can turn triangles into 3d objects. How this is done I'll explain with a picture:




system.png




I then use a map and camera system.





system2.png

My problem is I can't for the life of me work out how I'm supposed to work out the perspective, camera rotation and a lot of other things. If anyone would happen to know how to do this or have a link that can explain things I'd really appreciate it.

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!