UNPKG

@arcgis/core

Version:

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

6 lines (5 loc) 1.97 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.33/esri/copyright.txt for details. */ import{destroyMaybe as e}from"../../../../../../../core/maybe.js";import{Mesh as t}from"../../../meshing/Mesh.js";import{simplePipelineState as r}from"../../utils.js";import{Technique as s}from"../Technique.js";import{TechniqueType as o}from"../TechniqueType.js";import{VideoScreenShader as n}from"../shaders/VideoScreenShader.js";import{PrimitiveType as i,DataType as m}from"../../../../../../webgl/enums.js";import{VertexElementDescriptor as c}from"../../../../../../webgl/VertexElementDescriptor.js";class h extends s{constructor(){super(...arguments),this.type=o.VideoScreen,this._mesh=null,this.shaders={geometry:new n}}render(e,t){const{context:s,painter:o}=e,{texture:n,textureCoords:i}=t,m=this._getMesh(e),c=t.ndcRect[2],h=t.ndcRect[3],u=t.ndcRect[0],a=t.ndcRect[1],p=new Float32Array(180);for(let r=0;r<6;r++){const e=h*r/5;for(let t=0;t<6;t++){const s=c*t/5,{u:o,v:n}=i[6*r+t];p[5*(6*r+t)]=u+s,p[5*(6*r+t)+1]=a-e,p[5*(6*r+t)+2]=o,p[5*(6*r+t)+3]=n,p[5*(6*r+t)+4]=1}}m.vertexBuffers.get("geometry")?.buffer.setData(p);const d={texture:{texture:n,unit:0},opacity:t.opacity},f={shader:this.shaders.geometry,uniforms:{config:d},defines:{},optionalAttributes:null,useComputeBuffer:!1};o.setPipelineState(r),o.submitDrawMeshUntyped(s,f,m)}shutdown(){e(this._mesh)}_getMesh(e){const{context:r}=e,s=new Uint32Array(150);for(let t=0;t<5;t++)for(let e=0;e<5;e++){const r=6*(5*t+e),o=6*(t+1)+e+1,n=o-1,i=o-6,m=o-7;s[r]=o,s[r+1]=n,s[r+2]=i,s[r+3]=n,s[r+4]=m,s[r+5]=i}return this._mesh||(this._mesh=new t(r,{vertex:{geometry:{data:new Float32Array(180),attributes:[new c("position",2,m.FLOAT,0,20),new c("texcoord",2,m.FLOAT,8,20),new c("w",1,m.FLOAT,16,20)]}},index:{index:{data:s}},groups:[{primitive:i.TRIANGLES,index:"index"}],parts:[{group:0,start:0,count:s.length}]})),this._mesh}}export{h as VideoScreenTechnique};