/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../../../../chunks/_rollupPluginBabelHelpers","../../../../chunks/tslib.es6","../../../../core/Accessor","../../../../core/maybe","../../../../core/accessorSupport/decorators/property","../../../../core/arrayUtils","../../../../core/has","../../../../core/accessorSupport/ensureType","../../../../core/accessorSupport/decorators/subclass","../lib/ContentObjectType","../lib/GridLocalOriginFactory","../lib/ModelDirtySet","../lib/RenderGeometry","../lib/Util","../lib/WebGLLayer"],(function(e,t,o,n,r,i,a,s,c,d,l,u,y,h,f,b){"use strict";e.Model=function(e){function o(){var o;return(o=e.apply(this,arguments)||this).dirtySet=new y({model:t._assertThisInitialized(o)}),o._content=new Map,o._originFactory=new u.GridLocalOriginFactory(null,75e4),o}t._inheritsLoose(o,e);var n=o.prototype;return n.getObject=function(e){return this._content.get(e)},n.add=function(e){const t=e.id;f.assert(!this._content.has(t),"Model/Stage already contains object to be added"),this._content.set(t,e),b.isWebGLLayer(e)&&this.dirtySet.layerAdded(e)},n.remove=function(e){f.assert(this._content.has(e.id),"Model/Stage doesn't contain object to be removed"),this._content.delete(e.id),e.unload(),b.isWebGLLayer(e)&&this.dirtySet.layerRemoved(e)},n.addMany=function(e){for(const t of e)r.isSome(t)&&(f.assert(!this._content.has(t.id),"Model/Stage already contains object to be added"),this._content.set(t.id,t))},n.removeMany=function(e){for(const t of e)f.assert(this._content.has(t.id),"Model/Stage doesn't contain object to be removed"),this._content.delete(t.id),t.unload()},n.has=function(e){return this._content.has(e.id)},n.forEachOfType=function(e,t){this._content.forEach((o=>{o.type===e&&t(o)}))},n.getRenderGeometry=function(e,t){const{geometry:o,material:n,id:r,shaderTransformation:i,origin:a,instanceParameters:s}=t,c=new h.RenderGeometry(o,n,{id:r,boundingInfo:o.boundingInfo,calculateShaderTransformation:i,castShadow:e.castShadow});return c.updateTransformation((o=>e.getCombinedStaticTransformation(t,o))),c.origin=a||this._originFactory.getOrigin(c.boundingSphere),c.instanceParameters=s,c},n.updateRenderGeometryTransformation=function(e,t,o){if(r.isNone(e))return!1;o.updateTransformation((o=>e.getCombinedStaticTransformation(t,o)));const n=this._originFactory.getOrigin(o.boundingSphere);return o.origin!==n},n.getStats=function(){const e={},t=Array.from(this._content.values());for(let o=0;o<l.ContentObjectType.COUNT;++o)e[o]=t.filter((e=>e.type===o)).length;return{contentTypes:e,dirtySet:this.dirtySet.formatDebugInfo()}},t._createClass(o,[{key:"test",get:function(){return{content:Array.from(this._content.values())}}}]),o}(n),o.__decorate([i.property({constructOnly:!0})],e.Model.prototype,"dirtySet",void 0),e.Model=o.__decorate([d.subclass("esri.views.3d.webgl-engine.parts.Model")],e.Model),Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
