UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

6 lines (5 loc) 1.7 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.33/esri/copyright.txt for details. */ import{DisplayObject as t}from"../../../DisplayObject.js";import e from"../../DisplayEntity.js";import{MappedMesh as n}from"../../cpuMapped/MappedMesh.js";import s from"../../util/Reader.js";import{deserializeList as r}from"../../util/serializationUtils.js";import{PrimitiveType as i,DataType as o}from"../../../../../webgl/enums.js";class a extends t{static fromMeshData(t,i,o){const c=new Map;for(const e of t.data){const t=new n(i,e.layout);t.append(e),t.upload(),c.set(e.instanceId,t)}const d=new s(t.entities),I=r(d,e,{})??[];return new a(I,c,o)}constructor(t,e,n){super(),this.displayObjects=t,this._instanceIdToMesh=e,this._store=n}draw(t,e){if(null==this._activeInstanceId)throw new Error("InternalError: No active instanceId");for(const n of this.displayObjects)for(const s of n.records){if(s.instanceId!==this._activeInstanceId)continue;const n=t.context,r=this._instanceIdToMesh.get(this._activeInstanceId).getGeometryVAO(n,e),a=s.indexStart*Uint32Array.BYTES_PER_ELEMENT;n.bindVAO(r),n.drawElements(i.TRIANGLES,s.indexCount,o.UNSIGNED_INT,a),n.bindVAO(null)}}getStencilReference(){return 0}getAttributePrecisionPackFactors(){return{}}destroy(){for(const t of this._instanceIdToMesh.values())t.destroy();this._instanceIdToMesh.clear()}setActiveMesh(t){this._activeInstanceId=t}getInput(){if(null==this._activeInstanceId)throw new Error("InternalError: No active instanceId");return this._store.getInstance(this._activeInstanceId).getInput()}_createTransforms(){throw new Error("Method not implemented.")}}export{a as TestDisplayObject};