UNPKG

@doegis/core

Version:

DOE GIS API

3 lines (1 loc) 2.52 kB
import{_ as t}from"../../../../chunks/tslib.es6.js";import e from"../../../../core/Accessor.js";import{isSome as o,isNone as r}from"../../../../core/maybe.js";import{property as n}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import{subclass as i}from"../../../../core/accessorSupport/decorators/subclass.js";import{ContentObjectType as s}from"../lib/ContentObjectType.js";import{GridLocalOriginFactory as a}from"../lib/GridLocalOriginFactory.js";import c from"../lib/ModelDirtySet.js";import{RenderGeometry as d}from"../lib/RenderGeometry.js";import{assert as m}from"../lib/Util.js";import{isWebGLLayer as l}from"../lib/WebGLLayer.js";let h=class extends e{constructor(){super(...arguments),this.dirtySet=new c({model:this}),this._content=new Map,this._originFactory=new a(null)}getObject(t){return this._content.get(t)}add(t){const e=t.id;m(!this._content.has(e),"Model/Stage already contains object to be added"),this._content.set(e,t),l(t)&&this.dirtySet.layerAdded(t)}remove(t){m(this._content.has(t.id),"Model/Stage doesn't contain object to be removed"),this._content.delete(t.id),t.unload(),l(t)&&this.dirtySet.layerRemoved(t)}addMany(t){for(const e of t)o(e)&&(m(!this._content.has(e.id),"Model/Stage already contains object to be added"),this._content.set(e.id,e))}removeMany(t){for(const e of t)m(this._content.has(e.id),"Model/Stage doesn't contain object to be removed"),this._content.delete(e.id),e.unload()}has(t){return this._content.has(t.id)}forEachOfType(t,e){this._content.forEach((o=>{o.type===t&&e(o)}))}getRenderGeometry(t,e){const{shaderTransformer:r,localOrigin:n}=e,i=new d(e,{boundingInfo:e.boundingInfo,shaderTransformer:r,castShadow:t.castShadow});return i.updateTransformation((o=>t.getCombinedStaticTransformation(e,o))),i.localOrigin=o(n)?n:this._originFactory.getOrigin(i.boundingSphere),i}updateRenderGeometryTransformation(t,e,o){if(r(t))return!1;o.updateTransformation((o=>t.getCombinedStaticTransformation(e,o)));const n=this._originFactory.getOrigin(o.boundingSphere);return o.localOrigin!==n}getStats(){const t={},e=Array.from(this._content.values());for(let o=0;o<s.COUNT;++o)t[o]=e.filter((t=>t.type===o)).length;return{contentTypes:t,dirtySet:this.dirtySet.formatDebugInfo()}}get test(){return{content:Array.from(this._content.values())}}};t([n({constructOnly:!0})],h.prototype,"dirtySet",void 0),h=t([i("esri.views.3d.webgl-engine.parts.Model")],h);export{h as Model};