29,99 €
Three.js has become the industry standard for creating stunning 3D WebGL content. In this edition, you’ll learn about all the features of Three.js and understand how to integrate it with the newest physics engines. You'll also develop a strong grip on creating and animating immersive 3D scenes directly in your browser, reaping the full potential of WebGL and modern browsers.
The book starts with the basic concepts and building blocks used in Three.js and helps you explore these essential topics in detail through extensive examples and code samples. You'll learn how to create realistic-looking 3D objects using textures and materials and how to load existing models from an external source. Next, you'll understand how to control the camera using the Three.js built-in camera controls, which will enable you to fly or walk around the 3D scene you've created. Later chapters will cover the use of HTML5 video and canvas elements as materials for your 3D objects to animate your models. You’ll learn how to use morph targets and skeleton-based animation, before understanding how to add physics, such as gravity and collision detection, to your scene. Finally, you’ll master combining Blender with Three.js and creating VR and AR scenes.
By the end of this book, you'll be well-equipped to create 3D-animated graphics using Three.js.
Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:
Seitenzahl: 485
Veröffentlichungsjahr: 2023
Program 3D animations and visualizations for the web with JavaScript and WebGL
Jos Dirksen
BIRMINGHAM—MUMBAI
Copyright © 2023 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
Group Product Manager: Pavan Ramchandani
Publishing Product Manager: Bhavya Rao
Senior Editor: Mark Dsouza
Senior Content Development Editor: Rashi Dubey
Technical Editor: Simran Udasi
Copy Editor: Safis Editing
Project Coordinator: Sonam Pandey
Proofreader: Safis Editing
Indexer: Tejal Daruwale Soni
Production Designer: Vijay Kamble
Marketing Coordinator: Anamika Singh
First published: October 2013
Second edition: March 2015
Third edition: August 2018
Fourth edition: February 2023
Production reference: 1170123
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.
ISBN 978-1-80323-387-1
www.packt.com
To the memory of my father, who has been the best dad to me, an awesome grandfather to Sophie and Amber, and the kindest person I’ve ever known.
– Jos Dirksen
Jos Dirksen has worked as a software developer and architect for almost two decades. He has a lot of experience with a large range of technologies, ranging from backend technologies, such as Java, Kotlin, and Scala, to frontend development using HTML5, CSS, JavaScript, and TypeScript. 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.
He is currently working as a freelance full-stack engineer on various Scala and TypeScript projects.
Previously, Jos worked in many different roles in the private and public sectors, ranging from private companies such as ING, ASML, Malmberg, and Philips to organizations in the public sector, such as the Department of Defense and the Port of Rotterdam.
I want to thank the people who have supported me during writing this book. Especially my wife Brigitte, for always being there for me, and my mother Gerdie, who is always there to help us out!
George Oscar Eugene Campbell has been in the industry since 2017 as a JavaScript developer. He’s experienced in Three.js, Next.js, and TypeScript. He loves the natural creativity that programming offers and exploring the artistic side of things.
John Cotterell has been working as a frontend creative developer for 20 years now. He specializes in Three.js development, as well as AR, VR, and accompanying web technologies. More recently, he has spent time finding his way around the web audio API, GLSL, and the newer WebGPU standard, and is currently working on his first commercial game.
He lives in Bedford, UK, and when he’s not playing or developing games, he likes to spend his free time visiting art galleries with his daughter, Shannon.
Mrunal Sawant is a highly proficient individual who has worked extensively with Three.js to develop different visualization projects.
He completed his master’s in industrial mathematics with computer applications.
He is a skilled professional in the area of 3D visualization, CAD/BIM, and data interoperability (CAD data exchange).
Mrunal highly values his career and lives up to his motto “Work hard and play hard” by staying active doing sports and traveling around the country.
In the first part, we’ll introduce the basic concepts of Three.js and make sure you’ve got all the information to get up and running. We’ll start by setting up your development environment, and in the following chapters, explore some of the core concepts that make up Three.js.
In this part, there are the following chapters:
Chapter 1, Creating Your First 3D Scene with Three.jsChapter 2, The Basic Components that Make up a Three.js ApplicationChapter 3, Working with Light Sources in Three.jsIn the previous chapter, you learned about the basics of Three.js. We looked at a couple of examples, and you created your first complete Three.js application. In this chapter, we’ll dive a bit deeper into Three.js and explain the basic components that make up a Three.js application.
By the end of this chapter, you’ll have learned how to use the basic components that are used in every Three.js application and should be able to create simple scenes using these standard components. You should also feel comfortable working with Three.js applications that use the more advanced objects, since the approach used by Three.js for simple and advanced components is the same.
In this chapter, we will cover the following topics:
Creating a sceneHow geometries and meshes are relatedUsing different cameras for different scenesWe’ll start by looking at how you can create a scene and add objects.
In Chapter 1, Creating Your First 3D Scene with Three.js, you created a THREE.Scene, so you already know some of the basics of Three.js. We saw that for a scene to show anything, we need four different types of objects:
Camera: This determines which part of THREE.Scene is rendered onscreen.Lights: These have an effect on how materials are shown and are used when creating shadow effects (discussed in detail in Chapter 3, Working with Light Sources in Three.js).Meshes: These are the main objects that are rendered from the perspective of the camera. These objects contain the vertices and faces that make up the geometry (for example, a sphere or a cube) and contain a material, which defines what the geometry looks like.Renderer: This uses the camera and the information in the scene to draw (render) the output on the screen.THREE.Scene
