Skip to content

雷达扫描

扫描需要额外调用接口,需要引用插件 ScanningEffectMaterialProperty.js

HTML
<script src="http://show.wish3d.com/SDK/LSGlobe-2.0.0.569/Plugins/ScanningEffectMaterialProperty.js"></script>

雷达扫描

JavaScript
     /**
        * 雷达扫描
        * 插件ScanningEffectMaterialProperty.js
        * @param color:雷达扫描颜色
        */
            function computeGeometryPos(center, radius, fromA, toA, length) {
                var res = [];
                var interval = (toA - fromA) * Math.PI / 180 / length;
                var startA = fromA * Math.PI / 180;

                var mm = LSGlobe.Transforms.eastNorthUpToFixedFrame(center);
                var startPos = new LSGlobe.Cartesian3();
                for (var i = 0; i < length; i++) {
                    var a = startA + interval * i;
                    var p = new LSGlobe.Cartesian3(Math.sin(a) * radius, Math.cos(a) * radius, 0.);
                    res.push(LSGlobe.Matrix4.multiplyByPoint(mm, p, new LSGlobe.Cartesian3));
                    if (i === 0) {
                        startPos = LSGlobe.Matrix4.multiplyByPoint(mm, p, new LSGlobe.Cartesian3);
                    }
                }
                res.push(startPos);

                return res;
            }
            var center = new LSGlobe.Cartesian3.fromRadians(2.1208980215153845, 0.5450726579947579, 0);
            var radius = 150.
            var fromA = 270;
            var toA = -90;
            var res = computeGeometryPos(center, radius, fromA, toA, 360);
            var polygon = new LSGlobe.PolygonGeometry({
                polygonHierarchy: new LSGlobe.PolygonHierarchy(res)
            });

            var instance = new LSGlobe.GeometryInstance({
                geometry: polygon,
                id: 'id'
            });

            var primitive = new LSGlobe.GroundPrimitive({
                geometryInstances: [instance],
                appearance: new LSGlobe.EllipsoidSurfaceAppearance({
                    material: LSGlobe.Material.fromType(LSGlobe.Material.RadarScanDynamicType, {
                        color: LSGlobe.Color.YELLOW
                    })
                })
            });
            viewer.scene.primitives.add(primitive);

示例代码 code

code示例地址

Released under the MIT License.