@arcgis/core 4.34.0-next.3 → 4.34.0-next.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/22e53cb1c8c575fa4d46.js +1 -0
- package/assets/esri/core/workers/chunks/{b70f65ccee01d48a610e.js → f840e1655c4f6b6630be.js} +19 -19
- package/config.js +1 -1
- package/kernel.js +1 -1
- package/layers/knowledgeGraph/KnowledgeGraphSublayer.js +1 -1
- package/package.json +1 -1
- package/support/revision.js +1 -1
- package/views/2d/engine/Bitmap.js +1 -1
- package/views/2d/engine/flow/styles/Imagery.js +1 -1
- package/views/2d/engine/vectorTiles/GlyphMosaic.js +1 -1
- package/views/2d/engine/vectorTiles/SpriteMosaic.js +1 -1
- package/views/2d/engine/vectorTiles/TileHandler3D.js +1 -1
- package/views/2d/engine/vectorTiles/VectorTile.js +1 -1
- package/views/2d/engine/webgl/AttributeStoreView.js +1 -1
- package/views/2d/engine/webgl/GlyphMosaic.js +1 -1
- package/views/2d/engine/webgl/Overlay.js +1 -1
- package/views/2d/engine/webgl/OverlayMultipoint.js +1 -1
- package/views/2d/engine/webgl/SpriteMosaic.js +1 -1
- package/views/2d/engine/webgl/brushes/WGLBrushTileDebugInfo.js +1 -1
- package/views/2d/engine/webgl/effects/highlight/HighlightGradient.js +1 -1
- package/views/2d/engine/webgl/effects/post-processing/Colorize.js +1 -1
- package/views/2d/engine/webgl/effects/post-processing/DropShadow.js +1 -1
- package/views/2d/engine/webgl/effects/post-processing/Opacity.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/blend/BlendTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/dotDensity/DotDensityResources.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/magnifier/MagnifierTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/textureUtils.js +1 -1
- package/views/3d/environment/LocalAtmosphere.js +1 -1
- package/views/3d/environment/MarsAtmosphere.js +1 -1
- package/views/3d/layers/DrapedSubView3D.js +1 -1
- package/views/3d/layers/DynamicLayerView3D.js +1 -1
- package/views/3d/layers/SubView3D.js +1 -1
- package/views/3d/support/engineContent/marker.js +1 -1
- package/views/3d/webgl-engine/effects/magnifier/Magnifier.js +1 -1
- package/views/3d/webgl-engine/effects/smaa/SMAA.js +1 -1
- package/views/3d/webgl-engine/effects/ssao/SSAO.js +1 -1
- package/views/3d/webgl-engine/materials/stippleTextureRepository.js +1 -1
- package/views/support/imageReprojection.js +1 -1
- package/views/webgl/Texture.js +1 -1
- package/views/webgl/rasterUtils.js +1 -1
- package/assets/esri/core/workers/chunks/1ee6e9a88f0676032e91.js +0 -1
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{clamp as e}from"../../../../../../../core/mathUtils.js";import{disposeMaybe as t}from"../../../../../../../core/maybe.js";import{isSVG as i}from"../../../../../../../core/urlUtils.js";import{simplePipelineState as r}from"../../utils.js";import{Technique as s}from"../Technique.js";import{TechniqueType as o}from"../TechniqueType.js";import{MagnifierShader as a}from"../shaders/MagnifierShader.js";import{PixelFormat as
|
|
5
|
+
import{clamp as e}from"../../../../../../../core/mathUtils.js";import{disposeMaybe as t}from"../../../../../../../core/maybe.js";import{isSVG as i}from"../../../../../../../core/urlUtils.js";import{simplePipelineState as r}from"../../utils.js";import{Technique as s}from"../Technique.js";import{TechniqueType as o}from"../TechniqueType.js";import{MagnifierShader as a}from"../shaders/MagnifierShader.js";import{PixelFormat as u,TextureWrapMode as n,TextureSamplingMode as l}from"../../../../../../webgl/enums.js";import{Texture as h}from"../../../../../../webgl/Texture.js";import{TextureDescriptor as p}from"../../../../../../webgl/TextureDescriptor.js";class c extends s{constructor(){super(...arguments),this.type=o.Magnifier,this._resourcePixelRatio=1,this._position=[0,0,0,0],this.shaders={magnifier:new a}}updateResources(t,i,r,s){t.pixelRatio!==this._resourcePixelRatio&&this._destroyResources(),this._readbackTexture||this._initializeResources(t,i,r,s);const{context:o,pixelRatio:a}=t,{factor:u,offset:n,position:l}=s,{size:h}=t.state,p=s.size*a,c=1/u,x=Math.ceil(c*p);this._readbackTexture.resize(x,x);const m=a*h[0],d=a*h[1],_=.5*x,T=.5*x,f=e(a*l.x,_,m-_-1),R=e(d-a*l.y,T,d-T-1),g=f-_,b=R-T,y=this._readbackTexture;o.bindTexture(y,0),o.gl.copyTexImage2D(y.descriptor.target,0,y.descriptor.pixelFormat,g,b,x,x,0);const w=(f+n.x*a)/m*2-1,k=(R-n.y*a)/d*2-1,M=p/m*2,j=p/d*2;this._position[0]=w,this._position[1]=k,this._position[2]=M,this._position[3]=j}render(e,t){const{context:i,painter:s}=e;s.setPipelineState(r);const o={readbackTexture:{texture:this._readbackTexture,unit:0},maskTexture:{texture:this._maskTexture,unit:7},overlayTexture:{texture:this._overlayTexture,unit:6},drawPos:this._position,...t};s.submitDrawMesh(i,{shader:this.shaders.magnifier,uniforms:{config:o},defines:null,optionalAttributes:null,useComputeBuffer:!1},s.quadMesh)}shutdown(){this._destroyResources()}_initializeResources(e,t,r,s){const o=e.context;this._resourcePixelRatio=e.pixelRatio;const a=Math.ceil(s.size*e.pixelRatio);r.width=a,r.height=a;const c=new p(Math.ceil(a/s.factor));c.internalFormat=u.RGBA,c.wrapMode=n.CLAMP_TO_EDGE,c.samplingMode=l.NEAREST,c.flipped=!0,c.preMultiplyAlpha=!i(r.src)||!e.context.driverTest.svgPremultipliesAlpha.result,this._overlayTexture=new h(o,c,r),t.width=a,t.height=a,c.pixelFormat=c.internalFormat=u.ALPHA,this._maskTexture=new h(o,c,t),c.pixelFormat=c.internalFormat=u.RGBA,c.samplingMode=l.LINEAR,c.flipped=!1,this._readbackTexture=new h(o,c)}_destroyResources(){t(this._maskTexture),t(this._overlayTexture),t(this._readbackTexture),this._maskTexture=null,this._overlayTexture=null,this._readbackTexture=null}}export{c as MagnifierTechnique};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{SizedPixelFormat as e,TextureSamplingMode as r,PixelType as t,TextureWrapMode as n}from"../../../../../../../webgl/enums.js";import{FramebufferObject as o}from"../../../../../../../webgl/FramebufferObject.js";import{Texture as m}from"../../../../../../../webgl/Texture.js";import{TextureDescriptor as
|
|
5
|
+
import{SizedPixelFormat as e,TextureSamplingMode as r,PixelType as t,TextureWrapMode as n}from"../../../../../../../webgl/enums.js";import{FramebufferObject as o}from"../../../../../../../webgl/FramebufferObject.js";import{Texture as m}from"../../../../../../../webgl/Texture.js";import{TextureDescriptor as s}from"../../../../../../../webgl/TextureDescriptor.js";function u(o,m){const u=new s(o,m);return u.internalFormat=e.RGBA32F,u.samplingMode=r.NEAREST,u.dataType=t.FLOAT,u.isImmutable=!0,u.wrapMode=n.CLAMP_TO_EDGE,u}function i(e,r,t){const n=u(r,t);return new m(e,n)}function a(e,r,t){const n=u(r,t);return new o(e,n)}export{a as createNewFBO,i as createProcessedTexture};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import{disposeMaybe as t}from"../../../core/maybe.js";import{watch as r,initial as
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import{disposeMaybe as t}from"../../../core/maybe.js";import{watch as r,initial as s}from"../../../core/reactiveUtils.js";import"../../../core/Logger.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import"../../../core/Error.js";import{subclass as i}from"../../../core/accessorSupport/decorators/subclass.js";import{copy as o}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{create as m}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{InternalRenderCategory as n}from"../webgl.js";import{S as a}from"../../../chunks/SimpleAtmosphere.glsl.js";import{SimpleAtmosphereTechnique as p}from"./SimpleAtmosphereTechnique.js";import{SimpleAtmosphereTechniqueConfiguration as c,SimpleAtmosphereGeometry as f}from"./SimpleAtmosphereTechniqueConfiguration.js";import{earthAtmosphereTextureSimple as l}from"./resources/SimpleAtmosphereTexture.js";import{glLayout as u}from"../support/buffer/glUtil.js";import{newLayout as h}from"../support/buffer/InterleavedLayout.js";import{OpaqueEnvironment as b}from"../webgl-engine/effects/OpaqueEnvironment.js";import{RenderRequestType as g}from"../webgl-engine/lib/basicInterfaces.js";import{Default3D as j}from"../webgl-engine/lib/DefaultVertexAttributeLocations.js";import{createPolySphereData as _}from"../webgl-engine/lib/GeometryUtil.js";import{VertexArrayObject as d}from"../webgl-engine/lib/VertexArrayObject.js";import{VertexAttribute as w}from"../webgl-engine/lib/VertexAttribute.js";import{BufferObject as v}from"../../webgl/BufferObject.js";import{TextureWrapMode as x,PrimitiveType as A,Usage as T}from"../../webgl/enums.js";import{Texture as P}from"../../webgl/Texture.js";import{TextureDescriptor as y}from"../../webgl/TextureDescriptor.js";import{vertexCount as C}from"../../webgl/Util.js";let E=class extends b{constructor(){super(...arguments),this._configuration=new c,this._passParameters=new a,this._vao=null,this._vaoCount=0}initialize(){this._configuration.geometry=f.Cylinder,this.addHandles([r((()=>this.view.environment.atmosphereEnabled),(e=>e?this._enable():this._disable()),s)])}destroy(){this._passParameters.texture=t(this._passParameters.texture),this._vao=t(this._vao)}precompile(){this.techniques.precompile(p,this._configuration)}render(e){const t=e.find((({name:e})=>e===n.OPAQUE_ENVIRONMENT)),r=this.techniques.get(p,this._configuration);if(!r.compiled)return this.requestRender(g.UPDATE),t;const s=this.renderingContext;if(this._vao||(this._vao=O(s),this._vaoCount=C(this._vao,"geometry")),!this._passParameters.texture){const e=new y(1,512);e.wrapMode=x.CLAMP_TO_EDGE,e.flipped=!0,this._passParameters.texture=new P(s,e,l)}const i=s.bindTechnique(r,this.bindParameters,this._passParameters);return S(L,this.bindParameters.camera.viewMatrix),i.setUniformMatrix4fv("view",L),s.bindVAO(this._vao),i.assertCompatibleVertexAttributeLocations(this._vao),s.drawArrays(A.TRIANGLES,0,this._vaoCount),t}};function O(e){const t=_(1,2,!1),{data:r,indices:s}=t[0][1],i=q.createBuffer(s.length),o=i.position;for(let m=0;m<s.length;++m){const e=3*s[m%3==0?m+2:m%3==2?m-2:m];o.set(m,0,r[e]),o.set(m,1,r[e+1]),o.set(m,2,r[e+2])}return new d(e,j,new Map([["geometry",u(q)]]),new Map([["geometry",v.createVertex(e,T.STATIC_DRAW,i.buffer)]]))}function S(e,t){o(e,t),e[12]=0,e[13]=0,e[14]=0,e[15]=1}E=e([i("esri.views.3d.environment.LocalAtmosphere")],E);const L=m(),q=h().vec3f(w.POSITION);export{E as LocalAtmosphere};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import{lerp as t,clamp as r}from"../../../core/mathUtils.js";import{disposeMaybe as s}from"../../../core/maybe.js";import{watch as i,initial as o}from"../../../core/reactiveUtils.js";import"../../../core/Logger.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import"../../../core/Error.js";import{subclass as a}from"../../../core/accessorSupport/decorators/subclass.js";import{lookAt as n}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{create as m}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as h}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{l as p,g as c,f as u,j as l,h as f,k as _}from"../../../chunks/vec32.js";import{create as d}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as g}from"../../../geometry/ellipsoidUtils.js";import{newFloatArray as b}from"../../../geometry/support/FloatArray.js";import{InternalRenderCategory as j}from"../webgl.js";import{computeInnerAltitudeFade as x}from"./atmosphereUtils.js";import{S as V}from"../../../chunks/SimpleAtmosphere.glsl.js";import{SimpleAtmosphereTechnique as w}from"./SimpleAtmosphereTechnique.js";import{SimpleAtmosphereTechniqueConfiguration as v,SimpleAtmosphereGeometry as A}from"./SimpleAtmosphereTechniqueConfiguration.js";import{marsAtmosphereTextureSimple as P}from"./resources/MarsAtmosphereTexture.js";import{makePiecewiseLinearFunction as R}from"../support/mathUtils.js";import{glLayout as y}from"../support/buffer/glUtil.js";import{newLayout as S}from"../support/buffer/InterleavedLayout.js";import{OpaqueEnvironment as T}from"../webgl-engine/effects/OpaqueEnvironment.js";import{RenderRequestType as M}from"../webgl-engine/lib/basicInterfaces.js";import{Default3D as U}from"../webgl-engine/lib/DefaultVertexAttributeLocations.js";import{createQuadVAO as q}from"../webgl-engine/lib/glUtil3D.js";import{project as F}from"../webgl-engine/lib/Util.js";import{VertexArrayObject as C}from"../webgl-engine/lib/VertexArrayObject.js";import{VertexAttribute as E}from"../webgl-engine/lib/VertexAttribute.js";import{BufferObject as O}from"../../webgl/BufferObject.js";import{TextureWrapMode as I,PrimitiveType as D,Usage as L}from"../../webgl/enums.js";import{Texture as N}from"../../webgl/Texture.js";import{TextureDescriptor as W}from"../../webgl/TextureDescriptor.js";import{vertexCount as k}from"../../webgl/Util.js";const G=128,B=-1e4,z=0,H=50,Q=()=>1-511/512,J=R([[50,.1015625],[500,.21875],[5e3,1-250/512],[5e4,.4140625]]);let K=class extends T{constructor(e){super(e),this._passParameters=new V,this._configuration=new v,this._vao=null,this._vaoCount=0,this._fadeVao=null,this._fadeVaoCount=0,this._texV1=1;const t=e.view,r=g(t.spatialReference),{outerAtmosphereRimWidth:s,radius:i}=r;this._planetRadius=i,this._innerRimFactor=1+B/i,this._middleRimFactor=1+z/i,this._outerRimFactor=1+s/i,this._texV0=z/s,this._texVScale=this._texV1-this._texV0;const o=t.stage.renderView.techniques;o.precompile(w,this._configuration),this._configuration.geometry=A.Underground,o.precompile(w,this._configuration)}initialize(){this.addHandles(i((()=>this.view.environment.atmosphereEnabled),(e=>e?this._enable():this._disable()),o))}destroy(){this._passParameters.texture=s(this._passParameters.texture),this._fadeVao=s(this._fadeVao),this._vao=s(this._vao)}render(e){const t=e.find((({name:e})=>e===j.OPAQUE_ENVIRONMENT));this._update();const r=this.renderingContext;if(!this._passParameters.texture){const e=new W;e.wrapMode=I.CLAMP_TO_EDGE,e.flipped=!0,
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import{lerp as t,clamp as r}from"../../../core/mathUtils.js";import{disposeMaybe as s}from"../../../core/maybe.js";import{watch as i,initial as o}from"../../../core/reactiveUtils.js";import"../../../core/Logger.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import"../../../core/Error.js";import{subclass as a}from"../../../core/accessorSupport/decorators/subclass.js";import{lookAt as n}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{create as m}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as h}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{l as p,g as c,f as u,j as l,h as f,k as _}from"../../../chunks/vec32.js";import{create as d}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as g}from"../../../geometry/ellipsoidUtils.js";import{newFloatArray as b}from"../../../geometry/support/FloatArray.js";import{InternalRenderCategory as j}from"../webgl.js";import{computeInnerAltitudeFade as x}from"./atmosphereUtils.js";import{S as V}from"../../../chunks/SimpleAtmosphere.glsl.js";import{SimpleAtmosphereTechnique as w}from"./SimpleAtmosphereTechnique.js";import{SimpleAtmosphereTechniqueConfiguration as v,SimpleAtmosphereGeometry as A}from"./SimpleAtmosphereTechniqueConfiguration.js";import{marsAtmosphereTextureSimple as P}from"./resources/MarsAtmosphereTexture.js";import{makePiecewiseLinearFunction as R}from"../support/mathUtils.js";import{glLayout as y}from"../support/buffer/glUtil.js";import{newLayout as S}from"../support/buffer/InterleavedLayout.js";import{OpaqueEnvironment as T}from"../webgl-engine/effects/OpaqueEnvironment.js";import{RenderRequestType as M}from"../webgl-engine/lib/basicInterfaces.js";import{Default3D as U}from"../webgl-engine/lib/DefaultVertexAttributeLocations.js";import{createQuadVAO as q}from"../webgl-engine/lib/glUtil3D.js";import{project as F}from"../webgl-engine/lib/Util.js";import{VertexArrayObject as C}from"../webgl-engine/lib/VertexArrayObject.js";import{VertexAttribute as E}from"../webgl-engine/lib/VertexAttribute.js";import{BufferObject as O}from"../../webgl/BufferObject.js";import{TextureWrapMode as I,PrimitiveType as D,Usage as L}from"../../webgl/enums.js";import{Texture as N}from"../../webgl/Texture.js";import{TextureDescriptor as W}from"../../webgl/TextureDescriptor.js";import{vertexCount as k}from"../../webgl/Util.js";const G=128,B=-1e4,z=0,H=50,Q=()=>1-511/512,J=R([[50,.1015625],[500,.21875],[5e3,1-250/512],[5e4,.4140625]]);let K=class extends T{constructor(e){super(e),this._passParameters=new V,this._configuration=new v,this._vao=null,this._vaoCount=0,this._fadeVao=null,this._fadeVaoCount=0,this._texV1=1;const t=e.view,r=g(t.spatialReference),{outerAtmosphereRimWidth:s,radius:i}=r;this._planetRadius=i,this._innerRimFactor=1+B/i,this._middleRimFactor=1+z/i,this._outerRimFactor=1+s/i,this._texV0=z/s,this._texVScale=this._texV1-this._texV0;const o=t.stage.renderView.techniques;o.precompile(w,this._configuration),this._configuration.geometry=A.Underground,o.precompile(w,this._configuration)}initialize(){this.addHandles(i((()=>this.view.environment.atmosphereEnabled),(e=>e?this._enable():this._disable()),o))}destroy(){this._passParameters.texture=s(this._passParameters.texture),this._fadeVao=s(this._fadeVao),this._vao=s(this._vao)}render(e){const t=e.find((({name:e})=>e===j.OPAQUE_ENVIRONMENT));this._update();const r=this.renderingContext;if(!this._passParameters.texture){const e=new W(1,512);e.wrapMode=I.CLAMP_TO_EDGE,e.flipped=!0,this._passParameters.texture=new N(r,e,P)}if(this._passParameters.undergroundFadeAlpha<1){this._vao||(this._vao=this._createRibbon(r),this._vaoCount=k(this._vao,"geometry")),this._configuration.geometry=A.Cone;const e=this.techniques.get(w,this._configuration);if(!e.compiled)return this.requestRender(M.UPDATE),t;r.bindTechnique(e,this.bindParameters,this._passParameters),r.bindVAO(this._vao),r.drawArrays(D.TRIANGLES,0,this._vaoCount)}if(this._passParameters.undergroundFadeAlpha>0){this._fadeVao||(this._fadeVao=q(r),this._fadeVaoCount=k(this._fadeVao,"geometry")),this._configuration.geometry=A.Underground;const e=this.techniques.get(w,this._configuration);if(!e.compiled)return this.requestRender(M.UPDATE),t;r.bindTechnique(e,this.bindParameters,this._passParameters),r.bindVAO(this._fadeVao),r.drawArrays(D.TRIANGLE_STRIP,0,this._fadeVaoCount)}return t}_update(){const e=this.bindParameters.camera,s=d(),i=this._planetRadius,o=p(e.eye),a=o-i;if(a<0){const e=Math.min(-a/5e3,1);this._passParameters.undergroundFadeAlpha=e}else this._passParameters.undergroundFadeAlpha=0;const n=Math.max(H,a),m=i+B;this._passParameters.innerScale=ee(i+n,i,m)-1,this._passParameters.altitudeFade=x(a),c(s,e.eye,(i+H)/o),X(s,e.center,e.up,i,this._passParameters.silhouette);const u=this._computeScreenRimWidth(e,s,e.up,this._passParameters.silhouette),l=Q(),f=J(a);let _=this._texV0+l*this._texVScale,g=this._texV0+u*f*this._texVScale;if(a>H){X(e.eye,e.center,e.up,i,this._passParameters.silhouette);const s=this._computeScreenRimWidth(e,e.eye,e.up,this._passParameters.silhouette),o=r((s-1.5)/(u-1.5),0,1);_=this._texV0+o*l*this._texVScale,g=this._texV0+t(this._texV1,u*f,o)*this._texVScale}h(this._passParameters.texV,_,g)}_createRibbon(e){const t=b(3+3*G*3),r=new Uint32Array(3*G*5);t[0]=0,t[1]=0,t[2]=-1;for(let o=0;o<G;o++){const e=9*o+3;t[e]=o,t[e+1]=this._innerRimFactor,t[e+2]=-1,t[e+3]=o,t[e+4]=this._middleRimFactor,t[e+5]=0,t[e+6]=o,t[e+7]=this._outerRimFactor,t[e+8]=1;const s=3*o+1,i=o===G-1?1:s+3,a=15*o;r[a]=s,r[a+1]=s+1,r[a+2]=i+1,r[a+3]=i+1,r[a+4]=i,r[a+5]=s,r[a+6]=s+1,r[a+7]=s+2,r[a+8]=i+2,r[a+9]=i+2,r[a+10]=i+1,r[a+11]=s+1,r[a+12]=s,r[a+13]=i,r[a+14]=0}const s=te.createBuffer(r.length),i=s.position;for(let o=0;o<r.length;++o){const e=3*r[o];i.set(o,0,t[e]),i.set(o,1,t[e+1]),i.set(o,2,t[e+2])}return new C(e,U,new Map([["geometry",y(te)]]),new Map([["geometry",O.createVertex(e,L.STATIC_DRAW,s.buffer)]]))}_computeScreenRimWidth(e,t,r,s){return u(Z,s.center,s.v2),c($,Z,this._outerRimFactor),n(Y,t,Z,r),F(Z,Y,e.projectionMatrix,e.viewport,Z),F($,Y,e.projectionMatrix,e.viewport,$),l(Z,$)/e.height}};function X(e,t,r,s,i){const o=p(e),a=s*Math.sqrt(o*o-s*s)/o,n=Math.sqrt(s*s-a*a),m=i.v1,h=i.v2;return c(i.center,e,n/o),f(m,e,t),_(m)<1&&f(m,e,r),c(m,m,a/p(m)),f(h,m,e),c(h,h,a/p(h)),a}K=e([a("esri.views.3d.environment.MarsAtmosphere")],K);const Y=m(),Z=d(),$=d();function ee(e,t,r){return e*e/(Math.sqrt(e*e-t*t)*Math.sqrt(e*e-r*r)+t*r)}const te=S().vec3f(E.POSITION),re=K;export{re as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import{forEach as t,result as r}from"../../../core/asyncUtils.js";import{makeHandle as i}from"../../../core/handleUtils.js";import a from"../../../core/Logger.js";import{abortMaybe as s}from"../../../core/maybe.js";import{isAbortError as o,onAbort as n,throwIfAborted as l,isAborted as
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import{forEach as t,result as r}from"../../../core/asyncUtils.js";import{makeHandle as i}from"../../../core/handleUtils.js";import a from"../../../core/Logger.js";import{abortMaybe as s}from"../../../core/maybe.js";import{isAbortError as o,onAbort as n,throwIfAborted as l,isAborted as m,createAbortError as h}from"../../../core/promiseUtils.js";import{whenOnce as g}from"../../../core/reactiveUtils.js";import{property as d}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as c}from"../../../core/accessorSupport/decorators/subclass.js";import u from"../../../geometry/Extent.js";import{create as p,equals as f,width as y,height as x,copy as w,intersection as _}from"../../../geometry/support/aaBoundingRect.js";import{DrapeSourceType as b}from"./interfaces.js";import R from"./SubView3D.js";import{computeImageExportSize as E,createGeometryForExtent as v,createOuterImageGeometry as j}from"./support/overlayImageUtils.js";import{debugFlags as S}from"../support/debugFlags.js";import{OverlayIndex as M}from"../terrain/interfaces.js";import{DirtyOperation as A}from"../webgl-engine/lib/ModelDirtyTypes.js";import{RenderGeometry as I}from"../webgl-engine/lib/RenderGeometry.js";import{Texture as T}from"../webgl-engine/lib/Texture.js";import{UpdatePolicy as D}from"../webgl-engine/lib/UpdatePolicy.js";import{ImageMaterial as G}from"../webgl-engine/materials/ImageMaterial.js";import{TextureWrapMode as P}from"../../webgl/enums.js";let C=class extends R{constructor(e){super(e),this.drapeSourceType=b.RasterImage,this.updatePolicy=D.SYNC,this.type="draped",this.maximumDataResolution=null,this._images=new Array,this._extents=new Array,this._overlays=new Array,this._drapeSourceRenderer=null}initialize(){this._drapeSourceRenderer=this.view.basemapTerrain.overlayManager.registerGeometryDrapeSource(this),this.addHandles(i((()=>this.view.basemapTerrain.overlayManager.unregisterDrapeSource(this))))}setDrapingExtent(e,t){this._spatialReference=t,e.forEach(((e,t)=>{this._overlays[t]=e,this._updateImageExtent(e,t)}))}destroy(){this.clear()}get spatialReference(){return this._spatialReference}_updateImageExtent(e,t){const r=this._clippedExtent(e.extent,O);if(null==r)return;const i=E(e.extent,r,e.resolution);let s=e.pixelRatio*this.view.state.pixelRatio;const{layer:n}=this;if("imageMaxWidth"in n&&null!=n.imageMaxWidth||"imageMaxHeight"in n&&null!=n.imageMaxHeight){const e=n.imageMaxWidth,t=n.imageMaxHeight;if(i.width>e){const t=e/i.width;i.height=Math.floor(i.height*t),i.width=e,s*=t}if(i.height>t){const e=t/i.height;i.width=Math.floor(i.width*e),i.height=t,s*=e}}const l=this._extents[t];l&&f(l.extent,r)&&this._imageSizeEquals(r,l.imageSize,i)||(this._extents[t]={extent:p(r),imageSize:i,pixelRatio:s},this.suspended||this._fetch(t).catch((e=>{o(e)||a.getLogger(this).error(e)})))}clear(){for(let e=0;e<this._images.length;e++)this._clearImage(e)}async doRefresh(e){const t=[];for(let r=0;r<this._extents.length;r++)this._extents[r]&&t.push(this._fetch(r,e));await Promise.allSettled(t)}async processResult(e,t,r){(t instanceof HTMLImageElement||t instanceof HTMLCanvasElement)&&(e.image=t)}findExtentInfoAt(e){for(const t of this._extents){const r=t.extent;if(new u(r[0],r[1],r[2],r[3],this._spatialReference).contains(e))return t}return null}async redraw(e,r){await t(this._images,(async(t,i)=>{t&&(await e(t,r),await this._createStageObjects(i,t.image,r))}))}_imageSizeEquals(e,t,r){if(!this.maximumDataResolution)return!1;const i=y(e)/this.maximumDataResolution.x,a=x(e)/this.maximumDataResolution.y,s=i/t.width,o=a/t.height,n=i/r.width,l=a/r.height,m=Math.abs(s-n),h=Math.abs(o-l),g=S.TESTS_DISABLE_OPTIMIZATIONS?0:1.5;return m<=g&&h<=g}async _fetch(e,t){if(this.suspended)return;const r=this._extents[e],i=r.extent;this._images[e]||(this._images[e]={texture:null,material:null,renderGeometry:null,loadingPromise:null,loadingAbortController:null,image:null,pixelData:null,renderExtent:p(i)});const g=this._images[e];g.loadingAbortController=s(g.loadingAbortController);const d=new u(i[0],i[1],i[2],i[3],this._spatialReference);if(0===d.width||0===d.height)return void this._clearImage(e);const c=new AbortController;g.loadingAbortController=c,n(t,(()=>c.abort()));const f=c.signal,y=this._waitFetchReady(f).then((async()=>{l(f);const t={requestAsImageElement:!0,pixelRatio:this._overlays[e].pixelRatio,...this.layerView.getFetchOptions(),signal:f},{height:i,width:a}=r.imageSize;return this.layer?"imagery"===this.layer.type?this.layer.internalFetchImage(d,a,i,t):this.layer.fetchImage(d,a,i,t):null})).then((e=>{if(m(f))throw a.getLogger(this).warnOnce("A call to fetchImage resolved even though the request was aborted. fetchImage should not resolve if options.signal.aborted is true."),h();return this.processResult(g,e)})).then((()=>{w(g.renderExtent,i)}));g.loadingPromise=y,await this.updatingHandles.addPromise(y.then((async()=>{l(f),await this._createStageObjects(e,g.image,f)})).catch((e=>{throw e&&!o(e)&&a.getLogger(this).error(e),e})).finally((()=>{y===g.loadingPromise&&(g.loadingPromise=null,g.loadingAbortController=null)})))}_clearImage(e){const t=this._images[e];if(t){null!=t.renderGeometry&&(this._drapeSourceRenderer.removeGeometries([t.renderGeometry],A.UPDATE),t.renderGeometry=null);const e=this.view.stage,r=t.texture;r?.unload(),e.removeTexture(r),t.texture=null,t.material=null,t.loadingAbortController=s(t.loadingAbortController),t.loadingPromise=null,t.image=null,t.pixelData=null}}async _createStageObjects(e,t,i){const a=this.view.stage,s=this._images[e],o=()=>{s.texture?.unload(),a.removeTexture(s.texture),s.texture=null,s.renderGeometry&&(this._drapeSourceRenderer.removeGeometries([s.renderGeometry],A.UPDATE),s.renderGeometry=null)};if(t){const n=new T(t,{width:t.width,height:t.height,preMultiplyAlpha:!0,wrap:{s:P.CLAMP_TO_EDGE,t:P.CLAMP_TO_EDGE}});if(await r(this._images[e===M.INNER?M.OUTER:M.INNER].loadingPromise),l(i),o(),await a.schedule((()=>n.load(a.renderView.renderingContext)),i),!n.loaded)return void o();let m;if(a.addTexture(n),s.texture=n,s.material??=new G({draped:!0,texture:n}),s.material.setParameters({texture:n}),e===M.INNER)m=v(s.material,s.renderExtent);else{const e=this._images[0].renderExtent;if(!e)return void o();m=j(s.material,e,s.renderExtent)}s.renderGeometry=new I(m),s.renderGeometry.localOrigin=this._overlays[e].renderLocalOrigin,this._drapeSourceRenderer.addGeometries([s.renderGeometry],A.UPDATE)}else o(),s.material=null}_clippedExtent(e,t){if("local"!==this.view.viewingMode)return w(t,e);const r=this.view.basemapTerrain;return r.ready?_(e,r.extent,t):w(t,e)}async _waitFetchReady(e){await g((()=>this.view.stationary),e),l(e)}get usedMemory(){return this._images.reduce(((e,t)=>e+(t.texture?.usedMemory??0)),0)}};e([d()],C.prototype,"type",void 0),C=e([c("esri.views.3d.layers.DrapedSubView3D")],C);const O=p();export{C as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../core/has.js";import s from"../../../core/Logger.js";import{destroyMaybe as
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../core/has.js";import s from"../../../core/Logger.js";import{destroyMaybe as r}from"../../../core/maybe.js";import{debounce as t,isAbortError as i}from"../../../core/promiseUtils.js";import{property as o}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/RandomLCG.js";import{subclass as a}from"../../../core/accessorSupport/decorators/subclass.js";import n from"./DrapedSubView3D.js";import{LayerView3D as p}from"./LayerView3D.js";import{LayerViewPerformanceInfo as l}from"./support/LayerViewPerformanceInfo.js";import d from"../../layers/LayerView.js";import u from"../../layers/RefreshableLayerView.js";import{isInEffectiveScaleRange as c}from"../../support/layerViewUtils.js";import{projectWithZConversionSilent as h}from"../../support/projectionUtils.js";let m=class extends(u(p(d))){constructor(){super(...arguments),this.fullExtentInLocalViewSpatialReference=null,this.refreshDebounced=t((async e=>{this.destroyed||await this._doRefresh(e).catch((e=>{i(e)||s.getLogger(this).error(e)}))}),2e3),this.ignoresMemoryFactor=!1,this.unloadedMemory=0}get visibleAtCurrentScale(){const e=this.layer,s="effectiveScaleRange"in e?e.effectiveScaleRange:null;return c(s,this.view.scale)}isUpdating(){return super.isUpdating()||this.subView?.updating}initialize(){this._initSubView(),"local"===this.view.viewingMode&&this.addResolvingPromise((async()=>this.fullExtentInLocalViewSpatialReference=await h(this.layer.fullExtent,this.view.spatialReference))()),this._updatingHandles.add((()=>this.suspended),(()=>this._suspendedChangeHandler()))}destroy(){this.subView=r(this.subView)}_initSubView(){this.subView=new n({layerView:this})}async doRefresh(){return this._doRefresh()}async _doRefresh(e){this.suspended||await this.subView.doRefresh(e)}getFetchOptions(){}_suspendedChangeHandler(){this.suspended?this.subView.clear():this.refreshDebounced()}get test(){}get usedMemory(){return this.subView.usedMemory}get performanceInfo(){return new l(this.usedMemory)}};e([o()],m.prototype,"layer",void 0),e([o()],m.prototype,"suspended",void 0),e([o()],m.prototype,"fullExtentInLocalViewSpatialReference",void 0),e([o({readOnly:!0})],m.prototype,"visibleAtCurrentScale",null),e([o()],m.prototype,"updating",void 0),e([o()],m.prototype,"subView",void 0),m=e([a("esri.views.3d.layers.DynamicLayerView3D")],m);export{m as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import r from"../../../core/Accessor.js";import{property as t}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as s}from"../../../core/support/UpdatingHandles.js";let p=class extends r{constructor(e){super(e),this.updatingHandles=new s}destroy(){this.updatingHandles.destroy()}get updating(){return this.updatingHandles.updating}get layer(){return this.layerView.layer}get view(){return this.layerView.view}get suspended(){return this.layerView.suspended}get fullOpacity(){return this.layerView.fullOpacity}};e([t({constructOnly:!0})],p.prototype,"layerView",void 0),e([t({readOnly:!0})],p.prototype,"updatingHandles",void 0),e([t()],p.prototype,"updating",null),e([t()],p.prototype,"layer",null),e([t()],p.prototype,"view",null),e([t()],p.prototype,"suspended",null),e([t()],p.prototype,"fullOpacity",null),p=e([o("esri.views.3d.layers.SubView3D")],p);export{p as default};
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import r from"../../../core/Accessor.js";import{property as t}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as s}from"../../../core/support/UpdatingHandles.js";let p=class extends r{constructor(e){super(e),this.updatingHandles=new s}destroy(){this.updatingHandles.destroy()}get updating(){return this.updatingHandles.updating}get layer(){return this.layerView.layer}get view(){return this.layerView.view}get suspended(){return this.layerView.suspended}get fullOpacity(){return this.layerView.fullOpacity}get usedMemory(){return 0}};e([t({constructOnly:!0})],p.prototype,"layerView",void 0),e([t({readOnly:!0})],p.prototype,"updatingHandles",void 0),e([t()],p.prototype,"updating",null),e([t()],p.prototype,"layer",null),e([t()],p.prototype,"view",null),e([t()],p.prototype,"suspended",null),e([t()],p.prototype,"fullOpacity",null),p=e([o("esri.views.3d.layers.SubView3D")],p);export{p as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{createPrimitive as r}from"./sdfPrimitives.js";import{PixelFormat as e,TextureWrapMode as t}from"../../../webgl/enums.js";import{Texture as o}from"../../../webgl/Texture.js";import{TextureDescriptor as
|
|
5
|
+
import{createPrimitive as r}from"./sdfPrimitives.js";import{PixelFormat as e,TextureWrapMode as t}from"../../../webgl/enums.js";import{Texture as o}from"../../../webgl/Texture.js";import{TextureDescriptor as m}from"../../../webgl/TextureDescriptor.js";const s=64,i=s/2,n=i/5,p=s/n,f=.25;function u(p,f){const u=r(p,s,i,n),w=new m(s);return w.internalFormat=e.RGBA,w.wrapMode=t.CLAMP_TO_EDGE,new o(f,w,u)}export{u as createMarkerTexture,p as markerSizePerLineWidth,i as markerSymbolSize,s as markerTextureSize,n as markerThickness,f as markerTipThicknessFactor};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../../chunks/tslib.es6.js";import{createTask as s}from"../../../../../core/asyncUtils.js";import{clamp as r}from"../../../../../core/mathUtils.js";import{disposeMaybe as i}from"../../../../../core/maybe.js";import{watch as t,syncAndInitial as a}from"../../../../../core/reactiveUtils.js";import{createScreenPointArray as o,createRenderScreenPointArray as m,screenPointObjectToArray as n}from"../../../../../core/screenUtils.js";import{isSVG as h}from"../../../../../core/urlUtils.js";import{property as l}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as p}from"../../../../../core/accessorSupport/decorators/subclass.js";import{requestImage as u}from"../../../../../support/requestImageUtils.js";import{InternalRenderCategory as c}from"../../../webgl.js";import _ from"../../../webgl/RenderNode.js";import{MagnifierTechnique as g}from"./MagnifierTechnique.js";import{RenderRequestType as d}from"../../lib/basicInterfaces.js";import{Default3D as f}from"../../lib/DefaultVertexAttributeLocations.js";import{createQuadVAO as T,Layout as v}from"../../lib/glUtil3D.js";import{M as P}from"../../../../../chunks/Magnifier.glsl.js";import{loadMagnifierResources as k}from"../../../../magnifier/resources.js";import{PrimitiveType as b,PixelFormat as y,TextureWrapMode as j}from"../../../../webgl/enums.js";import{Texture as x}from"../../../../webgl/Texture.js";import{TextureDescriptor as R}from"../../../../webgl/TextureDescriptor.js";let S=class extends _{constructor(){super(...arguments),this.produces=c.MAGNIFIER,this.consumes={required:[c.MAGNIFIER]},this._imageSources=null,this._imageLoadTask=null,this._passParameters=new P,this._vao=null,this._magnifier=null,this._tmpScreenPoint=o(),this._tmpRenderPoint=m()}initialize(){this.addHandles([t((()=>this.view.magnifier),(e=>this._update(e)),a)])}_update(e){if(e===this._magnifier)return;this.removeAllHandles(),this._magnifier=e;const s=()=>{const e=this._validMagnifier;e?(this._loadResources(e),this.produces=c.MAGNIFIER):this.produces="disabled",this.requestRender()};this._magnifier&&this.addHandles(t((()=>this._magnifier?.version),s)),s()}get _validMagnifier(){return this._magnifier?.visible&&this._magnifier?.position&&this._magnifier?.size>0?this._magnifier:null}get _factor(){return this._magnifier?.factor||1}destroy(){this._magnifier=null,null!=this._imageLoadTask&&(this._imageLoadTask.task.abort(),this._imageLoadTask=null),this._disposeTextures(),this._vao=i(this._vao)}_disposeTextures(){this._passParameters.mask=i(this._passParameters.mask),this._passParameters.overlay=i(this._passParameters.overlay),this._passParameters.input=i(this._passParameters.input)}precompile(){this._imageSources&&this.techniques.precompile(g)}render(e){const s=this._validMagnifier,i=e.find((({name:e})=>e===c.MAGNIFIER));if(null==s)return i;if(null==this._imageSources)return this.requestRender(d.UPDATE),i;const t=this.renderingContext,a=this.camera.pixelRatio,o=Math.ceil(a*s.size);this._vao??=T(t,v.Pos2,f,0,1);const m=this.techniques.get(g);if(this._ensureTextureResources(t,o),!m.compiled||!this._passParameters.input)return this.requestRender(d.UPDATE),i;const h=Math.ceil(1/this._factor*o),l=this._passParameters.input;l.resize(h,h),n(s.position,this._tmpScreenPoint);const p=this.camera.screenToRender(this._tmpScreenPoint,this._tmpRenderPoint),u=this.camera.fullWidth,_=this.camera.fullHeight,P=.5*h,k=.5*h;p[0]=r(p[0],P,u-P-1),p[1]=r(p[1],k,_-k-1);const y=Math.floor(p[0]-P),j=Math.floor(p[1]-k);t.bindFramebuffer(i.fbo);return m.program.bindTexture("textureInput",l),t.gl.copyTexImage2D(l.descriptor.target,0,l.descriptor.pixelFormat,y,j,h,h,0),this._passParameters.magnifier=s,t.bindTechnique(m,this.bindParameters,this._passParameters),t.bindVAO(this._vao),t.drawArrays(b.TRIANGLE_STRIP,0,4),i}_loadResources(e){const{maskUrl:r,overlayUrl:i}=e;this._imageLoadTask?.maskUrl===r&&this._imageLoadTask?.overlayUrl===i||(this._imageLoadTask?.task.abort(),this._imageLoadTask=this._imageSources=null),this._imageSources||this._imageLoadTask||(this._imageLoadTask={maskUrl:r,overlayUrl:i,task:s((async e=>{const s=null==r||null==i?k(e):null,t=null!=r?u(r,{signal:e}):s.then((e=>e.mask)),a=null!=i?u(i,{signal:e}):s.then((e=>e.overlay));this._imageSources={mask:await t,overlay:await a}}))})}_ensureTextureResources(e,s){null==this._imageSources||this._passParameters.size===s&&this._passParameters.input&&this._passParameters.mask&&this._passParameters.overlay||(this._disposeTextures(),this._imageSources.overlay.width=this._imageSources.mask.width=s,this._imageSources.overlay.height=this._imageSources.mask.height=s,this._passParameters.overlay=new x(e,this._createTextureDescriptor(s,y.RGBA,this._imageSources.overlay),this._imageSources.overlay),this._passParameters.mask=new x(e,this._createTextureDescriptor(s,y.ALPHA,this._imageSources.mask),this._imageSources.mask),this._passParameters.input=new x(e,this._createTextureDescriptor(s,y.RGBA,null)))}_createTextureDescriptor(e,s,r){const i=this.renderingContext,t=new R(e
|
|
5
|
+
import{_ as e}from"../../../../../chunks/tslib.es6.js";import{createTask as s}from"../../../../../core/asyncUtils.js";import{clamp as r}from"../../../../../core/mathUtils.js";import{disposeMaybe as i}from"../../../../../core/maybe.js";import{watch as t,syncAndInitial as a}from"../../../../../core/reactiveUtils.js";import{createScreenPointArray as o,createRenderScreenPointArray as m,screenPointObjectToArray as n}from"../../../../../core/screenUtils.js";import{isSVG as h}from"../../../../../core/urlUtils.js";import{property as l}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as p}from"../../../../../core/accessorSupport/decorators/subclass.js";import{requestImage as u}from"../../../../../support/requestImageUtils.js";import{InternalRenderCategory as c}from"../../../webgl.js";import _ from"../../../webgl/RenderNode.js";import{MagnifierTechnique as g}from"./MagnifierTechnique.js";import{RenderRequestType as d}from"../../lib/basicInterfaces.js";import{Default3D as f}from"../../lib/DefaultVertexAttributeLocations.js";import{createQuadVAO as T,Layout as v}from"../../lib/glUtil3D.js";import{M as P}from"../../../../../chunks/Magnifier.glsl.js";import{loadMagnifierResources as k}from"../../../../magnifier/resources.js";import{PrimitiveType as b,PixelFormat as y,TextureWrapMode as j}from"../../../../webgl/enums.js";import{Texture as x}from"../../../../webgl/Texture.js";import{TextureDescriptor as R}from"../../../../webgl/TextureDescriptor.js";let S=class extends _{constructor(){super(...arguments),this.produces=c.MAGNIFIER,this.consumes={required:[c.MAGNIFIER]},this._imageSources=null,this._imageLoadTask=null,this._passParameters=new P,this._vao=null,this._magnifier=null,this._tmpScreenPoint=o(),this._tmpRenderPoint=m()}initialize(){this.addHandles([t((()=>this.view.magnifier),(e=>this._update(e)),a)])}_update(e){if(e===this._magnifier)return;this.removeAllHandles(),this._magnifier=e;const s=()=>{const e=this._validMagnifier;e?(this._loadResources(e),this.produces=c.MAGNIFIER):this.produces="disabled",this.requestRender()};this._magnifier&&this.addHandles(t((()=>this._magnifier?.version),s)),s()}get _validMagnifier(){return this._magnifier?.visible&&this._magnifier?.position&&this._magnifier?.size>0?this._magnifier:null}get _factor(){return this._magnifier?.factor||1}destroy(){this._magnifier=null,null!=this._imageLoadTask&&(this._imageLoadTask.task.abort(),this._imageLoadTask=null),this._disposeTextures(),this._vao=i(this._vao)}_disposeTextures(){this._passParameters.mask=i(this._passParameters.mask),this._passParameters.overlay=i(this._passParameters.overlay),this._passParameters.input=i(this._passParameters.input)}precompile(){this._imageSources&&this.techniques.precompile(g)}render(e){const s=this._validMagnifier,i=e.find((({name:e})=>e===c.MAGNIFIER));if(null==s)return i;if(null==this._imageSources)return this.requestRender(d.UPDATE),i;const t=this.renderingContext,a=this.camera.pixelRatio,o=Math.ceil(a*s.size);this._vao??=T(t,v.Pos2,f,0,1);const m=this.techniques.get(g);if(this._ensureTextureResources(t,o),!m.compiled||!this._passParameters.input)return this.requestRender(d.UPDATE),i;const h=Math.ceil(1/this._factor*o),l=this._passParameters.input;l.resize(h,h),n(s.position,this._tmpScreenPoint);const p=this.camera.screenToRender(this._tmpScreenPoint,this._tmpRenderPoint),u=this.camera.fullWidth,_=this.camera.fullHeight,P=.5*h,k=.5*h;p[0]=r(p[0],P,u-P-1),p[1]=r(p[1],k,_-k-1);const y=Math.floor(p[0]-P),j=Math.floor(p[1]-k);t.bindFramebuffer(i.fbo);return m.program.bindTexture("textureInput",l),t.gl.copyTexImage2D(l.descriptor.target,0,l.descriptor.pixelFormat,y,j,h,h,0),this._passParameters.magnifier=s,t.bindTechnique(m,this.bindParameters,this._passParameters),t.bindVAO(this._vao),t.drawArrays(b.TRIANGLE_STRIP,0,4),i}_loadResources(e){const{maskUrl:r,overlayUrl:i}=e;this._imageLoadTask?.maskUrl===r&&this._imageLoadTask?.overlayUrl===i||(this._imageLoadTask?.task.abort(),this._imageLoadTask=this._imageSources=null),this._imageSources||this._imageLoadTask||(this._imageLoadTask={maskUrl:r,overlayUrl:i,task:s((async e=>{const s=null==r||null==i?k(e):null,t=null!=r?u(r,{signal:e}):s.then((e=>e.mask)),a=null!=i?u(i,{signal:e}):s.then((e=>e.overlay));this._imageSources={mask:await t,overlay:await a}}))})}_ensureTextureResources(e,s){null==this._imageSources||this._passParameters.size===s&&this._passParameters.input&&this._passParameters.mask&&this._passParameters.overlay||(this._disposeTextures(),this._imageSources.overlay.width=this._imageSources.mask.width=s,this._imageSources.overlay.height=this._imageSources.mask.height=s,this._passParameters.overlay=new x(e,this._createTextureDescriptor(s,y.RGBA,this._imageSources.overlay),this._imageSources.overlay),this._passParameters.mask=new x(e,this._createTextureDescriptor(s,y.ALPHA,this._imageSources.mask),this._imageSources.mask),this._passParameters.input=new x(e,this._createTextureDescriptor(s,y.RGBA,null)))}_createTextureDescriptor(e,s,r){const i=this.renderingContext,t=new R(e);return t.pixelFormat=t.internalFormat=s,t.wrapMode=j.CLAMP_TO_EDGE,t.flipped=!!r,t.preMultiplyAlpha=!(s!==y.RGBA||!r||h(r.src)&&i.driverTest.svgPremultipliesAlpha.result),t}};e([l()],S.prototype,"produces",void 0),e([l()],S.prototype,"consumes",void 0),e([l()],S.prototype,"_imageSources",void 0),e([l()],S.prototype,"_imageLoadTask",void 0),S=e([p("esri.views.3d.webgl-engine.effects.magnifier.Magnifier")],S);export{S as Magnifier};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../../chunks/tslib.es6.js";import{disposeMaybe as r}from"../../../../../core/maybe.js";import{throwIfAborted as t}from"../../../../../core/promiseUtils.js";import{watch as s,syncAndInitial as i}from"../../../../../core/reactiveUtils.js";import{property as a}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as o}from"../../../../../core/accessorSupport/decorators/subclass.js";import{requestImage as n}from"../../../../../support/requestImageUtils.js";import{RenderCategory as c,InternalRenderCategory as
|
|
5
|
+
import{_ as e}from"../../../../../chunks/tslib.es6.js";import{disposeMaybe as r}from"../../../../../core/maybe.js";import{throwIfAborted as t}from"../../../../../core/promiseUtils.js";import{watch as s,syncAndInitial as i}from"../../../../../core/reactiveUtils.js";import{property as a}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as o}from"../../../../../core/accessorSupport/decorators/subclass.js";import{requestImage as n}from"../../../../../support/requestImageUtils.js";import{RenderCategory as c,InternalRenderCategory as m}from"../../../webgl.js";import u from"../../../webgl/RenderNode.js";import{ColorFormat as h}from"../../core/FBOCacheFormats.js";import{SMAABlendWeightsTechnique as l}from"./SMAABlendWeightsTechnique.js";import{SMAABlurTechnique as p}from"./SMAABlurTechnique.js";import{SMAAEdgeDetectTechnique as d}from"./SMAAEdgeDetectTechnique.js";import{SMAAPassParameters as f}from"./SMAAPassParameters.js";import{RenderRequestType as T}from"../../lib/basicInterfaces.js";import{PixelFormat as b,TextureSamplingMode as x,FramebufferBit as _,TextureWrapMode as A}from"../../../../webgl/enums.js";import{Texture as g}from"../../../../webgl/Texture.js";import{TextureDescriptor as C}from"../../../../webgl/TextureDescriptor.js";let j=class extends u{constructor(e){super(e),this.produces="disabled",this.consumes={required:[m.ANTIALIASING],optional:[c.COMPOSITE]},this._areaTexture=null,this._searchTexture=null,this._smaaParameters=new f}initialize(){this.addHandles([s((()=>this.isEnabled()),(e=>e?this.enable():this.disable()),i)])}async enable(){if(this.produces=m.ANTIALIASING,this._abortController||this._areaTexture&&this._searchTexture)return;this._abortController=new AbortController;const e=this._abortController.signal;try{const r=await import("./SMAAData.js");await this._loadTextures(r,e),this.requestRender(T.UPDATE)}catch{}this._abortController=null}async _loadTextures(e,r){t(r);const[s,i]=await Promise.allSettled([n(e.areaTexture,{signal:r}),n(e.searchTexure,{signal:r})]);if(t(r),"fulfilled"!==s.status||"fulfilled"!==i.status)return;const a=this.renderingContext;this._areaTexture=w(a,x.LINEAR,b.RGB,s.value),this._searchTexture=w(a,x.NEAREST,b.LUMINANCE,i.value)}disable(){this.produces="disabled"}destroy(){this._searchTexture=r(this._searchTexture),this._areaTexture=r(this._areaTexture)}precompile(){this.techniques.precompile(d),this.techniques.precompile(l),this.techniques.precompile(p)}render(e){const r=e.find((({name:e})=>e===m.ANTIALIASING));if(!this._areaTexture||!this._searchTexture)return this.requestRender(T.UPDATE),r;const t=this.techniques.get(d),s=this.techniques.get(l),i=this.techniques.get(p);if(!t.compiled||!s.compiled||!i.compiled)return this.requestRender(T.UPDATE),r;const a=e.find((({name:e})=>e===c.COMPOSITE));if(!a)return r;const o=a.fbo.width,n=a.fbo.height,u=this.renderingContext;u.setViewport(0,0,o,n);const f=this.fboCache.acquire(o,n,"smaa edges",h.RG8UNORM);u.bindFramebuffer(f.fbo),u.setClearColor(0,0,0,1),u.clear(_.COLOR),this._smaaParameters.color=a.getTexture();const b=this.bindParameters;u.bindTechnique(t,b,this._smaaParameters),u.screen.draw();const x=this.fboCache.acquire(o,n,"smaa blend");return u.bindFramebuffer(x.fbo),u.setClearColor(0,0,1,1),u.clear(_.COLOR),this._smaaParameters.inputTexture=f.getTexture(),this._smaaParameters.areaTexture=this._areaTexture,this._smaaParameters.searchTexture=this._searchTexture,u.bindTechnique(s,b,this._smaaParameters),u.screen.draw(),f.release(),u.bindFramebuffer(r.fbo),u.setClearColor(0,1,0,1),u.clear(_.COLOR),this._smaaParameters.inputTexture=x.getTexture(),u.bindTechnique(i,b,this._smaaParameters),u.screen.draw(),x.release(),r}};function w(e,r,t,s){const i=new C(s.width,s.height);return i.pixelFormat=t,i.wrapMode=A.CLAMP_TO_EDGE,i.samplingMode=r,new g(e,i,s)}e([a()],j.prototype,"produces",void 0),e([a()],j.prototype,"consumes",void 0),e([a({constructOnly:!0})],j.prototype,"isEnabled",void 0),e([a()],j.prototype,"_abortController",void 0),j=e([o("esri.views.3d.webgl-engine.effects.smaa.SMAA")],j);export{j as SMAA};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../../chunks/tslib.es6.js";import{clamp as r}from"../../../../../core/mathUtils.js";import{disposeMaybe as s}from"../../../../../core/maybe.js";import{watch as t}from"../../../../../core/reactiveUtils.js";import{Milliseconds as i}from"../../../../../core/time.js";import{property as o}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as a}from"../../../../../core/accessorSupport/decorators/subclass.js";import{set as m}from"../../../../../core/libs/gl-matrix-2/math/vec2.js";import{InternalRenderCategory as n}from"../../../webgl.js";import c from"../../../webgl/RenderNode.js";import{ColorFormat as p}from"../../core/FBOCacheFormats.js";import{distanceFadeEnd as h,distanceFadeStart as u}from"../../core/shaderLibrary/shading/ScreenSpaceConstants.js";import{SSAOBlurTechnique as l}from"./SSAOBlurTechnique.js";import{noiseData as d}from"./SSAONoiseData.js";import{SSAOPassParameters as f,BlurDrawParameters as b}from"./SSAOParameters.js";import{SSAOTechnique as w}from"./SSAOTechnique.js";import{RenderRequestType as T}from"../../lib/basicInterfaces.js";import{g as _}from"../../../../../chunks/SSAO.glsl.js";import{TextureWrapMode as P,PixelFormat as S,DepthStencilAttachment as j,FramebufferBit as g}from"../../../../webgl/enums.js";import{Texture as x}from"../../../../webgl/Texture.js";import{TextureDescriptor as q}from"../../../../webgl/TextureDescriptor.js";const O=2;let A=class extends c{constructor(e){super(e),this.consumes={required:["normals"]},this.produces=n.SSAO,this.isEnabled=()=>!1,this._enableTime=i(0),this._passParameters=new f,this._drawParameters=new b}initialize(){const e=Uint8Array.from(atob(d),(e=>e.charCodeAt(0))),r=new q;r.wrapMode=P.CLAMP_TO_EDGE,r.pixelFormat=S.RGB,r.wrapMode=P.REPEAT,r.hasMipmap=!0,
|
|
5
|
+
import{_ as e}from"../../../../../chunks/tslib.es6.js";import{clamp as r}from"../../../../../core/mathUtils.js";import{disposeMaybe as s}from"../../../../../core/maybe.js";import{watch as t}from"../../../../../core/reactiveUtils.js";import{Milliseconds as i}from"../../../../../core/time.js";import{property as o}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as a}from"../../../../../core/accessorSupport/decorators/subclass.js";import{set as m}from"../../../../../core/libs/gl-matrix-2/math/vec2.js";import{InternalRenderCategory as n}from"../../../webgl.js";import c from"../../../webgl/RenderNode.js";import{ColorFormat as p}from"../../core/FBOCacheFormats.js";import{distanceFadeEnd as h,distanceFadeStart as u}from"../../core/shaderLibrary/shading/ScreenSpaceConstants.js";import{SSAOBlurTechnique as l}from"./SSAOBlurTechnique.js";import{noiseData as d}from"./SSAONoiseData.js";import{SSAOPassParameters as f,BlurDrawParameters as b}from"./SSAOParameters.js";import{SSAOTechnique as w}from"./SSAOTechnique.js";import{RenderRequestType as T}from"../../lib/basicInterfaces.js";import{g as _}from"../../../../../chunks/SSAO.glsl.js";import{TextureWrapMode as P,PixelFormat as S,DepthStencilAttachment as j,FramebufferBit as g}from"../../../../webgl/enums.js";import{Texture as x}from"../../../../webgl/Texture.js";import{TextureDescriptor as q}from"../../../../webgl/TextureDescriptor.js";const O=2;let A=class extends c{constructor(e){super(e),this.consumes={required:["normals"]},this.produces=n.SSAO,this.isEnabled=()=>!1,this._enableTime=i(0),this._passParameters=new f,this._drawParameters=new b}initialize(){const e=Uint8Array.from(atob(d),(e=>e.charCodeAt(0))),r=new q(32);r.wrapMode=P.CLAMP_TO_EDGE,r.pixelFormat=S.RGB,r.wrapMode=P.REPEAT,r.hasMipmap=!0,this._passParameters.noiseTexture=new x(this.renderingContext,r,e),this.techniques.precompile(w),this.techniques.precompile(l),this.addHandles(t((()=>this.isEnabled()),(()=>this._enableTime=i(0))))}destroy(){this._passParameters.noiseTexture=s(this._passParameters.noiseTexture)}render(e){const s=e.find((({name:e})=>"normals"===e)),t=s?.getTexture(),o=s?.getTexture(j);if(!t||!o)return;const a=this.techniques.get(w),c=this.techniques.get(l);if(!a.compiled||!c.compiled)return this._enableTime=i(performance.now()),void this.requestRender(T.UPDATE);0===this._enableTime&&(this._enableTime=i(performance.now()));const d=this.renderingContext,f=this.view.qualitySettings.fadeDuration,b=this.bindParameters,P=b.camera,S=P.relativeElevation,x=r((h-S)/(h-u),0,1),q=f>0?Math.min(f,performance.now()-this._enableTime)/f:1,A=q*x;this._passParameters.normalTexture=t,this._passParameters.depthTexture=o,this._passParameters.projScale=1/P.computeScreenPixelSizeAtDist(1),this._passParameters.intensity=4*C/_(P)**6*A;const R=P.fullViewport[2],v=P.fullViewport[3],y=this.fboCache.acquire(R,v,"ssao input",p.RG8UNORM);d.bindFramebuffer(y.fbo),d.setViewport(0,0,R,v),d.bindTechnique(a,b,this._passParameters,this._drawParameters),d.screen.draw();const E=Math.round(R/O),M=Math.round(v/O),U=this.fboCache.acquire(E,M,"ssao blur",p.R8UNORM);d.bindFramebuffer(U.fbo),this._drawParameters.colorTexture=y.getTexture(),m(this._drawParameters.blurSize,0,O/v),d.bindTechnique(c,b,this._passParameters,this._drawParameters),d.setViewport(0,0,E,M),d.screen.draw(),y.release();const V=this.fboCache.acquire(E,M,n.SSAO,p.R8UNORM);return d.bindFramebuffer(V.fbo),d.setViewport(0,0,R,v),d.setClearColor(1,1,1,0),d.clear(g.COLOR),this._drawParameters.colorTexture=U.getTexture(),m(this._drawParameters.blurSize,O/R,0),d.bindTechnique(c,b,this._passParameters,this._drawParameters),d.setViewport(0,0,E,M),d.screen.draw(),d.setViewport4fv(P.fullViewport),U.release(),q<1&&this.requestRender(T.UPDATE),V}};e([o()],A.prototype,"consumes",void 0),e([o()],A.prototype,"produces",void 0),e([o({constructOnly:!0})],A.prototype,"isEnabled",void 0),A=e([a("esri.views.3d.webgl-engine.effects.ssao.SSAO")],A);const C=.5;export{A as SSAO,O as blurSizePixels};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{packFloatRGBA as t}from"../../../../core/floatRGBA.js";import{ProceduralTextureRepository as e}from"./ProceduralTextureRepository.js";import{PixelFormat as r,TextureWrapMode as o}from"../../../webgl/enums.js";import{Texture as n}from"../../../webgl/Texture.js";import{TextureDescriptor as i}from"../../../webgl/TextureDescriptor.js";function u(t,u){return new e((e=>{const{encodedData:u,textureSize:c}=a(e),f=new i;return f.internalFormat=r.RGBA,f.
|
|
5
|
+
import{packFloatRGBA as t}from"../../../../core/floatRGBA.js";import{ProceduralTextureRepository as e}from"./ProceduralTextureRepository.js";import{PixelFormat as r,TextureWrapMode as o}from"../../../webgl/enums.js";import{Texture as n}from"../../../webgl/Texture.js";import{TextureDescriptor as i}from"../../../webgl/TextureDescriptor.js";function u(t,u){return new e((e=>{const{encodedData:u,textureSize:c}=a(e),f=new i(c,1);return f.internalFormat=r.RGBA,f.wrapMode=o.REPEAT,new n(t,f,u)}),(t=>`${t.pattern.join(",")}-r${t.pixelRatio}`),u)}function a(e){const r=c(e),o=1/e.pixelRatio,n=f(e),i=s(e),u=(Math.floor(.5*(i-1))+.5)*o,a=[];let l=1;for(const t of r){for(let e=0;e<t;e++){const r=l*(Math.min(e,t-1-e)+.5)*o/u*.5+.5;a.push(r)}l=-l}const p=Math.round(r[0]/2),m=[...a.slice(p),...a.slice(0,p)],x=new Uint8Array(4*n);let d=0;for(const c of m)t(c,x,d),d+=4;return{encodedData:x,textureSize:n}}function c(t){return t.pattern.map((e=>Math.round(e*t.pixelRatio)))}function f(t){if(null==t)return 1;const e=c(t);return Math.floor(e.reduce(((t,e)=>t+e)))}function s(t){return c(t).reduce(((t,e)=>Math.max(t,e)))}export{s as computeLongestPattern,f as computeTextureSize,u as createStippleTextureRepository};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import t from"../../request.js";import e from"../../geometry/Point.js";import{execute as r}from"../../geometry/operators/projectOperator.js";import{projectResolution as i,getProjectionOffsetGrid as a}from"../../layers/support/rasterFunctions/rasterProjectionHelper.js";import{isImageSource as s,rasterize as n}from"../2d/engine/Bitmap.js";import o from"../2d/engine/webgl/VertexStream.js";import{createProgramTemplate as m}from"../2d/engine/webgl/shaders/MaterialPrograms.js";import{TextureWrapMode as c,PixelFormat as p,PixelType as h}from"../webgl/enums.js";import{FramebufferObject as x}from"../webgl/FramebufferObject.js";import{createTransformTexture as u}from"../webgl/rasterUtils.js";import{RenderingContext as d}from"../webgl/RenderingContext.js";import{Texture as g}from"../webgl/Texture.js";import{TextureDescriptor as _}from"../webgl/TextureDescriptor.js";class f{static{this._instanceRefCount=0}constructor(t){if(this._ownsRctx=!1,t)this._ownsRctx=!1,this._rctx=t;else{if(f._instance)return f._instanceRefCount++,f._instance;f._instanceRefCount=1,f._instance=this,this._ownsRctx=!0;const t=document.createElement("canvas").getContext("webgl2");t.getExtension("OES_texture_float"),this._rctx=new d(t,{})}const e={applyProjection:!0,bilinear:!1,bicubic:!1},r=m("raster/reproject","raster/reproject",new Map([["a_position",0]]),e);this._program=this._rctx.programCache.acquire(r.shaders.vertexShader,r.shaders.fragmentShader,r.attributes),this._rctx.useProgram(this._program),this._program.setUniform1f("u_opacity",1),this._program.setUniform1i("u_image",0),this._program.setUniform1i("u_flipY",0),this._program.setUniform1i("u_transformGrid",1),this._quad=new o(this._rctx,[0,0,1,0,0,1,1,1])}reprojectTexture(t,s,n=!1){const o=r(t.extent,s),m=new e({x:(t.extent.xmax-t.extent.xmin)/t.texture.descriptor.width,y:(t.extent.ymax-t.extent.ymin)/t.texture.descriptor.height,spatialReference:t.extent.spatialReference}),{x:d,y:g}=i(m,s,t.extent);let f=(d+g)/2;const l=Math.round((o.xmax-o.xmin)/f),w=Math.round((o.ymax-o.ymin)/f);f=(o.width/l+o.height/w)/2;const b=new e({x:f,y:f,spatialReference:o.spatialReference}),j=a({projectedExtent:o,srcBufferExtent:t.extent,pixelSize:b,hasWrapAround:!0,spacing:[16,16]}),D=u(this._rctx,j),R=new _(l,w);R.wrapMode=c.CLAMP_TO_EDGE;const y=new x(this._rctx,R);this._rctx.bindFramebuffer(y),this._rctx.setViewport(0,0,l,w),this._rctx.useProgram(this._program),this._rctx.bindTexture(t.texture,0),this._rctx.bindTexture(D,1),this._quad.bind();const{width:C=0,height:E=0}=t.texture.descriptor;if(this._program.setUniform2f("u_srcImageSize",C,E),this._program.setUniform2fv("u_transformSpacing",j.spacing),this._program.setUniform2fv("u_transformGridSize",j.size),this._program.setUniform2f("u_targetImageSize",l,w),this._quad.draw(),this._quad.unbind(),this._rctx.useProgram(null),this._rctx.bindFramebuffer(null),D.dispose(),n){const{width:t,height:e}=y,r=new ImageData(t??0,e??0);y.readPixels(0,0,t??0,e??0,p.RGBA,h.UNSIGNED_BYTE,r.data);const i=y.detachColorTexture();return y.dispose(),{texture:i,extent:o,imageData:r}}const T=y.detachColorTexture();return y.dispose(),{texture:T,extent:o}}reprojectBitmapData(t,e){const r=s(t.bitmapData)?n(t.bitmapData):t.bitmapData,i=new _
|
|
5
|
+
import t from"../../request.js";import e from"../../geometry/Point.js";import{execute as r}from"../../geometry/operators/projectOperator.js";import{projectResolution as i,getProjectionOffsetGrid as a}from"../../layers/support/rasterFunctions/rasterProjectionHelper.js";import{isImageSource as s,rasterize as n}from"../2d/engine/Bitmap.js";import o from"../2d/engine/webgl/VertexStream.js";import{createProgramTemplate as m}from"../2d/engine/webgl/shaders/MaterialPrograms.js";import{TextureWrapMode as c,PixelFormat as p,PixelType as h}from"../webgl/enums.js";import{FramebufferObject as x}from"../webgl/FramebufferObject.js";import{createTransformTexture as u}from"../webgl/rasterUtils.js";import{RenderingContext as d}from"../webgl/RenderingContext.js";import{Texture as g}from"../webgl/Texture.js";import{TextureDescriptor as _}from"../webgl/TextureDescriptor.js";class f{static{this._instanceRefCount=0}constructor(t){if(this._ownsRctx=!1,t)this._ownsRctx=!1,this._rctx=t;else{if(f._instance)return f._instanceRefCount++,f._instance;f._instanceRefCount=1,f._instance=this,this._ownsRctx=!0;const t=document.createElement("canvas").getContext("webgl2");t.getExtension("OES_texture_float"),this._rctx=new d(t,{})}const e={applyProjection:!0,bilinear:!1,bicubic:!1},r=m("raster/reproject","raster/reproject",new Map([["a_position",0]]),e);this._program=this._rctx.programCache.acquire(r.shaders.vertexShader,r.shaders.fragmentShader,r.attributes),this._rctx.useProgram(this._program),this._program.setUniform1f("u_opacity",1),this._program.setUniform1i("u_image",0),this._program.setUniform1i("u_flipY",0),this._program.setUniform1i("u_transformGrid",1),this._quad=new o(this._rctx,[0,0,1,0,0,1,1,1])}reprojectTexture(t,s,n=!1){const o=r(t.extent,s),m=new e({x:(t.extent.xmax-t.extent.xmin)/t.texture.descriptor.width,y:(t.extent.ymax-t.extent.ymin)/t.texture.descriptor.height,spatialReference:t.extent.spatialReference}),{x:d,y:g}=i(m,s,t.extent);let f=(d+g)/2;const l=Math.round((o.xmax-o.xmin)/f),w=Math.round((o.ymax-o.ymin)/f);f=(o.width/l+o.height/w)/2;const b=new e({x:f,y:f,spatialReference:o.spatialReference}),j=a({projectedExtent:o,srcBufferExtent:t.extent,pixelSize:b,hasWrapAround:!0,spacing:[16,16]}),D=u(this._rctx,j),R=new _(l,w);R.wrapMode=c.CLAMP_TO_EDGE;const y=new x(this._rctx,R);this._rctx.bindFramebuffer(y),this._rctx.setViewport(0,0,l,w),this._rctx.useProgram(this._program),this._rctx.bindTexture(t.texture,0),this._rctx.bindTexture(D,1),this._quad.bind();const{width:C=0,height:E=0}=t.texture.descriptor;if(this._program.setUniform2f("u_srcImageSize",C,E),this._program.setUniform2fv("u_transformSpacing",j.spacing),this._program.setUniform2fv("u_transformGridSize",j.size),this._program.setUniform2f("u_targetImageSize",l,w),this._quad.draw(),this._quad.unbind(),this._rctx.useProgram(null),this._rctx.bindFramebuffer(null),D.dispose(),n){const{width:t,height:e}=y,r=new ImageData(t??0,e??0);y.readPixels(0,0,t??0,e??0,p.RGBA,h.UNSIGNED_BYTE,r.data);const i=y.detachColorTexture();return y.dispose(),{texture:i,extent:o,imageData:r}}const T=y.detachColorTexture();return y.dispose(),{texture:T,extent:o}}reprojectBitmapData(t,e){const r=s(t.bitmapData)?n(t.bitmapData):t.bitmapData,i=new _(t.bitmapData.width,t.bitmapData.height);i.wrapMode=c.CLAMP_TO_EDGE;const a=new g(this._rctx,i,r),o=this.reprojectTexture({texture:a,extent:t.extent},e,!0);o.texture.dispose();const m=document.createElement("canvas"),p=o.imageData;m.width=p.width,m.height=p.height;return m.getContext("2d").putImageData(p,0,0),{bitmapData:m,extent:o.extent}}async loadAndReprojectBitmapData(e,r,i){const a=(await t(e,{responseType:"image"})).data,s=document.createElement("canvas");s.width=a.width,s.height=a.height;const n=s.getContext("2d");n.drawImage(a,0,0);const o=n.getImageData(0,0,s.width,s.height);if(r.spatialReference.equals(i))return{bitmapData:o,extent:r};const m=this.reprojectBitmapData({bitmapData:o,extent:r},i);return{bitmapData:m.bitmapData,extent:m.extent}}destroy(){this._ownsRctx?(f._instanceRefCount--,0===f._instanceRefCount&&(this._quad.dispose(),this._program.dispose(),this._rctx.dispose(),f._instance=null)):(this._quad.dispose(),this._program.dispose())}}export{f as ImageReprojector};
|
package/views/webgl/Texture.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import t from"../../core/Error.js";import"../../core/has.js";import e from"../../core/Logger.js";import{abortMaybe as i}from"../../core/maybe.js";import{throwIfAborted as r,isAbortError as s}from"../../core/promiseUtils.js";import{checkWebGLError as o}from"./checkWebGLError.js";import{TextureType as a,ResourceType as n,CompressedTextureFormat as p,TextureSamplingMode as l,TextureConstants as h,PixelFormat as m}from"./enums.js";import{FBOAttachmentType as d}from"./FBOAttachmentType.js";import{estimateMemory as c}from"./TextureDescriptor.js";import{isCompressedData as _,deriveInternalFormat as u,isTexImageSource as g,is3DTarget as T,validateTexture as x,isCompressedFormat as E,getDimensions as M,calcMipmapLevels as A,isSizedPixelFormat as b,isSizedDepthFormat as f,isSizedDepthStencilFormat as w}from"./textureUtils.js";import{ValidatedTextureDescriptor as I}from"./ValidatedTextureDescriptor.js";const R=null,D=()=>e.getLogger("esri/views/webgl/Texture");let S=class e{static{this.TEXTURE_UNIT_FOR_UPDATES=0}static{this.compressionWorkerHandle=null}constructor(e,i=null,r=null){if(this.type=d.Texture,this._glName=null,this._samplingModeDirty=!1,this._wrapModeDirty=!1,this._shadowFilterDirty=!1,this._wasImmutablyAllocated=!1,"context"in e)this._descriptor=e,r=i;else{const r=I.validate(e,i);if(!r)throw new t("texture:invalid-descriptor","Texture descriptor invalid");this._descriptor=r}this._descriptor.target===a.TEXTURE_CUBE_MAP?this._setDataCubeMap(r):this.setData(r)}get glName(){return this._glName}get descriptor(){return this._descriptor}get usedMemory(){return c(this._descriptor)}get cachedMemory(){return this.usedMemory}get isDirty(){return this._samplingModeDirty||this._wrapModeDirty||this._shadowFilterDirty}get hasWebGLTextureObject(){return!!this._glName}dispose(){this.abortCompression(),this._descriptor.context.gl&&this.hasWebGLTextureObject&&(this._descriptor.context.instanceCounter.decrement(n.Texture,this),this._descriptor.context.unbindTexture(this),this._descriptor.context.gl.deleteTexture(this._glName),this._glName=null)}release(){this.dispose()}resize(e,i){const r=this._descriptor;if(r.width!==e||r.height!==i){if(this._wasImmutablyAllocated)throw new t("texture:immutable-resize","Immutable textures can't be resized!");r.width=e,r.height=i,this._descriptor.target===a.TEXTURE_CUBE_MAP?this._setDataCubeMap(null):this.setData(null)}}enableCompression(t,e){this._descriptor.compressionHandle=t,this._descriptor.compressionCallback=e}disableCompression(){this._descriptor.compressionHandle=null,this._descriptor.compressionCallback=null}setData(t){this.abortCompression(),!_(t)&&this._descriptor.internalFormat&&this._descriptor.internalFormat in p&&(this._descriptor.internalFormat=void 0),this._setData(t),!_(t)&&this._descriptor.compressionHandle&&this._compressOnWorker(t)}updateData(i,r,s,o,a,n,p=0){n||D().error("An attempt to use uninitialized data!"),this.hasWebGLTextureObject||D().error("An attempt to update uninitialized texture!");const l=this._descriptor;l.internalFormat=u(l);const{context:h,pixelFormat:m,dataType:d,target:c,isImmutable:T}=l;if(T&&!this._wasImmutablyAllocated)throw new t("texture:uninitialized","Cannot update immutable texture before allocation!");const x=h.bindTexture(this,e.TEXTURE_UNIT_FOR_UPDATES,!0);(r<0||s<0||r+o>l.width||s+a>l.height)&&D().error("An attempt to update out of bounds of the texture!"),this._configurePixelStorage();const{gl:E}=h;p&&(o&&a||D().warn("Must pass width and height if `UNPACK_SKIP_ROWS` is used"),E.pixelStorei(E.UNPACK_SKIP_ROWS,p)),g(n)?E.texSubImage2D(c,i,r,s,o,a,m,d,n):_(n)?E.compressedTexSubImage2D(c,i,r,s,o,a,l.internalFormat,n.levels[i]):E.texSubImage2D(c,i,r,s,o,a,m,d,n),p&&E.pixelStorei(E.UNPACK_SKIP_ROWS,0),h.bindTexture(x,e.TEXTURE_UNIT_FOR_UPDATES)}updateData3D(i,r,s,o,a,n,p,l){l||D().error("An attempt to use uninitialized data!"),this.hasWebGLTextureObject||D().error("An attempt to update an uninitialized texture!");const h=this._descriptor;h.internalFormat=u(h);const{context:m,pixelFormat:d,dataType:c,isImmutable:g,target:x}=h;if(g&&!this._wasImmutablyAllocated)throw new t("texture:uninitialized","Cannot update immutable texture before allocation!");T(x)||D().warn("Attempting to set 3D texture data on a non-3D texture");const E=m.bindTexture(this,e.TEXTURE_UNIT_FOR_UPDATES);m.setActiveTexture(e.TEXTURE_UNIT_FOR_UPDATES),(r<0||s<0||o<0||r+a>h.width||s+n>h.height||o+p>h.depth)&&D().error("An attempt to update out of bounds of the texture!"),this._configurePixelStorage();const{gl:M}=m;if(_(l))l=l.levels[i],M.compressedTexSubImage3D(x,i,r,s,o,a,n,p,h.internalFormat,l);else{const t=l;M.texSubImage3D(x,i,r,s,o,a,n,p,d,c,t)}m.bindTexture(E,e.TEXTURE_UNIT_FOR_UPDATES)}generateMipmap(){const i=this._descriptor;if(0===i.width||0===i.height)return;if(!i.hasMipmap){if(this._wasImmutablyAllocated)throw new t("texture:immutable-change","Cannot add mipmaps to immutable texture after allocation");i.hasMipmap=!0,this._samplingModeDirty=!0,x(i)}i.samplingMode===l.LINEAR?(this._samplingModeDirty=!0,i.samplingMode=l.LINEAR_MIPMAP_NEAREST):i.samplingMode===l.NEAREST&&(this._samplingModeDirty=!0,i.samplingMode=l.NEAREST_MIPMAP_NEAREST);const r=this._descriptor.context.bindTexture(this,e.TEXTURE_UNIT_FOR_UPDATES);this._descriptor.context.setActiveTexture(e.TEXTURE_UNIT_FOR_UPDATES),this._descriptor.context.gl.generateMipmap(i.target),this._descriptor.context.bindTexture(r,e.TEXTURE_UNIT_FOR_UPDATES)}clearMipmap(){const e=this._descriptor;if(e.hasMipmap){if(this._wasImmutablyAllocated)throw new t("texture:immutable-change","Cannot delete mipmaps to immutable texture after allocation");e.hasMipmap=!1,this._samplingModeDirty=!0,x(e)}e.samplingMode===l.LINEAR_MIPMAP_NEAREST?(this._samplingModeDirty=!0,e.samplingMode=l.LINEAR):e.samplingMode===l.NEAREST_MIPMAP_NEAREST&&(this._samplingModeDirty=!0,e.samplingMode=l.NEAREST)}setSamplingMode(t){t!==this._descriptor.samplingMode&&(this._descriptor.samplingMode=t,this._samplingModeDirty=!0)}setWrapMode(t){t!==this._descriptor.wrapMode&&(this._descriptor.wrapMode=t,x(this._descriptor),this._wrapModeDirty=!0)}setShadowFiltering(t){t!==this._descriptor.linearFilterDepth&&(this._descriptor.linearFilterDepth=this._descriptor.compareEnabled=t,this.setSamplingMode(t?l.LINEAR:l.NEAREST),x(this._descriptor),this._shadowFilterDirty=!0)}applyChanges(){this._samplingModeDirty&&(this._applySamplingMode(),this._samplingModeDirty=!1),this._wrapModeDirty&&(this._applyWrapMode(),this._wrapModeDirty=!1),this._shadowFilterDirty&&(this._applyShadowMode(),this._shadowFilterDirty=!1)}abortCompression(){this._compressionAbortController=i(this._compressionAbortController)}_setData(i,r){const s=this._descriptor,a=s.context?.gl;if(!a)return;o(a),this.hasWebGLTextureObject||(this._glName=a.createTexture(),s.context.instanceCounter.increment(n.Texture,this)),x(s);const p=s.context.bindTexture(this,e.TEXTURE_UNIT_FOR_UPDATES);s.context.setActiveTexture(e.TEXTURE_UNIT_FOR_UPDATES),this._configurePixelStorage(),o(a);const l=r??s.target,h=T(l);if(g(i))this._setDataFromTexImageSource(i,l);else{const{width:e,height:r,depth:n}=s;if(null==e||null==r)throw new t("texture:missing-size","Width and height must be specified!");if(h&&null==n)throw new t("texture:missing-depth","Depth must be specified!");if(s.internalFormat=u(s),s.isImmutable&&!this._wasImmutablyAllocated&&this._texStorage(l,s.internalFormat,s.hasMipmap,e,r,n),_(i)){if(!E(s.internalFormat))throw new t("texture:format-mismatch","Attempting to use compressed data with an uncompressed format!");this._setDataFromCompressedSource(i,s.internalFormat,l)}else this._texImage(l,0,s.internalFormat,e,r,n,i),o(a),s.hasMipmap&&this.generateMipmap()}this._applySamplingMode(),this._applyWrapMode(),this._applyAnisotropicFilteringParameters(),this._applyShadowMode(),o(a),s.context.bindTexture(p,e.TEXTURE_UNIT_FOR_UPDATES)}_setDataCubeMap(t=null){for(let e=a.TEXTURE_CUBE_MAP_POSITIVE_X;e<=a.TEXTURE_CUBE_MAP_NEGATIVE_Z;e++)this._setData(t,e)}_configurePixelStorage(){const t=this._descriptor.context.gl,{unpackAlignment:e,flipped:i,preMultiplyAlpha:r}=this._descriptor;t.pixelStorei(t.UNPACK_ALIGNMENT,e),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,i?1:0),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r?1:0)}_setDataFromTexImageSource(t,e){const{gl:i}=this._descriptor.context,r=this._descriptor;r.internalFormat=u(r);const s=T(e),{width:a,height:n,depth:p}=M(t);r.width&&r.height,r.width||(r.width=a),r.height||(r.height=n),s&&r.depth,s&&(r.depth=p),r.isImmutable&&!this._wasImmutablyAllocated&&this._texStorage(e,r.internalFormat,r.hasMipmap,a,n,p),this._texImage(e,0,r.internalFormat,a,n,p,t),o(i),r.hasMipmap&&(this.generateMipmap(),o(i))}_setDataFromCompressedSource(t,e,i){const r=this._descriptor,{width:s,height:o,depth:a}=r,n=t.levels,p=A(i,s,o,a),l=Math.min(p,n.length)-1;this._descriptor.context.gl.texParameteri(r.target,h.MAX_LEVEL,l),this._forEachMipmapLevel(((t,r,s,o)=>{const a=n[Math.min(t,n.length-1)];this._compressedTexImage(i,t,e,r,s,o,a)}),l)}_texStorage(e,i,r,s,o,a){const{gl:n}=this._descriptor.context;if(!b(i)&&!f(i)&&!w(i))throw new t("texture:missing-format","Immutable textures must have a sized internal format");if(!this._descriptor.isImmutable)return;const p=r?A(e,s,o,a):1;if(T(e)){if(null==a)throw new t("texture:missing-depth","Missing depth dimension for 3D texture upload");n.texStorage3D(e,p,i,s,o,a)}else n.texStorage2D(e,p,i,s,o);this._wasImmutablyAllocated=!0}_texImage(e,i,r,s,o,a,n){const p=this._descriptor.context.gl,l=T(e),{isImmutable:h,pixelFormat:m,dataType:d}=this._descriptor;if(h){if(null!=n){const r=n;if(l){if(null==a)throw new t("texture:missing-depth","Missing depth dimension for 3D texture upload");p.texSubImage3D(e,i,0,0,0,s,o,a,m,d,r)}else p.texSubImage2D(e,i,0,0,s,o,m,d,r)}}else{const h=n;if(l){if(null==a)throw new t("texture:missing-depth","Missing depth dimension for 3D texture upload");p.texImage3D(e,i,r,s,o,a,0,m,d,h)}else p.texImage2D(e,i,r,s,o,0,m,d,h)}}_compressedTexImage(e,i,r,s,o,a,n){const p=this._descriptor.context.gl,l=T(e);if(this._descriptor.isImmutable){if(null!=n)if(l){if(null==a)throw new t("texture:missing-depth","Missing depth dimension for 3D texture upload");p.compressedTexSubImage3D(e,i,0,0,0,s,o,a,r,n)}else p.compressedTexSubImage2D(e,i,0,0,s,o,r,n)}else if(l){if(null==a)throw new t("texture:missing-depth","Missing depth dimension for 3D texture upload");p.compressedTexImage3D(e,i,r,s,o,a,0,n)}else p.compressedTexImage2D(e,i,r,s,o,0,n)}async _compressOnWorker(t){const{width:i,height:o,context:a,compressionHandle:n,compressionCallback:p,flipped:l,preMultiplyAlpha:h,hasMipmap:d}=this._descriptor,{compressedTextureETC:c,compressedTextureS3TC:_}=a.capabilities;if(!e.compressionWorkerHandle?.isCompressible(t,this._descriptor)||!c&&!_)return;this.abortCompression();const u=new AbortController;this._compressionAbortController=u,n.increment();try{let s;t instanceof Uint8Array?s=t.buffer:(s=await createImageBitmap(t,{imageOrientation:l?"flipY":"none"}),r(u));const a={data:s,width:i,height:o,needsFlip:t instanceof Uint8Array&&this.descriptor.flipped,components:this._descriptor.pixelFormat===m.RGBA?4:3,preMultiplyAlpha:h,hasMipmap:d,hasETC:!!c,hasS3TC:!!_},n=await e.compressionWorkerHandle.invoke(a,u.signal);if(r(u),n.compressedTexture&&this.hasWebGLTextureObject){const t=this.usedMemory;this._descriptor.internalFormat=n.internalFormat,this._setData(n.compressedTexture),p?.(t-this.usedMemory)}}catch(g){s(g)||D().error("Texture compression failed!")}finally{n.decrement(),this._compressionAbortController?.signal.aborted&&(this._compressionAbortController=null)}}_forEachMipmapLevel(e,i=1/0){let{width:r,height:s,depth:o,hasMipmap:n,target:p}=this._descriptor;const l=p===a.TEXTURE_3D;if(null==r||null==s||l&&null==o)throw new t("texture:missing-size","Missing texture dimensions for mipmap calculation");for(let t=0;e(t,r,s,o),n&&(1!==r||1!==s||l&&1!==o)&&!(t>=i);++t)r=Math.max(1,r>>1),s=Math.max(1,s>>1),l&&(o=Math.max(1,o>>1))}_applySamplingMode(){const t=this._descriptor,e=t.context?.gl;let i=t.samplingMode,r=t.samplingMode;i===l.LINEAR_MIPMAP_NEAREST||i===l.LINEAR_MIPMAP_LINEAR?(i=l.LINEAR,t.hasMipmap||(r=l.LINEAR)):i!==l.NEAREST_MIPMAP_NEAREST&&i!==l.NEAREST_MIPMAP_LINEAR||(i=l.NEAREST,t.hasMipmap||(r=l.NEAREST)),e.texParameteri(t.target,e.TEXTURE_MAG_FILTER,i),e.texParameteri(t.target,e.TEXTURE_MIN_FILTER,r)}_applyWrapMode(){const t=this._descriptor,e=t.context?.gl;"number"==typeof t.wrapMode?(e.texParameteri(t.target,e.TEXTURE_WRAP_S,t.wrapMode),e.texParameteri(t.target,e.TEXTURE_WRAP_T,t.wrapMode)):(e.texParameteri(t.target,e.TEXTURE_WRAP_S,t.wrapMode.s),e.texParameteri(t.target,e.TEXTURE_WRAP_T,t.wrapMode.t))}_applyShadowMode(){const t=this._descriptor,e=t.context?.gl,i=t.compareEnabled?e.COMPARE_REF_TO_TEXTURE:e.NONE;e.texParameteri(t.target,e.TEXTURE_COMPARE_MODE,i),t.compareEnabled&&e.texParameteri(t.target,e.TEXTURE_COMPARE_FUNC,e.GREATER),o(e)}_applyAnisotropicFilteringParameters(){const t=this._descriptor,e=t.context.capabilities.textureFilterAnisotropic;if(!e)return;t.context.gl.texParameterf(t.target,e.TEXTURE_MAX_ANISOTROPY,t.maxAnisotropy??1)}};export{S as Texture,R as tracer};
|
|
5
|
+
import t from"../../core/Error.js";import"../../core/has.js";import e from"../../core/Logger.js";import{abortMaybe as i}from"../../core/maybe.js";import{throwIfAborted as r,isAbortError as s}from"../../core/promiseUtils.js";import{checkWebGLError as o}from"./checkWebGLError.js";import{TextureType as a,ResourceType as n,CompressedTextureFormat as p,TextureSamplingMode as l,TextureConstants as h,PixelFormat as m}from"./enums.js";import{FBOAttachmentType as d}from"./FBOAttachmentType.js";import{estimateMemory as c}from"./TextureDescriptor.js";import{isCompressedData as _,deriveInternalFormat as u,isTexImageSource as g,is3DTarget as T,validateTexture as x,isCompressedFormat as E,getDimensions as M,calcMipmapLevels as A,isSizedPixelFormat as b,isSizedDepthFormat as f,isSizedDepthStencilFormat as w}from"./textureUtils.js";import{ValidatedTextureDescriptor as I}from"./ValidatedTextureDescriptor.js";const R=null,D=()=>e.getLogger("esri/views/webgl/Texture");let S=class e{static{this.TEXTURE_UNIT_FOR_UPDATES=0}static{this.compressionWorkerHandle=null}constructor(e,i=null,r=null){if(this.type=d.Texture,this._glName=null,this._samplingModeDirty=!1,this._wrapModeDirty=!1,this._shadowFilterDirty=!1,this._wasImmutablyAllocated=!1,"context"in e)this._descriptor=e,r=i;else{const r=I.validate(e,i);if(!r)throw new t("texture:invalid-descriptor","Texture descriptor invalid");this._descriptor=r}this._descriptor.target===a.TEXTURE_CUBE_MAP?this._setDataCubeMap(r):this.setData(r)}get glName(){return this._glName}get descriptor(){return this._descriptor}get usedMemory(){return c(this._descriptor)}get cachedMemory(){return this.usedMemory}get isDirty(){return this._samplingModeDirty||this._wrapModeDirty||this._shadowFilterDirty}get hasWebGLTextureObject(){return!!this._glName}dispose(){this.abortCompression(),this._descriptor.context.gl&&this.hasWebGLTextureObject&&(this._descriptor.context.instanceCounter.decrement(n.Texture,this),this._descriptor.context.unbindTexture(this),this._descriptor.context.gl.deleteTexture(this._glName),this._glName=null)}release(){this.dispose()}[Symbol.dispose](){this.dispose()}resize(e,i){const r=this._descriptor;if(r.width!==e||r.height!==i){if(this._wasImmutablyAllocated)throw new t("texture:immutable-resize","Immutable textures can't be resized!");r.width=e,r.height=i,this._descriptor.target===a.TEXTURE_CUBE_MAP?this._setDataCubeMap(null):this.setData(null)}}enableCompression(t,e){this._descriptor.compressionHandle=t,this._descriptor.compressionCallback=e}disableCompression(){this._descriptor.compressionHandle=null,this._descriptor.compressionCallback=null}setData(t){this.abortCompression(),!_(t)&&this._descriptor.internalFormat&&this._descriptor.internalFormat in p&&(this._descriptor.internalFormat=void 0),this._setData(t),!_(t)&&this._descriptor.compressionHandle&&this._compressOnWorker(t)}updateData(i,r,s,o,a,n,p=0){n||D().error("An attempt to use uninitialized data!"),this.hasWebGLTextureObject||D().error("An attempt to update uninitialized texture!");const l=this._descriptor;l.internalFormat=u(l);const{context:h,pixelFormat:m,dataType:d,target:c,isImmutable:T}=l;if(T&&!this._wasImmutablyAllocated)throw new t("texture:uninitialized","Cannot update immutable texture before allocation!");const x=h.bindTexture(this,e.TEXTURE_UNIT_FOR_UPDATES,!0);(r<0||s<0||r+o>l.width||s+a>l.height)&&D().error("An attempt to update out of bounds of the texture!"),this._configurePixelStorage();const{gl:E}=h;p&&(o&&a||D().warn("Must pass width and height if `UNPACK_SKIP_ROWS` is used"),E.pixelStorei(E.UNPACK_SKIP_ROWS,p)),g(n)?E.texSubImage2D(c,i,r,s,o,a,m,d,n):_(n)?E.compressedTexSubImage2D(c,i,r,s,o,a,l.internalFormat,n.levels[i]):E.texSubImage2D(c,i,r,s,o,a,m,d,n),p&&E.pixelStorei(E.UNPACK_SKIP_ROWS,0),h.bindTexture(x,e.TEXTURE_UNIT_FOR_UPDATES)}updateData3D(i,r,s,o,a,n,p,l){l||D().error("An attempt to use uninitialized data!"),this.hasWebGLTextureObject||D().error("An attempt to update an uninitialized texture!");const h=this._descriptor;h.internalFormat=u(h);const{context:m,pixelFormat:d,dataType:c,isImmutable:g,target:x}=h;if(g&&!this._wasImmutablyAllocated)throw new t("texture:uninitialized","Cannot update immutable texture before allocation!");T(x)||D().warn("Attempting to set 3D texture data on a non-3D texture");const E=m.bindTexture(this,e.TEXTURE_UNIT_FOR_UPDATES);m.setActiveTexture(e.TEXTURE_UNIT_FOR_UPDATES),(r<0||s<0||o<0||r+a>h.width||s+n>h.height||o+p>h.depth)&&D().error("An attempt to update out of bounds of the texture!"),this._configurePixelStorage();const{gl:M}=m;if(_(l))l=l.levels[i],M.compressedTexSubImage3D(x,i,r,s,o,a,n,p,h.internalFormat,l);else{const t=l;M.texSubImage3D(x,i,r,s,o,a,n,p,d,c,t)}m.bindTexture(E,e.TEXTURE_UNIT_FOR_UPDATES)}generateMipmap(){const i=this._descriptor;if(0===i.width||0===i.height)return;if(!i.hasMipmap){if(this._wasImmutablyAllocated)throw new t("texture:immutable-change","Cannot add mipmaps to immutable texture after allocation");i.hasMipmap=!0,this._samplingModeDirty=!0,x(i)}i.samplingMode===l.LINEAR?(this._samplingModeDirty=!0,i.samplingMode=l.LINEAR_MIPMAP_NEAREST):i.samplingMode===l.NEAREST&&(this._samplingModeDirty=!0,i.samplingMode=l.NEAREST_MIPMAP_NEAREST);const r=this._descriptor.context.bindTexture(this,e.TEXTURE_UNIT_FOR_UPDATES);this._descriptor.context.setActiveTexture(e.TEXTURE_UNIT_FOR_UPDATES),this._descriptor.context.gl.generateMipmap(i.target),this._descriptor.context.bindTexture(r,e.TEXTURE_UNIT_FOR_UPDATES)}clearMipmap(){const e=this._descriptor;if(e.hasMipmap){if(this._wasImmutablyAllocated)throw new t("texture:immutable-change","Cannot delete mipmaps to immutable texture after allocation");e.hasMipmap=!1,this._samplingModeDirty=!0,x(e)}e.samplingMode===l.LINEAR_MIPMAP_NEAREST?(this._samplingModeDirty=!0,e.samplingMode=l.LINEAR):e.samplingMode===l.NEAREST_MIPMAP_NEAREST&&(this._samplingModeDirty=!0,e.samplingMode=l.NEAREST)}setSamplingMode(t){t!==this._descriptor.samplingMode&&(this._descriptor.samplingMode=t,this._samplingModeDirty=!0)}setWrapMode(t){t!==this._descriptor.wrapMode&&(this._descriptor.wrapMode=t,x(this._descriptor),this._wrapModeDirty=!0)}setShadowFiltering(t){t!==this._descriptor.linearFilterDepth&&(this._descriptor.linearFilterDepth=this._descriptor.compareEnabled=t,this.setSamplingMode(t?l.LINEAR:l.NEAREST),x(this._descriptor),this._shadowFilterDirty=!0)}applyChanges(){this._samplingModeDirty&&(this._applySamplingMode(),this._samplingModeDirty=!1),this._wrapModeDirty&&(this._applyWrapMode(),this._wrapModeDirty=!1),this._shadowFilterDirty&&(this._applyShadowMode(),this._shadowFilterDirty=!1)}abortCompression(){this._compressionAbortController=i(this._compressionAbortController)}_setData(i,r){const s=this._descriptor,a=s.context?.gl;if(!a)return;o(a),this.hasWebGLTextureObject||(this._glName=a.createTexture(),s.context.instanceCounter.increment(n.Texture,this)),x(s);const p=s.context.bindTexture(this,e.TEXTURE_UNIT_FOR_UPDATES);s.context.setActiveTexture(e.TEXTURE_UNIT_FOR_UPDATES),this._configurePixelStorage(),o(a);const l=r??s.target,h=T(l);if(g(i))this._setDataFromTexImageSource(i,l);else{const{width:e,height:r,depth:n}=s;if(null==e||null==r)throw new t("texture:missing-size","Width and height must be specified!");if(h&&null==n)throw new t("texture:missing-depth","Depth must be specified!");if(s.internalFormat=u(s),s.isImmutable&&!this._wasImmutablyAllocated&&this._texStorage(l,s.internalFormat,s.hasMipmap,e,r,n),_(i)){if(!E(s.internalFormat))throw new t("texture:format-mismatch","Attempting to use compressed data with an uncompressed format!");this._setDataFromCompressedSource(i,s.internalFormat,l)}else this._texImage(l,0,s.internalFormat,e,r,n,i),o(a),s.hasMipmap&&this.generateMipmap()}this._applySamplingMode(),this._applyWrapMode(),this._applyAnisotropicFilteringParameters(),this._applyShadowMode(),o(a),s.context.bindTexture(p,e.TEXTURE_UNIT_FOR_UPDATES)}_setDataCubeMap(t=null){for(let e=a.TEXTURE_CUBE_MAP_POSITIVE_X;e<=a.TEXTURE_CUBE_MAP_NEGATIVE_Z;e++)this._setData(t,e)}_configurePixelStorage(){const t=this._descriptor.context.gl,{unpackAlignment:e,flipped:i,preMultiplyAlpha:r}=this._descriptor;t.pixelStorei(t.UNPACK_ALIGNMENT,e),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,i?1:0),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r?1:0)}_setDataFromTexImageSource(t,e){const{gl:i}=this._descriptor.context,r=this._descriptor;r.internalFormat=u(r);const s=T(e),{width:a,height:n,depth:p}=M(t);r.width&&r.height,r.width||(r.width=a),r.height||(r.height=n),s&&r.depth,s&&(r.depth=p),r.isImmutable&&!this._wasImmutablyAllocated&&this._texStorage(e,r.internalFormat,r.hasMipmap,a,n,p),this._texImage(e,0,r.internalFormat,a,n,p,t),o(i),r.hasMipmap&&(this.generateMipmap(),o(i))}_setDataFromCompressedSource(t,e,i){const r=this._descriptor,{width:s,height:o,depth:a}=r,n=t.levels,p=A(i,s,o,a),l=Math.min(p,n.length)-1;this._descriptor.context.gl.texParameteri(r.target,h.MAX_LEVEL,l),this._forEachMipmapLevel(((t,r,s,o)=>{const a=n[Math.min(t,n.length-1)];this._compressedTexImage(i,t,e,r,s,o,a)}),l)}_texStorage(e,i,r,s,o,a){const{gl:n}=this._descriptor.context;if(!b(i)&&!f(i)&&!w(i))throw new t("texture:missing-format","Immutable textures must have a sized internal format");if(!this._descriptor.isImmutable)return;const p=r?A(e,s,o,a):1;if(T(e)){if(null==a)throw new t("texture:missing-depth","Missing depth dimension for 3D texture upload");n.texStorage3D(e,p,i,s,o,a)}else n.texStorage2D(e,p,i,s,o);this._wasImmutablyAllocated=!0}_texImage(e,i,r,s,o,a,n){const p=this._descriptor.context.gl,l=T(e),{isImmutable:h,pixelFormat:m,dataType:d}=this._descriptor;if(h){if(null!=n){const r=n;if(l){if(null==a)throw new t("texture:missing-depth","Missing depth dimension for 3D texture upload");p.texSubImage3D(e,i,0,0,0,s,o,a,m,d,r)}else p.texSubImage2D(e,i,0,0,s,o,m,d,r)}}else{const h=n;if(l){if(null==a)throw new t("texture:missing-depth","Missing depth dimension for 3D texture upload");p.texImage3D(e,i,r,s,o,a,0,m,d,h)}else p.texImage2D(e,i,r,s,o,0,m,d,h)}}_compressedTexImage(e,i,r,s,o,a,n){const p=this._descriptor.context.gl,l=T(e);if(this._descriptor.isImmutable){if(null!=n)if(l){if(null==a)throw new t("texture:missing-depth","Missing depth dimension for 3D texture upload");p.compressedTexSubImage3D(e,i,0,0,0,s,o,a,r,n)}else p.compressedTexSubImage2D(e,i,0,0,s,o,r,n)}else if(l){if(null==a)throw new t("texture:missing-depth","Missing depth dimension for 3D texture upload");p.compressedTexImage3D(e,i,r,s,o,a,0,n)}else p.compressedTexImage2D(e,i,r,s,o,0,n)}async _compressOnWorker(t){const{width:i,height:o,context:a,compressionHandle:n,compressionCallback:p,flipped:l,preMultiplyAlpha:h,hasMipmap:d}=this._descriptor,{compressedTextureETC:c,compressedTextureS3TC:_}=a.capabilities;if(!e.compressionWorkerHandle?.isCompressible(t,this._descriptor)||!c&&!_)return;this.abortCompression();const u=new AbortController;this._compressionAbortController=u,n.increment();try{let s;t instanceof Uint8Array?s=t.buffer:(s=await createImageBitmap(t,{imageOrientation:l?"flipY":"none"}),r(u));const a={data:s,width:i,height:o,needsFlip:t instanceof Uint8Array&&this.descriptor.flipped,components:this._descriptor.pixelFormat===m.RGBA?4:3,preMultiplyAlpha:h,hasMipmap:d,hasETC:!!c,hasS3TC:!!_},n=await e.compressionWorkerHandle.invoke(a,u.signal);if(r(u),n.compressedTexture&&this.hasWebGLTextureObject){const t=this.usedMemory;this._descriptor.internalFormat=n.internalFormat,this._setData(n.compressedTexture),p?.(t-this.usedMemory)}}catch(g){s(g)||D().error("Texture compression failed!")}finally{n.decrement(),this._compressionAbortController?.signal.aborted&&(this._compressionAbortController=null)}}_forEachMipmapLevel(e,i=1/0){let{width:r,height:s,depth:o,hasMipmap:n,target:p}=this._descriptor;const l=p===a.TEXTURE_3D;if(null==r||null==s||l&&null==o)throw new t("texture:missing-size","Missing texture dimensions for mipmap calculation");for(let t=0;e(t,r,s,o),n&&(1!==r||1!==s||l&&1!==o)&&!(t>=i);++t)r=Math.max(1,r>>1),s=Math.max(1,s>>1),l&&(o=Math.max(1,o>>1))}_applySamplingMode(){const t=this._descriptor,e=t.context?.gl;let i=t.samplingMode,r=t.samplingMode;i===l.LINEAR_MIPMAP_NEAREST||i===l.LINEAR_MIPMAP_LINEAR?(i=l.LINEAR,t.hasMipmap||(r=l.LINEAR)):i!==l.NEAREST_MIPMAP_NEAREST&&i!==l.NEAREST_MIPMAP_LINEAR||(i=l.NEAREST,t.hasMipmap||(r=l.NEAREST)),e.texParameteri(t.target,e.TEXTURE_MAG_FILTER,i),e.texParameteri(t.target,e.TEXTURE_MIN_FILTER,r)}_applyWrapMode(){const t=this._descriptor,e=t.context?.gl;"number"==typeof t.wrapMode?(e.texParameteri(t.target,e.TEXTURE_WRAP_S,t.wrapMode),e.texParameteri(t.target,e.TEXTURE_WRAP_T,t.wrapMode)):(e.texParameteri(t.target,e.TEXTURE_WRAP_S,t.wrapMode.s),e.texParameteri(t.target,e.TEXTURE_WRAP_T,t.wrapMode.t))}_applyShadowMode(){const t=this._descriptor,e=t.context?.gl,i=t.compareEnabled?e.COMPARE_REF_TO_TEXTURE:e.NONE;e.texParameteri(t.target,e.TEXTURE_COMPARE_MODE,i),t.compareEnabled&&e.texParameteri(t.target,e.TEXTURE_COMPARE_FUNC,e.GREATER),o(e)}_applyAnisotropicFilteringParameters(){const t=this._descriptor,e=t.context.capabilities.textureFilterAnisotropic;if(!e)return;t.context.gl.texParameterf(t.target,e.TEXTURE_MAX_ANISOTROPY,t.maxAnisotropy??1)}};export{S as Texture,R as tracer};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{ZEROS as
|
|
5
|
+
import{ZEROS as e}from"../../core/libs/gl-matrix-2/factories/vec2f64.js";import{SizedPixelFormat as t,PixelType as n,TextureSamplingMode as a,TextureWrapMode as r,PixelFormat as u}from"./enums.js";import{Texture as i}from"./Texture.js";import{TextureDescriptor as o}from"./TextureDescriptor.js";function s(e,s,m="nearest",l=!1){const c=!(l&&"u8"===s.pixelType),f=c?n.FLOAT:n.UNSIGNED_BYTE,p=null==s.pixels||0===s.pixels.length?null:c?s.getAsRGBAFloat():s.getAsRGBA(),_=e.capabilities.textureFloatLinear,A=new o(s.width,s.height);return A.internalFormat=c?t.RGBA32F:u.RGBA,A.samplingMode=!_||"bilinear"!==m&&"cubic"!==m?a.NEAREST:a.LINEAR,A.dataType=f,A.wrapMode=r.CLAMP_TO_EDGE,new i(e,A,p)}function m(e,u){const{spacing:s,offsets:m,coefficients:l,size:[c,f]}=u,p=s[0]>1,_=new o(p?4*c:c,f);_.internalFormat=t.RGBA32F,_.dataType=n.FLOAT,_.samplingMode=a.NEAREST,_.wrapMode=r.CLAMP_TO_EDGE;const A=new Float32Array(p?c*f*16:2*m.length);if(p&&null!=l)for(let t=0,n=0;t<l.length;t++)A[n++]=l[t],t%3==2&&(A[n++]=1);else for(let t=0;t<f;t++)for(let e=0;e<c;e++){const n=4*(t*c+e),a=2*(e*f+t);A[n]=m[a],A[n+1]=m[a+1],A[n+3]=-1===m[a]?0:1}return new i(e,_,A)}function l(e,t){const n=new o(t.length/4,1);return n.internalFormat=u.RGBA,n.samplingMode=a.NEAREST,n.wrapMode=r.CLAMP_TO_EDGE,new i(e,n,t)}function c(e,t,s){const m=new o(s[0],s[1]);return m.internalFormat=u.ALPHA,m.pixelFormat=u.ALPHA,m.dataType=n.UNSIGNED_BYTE,m.samplingMode=a.NEAREST,m.wrapMode=r.CLAMP_TO_EDGE,new i(e,m,t)}function f(t,n,a,r=1,u=!0){return{u_flipY:u,u_applyTransform:!!t,u_opacity:r,u_transformSpacing:t?t.spacing:e,u_transformGridSize:t?t.size:e,u_targetImageSize:n,u_srcImageSize:a}}function p(e,t){return{u_colormapOffset:t||0,u_colormapMaxIndex:e?e.length/4-1:0}}function _(e){return{u_bandCount:e.bandCount,u_minOutput:e.minOutput,u_maxOutput:e.maxOutput,u_minCutOff:e.minCutOff,u_maxCutOff:e.maxCutOff,u_factor:e.factor,u_useGamma:e.useGamma,u_gamma:e.gamma,u_gammaCorrection:e.gammaCorrection}}function A(e){return{u_hillshadeType:e.hillshadeType,u_sinZcosAs:e.sinZcosAs,u_sinZsinAs:e.sinZsinAs,u_cosZs:e.cosZs,u_weights:e.weights,u_factor:e.factor,u_minValue:e.minValue,u_maxValue:e.maxValue}}export{l as createColormapTexture,c as createPixelMaskTexture,s as createRasterTexture,m as createTransformTexture,p as getColormapUniforms,f as getCommonUniforms,A as getShadedReliefUniforms,_ as getStretchUniforms};
|