今天來看看GroundPrimitive,選擇GroundPrimitive有三個目的:1 了解GroundPrimitive和Primitive的區(qū)別和關系 2 createGeometry的特殊處理 3 如何通過陰影體的方式實現(xiàn)貼地效果。
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