Skyline WEB-side development 4-- Add an event

skyline has a lot of built-in events can be called today to introduce several common events

A, Open () 

Opens the specified project

//初始化加载TerraExplorer工程
$(window).load(function() {
    try {
        var flyPath = "C:\\Users\\admin\\Desktop\\SkyglobeLB.fly";
        sgworld.AttachEvent("OnLoadFinished", OnProjectLoadFinished);
        sgworld.Project.Open(flyPath);
    } catch(ex) {
        addLog(ex.message);
    }
});

二、OnProjectLoadFinished()

After we execute the Open method SGWorld, loading FLY complete a project, it will trigger this event.

In other words, through this event we can determine at what time to complete loading FLY project, then we can say the words "Hello World!" Or, go perform some other operations in this event function, such as fly a place, on or off individual layers and so on.

// load event 
function OnProjectLoadFinished () {
     // the default fly to a certain location 
    var Washington = sgworld.Creator.CreatePosition (
         116.3912630081 ,
         39.9074812817 ,
         1000 ,
         0 ,
         0.0, // yaw angle 
        -43.0); // pitch angle 
    sgworld .Navigate.FlyTo (Washington); 
  Alert ( "the Hello World!"); }

 Three, OnFrame ()

Transmission frame is rendered prior to the event, allowing the client to perform operations in the frame motion mode (e.g., ground moving objects). Each frame move would trigger this method.

// add an event 
sgworld.AttachEvent ( "OnFrame" , OnFrame);
 // call 
function OnFrame () {
     IF (Lable =! Null ) { 
        lable.Position = lable.Position.Move (100, -90, $ ( " #pitch " ) .val ()); 
    } 
}

Four, OnLButtonClicked ()

Fires when the user clicks the left mouse button

// Register the left mouse button click event 
sgworld.AttachEvent ( "OnLButtonClicked" , OnLButtonClicked);
 // left mouse button click event 
function OnLButtonClicked (Flags, the X-, the Y-) { 
    Alert (Flags + "===" the X-+ + "= == "+ the Y); 
} 
// the Flags, define various combination is pressed, 
/ * MK_LBUTTON. 1 = 
MK_RBUTTON = 2 
MK_SHIFT. 4 = 
MK_CONTROL =. 8 
MK_MBUTTON = 16 
* / 
// X-coordinates X, mouse. Coordinates into screen coordinates, starting top left corner of the 3D window coordinates 
// the Y-, the Y-coordinates of the mouse. Coordinates into screen coordinates, the three-dimensional coordinates of the upper left corner of the window to start

Five, OnLButtonDblClk ()

Event is triggered when the user double-click the left mouse button

And four, OnLButtonClicked () similar

 

Six, OnLButtonDown ()

Event is triggered when the user presses the left mouse button

And four, OnLButtonClicked () similar

 

Seven, OnLButtonUp ()

Event is triggered when the user releases the mouse button

And four, OnLButtonClicked () similar

 

Eight, OnMButtonDblClk ()

Event is triggered when the user double-clicking the middle mouse button

And four, OnLButtonClicked () similar

 

Nine, OnMButtonDown ()

Event is triggered when the user presses the mouse button

And four, OnLButtonClicked () similar

 

Ten, OnMButtonUp ()

Event is triggered when the user releases the mouse button

And four, OnLButtonClicked () similar

 

Guess you like

Origin www.cnblogs.com/517chen/p/11179572.html