mirror of
https://github.com/WhitestormJS/whs.js.git
synced 2025-12-08 20:26:23 +00:00
775 B
775 B
Groups
Sometimes you need to make groups of objects (it's not conveniently to apply transforms to each object when can make just one to a group). In Three.js you make it using THREE.Object3D and it's children.
In Whitestorm.js we have WHS.Group that can do it in two ways:
Adding objects to an empty group
const sphere = new WHS.Sphere();
const box = new WHS.Box();
const group = new WHS.Group();
sphere.addTo(group);
box.addTo(group);
Making a group from objects
const sphere = new WHS.Sphere();
const box = new WHS.Box();
const group = new WHS.Group(box, sphere);
// OR: const group = new WHS.Group([box, sphere]);
You can list elements in sequence or pass an array. (see es6 rest/spread).