Tutorial & Videos

HTML5 3D Basics

What we’ll cover in this chapter:

  • The third dimension and perspective
  • Velocity and acceleration
  • Bouncing
  • Gravity
  • Wrapping
  • Easing and springing
  • Coordinate rotation
  • Collision detection

Up to now, everything in this book has been in just two (and sometimes only one) dimensions, and you’ve created some pretty interesting animations. Now, let’s take it to the next level. Creating graphics in 3D is exciting because the extra dimension seems to make things really come to life. We move through the basics of programming 3D fairly quickly, and after that, we’ll see how the motion
effects discussed in the previous chapters can be done with a third dimension. Specifically, this chapter covers velocity, acceleration, friction, gravity, bouncing, wrapping, easing, springing, coordinate rotation, and collision detection. For now, you are primarily concerned with taking an object and moving it around in 3D space, using perspective to calculate its size and position on the screen. The object we draw is flat, of course. It won’t have a back, side, top, or bottom that you can see. Over the next couple of chapters, you do some modeling of points, lines, shapes, and solids in 3D. It’s worth mentioning there is currently, at the time of writing, a 3D specification in development for the canvas element, called WebGL. However, it is not considered part of the HTML5 specification, and is not supported across all the major web browsers at this time (and it is not known if it ever will be). WebGL is, by design, a low-level means to execute code on the computer’s graphics card. Although WebGL is a powerful way to run hardware-accelerated graphics in the browser, it’s rather advanced and uses JavaScript more as a way to tie together other programs, called shaders, which are written in a separate shader language and are compiled when the browser loads the document. But WebGL could provide the foundation for the next generation of web-based graphics, on which other, easier to use, libraries and 3Dengines are built. There are still a number of issues facing its broad adoption by all browsers, but it does offer a glimpse into the future of graphics and games on the web.

Comments on: "HTML5 3D Basics" (2)

  1. Arrived at your blog through Digg. You already know I will be subscribing to your rss.

  2. I would really like to say thanks such a lot of for that work you have made in writing this posting. I am hoping the same most effective work by you later on also.

Leave a comment