Skip to content

图片旋转

图片旋转需要额外调用接口,需要引用插件 TextureDynamicMaterialProperty.js

HTML
<script src="SDK/Plugins/TextureDynamicMaterialProperty/TextureDynamicMaterialProperty.js"></script>

绘制可视域分析开始

JavaScript
    //初始化鼠标事件
    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.1206125026580582, 0.545178729438238, 14.721614698023599);
        var res = computeGeometryPos(center,500,270.,-90.,360);

        var polygon = new LSGlobe.PolygonGeometry({
            polygonHierarchy: new LSGlobe.PolygonHierarchy(res)
        });
        let instance = new LSGlobe.GeometryInstance({
            geometry:polygon,
            id:'nihao'
        });
        var primitive = new LSGlobe.Primitive({
            geometryInstances: [instance],
            appearance: new LSGlobe.EllipsoidSurfaceAppearance({
                material: LSGlobe.Material.fromType(LSGlobe.Material.TextureDynamicType, {
                    image:'images/bg.png'
                })
            })
        });

示例代码 code

code示例地址

Released under the MIT License.