Book Image

Three.js Cookbook

By : Jos Dirksen
Book Image

Three.js Cookbook

By: Jos Dirksen

Overview of this book

Table of Contents (15 chapters)
Three.js Cookbook
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Exploding a point cloud


You can create many interesting effects with point clouds. You can, for instance, create water, smoke, and cloud effects. In this recipe, we show you another interesting effect you can create with points. We'll show you how you can explode a point cloud where each point's path is based on its normal vector.

Getting ready

For this recipe, there aren't any steps that need to be taken before we start looking at the recipe. We've provided an example where you can see the resulting explosion in action. Open the 06.06-explode-geometry.html example in your browser and you'll see a screen that looks like the following screenshot:

If you click on the implode button, the points will move to the middle of the screen; if you click on explode, they'll move outwards. With the speed property, you can set the speed at which the points will move.

How to do it…

To accomplish this effect, you only need to perform a couple of small steps:

  1. The first thing we need to do is create the geometry...