Below is a graphic timeline representation the events that are fired during the initialisation of the viewer. Most events can be fired multiple times during the initialisation. All events can be fired multiple times; the OnChorLoaded function for example will fire for every chor loaded. The OnCreate event will only fire once however, when the window is initialised and ready to be loaded up with data.

OnScriptReady
OnChorLoaded
OnModelLoaded OnModelInstanced
OnSoundLoaded
OnCreate(1x) OnActionLoaded
t=0      t=T_all_loaded   t=T_tinal

As soon as the browser has created the viewer, the viewer will fire the onCreate event. You should use this event to load all the arcticPigs files you need, to create a script object and to add models, actions or choreographies to this script. The example below loads and initialises a choreography.

<SCRIPT Language="JScript" for="arctic" event="OnCreate()">
	// Create a new script to hold the chor
	hMain = arctic.world.newScript("main")
	// Load choreography
	arctic.doc.loadChor("Motorcycle/Motorcycle.chor") 
	// Add the chor to the script
	hMain.addChoreography("Motorcycle") 
	// Start the script. This event will only fire after the script is fully initialised
	hMain.start()
</SCRIPT>

As downloads are done asynchronously, returning from a call to one of the load functions does not indicate that the model is loaded and ready for use. You need to use the load-ready events to determine if a download has completed. For more information read the Asynchronous Downloads article.
A choreography references external models and actions. Loading a chor file will also start the downloads for all the referenced files. When each of these files has finished loading, they will fire their respective load-ready event (either onActionLoaded, onModelLoaded or onSoundLoaded). Generally you would not use this event unless you want to give some user feedback over the downloading progress.
It is through adding the choreography to the script that a 3D scene gets built. From the loaded model files renderable 3D models are built. These are denoted by the term 'model instance' throughout the documentation. As soon as a model instance is ready to be used in the 3D scene, the onModelInstanced event gets fired. You can use this event to attach handlers for mouse over events to the various groups of the model instance, or to activate certain poses on the model etc. Have a look at the Movie Player script example for more information on using the onModelInstanced event.

As soon as all model instances that are created through the choreography are fully initialised, the onScriptReady event is fired. If you have called the script::start command at any point, the scene will start animating immediately following the onScriptReady event.

 

©2000 arcticpigs. All rights reserved.
This is a draft version! The functionality of parts of the software are liable to change.