Quellcode durchsuchen

低空修改250318-01

zhiyuan-007 vor 1 Monat
Ursprung
Commit
6281919514

+ 30 - 0
src/components/mapJK.vue

@@ -71,6 +71,7 @@ import GeometryMeshEffect from "../units/map/GeometryMeshEffect.js";
 import QueryIn2D from "../units/map/QueryIn2D.js";
 import AddFlowPathEvent from "../units/map/AddFlowPathEvent.js";
 import MovePointStreamEvent from "../units/map/MovePointStreamEvent.js";
+import AddRadarEffectEvent from "../units/map/AddRadarEffect.js";
 export default {
   name: "mapJK",
   setup(){
@@ -101,6 +102,7 @@ export default {
     let reRenderingEvent = null;
     let pathPipeInstance = {};
     let flyGLTFInstances = {};
+    let radarEffectInstance = {};
     let addDrawEvent = null;
     let draw_GeometryMeshPrismEffectEvent = null;
     let symbolPathPipeEvent = null;
@@ -375,6 +377,9 @@ export default {
           case "GetBaseQJC":
             getBaseQJC(params);
             break;
+          case "RadarEffect":
+            radarEffect(params);
+            break;
         }
       }
       function setBackground(params){
@@ -2820,6 +2825,10 @@ export default {
               showThreeCubeDetail({
                 "id":"movePointCube",
                 "status":"hide"
+              });
+              addLightBall({
+                id:"ball",
+                status:"hide"
               })
               flyPointSocket.close();
               flyPointSocket = null
@@ -3466,6 +3475,27 @@ export default {
         })
       }
 
+      function radarEffect(params){
+        let status = params.status;
+        let id = params.id;
+        if(radarEffectInstance[id]){
+          radarEffectInstance[id].clear();
+          radarEffectInstance[id] = null;
+        }
+        if(status === "hide"){
+          return
+        }
+        let points = params.points;
+        let radarEffectInstance = new AddRadarEffectEvent({
+          view:m_view,
+          points
+        })
+        radarEffectInstance.start()
+        // 保存实例
+        lightBallInstance[id] = radarEffectInstance;
+      }
+
+
     })
   }
 }

+ 10 - 0
src/config/basicTool.json

@@ -2795,6 +2795,16 @@
             "token": ""
           }
         }
+      },
+      {
+        "code": "1-59",
+        "title": "雷达效果",
+        "data": {
+          "ActionName": "RadarEffect",
+          "Parameters": {
+            "token": ""
+          }
+        }
       }
     ]
   }

+ 39 - 0
src/units/map/AddRadarEffect.js

@@ -0,0 +1,39 @@
+
+import RenderNode from '@arcgis/core/views/3d/webgl/RenderNode.js'
+import * as webgl from "@arcgis/core/views/3d/webgl.js";
+import {radarEffectClass} from "../threejs/radarEffect.js";
+
+class AddRadarEffectEvent{
+    constructor(options) {
+        this.view = options.view;
+        this.addRadarEffectEvent = null;
+        this.points = options.points;
+        this.radius = options.radius || 10;
+        this.color = options.color || '#00FF7F';
+    }
+    start() {
+        let that = this;
+        if(this.addRadarEffectEvent){
+            this.clear();
+        }
+        let subRenderClass = RenderNode.createSubclass(radarEffectClass);
+        this.view.when(()=>{
+            that.addRadarEffectEvent =  new subRenderClass({
+                view: that.view,
+                points: that.points,
+                color:that.color,
+                radius: that.radius,
+                webgl
+            })
+        })
+    }
+    clear(){
+        if(this.addRadarEffectEvent){
+            this.addRadarEffectEvent.destroy();
+            this.addRadarEffectEvent = null;
+        }
+    }
+
+}
+
+export default AddRadarEffectEvent;

+ 128 - 0
src/units/threejs/radarEffect.js

@@ -0,0 +1,128 @@
+import * as THREE from "three";
+
+
+export const radarEffectClass = {
+    constructor(options) {
+        this.webgl = options.webgl;
+        this.view = options.view;
+        this.points = options.points;
+        this._camera = null;
+
+    },
+    initialize() {
+        this.clock = new THREE.Clock();
+
+        this.renderer = new THREE.WebGLRenderer({
+            context: this.gl, // 可用于将渲染器附加到已有的渲染环境(RenderingContext)中
+            premultipliedAlpha: false, // renderer是否假设颜色有 premultiplied alpha. 默认为true
+        });
+        this.renderer.setPixelRatio(window.devicePixelRatio); // 设置设备像素比。通常用于避免HiDPI设备上绘图模糊
+        this.renderer.setViewport(0, 0, this.view.width, this.view.height); // 视口大小设置
+
+        this.renderer.autoClear = false;
+        this.renderer.autoClearDepth = false;
+        this.renderer.autoClearColor = false;
+        // this.renderer.autoClearStencil = false;
+
+        let originalSetRenderTarget = this.renderer.setRenderTarget.bind(this.renderer);
+        this.renderer.setRenderTarget = function (target) {
+            originalSetRenderTarget(target);
+            if (target == null) {
+                context.bindRenderTarget();
+            }
+        };
+
+        this.scene = new THREE.Scene();
+        // setup the camera
+        let cam = this.camera;
+        this._camera = new THREE.PerspectiveCamera(cam.fovY, cam.aspect, cam.near, cam.far);
+
+        // 添加坐标轴辅助工具
+        const axesHelper = new THREE.AxesHelper(1);
+        axesHelper.position.copy(1000000, 100000, 100000);
+        this.scene.add(axesHelper);
+
+        let grid = new THREE.GridHelper(30, 10, 0xf0f0f0, 0xffffff);
+        this.scene.add(grid);
+
+        // setup scene lighting
+        this.ambient = new THREE.AmbientLight(0xffffff, 0.5);
+        this.scene.add(this.ambient);
+
+        this.sun = new THREE.DirectionalLight(0xffffff, 0.5);
+        this.sun.position.set(-600, 300, 60000);
+        this.scene.add(this.sun);
+        this.getGeometry();
+
+
+        this.resetWebGLState();
+    },
+
+
+    getGeometry() {
+        this.points.forEach(point => {
+            let pointGround = {
+                type: "point",
+                x: point[0],
+                y: point[1],
+                z: 1,
+                viewH: 3000,
+            };
+            let pointSky = {
+                type: "point",
+                x: point[0],
+                y: point[1],
+                z: 10,
+            }
+            const mixedPoints = [
+                pointGround.x, pointGround.y, pointGround.z,
+                pointSky.x, pointSky.y, pointSky.z,
+            ]
+            let cenP = [];
+            this.webgl.toRenderCoordinates(
+                this.view,
+                mixedPoints,
+                0,
+                this.view.spatialReference,
+                cenP,
+                0,
+                1
+            );
+
+
+
+        });
+    },
+
+    /**
+     * 渲染器更新渲染
+     * @memberof BuildingEffect
+     * @method render
+     * @param {Object} context 已有渲染器信息,无需传值
+     */
+    render(context) {
+        let cam = this.camera;
+        //需要调整相机的视角
+        this._camera.position.set(cam.eye[0], cam.eye[1], cam.eye[2]);
+        this._camera.up.set(cam.up[0], cam.up[1], cam.up[2]);
+        this._camera.lookAt(new THREE.Vector3(cam.center[0], cam.center[1], cam.center[2]));
+        // Projection matrix can be copied directly
+        this._camera.projectionMatrix.fromArray(cam.projectionMatrix);
+
+
+
+
+
+        this.renderer.state.reset();
+
+        this.bindRenderTarget();
+
+        this.renderer.render(this.scene, this._camera);
+        // as we want to smoothly animate the ISS movement, immediately request a re-render
+        this.requestRender();
+
+        // cleanup
+        this.resetWebGLState();
+    }
+
+}