presentation.html 5.49 KB
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <title></title>
    <script src="../js/jquery-3.4.1.min.js"></script>
    <script src="../js/JavaScript.js"></script>
    <script src="../js/popupJS.js"></script>
    <link rel="stylesheet" href="../css/layer.css">
    <link rel="stylesheet" href="../icon/iconfont.css">


</head>

<body marginwidth="0" marginheight="0">

    <!-- 动画演示 -->
    <div id="mainDiv" class="dialog donghua">
        <h1 class="title" onmousedown="MouseDown(event)" onmouseup="MouseUp(event)" onmouseout="MouseUp(event)">
            动画演示<i class="guanbibtn" onclick="Close()">X</i>
        </h1>
        <div class="main">
            <div class="tool">
                <i class="iconfont icon-tianjia-" title="新增演示工具" onclick="addNewDonghua"></i>
                <i class="iconfont icon-tianjia-" title="新增" onclick="addView()"></i>
            </div>
            <div class="tool">
                <i class="iconfont icon-tianjia-" title="新增" onclick="addFly()"></i>
                <i class="iconfont icon-bofang" title="播放" onclick="play()"></i>
                <i class="iconfont icon-zanting" title="暂停" onclick="pause()"></i>
                <i class="iconfont icon-daobo" title="倒退" onclick="previous()"></i>
                <i class="iconfont icon-dancibofang-" title="播放一次" onclick="playOnce()"></i>
                <i class="iconfont icon-xunhuan-" title="无线循环" onclick="loop()"></i>
                <i class="iconfont icon--" title="删除节点" onclick="delFly()"></i>
            </div>
            <ul class="ul">
                <li class="item">
                    <span class="check"></span>
                    <span class="id">ID</span>
                    <span class="describe">描述</span>
                </li>

            </ul>
        </div>
    </div>

    <script>
        var flymode = [];
        var presentation = undefined;
        var selectValue = -1;
        function addView() { alert("aaa"); }
        function addNewDonghua() {
            console.log("aaa");

            alert("进入addNewDonghua()");
            //无论 presentation是否为undefined,都需要创建演示工具
            // var sgWorld = CreateSGObj();
            // presentation = sgWorld.Creator.CreatePresentation(
            //     "",
            //     "演示工具"
            // );
            alert("创建presentation完成");
            //sgWorld.ProjectTree.EditItem(presentation.ID, 1);
            flymode = [];
            selectValue = -1;
            alert("已创建新的演示工具!");
        }
        function addFly() {
            if (presentation !== undefined) {
                var index = flymode.length + 1;
                flymode.push({ index: index, describe: "位置信息" });
                //    playIndex = 0;
                // sgWorld.Command.Execute(1099, 0);//添加位置的命令
                //获取当前的视角位置,并将其加入到演示工具中
                var sgWorld = CreateSGObj();
                var currentPos = sgWorld.Navigate.GetPosition(0);
                //演示工具新添加了一个移动摄像机到不同位置的演示步骤
                presentation.CreateLocationStep(1, 0, "", currentPos);
                var str = "<li class='item' >" +
                    "<span class='check'>" +
                    "<input type='radio' class='checkStep' name='checkStep' />" +
                    "</span>" +
                    "<span class='id'>" + index + "</span>" +
                    "<span class='describe'>位置信息</span></li>";
                $(".ul").append(str);

            }
        }
        function play() {
            if (presentation !== undefined) {
                //播放
                if (presentation.PresentationStatus === 1) {
                    //PS_NOTPLAYING = 1
                    presentation.PlayMode = 0;
                    presentation.PlayAlgorithm = 1;
                    presentation.PlaySpeedFactor = 2;
                    presentation.Play(0);
                } else if (presentation.PresentationStatus === 2) {
                    presentation.Resume(); //让演示工具从暂停的那一步恢复演示
                }
            }
        }
        function pause() {
            //暂停
            if (
                presentation !== undefined &&
                presentation.PresentationStatus === 1
            ) {
                presentation.Pause();
            }
        }
        function previous() {
            //上一步
            if (presentation !== undefined) {
                // sgWorld.Command.Execute(1114, 0);
                presentation.PreviousStep();
                presentation.Resume();
            }
        }
        function playOnce() {
            //播放一次 
            if (presentation !== undefined) presentation.LoopRoute = false;
        }
        function loop() {
            //循环
            if (presentation !== undefined) presentation.LoopRoute = true;
        }
        function delFly() {
            //获取单选框中选中的对象的index(序号),用于删除在演示工具中的节点
            if (presentation !== undefined) {
                var delIndex = flymode.findIndex(
                    item => item.index === selectValue
                );
                if (delIndex !== -1) {
                    flymode.splice(delIndex, 1);
                    presentation.DeleteStep(delIndex);
                }
            }
        }

    </script>
</body>


</html>