I am creating an Elevator using TypeScript. The elevator car (the part that moves up and down) is comprised of many objects, including (but not limited to) the inner doors, the walls, the control panel, the overhead light, and more.
I would prefer to declare this set of items in my Scene rather than in my code.
So, I created a Group to house all the items that I want. This group now has a unique item ID, so I’d like to select all child items of the group and make them move.
Here, this.carGroup
is my group of items.
this.carGroup.children.toArray().forEach(item => {
item.transition.moveBy(new Vector3(0, newHeight - oldHeight, 0), Math.abs(newHeight - oldHeight) / this.speeds[0]);
});
However, it appears that children
might not be the correct keyword to get a group item’s children. This is evident because my browser console outputted an error reading:
TypeError: Cannot read properties of
undefined
(reading0
)
classes.js:25
ateval
(play/EV.js:94:128
)
classes.js:25
atArray.forEach
(<anonymous>
)
classes.js:25
atElevator.upFloor
(play/EV.js:93:46
)
So how can I identify and act upon a set of multiple objects at once? Is a group the correct way?
Keep in mind that I would prefer to define this group of objects in my Scene rather than in my code. Listing all item object IDs of each object individually is to be avoided.