<viz>.addChild

Load a model file

 

<viz>.addChild(
    filename    
    parent = viz.WORLD    
    scene = viz.MainScene    
    rotate = viz.AUTO_COMPUTE    
    cache = viz.CACHE_DEFAULT    

)

 

filename

Filename of model


parent = viz.WORLD

viz.WORLD
viz.SCREEN
viz.HEAD
viz.ORTHO
<node3d> object


scene = viz.MainScene

If the parent is viz.WORLD, viz.SCREEN, or viz.HEAD, then the argument represents the scene to add the object to.
If the parent is viz.ORTHO, then the argument represents the window to add the object to.
If the parent is a valid node3d object, then the argument is ignored.


rotate = viz.AUTO_COMPUTE

Specifies which coordinate frame to rotate the model from. Can be one of the following values:

Rotate mode

viz.AUTO_COMPUTE

Automatically detect the coordinate frame based on the file type.

viz.ROTATE_NONE

Do not rotate the model.

viz.ROTATE_Y_UP

Rotate the model from a Y-up coordinate frame.

viz.ROTATE_Z_UP

Rotate the model from a Z-up coordinate frame.


cache = viz.CACHE_DEFAULT

One of the following cache modes:

Cache mode

viz.CACHE_DEFAULT

Use the default cache mode specified in the 'viz.model.cache' option. The default value of the option is viz.CACHE_NONE.

viz.CACHE_NONE

Do not use the cache and load the model from disk.

viz.CACHE_COPY

If the file has been loaded, return a copy, otherwise add the loaded model to the cache.

viz.CACHE_CLONE

If the file has been loaded, return a clone, otherwise add the loaded model to the cache.


Remarks

The cordinate [0,0,0] for a child object is the center of it's parent object.

Return Value

<node3d> object.

Example

sun = viz.add('white_ball.wrl')
earth = viz.addChild('white_ball.wrl', parent=sun)
moon = viz.addChild('white_ball.wrl', parent=earth)
sun.color(viz.YELLOW)
earth.color(viz.BLUE)
moon.color(viz.GRAY)

sun.setPosition(0,1.5,10)
earth.setPosition(0,3,0)
moon.setPosition(0,1,0)
sun.addAction(vizact.spin(0,0,1,8))
earth.addAction(vizact.spin(0,0,1,64))