Vizard 7 » Command Index » Vizard modules » viz » <viz>.addChild
7.7

<viz>.addChild

Load a model file

<viz>.addChild(  
filename  
parent = viz.WORLD  
scene = viz.MainScene  
flags = 0  
)  
filename
Filename of model
parent = viz.WORLD
viz.WORLD
viz.SCREEN
viz.ORTHO
<node3d> object
scene = viz.MainScene
If the parent is viz.WORLD or viz.SCREEN, 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.
flags = 0
Can include any combination of the following Load flags, one of the Rotate modes, and one of the Cache modes:

Load Flag

Description

viz.LOAD_ASYNC

Load the model asynchronously. See remarks below.

viz.LOAD_IGNORE_LIGHTS

Ignore all lights in the model.

viz.LOAD_IGNORE_SCENE_SETTINGS

Ignore scene settings embedded in the model.



Rotate Mode

Description

viz.ROTATE_DEFAULT

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 Mode

Description

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

This command loads the specified model from the file.

If the viz.LOAD_ASYNC flag is set, the model will be loaded asynchronously. In this case, the command will return immediately with a valid node handle. The status of the async operation can be queried using the <node3d>.getAsyncStatus command. When the async operation completes, due to either success or failure, a viz.ASYNC_EVENT will be triggered. The <vizact>.onAsyncLoad or <viztask>.waitAsyncLoad commands can be used to automatically process this event for a specified node.

Note: When loading asynchronously, most node commands will not work properly until the asynchronous operation has completed successfully.

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))

See also

<viz>.addChildFromBuffer
<vizact>.onAsyncLoad
<viztask>.waitAsyncLoad
<node3d>.getAsyncStatus