I have x many objects.
I want them all to be in the scene.
So I add them to the scene.
No problem.
But sometimes I want to refer to those objects in terms of groups.
So I make a group, add the objects to it and add that group to the scene.
Compiler doesn’t complain.
Off course, the objects were there to begin with so I can’t really tell if group adding is working.
But now I try to manipulate the objects via this new group and it doesn’t work.
When I do for instance,
thegroup.position.x-=800;
The objects of the group do not move.
But If I avoid adding the instances in the beginning.
Then I can add the group and then I can manipulate their location through the group.
Is there no way to just add all the instances to the scene.
Then define the groups?
I have a suspicion each object can only belong to one group at most. Is that the case?
Our world is full of objects.
And those objects are all in all kinds of groups.
I don’t think it is correct, to define groups by adding them to the scene.
Those are 2 different actions. Defining the group, and adding to the scene.
We should just add to the scene, what should be added to the scene.
Then define whatever groups we want to.
In the outer world objects can be in multiple groups at the same time.
So it can be confusing when people starting using threejs and the word group
doesn’t really have the same meaning anymore.
Maybe the word group should really be something like parent.
For that communicates better what it really is.
instances are purely virtual, you can’t control them like you do with normal objects.
most likely the only exception to this is drei/Instances, this abstracts instances so that each instance can be controlled as a single object, which can be grouped, nested, transformed.
in the following demo go to line 25, where it says <group position={[0, 0, 0]}> and change the y coordinate, you’ll see it. with that also the number of items can be controlled, you can add/remove instances runtime (try the slider).
this works because you’re giving <Instances> a rough estimate of how many objects you expect. it will then automatically determine how many exist and set the drawing-range so that it’s not drawing more than needed. probably doesn’t help because this uses react, but maybe it inspires you to find your own solution, certainly it’s possible if that’s the only take away.