Learning Three.js: The JavaScript 3D Library for WebGL


Learning Three.js: The JavaScript 3D Library for WebGL
eBook: $29.99
Formats: PDF, PacktLib, ePub and Mobi formats
$25.49
save 15%!
Print + free eBook + free PacktLib access to the book: $79.98    Print cover: $49.99
$49.99
save 37%!
Free Shipping!
UK, US, Europe and selected countries in Asia.
Also available on:
Overview
Table of Contents
Author
Support
Sample Chapters
  • Create and animate beautiful 3D graphics directly in the browser using JavaScript without the need to learn WebGL
  • Learn how to enhance your 3D graphics with light sources, shadows, and advanced materials and textures
  • Each subject is explained using extensive examples that you can directly use and adapt for your own purposes

Book Details

Language : English
Paperback : 402 pages [ 235mm x 191mm ]
Release Date : October 2013
ISBN : 1782166289
ISBN 13 : 9781782166283
Author(s) : Jos Dirksen
Topics and Technologies : All Books, Web Development, Open Source

Table of Contents

Preface
Chapter 1: Creating Your First 3D Scene with Three.js
Chapter 2: Working with the Basic Components That Make Up a Three.js Scene
Chapter 3: Working with the Different Light Sources Available in Three.js
Chapter 4: Working with the Three.js Materials
Chapter 5: Learning to Work with Geometries
Chapter 6: Using Advanced Geometries and Binary Operations
Chapter 7: Particles and the Particle System
Chapter 8: Creating and Loading Advanced Meshes and Geometries
Chapter 9: Animations and Moving the Camera
Chapter 10: Loading and Working with Textures
Chapter 11: Custom Shaders and Render Post Processing
Chapter 12: Adding Physics to Your Scene with Physijs
Index
  • Chapter 1: Creating Your First 3D Scene with Three.js
    • Requirements for using Three.js
    • Getting the source code
      • Using Git to clone the repository
      • Downloading and extracting the archive
      • Testing the examples
        • Python-based approach should work on most Unix/Mac systems
        • NPM-based approach if you've got Node.js installed
        • Portable version of Mongoose for Mac/Windows
    • Creating an HTML skeleton page
    • Rendering and viewing a 3D object
    • Adding materials, lights, and shadows
    • Expanding your first scene with animations
      • Introducing the requestAnimationFrame() method
      • Animating the cube
      • Bouncing the ball
    • Using the dat.GUI library to make experimenting easier
    • Using the ASCII effect
    • Summary
    • Chapter 2: Working with the Basic Components That Make Up a Three.js Scene
      • Creating a scene
        • Basic functionality of the scene
        • Adding the fog effect to the scene
        • Using the overrideMaterial property
      • Working with the Geometry and Mesh objects
        • The properties and functions of a geometry
        • The functions and attributes for a mesh
      • Using the available cameras for different uses
        • The orthographic camera versus the perspective camera
        • Focusing the camera on a specific point
      • Summary
      • Chapter 3: Working with the Different Light Sources Available in Three.js
        • Exploring the lights provided by Three.js
        • Learning about the basic lights
          • AmbientLight – a globally applied light source
            • Using the THREE.Color() object
          • PointLight – the light that shines in all directions
          • SpotLight – the light with a cone effect
          • DirectionalLight – for a far away sun-like light source
          • Using special lights for advanced lighting
            • HemisphereLight
            • AreaLight
            • LensFlare
        • Summary
        • Chapter 4: Working with the Three.js Materials
          • Understanding the common material properties
            • Basic properties
            • Blending properties
            • Advanced properties
          • Starting with the simple Mesh materials (basic, depth, and face)
            • The MeshBasicMaterial for simple surfaces
            • The MeshDepthMaterial for depth-based coloring
            • Combining the materials
            • The MeshNormalMaterial for normal-based colors
            • The MeshFaceMaterial for assigning a material to each face
          • Learning about the advanced materials
            • The MeshLambertMaterial for dull, non-shiny surfaces
            • The MeshPhongMaterial for shiny objects
            • Creating your own shaders with the ShaderMaterial
          • Using the materials for a line geometry
            • The LineBasicMaterial
            • The LineDashedMaterial
          • Summary
          • Chapter 5: Learning to Work with Geometries
            • The basic geometries provided by Three.js
              • Two-dimensional geometries
                • PlaneGeometry
                • CircleGeometry
                • ShapeGeometry
              • Three-dimensional geometries
                • CubeGeometry
                • SphereGeometry
                • CylinderGeometry
                • TorusGeometry
                • TorusKnotGeometry
                • PolyhedronGeometry
            • Summary
            • Chapter 6: Using Advanced Geometries and Binary Operations
              • ConvexGeometry
              • LatheGeometry
              • Create a geometry by extruding
                • ExtrudeGeometry
                • TubeGeometry
                • Extrude from SVG
                • ParametricGeometry
              • Creating 3D text
                • Rendering text
                • Adding custom fonts
              • Using binary operations to combine meshes
                • The subtract function
                • The intersect function
                • The union function
              • Summary
              • Chapter 7: Particles and the Particle System
                • Understanding particles
                • Particles, the particle system, and the BasicParticleMaterial
                • Styling particles with the HTML5 canvas
                  • Using HTML5 canvas with the CanvasRenderer class
                  • Using HTML5 canvas with the WebGLRenderer class
                • Using textures to style particles
                  • Working with sprites
                • Creating a particle system from an advanced geometry
                • Summary
                • Chapter 8: Creating and Loading Advanced Meshes and Geometries
                  • Geometry grouping and merging
                    • Grouping objects together
                    • Merging multiple meshes into a single mesh
                    • Loading geometries from external resources
                    • Saving and loading in Three.js JSON format
                      • Saving and loading a geometry
                      • Saving and loading a scene
                    • Working with Blender
                      • Installing the Three.js exporter in Blender
                      • Loading and exporting a model from Blender
                    • Importing from 3D file formats
                      • OBJ and MTL format
                      • Loading a collada model
                      • Loading STL, CTM, and VTK models
                      • Showing proteins from the protein databank
                      • Creating a particle system from a PLY model
                  • Summary
                  • Chapter 9: Animations and Moving the Camera
                    • Basic animations
                      • Simple animations
                      • Selecting objects
                      • Animating with Tween.js
                    • Working with the camera
                      • TrackballControls
                      • FlyControls
                      • RollControls
                      • FirstPersonControls
                      • OrbitControl
                      • PathControl
                    • Morphing and skeletal animation
                      • Animation with morph targets
                        • Animation with MorphAnimMesh
                        • Creating an animation by setting the morphTargetInfluence property
                      • Animation using bones and skinning
                    • Creating animations using external models
                      • Creating bones animation using Blender
                      • Loading an animation from a collada model
                      • Animation loaded from a Quake model
                    • Summary
                    • Chapter 10: Loading and Working with Textures
                      • Using textures in materials
                        • Loading a texture and applying it to mesh
                        • Using a bump map to create wrinkles
                        • Using more detailed bumps and wrinkles with a normal map
                        • Creating fake shadows using a light map
                        • Creating fake reflections using an environment map
                        • Specular map
                      • Advanced usage of textures
                        • Custom UV mapping
                        • Repeat wrapping
                        • Rendering to canvas and using it as a texture
                          • Using canvas as a texture
                          • Using canvas as a bump map
                          • Using the output from a video as a texture
                      • Summary
                      • Chapter 11: Custom Shaders and Render Post Processing
                        • Setting up the post processing
                          • Creating the EffectComposer object
                            • Configuring the EffectComposer object for post processing
                            • Updating the render loop
                        • Post processing passes
                          • Simple post processing passes
                            • Using the FilmPass to create a TV-like effect
                            • Adding a bloom effect to the scene with the BloomPass
                            • Outputting the scene as a set of dots with the DotScreenPass
                            • Showing the output of multiple renderers on the same screen
                          • Advanced EffectComposer flows by using masks
                          • Using the ShaderPass for custom effects
                            • Simple shaders
                            • Blurring shaders
                            • Advanced shaders
                        • Creating custom post processing shaders
                          • Custom grayscale shader
                          • Creating a custom bit shader
                        • Summary
                        • Chapter 12: Adding Physics to Your Scene with Physijs
                          • Creating a basic Three.js scene ready for Physijs
                          • Material properties
                          • Basic supported shapes
                          • Using constraints to limit movement of objects
                            • Using PointConstraint to limit movement between two points
                            • Creating door-like constraints with a HingeConstraint
                            • Limiting movement to a single axis with a SliderConstraint
                            • Creating a ball joint-like constraint with the ConeTwist Constraint
                            • Creating detailed control with the DOFConstraint
                          • Summary

                          Jos Dirksen

                          Jos Dirksen has worked as a Software Developer and Architect for more than a decade. He has much experience in a large range of technologies ranging from backend technologies, such as Java and Scala, to frontend development using HTML5, CSS, and JavaScript. Besides working with these technologies, Jos also regularly speaks at conferences and likes to write about new and interesting technologies on his blog. He also likes to experiment with new technologies and see how they can best be used to create beautiful data visualizations, the results of which you can see on his blog at http://www.smartjava.org/. Jos is currently working as an Enterprise Architect for Malmberg, a large Dutch publisher of educational material. He is helping to create a new digital platform for the creation and publishing of educational content for primary, secondary, and vocational education. Previously, Jos has worked in many different roles in the private and public sectors, ranging from private companies such as Philips and ASML to organizations in the public sector, such as the Department of Defense. Besides his interest in frontend JavaScript and HTML5 technologies, he is also interested in backend service development using REST and traditional web service technologies. Jos has already written two books on this subject. He is the coauthor of the Open Source ESBs in action book that was published in 2008, and in 2012 he published a book on how to apply SOA Governance in a practical manner. This book is titled SOA Governance in Action.
                          Sorry, we don't have any reviews for this title yet.

                          Code Downloads

                          Download the code and support files for this book.


                          Submit Errata

                          Please let us know if you have found any errors not listed on this list by completing our errata submission form. Our editors will check them and add them to this list. Thank you.


                          Errata

                          - 1 submitted: last submission 11 Feb 2014

                          The following points are related to the newer version of Three.js

                          Chapter 1

                          * current version of THREE has no method called AsciiEffect. It is a separate module.

                          * setClearColorHex function is being deprecated and replaced by setClearColor

                          Sample chapters

                          You can view our sample chapters and prefaces of this title on PacktLib or download sample chapters in PDF format.

                          Frequently bought together

                          Learning Three.js: The JavaScript 3D Library for WebGL +    Oracle Enterprise Manager Cloud Control 12c: Managing Data Center Chaos =
                          50% Off
                          the second eBook
                          Price for both: $48.15

                          Buy both these recommended eBooks together and get 50% off the cheapest eBook.

                          What you will learn from this book

                          • Create standard HTML skeleton and render loops for your Three.js projects
                          • Learn how to use the different geometries that are provided by Three.js
                          • Apply realistic lighting and shadows to the 3D objects you have created
                          • Learn how the different types of materials in Three.js work and how they interact with your 3D objects and the rest of the environment
                          • Use the different camera controls provided by Three.js to effortlessly navigate around your 3D scene
                          • Work with a particle system to create snow, rain, and galaxy-like effects
                          • Import and animate models from external formats such as OBJ, STL, Collada, and much more
                          • Create and run animations using either morph targets or bones animations
                          • Use advanced textures on materials to create realistic looking 3D objects using bump maps, normal maps, specular maps, and light maps
                          • Change the output of Three.js rendered using one of its post processing options
                          • Interact directly with WebGL by creating custom vertex and fragment shaders
                          • Apply physics to your 3D objects using the Physijs JavaScript library

                          In Detail

                          Three.js is a JavaScript 3D library that offers a wide range of features for creating and displaying stunning 3D computer graphics on a web browser in an intuitive manner using JavaScript without having to deal with the complexity of a WebGL low-level API. Even though WebGL makes it possible to create 3D graphics in the browser without having to use plugins, programming WebGL, however, is hard and complex. This book shows you how Three.js allows you to be independent of browser plugins.

                          If you are an experienced web designer who wants to set the tone for an immersive design environment in your applications then this book is for you.

                          "Learning Three.js: The JavaScript 3D Library for WebGL" is a practical, example-rich book that will help you to master all the features of Three.js. With this book, you’ll learn how to create and animate gorgeous looking 3D scenes directly in your browser utilizing the full potential of WebGL and modern browsers without having to learn WebGL.

                          "Learning Three.js: The JavaScript 3D Library for WebGL" starts by going over the basic concepts and building blocks used in Three.js. From there on, it will expand on these subjects using extensive examples and code samples. This will allow you to learn everything you need to know about Three.js in an easy and interactive manner.

                          Besides the basic concepts, this book will show you how you can create realistic looking 3D objects using materials and textures as well as how to load them from externally created models. You’ll learn how to easily control the camera using the Three.js build-in camera controls so you can fly or walk around the 3D scene you have created. You will also learn how to use morph and bones-based animation and how to add physics to your scene.

                          After reading Learning Three.js: The JavaScript 3D Library for WebGL and playing around with the extensive set of examples, you’ll know everything that is required to create 3D animating graphics using Three.js that run in any browser.

                          Approach

                          This book contains an extensive set of practical examples and an easy-to-follow approach to creating 3D objects.

                          Who this book is for

                          This book is great for anyone who already knows JavaScript and who wants to start creating 3D graphics that run in any browser. You don’t need to know anything about advanced math or WebGL; all that is needed is a general knowledge of JavaScript and HTML. The required materials and examples can be freely downloaded and all tools used in this book are open source.

                          Code Download and Errata
                          Packt Anytime, Anywhere
                          Register Books
                          Print Upgrades
                          eBook Downloads
                          Video Support
                          Contact Us
                          Awards Voting Nominations Previous Winners
                          Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
                          Resources
                          Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software