cesium 使用entities、primitives添加的模型并且改变模型颜色

时间:2025-01-20 14:54:52

entities方式绘制模型:【线条】

 var gltf = ({
          guid: crossguid,
          name: 'gltf',
          polyline: {
            width: 1,
            material: ,
            show: true,
            positions: Cesium.(nodePositionArr),
            distanceDisplayCondition: new (0, 10000)
          },
        });

primitives方式添加模型:

 (
          ({
            id: ,
            url: '/model/' + _that.fileglb + '/' +  + '.glb', // 本地文件
            modelMatrix: towerMt4Tower,
            scale: 1, // 放大倍数
          }),
        )

通过鼠标右键点击模型使模型变颜色成选中状态:

    // 鼠标右键获取属性
    const handler = new (canvas);
    const canvas = ;
    const ellipsoid = ;
    (function (click) {
      // 禁止浏览器鼠标右键菜单
       = function () {
        return false;
      };
      _that.pickModel = ();
      _that.position = ();
      const pickModel = _that.pickModel;
      if (pickModel) {
        if () {
          //entities  添加模型变色
           = ;
        } else {
          //primitive  添加模型变色
           = new (1.0, 0, 0, 1.0);
        }
      } 
    }, .RIGHT_CLICK);

在关闭的事件中记得要删除鼠标点击事件,否则会叠加重复触发

 (.RIGHT_CLICK)//移除鼠标右键事件