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

  1. 大神,请教一下,我照您的写primitive管线,报错 Cannot read property ‘attributes’ of undefined是怎么回事呀,谢谢呀

    1. 定位一下错误,或者看你的attributes是不是写错了啥的,你这么描述,不太知道是什么回事。。。

  2. 当我改成动态渲染时会报这个错: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;

        }

        1. 我把所有的vertexFormat都试了一次,都报那个错,这是我的代码,大神麻烦您帮我看看吧,谢谢呀

发表评论

电子邮件地址不会被公开。 必填项已用*标注