@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 2.92 kB
JavaScript
/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
*/
import{identity as t,scale as e}from"../../../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as r}from"../../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromArray as o,create as i}from"../../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{computeTranslationToOriginAndRotation as n}from"../../../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{create as s,size as a}from"../../../../../../geometry/support/aaBoundingBox.js";import{objectSymbolLayerPrimitiveBoundingBox as l,objectSymbolLayerSizeWithResourceSize as d}from"../../../../../../symbols/support/symbolLayerUtils3D.js";import{computeObjectScale as c}from"../../graphicUtils.js";import{readMapCoordinates as m,readObjectIds as h}from"../featureData/processingUtils.js";import{createPrimitiveGeometry as p}from"./primitiveObjectUtils.js";class f{constructor(t){this._context=t,this.lodRendererId=null,this._loaded=!1,this._loadingPromise=null,this._primitive="cone"}get loaded(){return this._loaded}load(){return null==this._loadingPromise&&(this._loadingPromise=this._load()),this._loadingPromise}async _load(){const t=this._context.renderCommandContext.createEncoder(),e=t.createMaterial("default"),r=p(this._primitive,e);this.lodRendererId=t.createLodRenderer(r),await t.dispatch(),this._loaded=!0}async createAddCommand(t){const e=this._context.renderCommandContext.createEncoder();if(null==this.lodRendererId)throw new Error("expected lod renderer id to not be null");const{featureCount:r}=t;if(0===r)return e;const i=!0,n=s(l(this._primitive)),c=o(a(n)),p=o(d(c,{isPrimitive:i,width:100,depth:null,height:null})),f=new Float64Array(16*r),u=new Float64Array(16*r),g=m(t,this._context);for(let o=0;o<r;++o){const t=o,e=g[3*o+0],r=g[3*o+1],i=g[3*o+2],n=this._computeGlobalTransform(e,r,i,this._context.viewSpatialReference,x),s=this._computeLocalTransform(p,c,_);this._writeMatrixToTypedBuffer(f,t,s),this._writeMatrixToTypedBuffer(u,t,n)}const y=h(t,this._context),T={featureIds:new Uint32Array(y),localTransforms:f,globalTransforms:u};return e.addLodInstances(this.lodRendererId,T),e}async createRemoveCommand(t){const e=this._context.renderCommandContext.createEncoder();if(null==this.lodRendererId)return e;const r=h(t,this._context);return e.removeLodInstances(this.lodRendererId,r),e}_writeMatrixToTypedBuffer(t,e,r){let o=16*e;for(let i=0;i<16;i++)t[o++]=r[i]}_computeGlobalTransform(t,e,r,o,i){return u[0]=t,u[1]=e,u[2]=r,n(o,u,i,this._context.renderSpatialReference),i}_computeLocalTransform(e,r,o){return t(o),this._applyObjectScale(e,r,o),o}_applyObjectScale(t,r,o){const i=c(t,t,r,this._context.renderCoordsHelper.unitInMeters);1===i[0]&&1===i[1]&&1===i[2]||e(o,o,i)}}const u=i(),_=r(),x=r();export{f as TestObjectSymbol};