• SkylineGlobe7.0.1版本 通过鼠标左右平移模型对象


    帮同事写了一段测试代码,如下:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>MoveObject</title>
        
         <script type = "text/javascript" language = "javascript">
             function Init() {
                 try{
                     var SGWorld = new CreateSGObj();                 
                     SGWorld.Open("C:\Users\Administrator\Desktop\a.FLY");
                 }
                 catch (e)
                 {
    
                 }
             }
    
             function MoveObject()
             {
                 var SGWorld = new CreateSGObj();
                 SGWorld.AttachEvent("OnLButtonDown", OnLButtonDown);
                 SGWorld.AttachEvent("OnRButtonDown", OnRButtonDown);
             }
    
             var sobj = null;
             function OnLButtonDown(Flags, X, Y)
             {
                 var SGWorld = CreateSGObj();
                 var CursorCoord = SGWorld.Window.pixelToWorld(X, Y, 1);//第三个参数设置为1,表示鼠标点选对象的时候,只选择Model类型的对象
                 if (CursorCoord.ObjectID == null || CursorCoord.ObjectID=="")
                     return false;
                 var obj = SGWorld.Creator.GetObject(CursorCoord.ObjectID);
                 var opos = obj.Position.Copy();
                 var campos = SGWorld.Navigate.GetPosition(3);
                 var tpos = obj.Position.Move(100, campos.Yaw+90, 0);//将当前模型对象位置向右侧平移100米
                 tpos.Yaw = opos.Yaw;
                 obj.Position = tpos;
             }
    
             function OnRButtonDown(Flags, X, Y) {
                 var SGWorld = CreateSGObj();
                 var CursorCoord = SGWorld.Window.pixelToWorld(X, Y, 1);
                 if (CursorCoord.ObjectID == null || CursorCoord.ObjectID == "")
                     return false;
                 var obj = SGWorld.Creator.GetObject(CursorCoord.ObjectID);
                 var opos = obj.Position.Copy();
                 var campos = SGWorld.Navigate.GetPosition(3);
                 var tpos = obj.Position.Move(100, campos.Yaw - 90, 0);//将当前模型对象位置向左侧平移100米
                 tpos.Yaw = opos.Yaw;
                 obj.Position = tpos;
                 return true;
             }
    
             // SGWorld701
             function CreateSGObj() {
                 try {
                     var obj = document.getElementById("SGWorld");
                     if (obj == null) {
                         obj = document.createElement('object');
                         obj.setAttribute("name", "SGWorld");
                         obj.setAttribute("id", "SGWorld");
                         obj.style.height = "1px";
                         obj.style.width = "1px";
                         obj.setAttribute("classid", "CLSID:3A4F919C-65A8-11D5-85C1-0001023952C1");
                         document.body.appendChild(obj);
                     }
                     return obj;
                 }
                 catch (e) {
                     alert(e);
                 }
             }
         </script>
    </head>
    <body onload="Init();" >
        <table style="margin: 0px; border: 0px;">
            <tr>
                <td colspan="4">
                    <input id="Button1" type="button" value="button" onclick="MoveObject()" />
                </td>
            </tr>       
        </table>
        <object id="TerraExplorerInformationWindow" classid="CLSID:3a4f9193-65a8-11d5-85c1-0001023952c1" style=" 19%; height: 560px;"></object>
        <object id="TerraExplorer3DWindow" classid="CLSID:3a4f9192-65a8-11d5-85c1-0001023952c1" style=" 80%; height: 560px;"></object>
    </body>
    </html>
  • 相关阅读:
    转 configure: error: Cannot find ldap.h
    DDoS(Distributed Denial of Service,分布式拒绝服务)
    j2ee 1.5和1.6的区别
    机器学习
    免安装版Tomcat6.0启动方法
    mysql补充(2)常用sql语句
    mysql补充(4)数据完整性
    mysql补充(3)优化sql语句查询常用的30种方法
    mysql补充(1)校对集utf8_unicode_ci与utf8_general_ci
    jdbc(1)(一)
  • 原文地址:https://www.cnblogs.com/yitianhe/p/8532989.html
Copyright © 2020-2023  润新知