11 thoughts to “Cesium实战(十二)使用Primitive替代entity”

  1. 当我改成动态渲染时会报这个错:The appearance requires vertex shader attribute input ‘prevPosition2DHigh’, which was not computed as part of the Geometry. Use the appearance’s vertexFormat property when constructing the geometry.大神,帮帮我吧

      1. 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;

        }

  2. 你好,使用primitive 画几何体,按照你的参数
    vertexFormat : Cesium.VertexFormat.POSITION_AND_NORMAL

    appearance : new Cesium.PerInstanceColorAppearance({
    translucent : false,
    closed : true
    })
    看起来还是没有立体感,这个要怎么解决呢