Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PolylineGeometry with marterial of PerInstanceColorAppearance does not work #8556

Closed
a873054267 opened this issue Jan 21, 2020 · 1 comment
Closed

Comments

@a873054267
Copy link

a873054267 commented Jan 21, 2020

I want to render the polyline with the marterial of PerInstanceColorAppearance,But it's seem to not take effet with the following code.
I finally made it when I use SimplePolylineGeometry to construct instance.So I want to understand what's the diffrent of PolylineGeometry and SimplePolylineGeometry on this point.

instanceFunction function getGeometryInstance (lineStringArray) { return new Cesium.GeometryInstance({ geometry : new Cesium.SimplePolylineGeometry({ positions : Cesium.Cartesian3.fromDegreesArrayHeights(lineStringArray), width : this.style.width, dashLength : 60, vertexFormat : Cesium.PolylineColorAppearance.POSITION_ONLY }), attributes : { color :Cesium.ColorGeometryInstanceAttribute.fromColor(Cesium.Color.fromRandom({alpha : 0.5})) } }); }

var instances=[]
let arr=[116.2440766312067, 40.07389305730007, 34.855640866749, 116.24395125626549, 40.07382653757002, 34.9963782427669]
instances.push(getGeometryInstance(arr))
arr=[116.24393223274961, 40.073864289142065, 34.97, 116.24400014887023, 40.07389668017142, 34.870453622917]
instances.push(getGeometryInstance(arr))

addprimitive

var primitive= viewer.scene.primitives.add(new Cesium.Primitive({
geometryInstances : instances,
appearance : new Cesium.PerInstanceColorAppearance({
flat : true,
translucent : false
}),
asynchronous:false,
}))

@hpinkos
Copy link
Contributor

hpinkos commented Jan 21, 2020

Hi @a873054267, See this example: https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Apps/Sandcastle/gallery/development/Simple%20Polyline.html

Unless you have a reason not to, I would recommend adding polylines using the Entity API https://sandcastle.cesium.com/?src=Polyline.html&label=Geometries

Next time you have a question, please ask on our forum: https://groups.google.com/forum/#!forum/cesium-dev

@hpinkos hpinkos closed this as completed Jan 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants