Cesium克隆帮你防止重复加载模型卡顿--Cesium.clone()

 利用Cesium.clone(),轻松加载飞机模型双胞胎,而且不卡顿。

注意:不要直接克隆entity,因为ID冲突,无法加载到场景中。

 var position = Cesium.Cartesian3.fromDegrees(-123.0744619, 44.0503706, height);
    var position1 = Cesium.Cartesian3.fromDegrees(-123.0744619, 44.0503006, height);
    var heading = Cesium.Math.toRadians(135);
    var pitch = 0;
    var roll = 0;
    var hpr = new Cesium.HeadingPitchRoll(heading, pitch, roll);
    var orientation = Cesium.Transforms.headingPitchRollQuaternion(position, hpr);

    var entity = viewer.entities.add({
        name : url,
        position : position,
        orientation : orientation,
        model : {
            uri : url,
            minimumPixelSize : 128,
            maximumScale : 20000
        }
    });
    viewer.trackedEntity = entity;
    
   var entity_model = Cesium.clone(entity.model);
    viewer.entities.add({
        name : url,
        position : position1,
        orientation : orientation,
        model : entity_model
    });

你可能感兴趣的:(Cesium,JavaScript,webGIS)