UNPKG

@arcgis/core

Version:

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

6 lines (5 loc) 3.37 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.32/esri/copyright.txt for details. */ import{_ as e}from"../../../../../../chunks/tslib.es6.js";import{property as r}from"../../../../../../core/accessorSupport/decorators/property.js";import"../../../../../../core/has.js";import"../../../../../../core/Logger.js";import"../../../../../../core/RandomLCG.js";import{subclass as t}from"../../../../../../core/accessorSupport/decorators/subclass.js";import{glLayout as i}from"../../../../support/buffer/glUtil.js";import{ShaderOutput as s}from"../../../../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{SyncRenderPlugin as o}from"../../../../webgl-engine/effects/RenderPlugin.js";import{GLMaterials as n}from"../../../../webgl-engine/lib/GLMaterials.js";import{RenderSlot as a}from"../../../../webgl-engine/lib/RenderSlot.js";import{DrawParameters as l}from"../../../../webgl-engine/materials/DrawParameters.js";let m=class extends o{constructor(e){super(e),this._glMaterials=null,this._produces=new Map,this._renderGeometries=new Map,this._vaoCache=null,this._drawParameters=new l,this._bufferWriter=null}get produces(){return this._produces}get numFeatures(){const e=6;let r=0;return this._renderGeometries.forEach((t=>r+=t.numElements/e)),r}get usedMemory(){let e=0;return this._renderGeometries.forEach((r=>{e+=r.vao.usedMemory})),e}initialize(){this._bufferWriter=this.material.createBufferWriter(),this.material.produces.forEach(((e,r)=>{this._produces.set(r,(r=>r!==s.Highlight&&r!==s.ShadowHighlight&&e(r)))}))}destroy(){this._glMaterials.dispose();const e=this._renderGeometries.keys();for(const r of e)this.removeRenderGeometry(r)}acquireTechniques(e){const r=this.material;if(!r.shouldRender(e))return null;const{output:t,bind:i}=e,o=r.produces.get(i.slot);if(!o?.(t))return null;if(t===s.Highlight||t===s.ShadowHighlight)return null;const n=this._glMaterials.load(e.rctx,i.slot,t);return n?.beginSlot(i)}render(e,r){const t=this._renderGeometries;if(0===t.size)return;const{bind:i}=e,s=i.slot===a.OCCLUDER_MATERIAL||i.slot===a.TRANSPARENT_OCCLUDER_MATERIAL?i.slot:null,o=e.rctx;o.runAppleAmdDriverHelper(),o.bindTechnique(r,i,this.material.parameters);const n=r.program;for(const[a,l]of t)this._drawParameters.origin=l.localOrigin,n.bindDraw(i,this.material.parameters,this._drawParameters),r.ensureAttributeLocations(l.vao),o.bindVAO(l.vao),o.setPipelineState(r.getPipeline(!1,s)),o.drawArrays(r.primitiveType,0,l.numElements)}initializeRenderContext(e,r){this._glMaterials=new n(this.material,e.materials),this._vaoCache=e.renderContext.rctx.getVaoCache(this.material.vertexAttributeLocations,i(this._bufferWriter.vertexBufferLayout))}uninitializeRenderContext(){}addRenderGeometry(e,r,t){this.removeRenderGeometry(e);const i=this._vaoCache.newVao(r.data.byteLength);i.vertexBuffers.get("geometry").setSubData(new Uint8Array(r.data),0,0,r.data.byteLength);const s={localOrigin:t,vao:i,numElements:r.elementCount};return this._renderGeometries.set(e,s),s}removeRenderGeometry(e){const r=this._renderGeometries.get(e);null!=r&&(this._vaoCache.deleteVao(r.vao),this._renderGeometries.delete(e))}hasHighlightOptions(e){return!1}};e([r({constructOnly:!0})],m.prototype,"material",void 0),m=e([t("esri.views.3d.layers.graphics.pipeline.rendering.DirectRenderer")],m);export{m as DirectRenderer};