User Guide

312 APPENDIX E
Callbacks
suggestLocation(loc)
A SceneGroup script’s mySceneGroup.suggestLocation(loc) is called to notify the SceneGroup that it should
move to a new location (position and orientation, represented as a single Transform object). A default
(prototype) implementation of suggestLocation is provided which performs a simple linear interpolation
between the old location and the new. Avatars are moved via mySceneGroup.suggestLocation, so overriding this
with your own function allows you to provide your own method of interpolation. (The frequency with which
suggestLocation will be called for avatar motion is undefi ned, as it depends on network and other unpredictable
factors.) World scripts which create SceneGroups may also call suggestLocation on those SceneGroups. Any
such external calls are passed into the SceneGroups own script as a call to mySceneGroup.suggestLocation(loc),
which by default will envoke the prototype linear interpolation or may be overridden by the SceneGroups script.
// Save the default version which does linear interpolation:
mySceneGroup.interpolateTo = mySceneGroup.suggestLocation;
// Override with our own method which prints the
// target location for our information and then
// invokes the default linear interpolation:
mySceneGroup.suggestLocation = function(location)
{
chat.print(“Avatar has been asked to move to: “ + location);
this.interpolateTo(location);
}
Script
The Script scene element is a powerful object to causing dynamic activity in an Atmosphere world, and the purpose
for which these documents were written! The Script object itself is now exposed in the Atmosphere API, which
enables it to use it’s own properties of position, orientation, and transform when performing object movement and
other vector math. A Script also has no geometric volume, which places it’s pivot point at the exact origin. This is
useful for using a Script to specify an axis of rotation.
A very powerful new aspect of Atmosphere JavaScripts is the ability to divide the script into two sections; a top
section which is processed when the script is loaded in the Authoring Application, and a bottom section which is
processed when the script is run in the Atmosphere Player. Many scripts are included with the Atmosphere Authoring
application, and observing their code content will help greatly in understanding how the scripts are used. To aid
further, an explanation of the script workfl ow is as follows:
A top section of the script is fi rst defi ned by two custom comment lines:
//BEGIN_AUTHORING_PROPERTIES
//END_AUTHORING_PROPERTIES
Any Javascript within this top section is read and processed only when the script is added to a world, or when a saved
world is reloaded into the authoring application.