Jump to Main Content
Jump to Main Content

BlinkScript Distant Light Code Example



Description


This code example shows how to add a distant light. See how the light is comming from behind the Ogere head illuminating the back of the head and not the face. All the code and assets are in the projects Scripts directory. You can download the project using the link above.

PostWorld.js


// Turn on debug so that Chat.printDebug() and Chat.dump() work
Chat.debugOutput = true;

// Display the stats panel in the bottom left corner of screen
Application.statsVisible = true;

// Turn on collisions, but allow the user to turn it off
Actor.setCollisionSetting( true, false );

// Turn on gravity, but allow the user to turn it off
Actor.setGravitySetting( true, false );

// Hide the avatar
Actor.showAvatar  = false;

// Hide the chat panel
Application.chatPaneVisible = false;

// Set ambient light for the scene
Scene.ambientLightColor = Color(0.25, 0.25, 0.25, 0);

// Create the floor
var oGround = Scene.createGround( "MainFloor", "RustySteel", 3000.0, 3000.0, true );

// Add the Ogre head
oHeadEntity = Scene.createEntity( "OgreHead", "ogrehead.mesh" );
oHeadNode = Scene.createSceneNode( "OgreHeadNode" );
oHeadNode.attachObject( oHeadEntity );
oHeadNode.position = Vector( 0, 175, -500 );

// Create the Distant light
oDistantLight  = Scene.createDistantLight( "DistantLight" );

// Set the direction that the light points
// It will come from the back of the Ogres head,
// leaving the face dark and the back of the head light
oDistantLight.direction = Vector( 0, -0.5, 0.5 );


Related BlinkScript Examples
?????? ?????? ?????? ??????