Quickredfox
Quickredfox

Reputation: 1466

In the THREE.js documentation, it says using Group is better than Object3d but why?

It says in the documentation for Object3d:

Note that this can be used for grouping objects via the .add( object ) method which adds the object as a child, however it is better to use Group for this.

But why is it better to use Group?

Upvotes: 7

Views: 2025

Answers (1)

WestLangley
WestLangley

Reputation: 104823

You may use THREE.Group or THREE.Object3D to hold a collection of objects.

It is "better" to use THREE.Group only in the sense that

(1) it may make your code more readable, and

(2) the use of THREE.Group is a hint to the renderer that the object itself is not renderable.

object instanceof THREE.Object3D; // object could be renderable (e.g., a THREE.Mesh)

object instanceof THREE.Group; // object, itself, is not renderable

three.js r.84

Upvotes: 14

Related Questions