Issue with addChild and "Error: GUID already exists in graph"

Run the example below, and check out the browser console.

You’ll see “Error: GUID already exists in graph”

It should be possible to parent this to another entity, irrespective if it is already a child of something.

Note that addChild fails with the error above, but addChildAndSaveTransform works.

addChild is used to add an entity that is not already in the hierarchy. You should use reparent() if the entity is already in the hierarchy. Or parent.removeChild() before you call addChild.

addChildAndSaveTransform() isn’t an API function so you shouldn’t use that (we will probably change it in the future)

Would it make sense for addChild to call reparent internally when it detects that a parent already exists, rather than raise the error?

Having used a number of other 3D APIs, that is the behaviour I expected.

Potentially, though it’s also useful to be aware that a child is being added twice (often incorrectly)