cesium加载批量模型

cesium加载批量模型

 class CreateModel {
            constructor() { }

            // 添加单条数据
            addEntity(item) {
                // 删除实体
                // viewer.entities.removeAll();
                // 添加实体位置
                var position = Cesium.Cartesian3.fromDegrees(
                    ...item.latLon,
                    item.height
                );
                //弧度的航向分量。
                var heading = Cesium.Math.toRadians(135);
                //弧度的螺距分量。
                var pitch = 0;
                //滚动分量(以弧度为单位)
                var roll = 0;
                //HeadingPitchRoll旋转表示为航向,俯仰和滚动。围绕Z轴。节距是绕负y轴的旋转。滚动是关于正x轴。
                var hpr = new Cesium.HeadingPitchRoll(heading, pitch, roll);
                var orientation = Cesium.Transforms.headingPitchRollQuaternion(
                    position,
                    hpr
                );
             
                //实体
                var entity = viewer.entities.add({
                    name: item.url,
                    position: position,
                    orientation: orientation,
                    model: {
                        uri: item.url,
                        //不管缩放如何,模型的最小最小像素大小。
                        minimumPixelSize: 10000,
                        //模型的最大比例尺大小。 minimumPixelSize的上限。
                        maximumScale: 20000,
                    },
                });
                viewer.trackedEntity = entity;
                // 获取或设置相机当前正在跟踪的Entity实例。
            }
        }

        const createModel = new CreateModel();
        // data是模型资源的数据
        const data = [
            { url: '/model/untitled.glb', latLon: [114.35850419018853, 38.914157063533844], height: 50},
            { url: '/model/untitled.glb', latLon: [116.35850419018553, 39.914157063534844], height: 50},
            {url: '/model/untitled.glb', latLon: [116.35850419018553, 39.914157063534844], height: 50},
            {url: '/model/untitled.glb', latLon: [117.55850419018553, 39.914157063534844], height: 50},
            {url: '/model/untitled.glb', latLon: [118.85850419018553, 39.914157063534844], height: 50},
            {url: '/model/untitled.glb', latLon: [113.41850419018553, 39.914157063534844], height: 50},
            {url: '/model/untitled.glb', latLon: [112.45850419018553, 39.914157063534844], height: 50},
            {url: '/model/untitled.glb', latLon: [111.55850419018553, 39.914157063534844], height: 50},
            {url: '/model/untitled.glb', latLon: [116.35850419018553, 31.914157063534844], height: 50},
            {url: '/model/untitled.glb', latLon: [117.55850419018553, 32.914157063534844], height: 50},
            {url: '/model/test.glb', latLon: [118.85850419018553, 33.914157063534844], height: 50},
            {url: '/model/test.glb', latLon: [113.41850419018553, 34.914157063534844], height: 50},
            {url: '/model/untitled6.glb', latLon: [116.35850419018553, 39.914157063534844], height: 50},
            {url: '/model/untitled.glb', latLon: [111.55850419018553, 39.914157063534844], height: 50},
        ];
        // 循环数据
        data.forEach((item, i) => {
            // item是数组中的单条
            createModel.addEntity(item)
        });
  • 1
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值