3D Lingo Dictionary > A-B > addChild |  |

addChild

Syntax

    member(whichCastmember).node(whichParentNode).addChild(member(whichCastmember).node(whichChildNode) {,#preserveWorld})

Description

3D command; adds the node `whichChildNode` to the list of children of the node `whichParentNode`, and removes it from the list of children of its former parent. Either `node` argument can be a model, group, camera, or light. An equivalent operation would be to set the `parent` property of `whichChildNode` to `whichParentNode`.

The optional `#``preserveWorld` parameter has two possible values: `#preserveWorld` or `#preserveParent`. When the child is added with `#preserveParent` specified, the parent-relative transform of the child remains unchanged and the child jumps to that transform in the space of its new parent. The child's world transform is recalculated. When the child is added with `#preserveWorld` specified, the world transform of the child remains unchanged and the child does not jump to its transform in the space of its new parent. Its parent-relative transform is recalculated.

Examples

This statement adds the model named Tire to the list of children of the model named Car.

    member("3D").model("Car").addChild(member("3D").model("Tire"))

This statement adds the model named Bird to the list of children of the camera named MyCamera and uses the `#preserveWorld` argument to maintain Bird's world position.

    member("3D").camera("MyCamera").addChild(member("3D").model
    ("Bird"), #preserveWorld)

See also

`parent`, `addToWorld`, `removeFromWorld`