Book Image

Learning Three.js - the JavaScript 3D Library for WebGL

By : Jos Dirksen
Book Image

Learning Three.js - the JavaScript 3D Library for WebGL

By: Jos Dirksen

Overview of this book

Table of Contents (20 chapters)
Learning Three.js – the JavaScript 3D Library for WebGL Second Edition
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
8
Creating and Loading Advanced Meshes and Geometries
Index

Using constraints to limit movement of objects


Until now, we've seen some basic physics in action. We've seen how the various shapes respond to gravity, friction, and restitution and how they affect collisions. Physijs also provides advanced constructs that allow you to limit the movement of your objects. In Physijs, these objects are called constraints. The following table gives an overview of the constraints that are available in Physijs:

Constraint

Description

PointConstraint

This allows you to fix the position of one object to the position of another object. If one object moves, the other will move with it, keeping the distance and orientation between them the same.

HingeConstraint

HingeConstraint allows you to limit the movement of an object as if it were on a hinge, such as a door.

SliderConstraint

This constraint, as the name implies, allows you to limit the movement of an object to a single axis, for instance, a sliding door.

ConeTwistConstraint

With this constraint...