cesium 隐藏entity_Cesium实战(十二)使用Primitive替代entity

这个函数演示了如何在Cesium中使用PolylineVolumeGeometry和Primitive来替代Entity创建动态线。它接受位置、线宽、颜色、图片、速度和是否闭合等参数,通过动态纹理和动画实现线段的显示效果。最后,将创建的Primitive添加到场景的primitives集合中。
摘要由CSDN通过智能技术生成

function creatgxPolylinePrimit(positions, linewidth, linecolor, img, speed, isClose) {

var cvs = img;

var pl = new Cesium.PolylineVolumeGeometry({

polylinePositions: positions,

shapePositions: computeCircle(linewidth),

vertexFormat: Cesium.VertexFormat.POSITION_ONLY

});

var ins = new Cesium.GeometryInstance({

geometry: Cesium.PolylineVolumeGeometry.createGeometry(pl),

attributes: {

color: Cesium.ColorGeometryInstanceAttribute.fromColor(Cesium.Color.RED),

}

})

// var ins = GeometryIns(pl);

var linesInstances = [];

linesInstances.push(ins);

var cesiumColor = Cesium.Color.fromCssColorString(linecolor);

var appc = new Cesium.PolylineMaterialAppearance({

material: new Cesium.Material({

fabric: {

uniforms: {

image: cvs,

animationSpeed: speed,

color: cesiumColor

},

source: “czm_material czm_getMaterial(czm_materialInput materialInput) { \n\

czm_material material = czm_getDefaultMaterial(materialInput);\n\

vec2 st = materialInput.st;\n\

float time = czm_frameNumber * animationSpeed;\n\

vec4 colorImage = texture2D(image,vec2(fract(st.s – time), st.t));\n\

material.alpha = colorImage.a;\n\

material.diffuse = colorImage.rgb;\n\

return material;\n\

} \n”,

// aboveGround: true,

},

}),

})

// var curPrimitive = primitv(linesInstances, appc);

var curPrimitive = new Cesium.Primitive({

geometryInstances: linesInstances,

appearance: appc,

asynchronous: false

});

curPrimitive = window.CesiumViewer.scene.primitives.add(curPrimitive);

return curPrimitive;

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值