How three.js dealing with scene graph when we directly change parent property?

Viewed 19

I saw Three.js Object3D.parent property is just a plain property (not a getter setter);

So when I change the property like object.parent = anotherObject, How did Three.js manage its bi-direction dependencies parent-child then?

Is it allowed for doing that?
If not then why typedef still allows me to do so?

1 Answers

Why object3D is required to expose the parent property?

The reason is very simple I just didn't realised.

Basically Scene and Object3D is the setter of the Object3D.parent property, So it need to be public.

Three.js user must acknowledge that they can't directly change this property.

The only solution to hide the property out from typescript is using an interface.
For example IObject3D, But would increase a lot of complexity so obviously not worth do it.

Related