@doegis/core
Version:
DOE GIS API
3 lines (1 loc) • 1.48 kB
JavaScript
import{isSome as e}from"../../../../../../core/maybe.js";import{writeColor as t}from"../../color.js";import{DOT_DENSITY_MAX_FIELDS as o}from"../../definitions.js";import{Technique as r}from"../Technique.js";import{DataType as a}from"../../../../../webgl/enums.js";class n extends r{static getStorageSpec({attributes:e}){return{visualVariables:!1,attributes:e??null}}static _createRendererSchema(){return{type:"dot-density",colors:new Float32Array(32),dotValue:-1,dotSize:-1,dotScale:-1,dotBlending:!1,backgroundColor:new Float32Array(4),activeDots:new Float32Array(8),seed:-1}}static createOrUpdateRendererSchema(r,a){const{attributes:n,dotValue:i,referenceScale:d,dotSize:l,dotBlendingEnabled:s,seed:c,backgroundColor:u}=a,m=e(r)&&"dot-density"===r.type?r:this._createRendererSchema();m.dotValue=i,m.dotSize=l,m.dotScale=d,m.dotBlending=s,m.seed=c;const{colors:g,activeDots:p,backgroundColor:y}=m;for(let e=0;e<o;e++){const o=e>=n.length?null:n[e].color;t(g,o,4*e)}for(let e=0;e<8;e++)p[e]=e<a.attributes.length?1:0;return t(y,u),m}static getVariation(e){return{ddDotBlending:e.dotBlending}}static getVariationHash(e){return e.dotBlending?1:0}}n.type="dot-density",n.programSpec={shader:"materials/fill",vertexLayout:{geometry:[{location:0,name:"a_pos",count:2,type:a.SHORT},{location:1,name:"a_id",count:3,type:a.UNSIGNED_BYTE},{location:2,name:"a_bitset",count:1,type:a.UNSIGNED_BYTE},{location:3,name:"a_inverseArea",count:1,type:a.FLOAT}]}};export{n as DotDensityTechnique};