User Guide
63
ADOBE ATMOSPHERE
User Guide
For example, the following code deļ¬nes the parameters for rendering with fog:
// Set the fog color to bluish white
fog.color =[0.5, 0.6, 0.8];
// Specify quadratic drop-off with distance
// This is softer than linear fog (1)
fog.dropOff =2;
// Set the distance away that fog starts
fog.near = 1.0
// Set the distance away that the fog becomes completely opaque
fog.far = 400.0
// Now make the fog appear
fog.active = true;
For more information on the FogModel module, see the Atmosphere JavaScript API
documentation.
Adding buttons and sliders to the Atmosphere Browser
The Button and Slider modules provide methods and properties for adding controls to the
Atmosphere Browser. These controls appear in the Controls panel of the Browser.
Creating buttons and sliders allows you to add user-controlled interactivity to a world.
For example, the following code adds a toggle switch to control whether the scene uses fog
and adds a slider to control the drop-off parameter of the fog:
if (hasModule("Button")) {
// Make a toggle to activate the fog
fogToggle = Toggle("Fog").add();
fogToggle.onClick = function(state) {
fog.active = state;
}
fogToggle.state = true;
// Now make a slider to control the drop-off parameter
fogDropOff = Slider("Fog DropOff").add();
fogDropOff.integersOnly = true;
fogDropOff.range = [0,2];
fogDropOff.onChange = function(val) { fog.dropOff = val; }
fogDropOff.value = fog.dropOff;
}
For more information on the Button module and the Slider module, see the Atmosphere
JavaScript API documentation.
atmosphere.book Page 63 Wednesday, March 21, 2001 6:14 PM










