Custom Gis Application with Arcgis Javascript API with modern layouting
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

7 lines
2.1 KiB

// All material copyright Esri, All Rights Reserved, unless otherwise specified.
// See https://js.arcgis.com/4.30/esri/copyright.txt for details.
//>>built
define(["exports","../../core/Logger","./storageLayouts"],function(u,x,v){const g=(()=>{var b=new ArrayBuffer(2);const a=new Uint8Array(b);b=new Uint16Array(b);a[0]=170;a[1]=187;return 48042===b[0]})(),w=()=>x.getLogger("esri.views.webgl.UniformBufferLayout");class y{constructor(b){this._layout=new Map;this.byteLength=this._buildLayout(b);this.array=new ArrayBuffer(this.byteLength);this.arrayView32=new Float32Array(this.array);this._dataView=new DataView(this.array)}setValues(b,a){for(const c in b)this.setValue(c,
b[c],a)}setValue(b,a,c){if(this._layout.has(b)){var f=this.byteLength/4,e=0,{type:q,offset:h,arrayLength:r}=this._layout.get(b),{numberType:m,elementLength:k,elementCount:t,arrayStride:l}=v.STD140_LAYOUT[q],d="number"!==typeof a;b=r*t;(d?"byteLength"in a?a.byteLength/4:a.length:1)!==b*k&&w().warn("Attempting to set layout array member value with the wrong length!");if(d)for(d=0;d<b;d++)for(let n=0;n<k;n++){var p=h+d*l+4*n;this._setData(p,a[d*k+n],m)&&(p/=4,f=Math.min(f,p),e=Math.max(e,p+1))}else this._setData(h,
a,m)&&(a=h/4,f=Math.min(f,a),e=Math.max(e,a+1));c&&(c.from=Math.min(f,c.from),c.to=Math.max(e,c.to))}else w().warn("Trying to set an unrecognized layout array member!")}_setData(b,a,c){switch(c){case "Int32":if(a!==this._dataView.getInt32(b,g))return this._dataView.setInt32(b,a,g),!0;break;case "Uint32":if(a!==this._dataView.getUint32(b,g))return this._dataView.setUint32(b,a,g),!0;break;case "Float32":if(a!==this._dataView.getFloat32(b,g))return this._dataView.setFloat32(b,a,g),!0}return!1}_buildLayout(b){let a=
0;for(const {name:f,type:e,count:q}of b){const {elementLength:h,elementCount:r,elementAlignment:m,arrayStride:k,arrayAlignment:t}=v.STD140_LAYOUT[e];b=q??1;var c=b*r;const l=1<c,d=l?t:m;c=l?c*k:4*h;a+=(d-a%d)%d;this._layout.set(f,{type:e,offset:a,arrayLength:b});a+=c;l&&(a+=(d-a%d)%d)}return a+(16-a%16)%16}}u.UniformBufferLayout=y;Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})});