Entity 和primitive 对比
- entity偏向数据,primitive偏向图形.primitive更底层
- entity用法简单,primitive用法复杂。我们会有这样的疑问:entity已经封装的如此完美,调用如此便捷,为何还要primitive接口呢?区别就是加载效率。primitive更接近webgl底层,没有entity各种各样的附加属性,因此在加载时效率会更高。
Entity
for (let index = 0; index < 1000; index++) {
viewer.entities.add({
position: new Cesium.Cartesian3.fromDegrees(Math.random() * 100, Math.random() * 100, 10000),
ellipse: {
semiMinorAxis: 10000.0,
semiMajorAxis: 10000.0,
material: Cesium.Color.RED
}
});
}
Primitive
var instances = [];
for (let index = 0; index < 1000; index++) {
var ellipse = new Cesium.EllipseGeometry({
center: new Cesium.Cartesian3.fromDegrees(Math.random() * 100, Math.random() * 100),
semiMajorAxis: 10000.0,
semiMinorAxis: 10000.0,
});
var geometry = Cesium.EllipseGeometry.createGeometry(ellipse);
var ellipseInstance = new Cesium.GeometryInstance({
geometry: geometry,
attributes: {
color: Cesium.ColorGeometryInstanceAttribute.fromColor(Cesium.Color.RED)
}
});
instances.push(ellipseInstance);
}
viewer.scene.primitives.add(new Cesium.Primitive({
geometryInstances: instances,
appearance: new Cesium.PerInstanceColorAppearance(),
asynchronous: false,
}));
标签:index,primitive,Entity,Cesium,new,entity,对比,Math
From: https://www.cnblogs.com/little-oil/p/16639582.html