Applying matrix transformations

In the first couple of recipes in this chapter, we used the rotation property and applied translations to get the desired rotational effect. Behind the scenes, Three.js uses matrix transformations to modify the shape and position of the mesh or the geometry. Three.js also provides the functionality to apply custom matrix transformations directly to a geometry or a mesh. In this recipe, we'll show you how you can apply your own custom matrix transformations directly to a Three.js object.

Getting ready

To view this recipe in action and experiment with the various transformations, open the 02.15-apply-matrix-transformations.html example in your browser. You'll be presented with the following simple Three.js scene:

In ...

Get Three.js Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.