Javascript 铯几何姿态-如何设置多色
我有以下基于坐标列表创建三角形(形成对象)的代码。我想用不同的颜色给每个三角形上色。目前,所有三角形都具有相同的颜色。可能吗 似乎没有选项可以设置颜色列表而不是一种颜色Javascript 铯几何姿态-如何设置多色,javascript,cesium,Javascript,Cesium,我有以下基于坐标列表创建三角形(形成对象)的代码。我想用不同的颜色给每个三角形上色。目前,所有三角形都具有相同的颜色。可能吗 似乎没有选项可以设置颜色列表而不是一种颜色 for (j = 0; j < NumberOfObjects; j++) { var mypositions = Cesium.Cartesian3.fromDegreesArrayHeights(AllObjectCoordinates[j]); var numPositions = mypositions.lengt
for (j = 0; j < NumberOfObjects; j++) {
var mypositions = Cesium.Cartesian3.fromDegreesArrayHeights(AllObjectCoordinates[j]);
var numPositions = mypositions.length;
var pos = new Float64Array(numPositions * 3);
var normals = new Float32Array(numPositions * 3);
for (var i = 0; i < numPositions; ++i) {
pos[i * 3] = mypositions[i].x;
pos[i * 3 + 1] = mypositions[i].y;
pos[i * 3 + 2] = mypositions[i].z;
normals[i * 3] = 1;
normals[i * 3 + 1] = 0;
normals[i * 3 + 2] = 0;
}
var geometry = new Cesium.Geometry({
vertexFormat : Cesium.VertexFormat.ALL,
attributes: {
position: new Cesium.GeometryAttribute({
componentDatatype: Cesium.ComponentDatatype.DOUBLE, // not FLOAT
componentsPerAttribute: 3,
values: pos
}),
normal: new Cesium.GeometryAttribute({
componentDatatype: Cesium.ComponentDatatype.FLOAT,
componentsPerAttribute: 3,
values: normals
}),
},
indices: new Uint32Array(Array.apply(null, {length: (numPositions)}).map(Number.call, Number)),
primitiveType: Cesium.PrimitiveType.TRIANGLES,
boundingSphere: Cesium.BoundingSphere.fromVertices(pos)
});
Cesium.GeometryPipeline.computeNormal(geometry);
var myInstance = new Cesium.GeometryInstance({
geometry: geometry,
attributes: {
color: new Cesium.ColorGeometryInstanceAttribute.fromColor(Cesium.Color.fromCssColorString("#ffff99"))
},
show: new Cesium.ShowGeometryInstanceAttribute(true),
id : 'Objekat'
});
var Objekat = viewer.scene.primitives.add(new Cesium.Primitive({
geometryInstances: [myInstance],
asynchronous: false,
appearance: new Cesium.PerInstanceColorAppearance({
closed: true,
translucent: false
})
}));
}
(j=0;j{
var mypositions=Ce.Cartesian3.从度数阵列高度(AllObject坐标[j]);
var numPositions=mypositions.length;
var pos=新的Float64Array(numPositions*3);
var normals=新的Float32Array(numPositions*3);
对于(变量i=0;i