简体   繁体   English

cesium 我有 10,000 个实体,我怎么能不尝试使用循环方法来更改它们的材质?

[英]cesium I have 10,000 entities, how can I do not try a loop approach to change their material?

From

new Cesium.PolylineGlowMaterialProperty({
            glowPower: 0.15,
            color: Cesium.Color.fromCssColorString("rgba(42,92,170, 0.15)")
        });

To

new Cesium.PolylineGlowMaterialProperty({
            glowPower: 0.3,
            color: Cesium.Color.fromCssColorString("rgba(255,255,255, 0.15)")
        });

Is there a way to change all the materials as a whole?有没有办法将所有材料作为一个整体改变?

I think you'll need to loop through all the entities, but you probably don't want to allocate a new PolylingGlowMaterial for each one, as that could be slow.我认为您需要遍历所有实体,但您可能不想为每个实体分配一个新的PolylingGlowMaterial ,因为这可能会很慢。 Instead, try changing the value on the existing material.相反,请尝试更改现有材料的值。 Assuming this is a "constant" (non-time-varying) property as shown above, there's a setValue available.假设这是一个如上所示的“常量”(非时变)属性,则有一个setValue可用。 It goes something like this:它是这样的:

entity.polyline.material.glowPower.setValue(0.3);
entity.polyline.material.color.setValue(Cesium.Color.WHITE.withAlpha(0.15));

I've also shown a different way to get the same color here, without asking Cesium to parse 10000 color strings.我还展示了一种不同的方法来获得相同的颜色,而无需要求 Cesium 解析 10000 个颜色字符串。 If all 10000 entities are the same color, you should allocate this color before the loop starts, and just hand out thousands of references to it, rather than redoing it in the loop.如果所有 10000 个实体都是相同的颜色,您应该在循环开始之前分配这种颜色,并且只分发数千个对它的引用,而不是在循环中重做。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM