From bc22bb69fee34a1901f2d3821a022cd848f8921c Mon Sep 17 00:00:00 2001
From: liuyg <376836862@qq.com>
Date: Mon, 28 Jun 2021 16:14:10 +0800
Subject: [PATCH] 实体建造添加放大倍数

---
 widgets/modelDiagram/Widget.js |  144 +++++++++++++----------------------------------
 1 files changed, 40 insertions(+), 104 deletions(-)

diff --git a/widgets/modelDiagram/Widget.js b/widgets/modelDiagram/Widget.js
index 9364133..c043bf9 100644
--- a/widgets/modelDiagram/Widget.js
+++ b/widgets/modelDiagram/Widget.js
@@ -3,16 +3,16 @@
 // 模块描述:显示坐标
 ///////////////////////////////////////////////////////////////////////////
 define([
-        'dojo/_base/declare',
-        'dojo/_base/lang',
-        'dojo/_base/array',
-        'dojo/_base/html',
-        'dojo/topic',
-        'jimu/BaseWidget',
-        'jimu/utils',
-        'jimu/css!libs/zTree_v3/css/zTreeStyle/zTreeStyle.css',
-        'libs/zTree_v3/js/jquery.ztree.all'
-    ],
+    'dojo/_base/declare',
+    'dojo/_base/lang',
+    'dojo/_base/array',
+    'dojo/_base/html',
+    'dojo/topic',
+    'jimu/BaseWidget',
+    'jimu/utils',
+    'jimu/css!libs/zTree_v3/css/zTreeStyle/zTreeStyle.css',
+    'libs/zTree_v3/js/jquery.ztree.all'
+],
     function (declare,
         lang,
         array,
@@ -113,17 +113,17 @@
                             title: '热气球',
                             value: './images/gltf/CesiumBalloon.glb',
                             id: 104,
-                            num: [3, 3, 1, 1]
+                            num: [3, 3, 15, 17]
                         }, {
                             title: '牛奶车',
                             value: './images/gltf/CesiumMilkTruck.glb',
                             id: 105,
-                            num: [3, 3, 1, 1]
+                            num: [3, 3, 3, 5]
                         }, {
                             title: '牛奶车gltf',
                             value: './images/gltf/CesiumMilkTruck.gltf',
                             id: 106,
-                            num: [3, 3, 1, 1]
+                            num: [3, 3, 3, 5]
                         }, {
                             title: '人gltf',
                             value: './images/gltf/walk.gltf',
@@ -139,11 +139,24 @@
                             dom.empty();
                             var str = `${obj.title} <i class="layui-icon layui-icon-down layui-font-12"></i>`
                             dom.append(str);
-                            that.setNum(obj.num)
+                            a = obj.num[2];
+                            b = obj.num[3];
+                            that.getInput();
+                            var neWnum = [obj.num[0], obj.num[1], obj.num[2] * that.scale, obj.num[3] * that.scale]
+                            that.setNum(neWnum);
                         }
                     });
                 });
-
+                var a = 1;
+                var b = 1;
+                $("#modelDiagrambeishu").on("input", function () {
+                    // $('#modelDiagramW').val();
+                    var it = $(this).val();
+                    $('#modelDiagramJW').val(a * it);
+                    // $('#modelDiagramH').val();
+                    $('#modelDiagramJH').val(b * it);
+                    console.log(a, b, it)
+                });
 
             },
             urls: './images/gltf/Cesium_Man.glb',
@@ -153,20 +166,23 @@
                 $('#modelDiagramJW').val(num[2])
                 $('#modelDiagramJH').val(num[3])
             },
-            beginCesium: function (a, b, g, once) {
+            beginCesium: function (a, b, g, once, scale) {
                 var viewer = this.map,
                     that = this,
                     url = that.urls;
 
                 //静态
                 // var position = Cesium.Cartesian3.fromDegrees(116.058987, 28.973468, 1000);
+
+                // console.log(a, b, g, scale)
+
                 var position = Cesium.Cartesian3.fromDegrees(a, b, g);
                 that.entityPeople = viewer.entities.add({ //viewer.trackedEntity跟随
                     name: url,
                     position: position,
                     model: {
                         uri: url,
-                        scale: 110
+                        scale: scale
                     },
                 });
 
@@ -174,38 +190,14 @@
 
                 if (once == 'once') {
                     // viewer.trackedEntity = that.entityPeople;
+                    var gg = g + scale * 6;
                     that.map.camera.flyTo({
-                        destination: position,
+                        destination: Cesium.Cartesian3.fromDegrees(a, b, gg),
                         duration: 3
                     });
                 }
 
 
-            },
-            entityPeople: '',
-            seeEntity: true,
-            openEntity: false,
-            time: '',
-            beginPlay: function () {
-                var postion = [116.058987, 28.973468, 1000],
-                    a = 116.058987,
-                    b = 28.973468,
-                    g = 1000;
-                this.time = setInterval(() => {
-
-                    if (this.openEntity) {
-                        // this.map.entities.remove(this.entityPeople)//删除entity
-                        // this.map.entities.remove(this.map.trackedEntity)//删除entity
-                        this.map.entities.removeAll();
-                    } else {
-                        a += 0.01;
-                        b += 0.01;
-                        // g += 0.01;
-                        this.beginCesium(a, b);
-                    }
-                    this.openEntity = !this.openEntity;
-                    console.log(this.openEntity)
-                }, 1000);
             },
             stopPlay: function () {
                 this.map.entities.removeAll();
@@ -227,18 +219,20 @@
                 this.a = $('#modelDiagramjdu').val() == '' ? 116.058987 : +$('#modelDiagramjdu').val();
                 this.b = $('#modelDiagramwdu').val() == '' ? 28.973468 : +$('#modelDiagramwdu').val();
                 this.g = $('#modelDiagramgdu').val() == '' ? 1000 : +$('#modelDiagramgdu').val();
+                this.scale = $('#modelDiagrambeishu').val() == '' ? 1000 : +$('#modelDiagrambeishu').val();
             },
             a: '',
             b: '',
             g: '',
+            scale: '',
             //重复添加
             always: function (aa = 'a', bb = 'b') {
                 this.getInput();
                 // console.log([a, b, g])
                 if (aa != 'a' && bb != 'b') {
-                    this.beginCesium(aa, bb, this.g);
+                    this.beginCesium(aa, bb, this.g, '', this.scale);
                 } else {
-                    this.beginCesium(this.a, this.b, this.g);
+                    this.beginCesium(this.a, this.b, this.g, '', this.scale);
                 }
             },
             //单次添加
@@ -246,67 +240,9 @@
                 this.stopPlay();
                 this.getInput();
                 // console.log([a, b, g])
-                this.beginCesium(this.a, this.b, this.g, 'once');
+                this.beginCesium(this.a, this.b, this.g, 'once', this.scale);
             },
-            closeModo: function () {
-                if (this.openEntity) {
-                    // this.map.entities.remove(this.entityPeople)//删除entity
-                    // this.map.entities.remove(this.map.trackedEntity)//删除entity
-                    this.map.entities.removeAll();
-                } else {
-                    this.getInput
-                    // console.log([a, b, g])
-                    this.beginCesium(a, b, g);
-                }
-                this.openEntity = !this.openEntity;
-                console.log(this.openEntity)
-                // var that = this;
-                // if (that.seeEntity) {
-                // 	this.map.trackedEntity = that.entityPeople;//目标视野跟踪
-                // } else {
-                // 	this.map.trackedEntity = '';
-                // }
-                // viewer.entities.remove(that.entityPeople)//删除entity
 
-                // viewer.entities.removeById(id)//根据id删除entity
-
-                // viewer.entities.removeAll()//清空所有entity
-
-                // viewer.entities.getById(id)// 获取enetity
-
-                // viewer.entities.contains(entity)// 是否包含
-                // viewer.entities.removeById('')
-            },
-            beginModelDiagram: function () {
-                var that = this,
-                    viewer = that.map,
-                    scene = viewer.scene;
-                // scene.globe.show = false;
-                viewer.shouldAnimate = true;
-                var collect = new Cesium.InstanceLayer(scene._context),
-                    url = "./images/gltf/walk.gltf",
-                    gltf = viewer.entities.add({
-                        name: "gltf",
-                        position: new Cesium.Cartesian3.fromDegrees(115.783206 - 0.002034006, 28.810602 - 0.005072179, 800),
-                        model: {
-                            uri: url
-                        }
-                    });
-                viewer.zoomTo(gltf);
-                $("#modelDiagramSelOpt").change(function () {
-                    var value = $(this).val();
-                    if (value === "1") {
-                        collect.removeInstance(url, [collect._instances._array[0]._array[0].id]);
-                        viewer.entities._show = true;
-                    } else {
-                        viewer.entities._show = false;
-                        collect.add(url, {
-                            position: new Cesium.Cartesian3.fromDegrees(115.783206 - 0.002034006, 28.810602 - 0.005072179, 1000)
-                        });
-
-                    }
-                })
-            },
             onClose: function () {
                 //面板关闭的时候触发 (when this panel is closed trigger)
             },

--
Gitblit v1.9.3