Bootstrap

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

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;

}

;