ansel0926
2022-05-18 f0efddd9e32b9c5dc828401c4092be004b4826cf
1
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("Cesium")):"function"==typeof define&&define.amd?define(["Cesium"],t):"object"==typeof exports?exports["xbsjMixins/xbsjGroundPrimitiveMixin"]=t(require("Cesium")):e["xbsjMixins/xbsjGroundPrimitiveMixin"]=t(e.Cesium)}("undefined"!=typeof self?self:this,function(e){return function(e){function t(r){if(i[r])return i[r].exports;var n=i[r]={i:r,l:!1,exports:{}};return e[r].call(n.exports,n,n.exports,t),n.l=!0,n.exports}var i={};return t.m=e,t.c=i,t.d=function(e,i,r){t.o(e,i)||Object.defineProperty(e,i,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var i=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(i,"a",i),i},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=86)}({0:function(t,i){t.exports=e},86:function(e,t,i){"use strict";var r,n;r=[i(0)],void 0!==(n=function(e){function t(t,r){if(!e.defined(t))throw new DeveloperError("viewer is required.");t._xbsjGroundPrimitive||(i(t.scene),t._xbsjGroundPrimitive=!0,e.defineProperties(t,{xbsjGroundPrimitive:{configurable:!0,get:function(){return t._xbsjGroundPrimitive}}}))}function i(t){function i(t,i){var r=t._pickDepths||t._defaultView&&t._defaultView.pickDepths,n=r[i];return e.defined(n)||(n=new e.PickDepth,r[i]=n),n}t.context._us.updateCamera;t.context._us.updateCamera=function(t){this._originUpdateCamera?this._originUpdateCamera.bind(this)(t):e.UniformState.prototype.updateCamera.bind(this)(t),this._xbsjScene=t._scene};var r,n;t.context._us.updatePass;t.context._us.updatePass=function(o){if(this._originUpdatePass?this._originUpdatePass.bind(this)(o):e.UniformState.prototype.updatePass.bind(this)(o),o===e.Pass.CESIUM_3D_TILE_CLASSIFICATION||o===e.Pass.OPAQUE){var a;a=this._xbsjScene._passState||this._xbsjScene._defaultView.passState;var s=this._xbsjScene._context,u=i(t,0);o===e.Pass.CESIUM_3D_TILE_CLASSIFICATION?a.framebuffer&&a.framebuffer.depthStencilTexture&&(u.update(s,a.framebuffer.depthStencilTexture),u.executeCopyDepth(s,a),n=u._depthTexture,r=s.uniformState.globeDepthTexture,s.uniformState.globeDepthTexture=n):o===e.Pass.OPAQUE&&void 0!==a.framebuffer&&(s.uniformState.globeDepthTexture=r)}}}function r(t,i,r,n,o,s,u,c,m){if(void 0===t||void 0===i)return void console.error("必须设置center和width!");r=r||i,n=n||0,s=s||e.Color.WHITE,o=o||"";var h=a(t,i,r,n),p=new e.Material({fabric:{type:"Image",uniforms:{image:o,color:s}}});return new e.XbsjGroundPrimitive({geometryInstances:new e.GeometryInstance({geometry:new e.PolygonGeometry({polygonHierarchy:new e.PolygonHierarchy(h),stRotation:-n})}),appearance:new e.MaterialAppearance({material:p}),classificationType:m,minHeight:u,maxHeight:c})}function n(t,i,r,n,o,a,s,u,c){a=a||e.Color.WHITE,o=o||"";var m=new e.Material({fabric:{type:"Image",uniforms:{image:o,color:a}}}),h=new e.RectangleGeometry({rectangle:e.Rectangle.fromDegrees(t,i,r,n)});return new e.XbsjGroundPrimitive({geometryInstances:new e.GeometryInstance({geometry:h}),appearance:new e.MaterialAppearance({material:m}),classificationType:c,minHeight:s,maxHeight:u})}function o(t,i,r,n){var o=new e.PolygonGeometry({polygonHierarchy:new e.PolygonHierarchy(t),height:i,perPositionHeight:!1,extrudedHeight:r});return new e.ClassificationPrimitive({geometryInstances:[new e.GeometryInstance({geometry:o,attributes:{color:e.ColorGeometryInstanceAttribute.fromColor(n)}})],classificationType:e.ClassificationType.CESIUM_3D_TILE})}e.XbsjGroundPrimitive=function(e,t,i,r,n,o,a,s,u,c,m,h,p,d,l,g,f,v,_,y,b,x,I,w,P,S,C,T,H){function M(t){t=u(t,u.EMPTY_OBJECT);var i=t.appearance,r=t.geometryInstances;if(!c(i)&&c(r))for(var n=g(r)?r:[r],o=n.length,a=0;a<o;a++){var s=n[a].attributes;if(c(s)&&c(s.color)){i=new C({flat:!0});break}}this.appearance=i,this.geometryInstances=t.geometryInstances,this.show=u(t.show,!0),this.classificationType=u(t.classificationType,S.BOTH),this.debugShowBoundingVolume=u(t.debugShowBoundingVolume,!1),this.debugShowShadowVolume=u(t.debugShowShadowVolume,!1),this._boundingVolumes=[],this._boundingVolumes2D=[],this._ready=!1,this._readyPromise=w.defer(),this._primitive=void 0,this._maxHeight=void 0,this._minHeight=void 0,this._maxTerrainHeight=e._defaultMaxTerrainHeight,this._minTerrainHeight=e._defaultMinTerrainHeight,this._boundingSpheresKeys=[],this._boundingSpheres=[],this._useFragmentCulling=!1,this._zIndex=void 0;var m=this;this._classificationPrimitiveOptions={geometryInstances:void 0,appearance:void 0,vertexCacheOptimize:u(t.vertexCacheOptimize,!1),interleave:u(t.interleave,!1),releaseGeometryInstances:u(t.releaseGeometryInstances,!0),allowPicking:u(t.allowPicking,!0),asynchronous:u(t.asynchronous,!0),compressVertices:u(t.compressVertices,!0),_createBoundingVolumeFunction:void 0,_updateAndQueueCommandsFunction:void 0,_pickPrimitive:m,_extruded:!0,_uniformMap:N},this._vtxfMaxHeight=t.maxHeight,this._vtxfMinHeight=t.minHeight}function E(e){return function(t,i){if(e._vtxfMaxHeight)return e._vtxfMaxHeight;var r=i.maximumRadius,n=r/Math.cos(.5*t)-r;return e._maxHeight+n}}function V(e){return function(t,i){return e._vtxfMinHeight?e._vtxfMinHeight:e._minHeight}}function G(e,t){var i=e.mapProjection.ellipsoid;{if(c(t.attributes)&&c(t.attributes.position3DHigh)){for(var r=t.attributes.position3DHigh.values,o=t.attributes.position3DLow.values,a=r.length,s=Number.POSITIVE_INFINITY,u=Number.POSITIVE_INFINITY,m=Number.NEGATIVE_INFINITY,h=Number.NEGATIVE_INFINITY,p=0;p<a;p+=3){var d=n.unpack(r,p,F),l=n.unpack(o,p,k),g=n.add(d,l,R),f=i.cartesianToCartographic(g,U),v=f.latitude,_=f.longitude;s=Math.min(s,v),u=Math.min(u,_),m=Math.max(m,v),h=Math.max(h,_)}var y=B;return y.north=m,y.south=s,y.east=h,y.west=u,y}if(c(t.rectangle))return t.rectangle}}function A(t,i,r){var n=e.getApproximateTerrainHeights(i,r);t._minTerrainHeight=n.minimumTerrainHeight,t._maxTerrainHeight=n.maximumTerrainHeight}function D(e,i,r){var o=i.mapProjection.ellipsoid,a=G(i,r);if(a.width<f.PI){var s=v.fromRectangle(a,e._maxHeight,e._minHeight,o);e._boundingVolumes.push(s)}else{var u=r.attributes.position3DHigh.values,c=r.attributes.position3DLow.values;e._boundingVolumes.push(t.fromEncodedCartesianVertices(u,c))}if(!i.scene3DOnly){var m=i.mapProjection,h=t.fromRectangleWithHeights2D(a,m,e._maxHeight,e._minHeight);n.fromElements(h.center.z,h.center.x,h.center.y,h.center),e._boundingVolumes2D.push(h)}}function O(e,t){return Math.floor(e%t/3)}function j(e,t,i,r,n,o,a,s){var u;u=t.mode===T.SCENE3D?e._boundingVolumes:e._boundingVolumes2D;var c;switch(e.classificationType){case S.TERRAIN:c=I.TERRAIN_CLASSIFICATION;break;case S.CESIUM_3D_TILE:c=I.CESIUM_3D_TILE_CLASSIFICATION;break;default:c=I.CLASSIFICATION}var m=t.commandList,h=t.passes,p=e._primitive;if(h.render){var d,l,g=i.length;for(d=0;d<g;++d)l=i[d],t.mode!==T.SCENE3D&&l.shaderProgram===p._spColor&&p._needs2DShader&&(l=l.derivedCommands.appearance2D),l.owner=e,l.modelMatrix=n,l.boundingVolume=u[O(d,g)],l.cull=o,l.debugShowBoundingVolume=a,l.pass=c,m.push(l);if(t.invertClassification){var f=p._commandsIgnoreShow,v=f.length;for(d=0;d<v;++d){var _=Math.floor(d/2);l=f[d],l.modelMatrix=n,l.boundingVolume=u[_],l.cull=o,l.debugShowBoundingVolume=a,m.push(l)}}}if(h.pick){var y,b=r.length;e._useFragmentCulling||(p=e._primitive,y=p._primitive._pickOffsets);for(var x=0;x<b;++x){var w=r[x];t.mode!==T.SCENE3D&&w.shaderProgram===p._spPick&&p._needs2DShader&&(w=w.derivedCommands.pick2D);var P=u[O(x,b)];if(!e._useFragmentCulling){P=u[y[O(x,b)].index]}w.owner=e,w.modelMatrix=n,w.boundingVolume=P,w.cull=o,w.pass=c,m.push(w)}}}var N={u_globeMinimumAltitude:function(){return 55e3}};m(M.prototype,{vertexCacheOptimize:{get:function(){return this._classificationPrimitiveOptions.vertexCacheOptimize}},interleave:{get:function(){return this._classificationPrimitiveOptions.interleave}},releaseGeometryInstances:{get:function(){return this._classificationPrimitiveOptions.releaseGeometryInstances}},allowPicking:{get:function(){return this._classificationPrimitiveOptions.allowPicking}},asynchronous:{get:function(){return this._classificationPrimitiveOptions.asynchronous}},compressVertices:{get:function(){return this._classificationPrimitiveOptions.compressVertices}},ready:{get:function(){return this._ready}},readyPromise:{get:function(){return this._readyPromise.promise}}}),M.isSupported=P.isSupported;var F=new n,k=new n,R=new n,U=new o,B=new _;return M.initializeTerrainHeights=function(){return e.initialize()},M.prototype.update=function(t){if(c(this._primitive)||c(this.geometryInstances)){if(!c(e._terrainHeights)){if(!this.asynchronous)throw new p("For synchronous GroundPrimitives, you must call GroundPrimitive.initializeTerrainHeights() and wait for the returned promise to resolve.");return void M.initializeTerrainHeights()}var i=this,r=this._classificationPrimitiveOptions;if(!c(this._primitive)){var n,o,a,s,u,m=t.mapProjection.ellipsoid,h=g(this.geometryInstances)?this.geometryInstances:[this.geometryInstances],d=h.length,f=new Array(d);for(s=0;s<d;++s){n=h[s],o=n.geometry;var v=G(t,o);c(u)?c(v)&&_.union(u,v,u):u=_.clone(v);var y=n.id;if(c(y)&&c(v)){var b=e.getInstanceBoundingSphere(v,m);this._boundingSpheresKeys.push(y),this._boundingSpheres.push(b)}if(a=o.constructor,!c(a)||!c(a.createShadowVolume))throw new p("Not all of the geometry instances have GroundPrimitive support.")}A(this,u,m);var x=t.terrainExaggeration;this._minHeight=this._minTerrainHeight*x,this._maxHeight=this._maxTerrainHeight*x;var I=M._supportsMaterials(t.context);if(this._useFragmentCulling=I,I){var w,S=!0;for(s=0;s<d;++s)if(n=h[s],o=n.geometry,u=G(t,o),H.shouldUseSphericalCoordinates(u)){S=!1;break}for(s=0;s<d;++s){n=h[s],o=n.geometry,a=o.constructor;var C=G(t,o),T=o.textureCoordinateRotationPoints;w=S?H.getPlanarTextureCoordinateAttributes(C,T,m,t.mapProjection,this._maxHeight):H.getSphericalExtentGeometryInstanceAttributes(C,T,m,t.mapProjection);var O=n.attributes;for(var N in O)O.hasOwnProperty(N)&&(w[N]=O[N]);f[s]=new l({geometry:a.createShadowVolume(o,V(this),E(this)),attributes:w,id:n.id})}}else for(s=0;s<d;++s)n=h[s],o=n.geometry,a=o.constructor,f[s]=new l({geometry:a.createShadowVolume(o,V(this),E(this)),attributes:n.attributes,id:n.id});r.geometryInstances=f,r.appearance=this.appearance,r._createBoundingVolumeFunction=function(e,t){D(i,e,t)},r._updateAndQueueCommandsFunction=function(e,t,r,n,o,a,s,u){j(i,t,r,n,o,a,s,u)},this._primitive=new P(r),this._primitive.readyPromise.then(function(e){i._ready=!0,i.releaseGeometryInstances&&(i.geometryInstances=void 0);var t=e._error;c(t)?i._readyPromise.reject(t):i._readyPromise.resolve(i)})}this._primitive.appearance=this.appearance,this._primitive.show=this.show,this._primitive.debugShowShadowVolume=this.debugShowShadowVolume,this._primitive.debugShowBoundingVolume=this.debugShowBoundingVolume,this._primitive.update(t)}},M.prototype.getBoundingSphere=function(e){var t=this._boundingSpheresKeys.indexOf(e);if(-1!==t)return this._boundingSpheres[t]},M.prototype.getGeometryInstanceAttributes=function(e){if(!c(this._primitive))throw new p("must call update before calling getGeometryInstanceAttributes");return this._primitive.getGeometryInstanceAttributes(e)},M.prototype.isDestroyed=function(){return!1},M.prototype.destroy=function(){return this._primitive=this._primitive&&this._primitive.destroy(),h(this)},M._supportsMaterials=function(e){return e.depthTexture},M.supportsMaterials=function(e){return a.typeOf.object("scene",e),M._supportsMaterials(e.frameState.context)},M}(e.ApproximateTerrainHeights,e.BoundingSphere,e.buildModuleUrl,e.Cartesian2,e.Cartesian3,e.Cartographic,e.Check,e.ColorGeometryInstanceAttribute,e.defaultValue,e.defined,e.defineProperties,e.destroyObject,e.DeveloperError,e.GeographicTilingScheme,e.GeometryInstance,e.isArray,e.Math,e.OrientedBoundingBox,e.Rectangle,e.RectangleGeometry,e.Resource,e.DrawCommand,e.Pass,e.when,e.ClassificationPrimitive,e.ClassificationType,e.PerInstanceColorAppearance,e.SceneMode,e.ShadowVolumeAppearance);var a=function(){function t(t,s,u,c,m){var h=e.Transforms.eastNorthUpToFixedFrame(t,e.Ellipsoid.WGS84,i),p=e.Quaternion.fromAxisAngle(e.Cartesian3.UNIT_Z,c,r),d=e.Matrix4.fromTranslationQuaternionRotationScale,l=d(e.Cartesian3.ZERO,p,o(s,u),n),g=e.Matrix4.multiply(h,l,l);return void 0===m&&(m=[]),a.forEach(function(t,i){void 0===m[i]&&(m[i]=new e.Cartesian3),e.Matrix4.multiplyByPoint(g,t,m[i])}),m}var i=new e.Matrix4,r=new e.Quaternion,n=new e.Matrix4,o=e.Cartesian3.fromElements,a=[o(-.5,-.5,0),o(.5,-.5,0),o(.5,.5,0),o(-.5,.5,0)];return t}();return e.createXbsjGroundPrimitive=r,e.createXbsjGroundPrimitiveFromRectangle=n,e.createXbsjHighlightPolygon=o,e.xbsjGroundPrimitiveMixin=t,t}.apply(t,r))&&(e.exports=n)}})});