方法1:
//图片目录必须在静态文件夹下,否则会被打包导致找不到,无贴图效果 var image="../../../../static/arrow/"+key+".png" //var image = '../img/arrow/'+key+".png"; // 设置x,y的正负值,可完成图片的正反面交替 var arrowMaterial = new Cesium.Material.fromType('Image', { image : image, repeat : { x : 1, y : 1 } }); var primitive = new Cesium.Primitive({ geometryInstances : geomInstance[key], appearance : new Cesium.MaterialAppearance({ material : arrowMaterial }), show:this.show, asynchronous:false }); viewer.scene.primitives.add(primitive)
方法2:
var position = Cesium.Cartesian3.fromDegrees(116.30073537233423,40.03365630724397,0);
var heading = Cesium.Math.toRadians(-20.0);
var pitch = Cesium.Math.toRadians(0);
var roll = Cesium.Math.toRadians(1.0);
var orientation = Cesium.Transforms.headingPitchRollQuaternion(position, new Cesium.HeadingPitchRoll(heading, pitch, roll));
//定义orientation可以旋转图片
var redPlane = viewer.entities.add({
name : 'Red plane with black outline',
position: position,
orientation : orientation,
plane : {
plane : new Cesium.Plane(Cesium.Cartesian3.UNIT_Z, 0.0),
dimensions : new Cesium.Cartesian2(7.0, 17.0),
material : '1.jpg',
outline : true,
outlineColor : Cesium.Color.BLACK
}
});
viewer.zoomTo(redPlane)