// All material copyright ESRI, All Rights Reserved, unless otherwise specified.
// See https://js.arcgis.com/4.8/esri/copyright.txt for details.
//>>built
define("require exports ../../../../core/tsSupport/extendsHelper ../../../../core/tsSupport/generatorHelper ../../../../core/tsSupport/awaiterHelper ../../../../geometry/support/aaBoundingBox ./featureExpressionInfoUtils ./Graphics3DGraphicElevationContext ./graphicUtils ../../lib/glMatrix ../../webgl-engine/lib/HighlightUtils".split(" "),function(m,F,G,y,z,h,A,B,C,n,D){m=function(){function a(b,a,t,e){this.type="lod-instance";this.alignedTerrainElevation=0;this.needsElevationUpdates=!1;this.graphics3DSymbolLayer=
b;this.instanceIndex=a;this.elevationAligner=t;this.elevationContext=new B(e)}a.prototype.initialize=function(b,a){};a.prototype.setVisibility=function(b){var a=this.lodRenderer.instanceData;return b!==a.getVisible(this.instanceIndex)?(a.setVisible(this.instanceIndex,b),!0):!1};a.prototype.destroy=function(){null!=this.instanceIndex&&(this.lodRenderer.instanceData.removeInstance(this.instanceIndex),this.graphics3DSymbolLayer.notifyDestroyGraphicLayer(this))};a.prototype.alignWithElevation=function(b,
a,e){this.elevationAligner&&(A.setContextFeature(this.elevationContext.featureExpressionInfoContext,e),b=this.elevationAligner(this,this.elevationContext,b,a),null!=b&&(this.alignedTerrainElevation=b))};a.prototype.getBSRadius=function(){var b=this.lodRenderer;return b.baseBoundingSphere.radius*b.instanceData.getScaleFactor(this.instanceIndex)};a.prototype.getCenterObjectSpace=function(){return this.lodRenderer.baseBoundingSphere.center};a.prototype.getBoundingBoxObjectSpace=function(b){b=b||h.create();
h.set(b,this.lodRenderer.baseBoundingBox);return b};a.prototype.getProjectedBoundingBox=function(b,a,t,m){return z(this,void 0,void 0,function(){var c,u,p,d,q,r,f,l,w;return y(this,function(k){switch(k.label){case 0:c=this.getBoundingBoxObjectSpace(t);u=E;p=h.isPoint(c)?1:u.length;this.lodRenderer.instanceData.getTransform(this.instanceIndex,x);for(d=0;d<p;d++)q=u[d],e[0]=c[q[0]],e[1]=c[q[1]],e[2]=c[q[2]],n.mat4d.multiplyVec3(x,e),g[3*d+0]=e[0],g[3*d+1]=e[1],g[3*d+2]=e[2];if(!b(g,0,p))return[2,null];
h.empty(c);r=null;this.calculateRelativeScreenBounds&&(r=this.calculateRelativeScreenBounds());for(d=0;d<3*p;d+=3){for(f=0;3>f;f++)c[f]=Math.min(c[f],g[d+f]),c[f+3]=Math.max(c[f+3],g[d+f]);r&&m.push({location:g.slice(d,d+3),screenSpaceBoundingRect:r})}if(!a)return[3,5];h.center(c,v);if("absolute-height"===this.elevationContext.mode)return[3,5];l=void 0;w=C.demResolutionForBoundingBox(c,a);k.label=1;case 1:return k.trys.push([1,3,,4]),[4,a.service.queryElevation(v[0],v[1],w)];case 2:return l=k.sent(),
[3,4];case 3:return k.sent(),l=null,[3,4];case 4:null!=l&&h.offset(c,0,0,-this.alignedTerrainElevation+l),k.label=5;case 5:return[2,c]}})})};a.prototype.addHighlight=function(a,e){var b=this;this.highlightId=D.generateHighlightId();this.lodRenderer.instanceData.setHighlight(this.instanceIndex,!0);a.addExternal(function(a){b.lodRenderer.instanceData.setHighlight(b.instanceIndex,!1);b.highlightId=null},this.highlightId)};a.prototype.removeHighlight=function(a){this.highlightId&&a.remove(this.highlightId)};
Object.defineProperty(a.prototype,"lodRenderer",{get:function(){return this.graphics3DSymbolLayer.lodRenderer},enumerable:!0,configurable:!0});return a}();var g=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],e=n.vec3d.create(),v=n.vec3d.create(),E=[[0,1,2],[3,1,2],[0,4,2],[3,4,2],[0,1,5],[3,1,5],[0,4,5],[3,4,5]],x=n.mat4d.create();return m});