今天来看看GroundPrimitive,选择GroundPrimitive有三个目的:1 了解GroundPrimitive和Primitive的区别和关系 2 createGeometry的特殊处理 3 如何通过阴影体的方式实现贴地效果。
GroundPrimitive.prototype.update
可以认为GroundPrimitive是Primitive的扩展,通过Update我们可以很好的理解这个过程:
GroundPrimitive.prototype.update = function(frameState) { if (!defined(this._primitive)) { // Key 1
setMinMaxTerrainHeights(this, rectangle, frameState.mapProjection.ellipsoid);
// Key 2
for (i = 0; i < length; ++i) {
instance = instances[i];
geometry = instance.geometry;
instanceType = geometry.constructor;
groundInstances[i] = new GeometryInstance({
geometry : instanceType.createShadowVolume(geometry, getComputeMinimumHeightFunction(this),
getComputeMaximumHeightFunction(this)),
attributes : instance.attributes,
id : instance.id,
&nbs


