@arcgis/core 5.1.0-next.33 → 5.1.0-next.35
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/WebScene.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{91e9337bef87ada2e05c.js → 0e78678281bcb888964d.js} +1 -1
- package/assets/esri/core/workers/chunks/{8d4ddaace906dd09de2c.js → 0f2d6f267d235db48767.js} +1 -1
- package/assets/esri/core/workers/chunks/{8109476a7b1039d424ab.js → 0fd191f9c10b3b7c83f4.js} +1 -1
- package/assets/esri/core/workers/chunks/{f7e66295401b85e2c91d.js → 19955d064c17ba2fd9ad.js} +1 -1
- package/assets/esri/core/workers/chunks/{cf045900f179210f22d2.js → 2128a66f522d15493ce2.js} +1 -1
- package/assets/esri/core/workers/chunks/{ab679e5d76d70a1672af.js → 266933f1139ed0e8919f.js} +1 -1
- package/assets/esri/core/workers/chunks/{55165b6b49b87c1aff8f.js → 2d49a611ad3441d7e759.js} +9 -13
- package/assets/esri/core/workers/chunks/{48968fb9e103ee6c3579.js → 2f20a21db44bd8448e9e.js} +1 -1
- package/assets/esri/core/workers/chunks/{5b22245bf02f839d79e3.js → 5691c1624190abeaebea.js} +1 -1
- package/assets/esri/core/workers/chunks/{bfdfa737f8e7b0bee417.js → 64e1273e4e79c73ed579.js} +1 -1
- package/assets/esri/core/workers/chunks/{6ba87ebb1c8c5f1d4798.js → 6f1c590abd0e3adeb8fc.js} +1 -1
- package/assets/esri/core/workers/chunks/{5cb4cd1cc6c21f69b925.js → 7948d6f14ae44d346d88.js} +1 -1
- package/assets/esri/core/workers/chunks/{c2c339b2df1c4466f4d4.js → 7c16493ea34c49a6291e.js} +1 -1
- package/assets/esri/core/workers/chunks/{ba477072b1d1d3b5f78b.js → 85f309c1888c1c8411b1.js} +1 -1
- package/assets/esri/core/workers/chunks/{938125c024e1524a57e6.js → 942e4d69b140bc2f97c9.js} +1 -1
- package/assets/esri/core/workers/chunks/{cc69e61d6a7c220e3dd8.js → a53979c45ee429e21b99.js} +2 -2
- package/assets/esri/core/workers/chunks/ad4f0a4e2dde44cd43d4.js +1 -0
- package/assets/esri/core/workers/chunks/bd902ae413887082b453.js +1 -0
- package/assets/esri/core/workers/chunks/{209d8ee81cc3ebb18b27.js → c3e711dc608eedda2d14.js} +1 -1
- package/assets/esri/core/workers/chunks/{d22cc7d485c032181bbc.js → e9dd60d0220036545ebb.js} +1 -1
- package/assets/esri/core/workers/chunks/{fa62d43ccf5cb991dddd.js → eb811adbc5243d293ef5.js} +1 -1
- package/assets/esri/libs/lyr3d/lyr3DWorker.wasm +0 -0
- package/config.js +1 -1
- package/core/has.js +1 -1
- package/kernel.js +1 -1
- package/package.json +4 -4
- package/portal/schemas/definitions.js +1 -1
- package/support/revision.js +1 -1
- package/views/2d/engine/vectorTiles/VectorTileContainer.js +1 -1
- package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
- package/views/2d/layers/features/support/FeatureSetReader.js +1 -1
- package/views/3d/analysis/Dimension/lengthDimensionUtils.js +1 -1
- package/views/3d/environment/EnvironmentManager.js +1 -1
- package/views/3d/layers/I3SMeshView3D.js +1 -1
- package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
- package/views/3d/layers/IntegratedMeshLayerView3D.js +1 -1
- package/views/3d/layers/IntegratedMeshNormals.js +1 -1
- package/views/3d/layers/SceneLayerWorker.js +1 -1
- package/views/3d/support/GaussianSplatSortWorker.js +1 -1
- package/views/3d/support/GaussianSplatWorkerHandle.js +1 -1
- package/views/3d/support/gaussianSplatting/GaussianSplatDataStore.js +1 -1
- package/views/3d/webgl-engine/collections/Component/ComponentDrawParameters.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterialRepository.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/collections/Component/SourceGeometry.js +1 -1
- package/views/3d/webgl-engine/core/renderPasses/RenderPassManager.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/attributes/VertexNormal.glsl.js +7 -11
- package/views/3d/webgl-engine/core/shaderLibrary/attributes/VertexPosition.glsl.js +2 -2
- package/views/3d/webgl-engine/lib/GaussianSplatRenderNode.js +1 -1
- package/views/3d/webgl-engine/lib/Normals.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/draw/plugins/CircularArcSegmentPlugin.js +1 -1
- package/views/support/euclideanLengthMeasurementUtils.js +1 -1
- package/widgets/FloorFilter/FloorFilterViewModel.js +1 -1
- package/assets/esri/core/workers/chunks/2541724a29f6058718f8.js +0 -1
- package/assets/esri/core/workers/chunks/f104d83b7b31a16908ee.js +0 -1
- /package/assets/esri/core/workers/chunks/{cc69e61d6a7c220e3dd8.js.LICENSE.txt → a53979c45ee429e21b99.js.LICENSE.txt} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{hasScaling as e}from"../../../core/mathUtils.js";import r from"../../../geometry/SpatialReference.js";import{ensurePackedMat4f64 as
|
|
2
|
+
import{hasScaling as e}from"../../../core/mathUtils.js";import{fromMat4 as r}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as t}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import o from"../../../geometry/SpatialReference.js";import{ensurePackedMat4f64 as n,ensurePackedArray as s}from"../../../geometry/support/DoubleArray.js";import i from"../../../geometry/support/MeshGeoreferencedVertexSpace.js";import a from"../../../geometry/support/MeshLocalVertexSpace.js";import{b as f,n as c}from"../../../chunks/vec3.js";import{get as l,cleanup as u}from"../../../libs/i3s/I3SModule.js";import{addNormals as m}from"./IntegratedMeshNormals.js";import{TransformedGeometry as p,TransformedData as y}from"./SceneLayerWorkerHandle.js";async function d(e){E=await M();const r=[e.geometryBuffer];return{result:U(E,e,r),transferList:r}}async function h(e){E=await M();const r=[e.geometryBuffer],{geometryBuffer:t}=e,o=t.byteLength,n=E._malloc(o),s=new Uint8Array(E.HEAPU8.buffer,n,o);s.set(new Uint8Array(t));const i=E.dracoDecompressPointCloudData(n,s.byteLength);if(E._free(n),i.error.length>0)throw new Error(`i3s.wasm: ${i.error}`);const a=i.featureIds?.length>0?i.featureIds.slice():null,f=i.positions.slice();return a&&r.push(a.buffer),r.push(f.buffer),{result:{positions:f,featureIds:a},transferList:r}}async function g(e){await M(),P(e);const r={buffer:e.buffer};return{result:r,transferList:[r.buffer]}}async function b(e){await M(),S(e)}async function w(e){E=await M(),E.setLegacySchema(e.context,e.jsonSchema)}async function j(e){const{localMatrix:r,origin:t,positions:f,vertexSpace:c}=e,l=o.fromJSON(e.inSpatialReference),u=o.fromJSON(e.outSpatialReference),m=r?n(r):void 0,p=s(t);let y;const[{projectBuffer:d},{initializeProjection:h}]=await Promise.all([import("../../../geometry/projection/projectBuffer.js"),import("../../../geometry/projectionUtils.js")]);await h(l,u);const g=[0,0,0];if(!d(p,l,0,g,u,0))throw new Error("Failed to project");if("georeferenced"===c.type&&null==c.origin){if(y=new Float64Array(f.length),!d(f,l,0,y,u,0,y.length/3))throw new Error("Failed to project")}else{const e="georeferenced"===c.type?i.fromJSON(c):a.fromJSON(c),{projectMeshVertexPositions:r}=await import("../../../geometry/support/meshUtils/projectMeshVertexPositions.js"),t=r({vertexAttributes:{position:f},transform:m?{localMatrix:m}:void 0,vertexSpace:e,spatialReference:l},u);if(!t)throw new Error("Failed to project");y=t}const b=y.length,[w,j,A]=g;for(let o=0;o<b;o+=3)y[o]-=w,y[o+1]-=j,y[o+2]-=A;return{result:{projected:y,original:f,projectedOrigin:g},transferList:[y.buffer,f.buffer]}}async function A({normalMatrix:r,normals:t}){const o=new Float32Array(t.length);return f(o,t,r),e(r)&&c(o,o),{result:{transformed:o,original:t},transferList:[o.buffer,t.buffer]}}function x(e){_(e)}let L,E;function S(e){if(!E)return;const r=e.modifications,t=E._malloc(8*r.length),o=new Float64Array(E.HEAPU8.buffer,t,r.length);for(let n=0;n<r.length;++n)o[n]=r[n];E.setModifications(e.context,t,r.length,e.isGeodetic),E._free(t)}function U(e,o,n){const{context:s,globalTrafo:i,mbs:a,obbData:f,layouts:c,needNormals:l,computeNormals:u,elevationOffset:d,geometryBuffer:h,geometryDescriptor:g,indexToVertexProjector:b,vertexToRenderProjector:w,normalReferenceFrame:j}=o,A=e._malloc(h.byteLength),x=33,L=e._malloc(x*Float64Array.BYTES_PER_ELEMENT),E=new Uint8Array(e.HEAPU8.buffer,A,h.byteLength);E.set(new Uint8Array(h));const S=new Float64Array(e.HEAPU8.buffer,L,x);v(S,[NaN,NaN,NaN],0);let U=3;v(S,i,U),U+=16,v(S,a.center,U),U+=3,S[U++]=a.radius,f&&v(S,f,U++);const N={isDraco:!1,isLegacy:!1,color:c.some(e=>e.some(e=>"color"===e.name)),normal:l&&c.some(e=>e.some(e=>"normalCompressed"===e.name)),uv0:c.some(e=>e.some(e=>"uv0"===e.name)),uvRegion:c.some(e=>e.some(e=>"uvRegion"===e.name)),featureIndex:g.featureIndex},P=e.process(s,!!f,A,E.byteLength,g,N,L,d,b,w,j);if(e._free(L),e._free(A),P.error.length>0)throw new Error(`i3s.wasm: ${P.error}`);if(P.discarded)return null;const _=P.componentOffsets.length>0?P.componentOffsets.slice():null,I=P.featureIds.length>0?P.featureIds.slice():null,M=P.anchorIds.length>0?Array.from(P.anchorIds):null,F=P.anchors.length>0?Array.from(P.anchors):null,O=1===P.indicesType?new Uint16Array(P.indices.buffer,P.indices.byteOffset,P.indices.byteLength/2).slice():new Uint32Array(P.indices.buffer,P.indices.byteOffset,P.indices.byteLength/4).slice(),B=c[0].slice(),R=r(t(),i),T=m(P.interleavedVertedData,O,B,u&&!N.normal,R),D=P.positions.slice(),{buffer:H,byteOffset:V,byteLength:J}=P.positionIndices,C=1===P.positionIndicesType?new Uint16Array(H,V,J/2).slice():new Uint32Array(H,V,J/4).slice(),k=new p(B,T.data,T.indices,P.hasColors,P.hasModifications,{data:D,indices:C});return I&&n.push(I.buffer),_&&n.push(_.buffer),n.push(T.data),n.push(T.indices.buffer),n.push(D.buffer),n.push(C.buffer),new y(_,I,M,F,k,i,P.obb)}function N(e){return 0===e?0:1===e?1:2===e?2:3}function P(e){if(!E)return;const{context:r,buffer:t}=e,o=E._malloc(t.byteLength),n=t.byteLength/Float64Array.BYTES_PER_ELEMENT,s=new Float64Array(E.HEAPU8.buffer,o,n),i=new Float64Array(t);s.set(i),E.filterOBBs(r,o,n),i.set(s),E._free(o)}function _(e){0===E?.destroy(e)&&(E=null,L=null,u())}function v(e,r,t){for(let o=0;o<r.length;++o)e[o+t]=r[o]}async function I(){E||await M()}async function M(){return E||(E=await(L??=l())),E}const F={transform:(e,r)=>E&&U(E,e,r),destroy:_};export{x as destroyContext,h as dracoDecompressPointCloudData,g as filterObbsForModifications,P as filterObbsForModificationsSync,I as initialize,N as interpretObbModificationResults,d as process,j as project,w as setLegacySchema,b as setModifications,S as setModificationsSync,F as test,A as transformNormals};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
class t{constructor(t,s,
|
|
2
|
+
class t{constructor(t,n,s,r=!1){this.distances=t,this.sortOrderIndices=n,this.numGaussians=s,this.preciseSort=r}}class n{constructor(t,n){this.distances=t,this.sortedOrderIndices=n}}let s=null,r=null,e=0,o=0;const i=10,a=20,c=.25,l=1.5;function u(t,n){let s=Math.max(1,t);for(;s<n;)s=Math.ceil(s*l);return s}function f(t,n){t>e&&(e=u(e,t),s=new Uint32Array(e)),n>o&&(o=u(o,n),r=new Uint32Array(o)),r.fill(0,0,n)}function h(t,n){const e=t.length,o=Math.max(i,Math.min(a,Math.round(Math.log2(e/c)))),l=1+(1<<o);f(e,l);let u=t[0],h=t[0];for(let s=0;s<t.length;s++)u=Math.min(u,t[s]),h=Math.max(h,t[s]);const d=h-u;if(d<1e-6)for(let i=0;i<e;++i)s[i]=0,r[0]++;else{const n=(1<<o)/d;for(let o=0;o<e;o++){const e=(t[o]-u)*n>>>0;s[o]=e,r[e]++}}for(let s=1;s<l;s++)r[s]+=r[s-1];for(let i=0;i<e;i++){const t=s[i];n[--r[t]]=i}}async function d(t){const{distances:s,sortOrderIndices:r,preciseSort:e,numGaussians:o}=t,i=s.subarray(0,o),a=r.subarray(0,o);if(0===i.length||0===a.length)return{result:new n(s,r),transferList:[s.buffer,r.buffer]};if(e){const t=Array.from(a.keys());t.sort((t,n)=>i[t]-i[n]||t-n);const n=t.map(t=>a[t]);a.set(n)}else h(i,a);return{result:new n(s,r),transferList:[s.buffer,r.buffer]}}function m(){M()}function M(){s=null,r=null,e=0,o=0}export{t as SplatSortWorkerInput,n as SplatSortWorkerOutput,M as clear,m as destroy,d as sort};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{WorkerHandle as r}from"../../../core/workers/WorkerHandle.js";class
|
|
2
|
+
import{WorkerHandle as r}from"../../../core/workers/WorkerHandle.js";class t extends r{constructor(r){super("GaussianSplatSortWorker","sort",{sort:r=>[r.distances.buffer,r.sortOrderIndices.buffer]},r,{strategy:"dedicated"})}sort(r,t){return this.invokeMethod("sort",r,t)}clear(){return this.broadcast({},"clear")}async destroyWorkerAndSelf(){await this.broadcast({},"destroy"),this.destroy()}}export{t as GaussianSplatSortWorkerHandle};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{reallocGrowthFactor as e}from"../../../../core/arrayUtils.js";import{signal as t}from"../../../../core/signal.js";import{
|
|
2
|
+
import{reallocGrowthFactor as e}from"../../../../core/arrayUtils.js";import{signal as t}from"../../../../core/signal.js";import{Milliseconds as r,now as s}from"../../../../core/time.js";import{normalize as i}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{intersectsSphere as n}from"../../../../geometry/support/frustum.js";import{Sphere as o}from"../../../../geometry/support/sphere.js";import{makeScheduleFunction as u}from"../../layers/support/makeScheduleFunction.js";import{GaussianSplatSortWorkerHandle as h}from"../GaussianSplatWorkerHandle.js";import{GaussianSplatFadeTexture as d}from"./GaussianSplatFadeTexture.js";import{GaussianSplatOrderTexture as l}from"./GaussianSplatOrderTexture.js";import{GaussianSplatTextureAtlas as _}from"./GaussianSplatTextureAtlas.js";import{TaskPriority as c}from"../../../support/Scheduler.js";class f{constructor(e){this._updating=t(!1),this._useDeterministicSort=!1,this.visibleGaussians=0,this._visibleGaussianTiles=new Array,this._bufferCapacity=0,this._minimumBoundingSphere=new o,this._cameraDirectionNormalized=a(),this._frameTask=null,this._workerHandle=null,this._isSorting=!1,this._pendingSortTask=!1,this._scheduledSortStartTimeout=null,this._lastSortStartTime=r(-1/0),this._sortInterval=r(80),this._renderer=e,this._orderTexture=new l(this._renderer.renderingContext),this._fadingTexture=new d(this._renderer.renderingContext),this._textureAtlas=new _(this._renderer.renderingContext,this._renderer.view.resourceController.memoryController,this._renderer.fboCache);const{resourceController:s}=this._renderer.view;this._workerHandle=new h(u(s)),this._frameTask=s.scheduler.registerTask(c.GAUSSIAN_SPLAT_SORTING)}get textureAtlas(){return this._textureAtlas}get orderTexture(){return this._orderTexture}get fadingTexture(){return this._fadingTexture}get visibleGaussianTiles(){return this._visibleGaussianTiles}forEachTile(e){for(const t of this._visibleGaussianTiles)e(t)}updateGaussianVisibility(e){this._visibleGaussianTiles=e,this.requestSort()}get updating(){return this._updating.value}destroy(){this._pendingSortTask=!1,null!=this._scheduledSortStartTimeout&&(clearTimeout(this._scheduledSortStartTimeout),this._scheduledSortStartTimeout=null),this._frameTask.remove(),this._workerHandle?.destroyWorkerAndSelf(),this._textureAtlas.destroy(),this._orderTexture.destroy(),this._fadingTexture.destroy()}requestSort(){return this._updating.value=!0,!this._pendingSortTask&&(this._pendingSortTask=!0,this._scheduleSortStart(),!0)}_scheduleSortStart(){if(this._isSorting)return;const e=s()-this._lastSortStartTime,t=this._sortInterval-e;t<=0?this._startSortIfRequired():null==this._scheduledSortStartTimeout&&(this._scheduledSortStartTimeout=setTimeout(()=>{this._scheduledSortStartTimeout=null,this._pendingSortTask&&!this._isSorting&&this._scheduleSortStart()},t))}_startSortIfRequired(){!this._isSorting&&this._pendingSortTask&&(this._isSorting=!0,this._pendingSortTask=!1,this._lastSortStartTime=s(),this._sortOnWorker().finally(()=>this._handleSortComplete()))}_handleSortComplete(){this._isSorting=!1,this._pendingSortTask?this._scheduleSortStart():this._updating.value=!1}_clearBuffersAndTextures(){this._atlasIndicesBuffer=void 0,this._sortedAtlasIndicesBuffer=void 0,this._distancesBuffer=void 0,this._sortOrderBuffer=void 0,this._bufferCapacity=0,this._orderTexture.clear(),this._textureAtlas.clear()}_computeExpandedCapacity(t,r){let s=Math.max(1,t);for(;s<r;)s=Math.ceil(s*e);return s}_ensureSortBufferCapacities(e){if(this._bufferCapacity<e){const t=this._computeExpandedCapacity(this._bufferCapacity,e);this._atlasIndicesBuffer=new Uint32Array(t),this._distancesBuffer=new Float64Array(t),this._sortOrderBuffer=new Uint32Array(t),this._bufferCapacity=t}}_ensureSortedAtlasIndicesBufferCapacity(e){if(!(e<=0)&&(!this._sortedAtlasIndicesBuffer||this._sortedAtlasIndicesBuffer.length<e)){const t=this._sortedAtlasIndicesBuffer?.length??0,r=this._computeExpandedCapacity(t,e);this._sortedAtlasIndicesBuffer=new Uint32Array(r)}}_clearAllBuffersAndTextures(){this._clearBuffersAndTextures(),this._workerHandle?.clear()}async _sortOnWorker(){if(0===this._visibleGaussianTiles.length)return this.visibleGaussians=0,this._clearAllBuffersAndTextures(),void this._renderer.requestRender(1);this._useDeterministicSort&&this._visibleGaussianTiles.sort((e,t)=>e.obb.centerX-t.obb.centerX||e.obb.centerY-t.obb.centerY||e.obb.centerZ-t.obb.centerZ);const e=this._visibleGaussianTiles,t=e.length;let r=0;for(let i=0;i<t;i++)r+=e[i].gaussianAtlasIndices.length;this._ensureSortBufferCapacities(r),this._textureAtlas.ensureTextureAtlas();const{frustum:s}=this._renderer.camera;i(this._cameraDirectionNormalized,this._renderer.camera.ray.direction);const a=this._cameraDirectionNormalized[0],o=this._cameraDirectionNormalized[1],u=this._cameraDirectionNormalized[2];let h=0;const d=1.5,l=this._atlasIndicesBuffer,_=this._distancesBuffer,c=this._sortOrderBuffer,f=this._minimumBoundingSphere,m=f.center;for(let i=0;i<t;i++){const t=e[i],{gaussianAtlasIndices:r,relativePositions:c,obb:S,maxScale:p}=t,T=r.length,{centerX:g,centerY:x,centerZ:b}=S;if(m[0]=g,m[1]=x,m[2]=b,f.radius=(S.radius+p)*d,!n(s,f))continue;l.set(r,h);const A=a*g+o*x+u*b,B=h+T;for(let e=h,s=0;e<B;e++,s+=3){const t=c[s],r=c[s+1],i=c[s+2];_[e]=t*a+r*o+i*u+A}h=B}for(let i=0;i<h;i++)c[i]=i;if(0===h)return this.visibleGaussians=0,this._clearAllBuffersAndTextures(),void this._renderer.requestRender(1);const S={distances:this._distancesBuffer,sortOrderIndices:this._sortOrderBuffer,numGaussians:h,preciseSort:this._useDeterministicSort},p=await(this._workerHandle?.sort(S));p&&(this._distancesBuffer=p.distances,this._sortOrderBuffer=p.sortedOrderIndices);const T=async e=>{const{paddedSize:t}=this._orderTexture.ensureCapacity(h);this._ensureSortedAtlasIndicesBufferCapacity(t);const r=this._atlasIndicesBuffer,s=this._sortOrderBuffer,i=this._sortedAtlasIndicesBuffer;for(let a=0;a<h;a++)i[a]=r[s[a]];this._orderTexture.setData(i,h),this.visibleGaussians=h,this._renderer.requestRender(1),e.madeProgress()};await this._frameTask.schedule(T)}set useDeterministicSort(e){this._useDeterministicSort=e}}export{f as GaussianSplatDataStore};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{invert as e,transpose as t}from"../../../../../core/libs/gl-matrix-2/math/mat3.js";import{clone as r}from"../../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{ones as s,clone as o}from"../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{VertexPositionDrawParameters as i}from"../../core/shaderLibrary/attributes/VertexPosition.glsl.js";import{TwoVectorPosition as a}from"../../core/util/TwoVectorPosition.js";class n extends i{constructor(s,o){super(),this._componentParameters=u;const{transform:i,toMapSpace:n}=s;this.toMapSpace=n;const l=r(i.rotationScale);e(l,l),t(l,l),this.transformNormalGlobalFromModel=l;const m=new a(i.position);this.transformWorldFromModelTL=m.low,this.transformWorldFromModelTH=m.high,this.transformWorldFromModelRS=i.rotationScale,this.useENUForGlobalOverlayUV=s.obb.radius<h,this.baseColor=o.baseColor,this.opacity=o.opacity,this.textureAlphaCutoff=o.textureAlphaCutoff,this.mrrFactors=o.mrrFactors,this.emissiveBaseColor=o.emissiveBaseColor,this.baseColorTexture=o.baseColorTexture,this.metallicRoughnessTexture=o.metallicRoughnessTexture,this.normalTexture=o.normalTexture,this.occlusionTexture=o.occlusionTexture,this.emissionTexture=o.emissionTexture;const c=new Float32Array(
|
|
2
|
+
import{invert as e,transpose as t}from"../../../../../core/libs/gl-matrix-2/math/mat3.js";import{clone as r}from"../../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{ones as s,clone as o}from"../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{VertexPositionDrawParameters as i}from"../../core/shaderLibrary/attributes/VertexPosition.glsl.js";import{TwoVectorPosition as a}from"../../core/util/TwoVectorPosition.js";class n extends i{constructor(s,o){super(),this._componentParameters=u;const{transform:i,toMapSpace:n}=s;this.toMapSpace=n;const l=r(i.rotationScale);e(l,l),t(l,l),this.transformNormalGlobalFromModel=l;const m=new a(i.position);this.transformWorldFromModelTL=m.low,this.transformWorldFromModelTH=m.high,this.transformWorldFromModelRS=i.rotationScale,this.useENUForGlobalOverlayUV=s.obb.radius<h,this.baseColor=o.baseColor,this.opacity=o.opacity,this.textureAlphaCutoff=o.textureAlphaCutoff,this.mrrFactors=o.mrrFactors,this.emissiveBaseColor=o.emissiveBaseColor,this.baseColorTexture=o.baseColorTexture,this.metallicRoughnessTexture=o.metallicRoughnessTexture,this.normalTexture=o.normalTexture,this.occlusionTexture=o.occlusionTexture,this.emissionTexture=o.emissionTexture;const c=new Float32Array(15);c.set(this.transformWorldFromModelTL,0),c.set(this.transformWorldFromModelTH,3),c.set(this.transformWorldFromModelRS,6),this.transformationFloats=c}destroy(){this.baseColorTexture?.dispose(),this.metallicRoughnessTexture?.dispose(),this.emissionTexture?.dispose(),this.occlusionTexture?.dispose(),this.normalTexture?.dispose()}setTransformationDrawId(e){this.transformationDrawId=e}get texture(){return this.baseColorTexture?.texture}get textureMetallicRoughness(){return this.metallicRoughnessTexture?.texture}get textureEmissive(){return this.emissionTexture?.texture}get textureOcclusion(){return this.occlusionTexture?.texture}get textureNormal(){return this.normalTexture?.texture}get componentParameters(){return this._componentParameters}updateComponentParameters(e,t){this._componentParameters=e,this.textureBackedBuffer=t}get castAnyShadows(){return 2!==this.componentParameters.castShadows}}class l{constructor(e,t,r,s,i){this.castShadows=i,this.componentDataType=0,this.externalColor=o(e),this.externalColorMixMode=t,this.emissiveStrength=r,this.emissiveSource=s}get transparent(){return this.externalColor[3]<1?0:2}get opaqueOverride(){return 3===this.externalColorMixMode&&1===this.externalColor[3]?0:2}get emissiveOverride(){return this.emissiveStrength>0?0:2}get emissiveSourceOverride(){return 1===this.emissiveSource?0:2}}class m{constructor(e,t,r,s,o){this.transparent=e,this.opaqueOverride=t,this.emissiveOverride=r,this.emissiveSourceOverride=s,this.castShadows=o,this.componentDataType=1}}const u=new l(s(),1,0,0,0),h=5e4;export{n as ComponentDrawParametersImplementation,l as ComponentParametersUniform,m as ComponentParametersVarying,u as defaultComponentParameters};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{exactEquals as e}from"../../../../../../core/libs/gl-matrix-2/math/vec3.js";import{ZEROS as
|
|
2
|
+
import{exactEquals as e}from"../../../../../../core/libs/gl-matrix-2/math/vec3.js";import{ZEROS as t}from"../../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ComponentTechnique as r}from"./ComponentTechnique.js";import{ComponentTechniqueConfiguration as s}from"./ComponentTechniqueConfiguration.js";import{MaterialBase as i}from"../../../core/material/MaterialBase.js";import{isColor as o}from"../../../core/shaderLibrary/ShaderOutput.js";class a extends i{constructor(e,t,r,i,o){super(),this.parameters=e,this.key=o,this.usePBR=e.usePBR,this.hasParametersFromSource=e.hasParametersFromSource,this.isGround=e.isGround,this.slicePlaneEnabled=e.slicePlaneEnabled,this.isIntegratedMesh=e.isIntegratedMesh,this.applySSAO=e.applySSAO,this.hasEmissions=u(e,r,i),this.materialPass=n(e,r),this._configuration=new s(i.sphericalSR),this._initializeMaterialConfiguration(e,t,r,i)}destroy(){}acquireTechnique(e,t,s,i){const o=this._updateConfiguration(t,s);return e.get(r,o,i.layout)}_initializeMaterialConfiguration(e,t,r,s){const i=this._configuration;i.hasMetallicRoughnessTexture=null!=e.metallicRoughnessTexture,i.hasOcclusionTexture=null!=e.occlusionTexture,i.hasNormalTexture=null!=e.normalTexture,i.sphereDepthInterpolate=e.sphereDepthInterpolate&&i.spherical,i.ellipsoidMode=e.ellipsoidMode,i.doubleSidedMode=e.doubleSided?1:0,i.hasColorTexture=null!=e.baseColorTexture,i.cullFace=e.cullFace,i.alphaDiscardMode=e.alphaDiscardMode,i.hasVertexColors=t.hasVertexColors,i.textureCoordinateType=t.textureCoordinateType,i.shadeNormals=t.shadeNormals,i.normalType=t.hasNormals?1:2,i.hasPolygonOffset=e.polygonOffsetEnabled,i.vertexPositionRotationType=t.vertexPositionRotationType,i.vertexNormalRotationType=t.vertexNormalRotationType,i.componentDataType=r.componentDataType,i.emissionSource=c(e,r,s)}_updateConfiguration(e,t){const r=this._configuration,{identifier:s,output:i}=e,a=0===s;r.output=i,r.hasEmission=t.hasEmission&&a,r.renderOccluded=10===t.slot,r.oitPass=a?t.oitPass:0,r.terrainDepthTest=a&&t.terrainDepthTest,r.cullAboveTerrain=!!a&&t.cullAboveTerrain;const n=this.isIntegratedMesh?d(t)?h(t)?3:2:1:0;r.integratedMeshMode=n,r.pbrMode=3===n?4:this.usePBR?this.hasParametersFromSource?0!==r.shadeNormals&&this.isIntegratedMesh?0:2:1:0,r.hasSlicePlane=null!=t.slicePlane&&this.slicePlaneEnabled,r.isGroundSlice=r.hasSlicePlane&&this.isGround;const{materialPass:l}=this;r.blendingEnabled=a&&(1===l||2===l&&e.transparent||4===l)||r.isGroundSlice,r.hasHighlightMixTexture=2===s&&null!=t.highlightMixTexture,r.snowCover=a&&t.snowCover>0,r.vertexDiscardMode=a&&2===l?e.transparent?2:1:0;const u=a&&o(i);return r.receiveAmbientOcclusion=u&&this.applySSAO&&!r.renderOccluded&&null!=t.ssao?.getTexture(),r.hasOccludees=u&&t.hasOccludees,r.receiveShadows=u&&t.shadowMap.ready,r.screenSpaceReflections=u&&null!=t.ssr.lastFrameColor,r.cloudReflections=u&&null!=t.clouds.data?.cubeMap?.colorTexture,r}}function n(e,t){const{alphaDiscardMode:r,isIntegratedMesh:s,slicePlaneEnabled:i}=e,{transparent:o,opaqueOverride:a}=t,n=e.opacity<1,l=e.baseColor[3]<1;if(s)return n||i?4:3;if(n)return 1;if(0===a)return 0;if(l||0===r||3===r)return 1;switch(o){case 2:return 0;case 0:return 1;case 1:return 2}}function l(r){return null!=r.emissionTexture||!e(r.emissiveBaseColor,t)}function u(e,t,r){const s=l(e);return r.floatBufferBlendSupported&&2!==t.emissiveOverride&&(s||2!==t.emissiveSourceOverride)}function c(e,t,r){const s=null!=e.emissionTexture,{emissiveSourceOverride:i}=t,o=1===i,a=2===i,n=u(e,t,r),c=l(e);return n?c?a?s?4:2:o?s?5:7:6:o?7:6:0}function h(e){return null!=e.overlay?.getTexture(3)}function d(e){return null!=e.overlay?.getTexture(1)}export{a as ComponentMaterial,c as calculateEmissionSource,u as calculateHasEmissions,l as calculateHasEmissiveBase,n as computeMaterialPass};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import"../../../../../../core/has.js";import"../../../../../../core/Logger.js";import{ComponentMaterial as e,computeMaterialPass as
|
|
2
|
+
import"../../../../../../core/has.js";import"../../../../../../core/Logger.js";import{ComponentMaterial as e,computeMaterialPass as t,calculateHasEmissions as r,calculateEmissionSource as a}from"./ComponentMaterial.js";class o{constructor(e,t){this._materialRepository=new Map,this._globalMaterialParameters={floatBufferBlendSupported:e.driverTest.floatBufferBlend.result,sphericalSR:t}}acquireMaterial(t,r,a){const o=l(t,r,a,this._globalMaterialParameters),s=this._materialRepository.get(o);if(s)return s.count++,s.material.key,s.material;const i=new e(t,r,a,this._globalMaterialParameters,o);return this._materialRepository.set(o,{material:i,count:1}),i}releaseMaterial(e){const{key:t}=e,r=this._materialRepository.get(t);if(!r||r.count<1)throw new Error("Internal error in material repository");1===r.count?this._materialRepository.delete(t):r.count--}}function l(e,o,l,s){const i=t(e,l),n=r(e,l,s),u=a(e,l,s);return`|${+e.usePBR}|${+e.hasParametersFromSource}|${+e.isGround}|${+e.slicePlaneEnabled}|${+e.isIntegratedMesh}|${+e.applySSAO}|${+i}|${+l.componentDataType}|${+n}|${+u}|${+e.sphereDepthInterpolate}|${+e.ellipsoidMode}|${+e.doubleSided}|${+e.cullFace}|${+e.alphaDiscardMode}|${+o.hasVertexColors}|${+o.textureCoordinateType}|${+o.shadeNormals}|${+o.hasNormals}|${+e.polygonOffsetEnabled}|${+o.vertexPositionRotationType}|${+o.vertexNormalRotationType}|`+ +(null!=e.baseColorTexture)+"|"+ +(null!=e.emissionTexture)+"|"+ +(null!=e.metallicRoughnessTexture)+"|"+ +(null!=e.occlusionTexture)+"|"+ +(null!=e.normalTexture)+"|"+ +l.emissiveOverride}export{o as ComponentMaterialRepository,l as makeMaterialKey};
|
package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{isColorHighlightOrOLID as t}from"../../../core/shaderLibrary/ShaderOutput.js";import{parameter as o}from"../../../core/shaderTechnique/ShaderTechniqueConfiguration.js";import{SphereDepthInterpolateConfiguration as i}from"../../../shaders/SphereDepthInterpolate.glsl.js";class s extends i{constructor(e){super(),this.sphericalSR=e,this.output=0,this.textureCoordinateType=0,this.componentDataType=0,this.cullFace=2,this.vertexDiscardMode=0,this.doubleSidedMode=2,this.alphaDiscardMode=1,this.integratedMeshMode=0,this.oitPass=0,this.pbrMode=0,this.normalType=0,this.emissionSource=0,this.shadeNormals=1,this.hasEmission=!1,this.hasVertexColors=!1,this.hasSlicePlane=!1,this.isGroundSlice=!1,this.hasColorTexture=!1,this.hasHighlightMixTexture=!1,this.receiveAmbientOcclusion=!0,this.receiveShadows=!0,this.blendingEnabled=!0,this.screenSpaceReflections=!1,this.hasPolygonOffset=!1,this.hasMetallicRoughnessTexture=!1,this.hasOcclusionTexture=!1,this.hasNormalTexture=!1,this.hasOccludees=!1,this.terrainDepthTest=!1,this.cullAboveTerrain=!1,this.hasNormalTextureTransform=!1,this.cloudReflections=!0,this.snowCover=!1,this.renderOccluded=!1,this.sphereDepthInterpolate=!1,this.
|
|
2
|
+
import{__decorate as e}from"tslib";import{isColorHighlightOrOLID as t}from"../../../core/shaderLibrary/ShaderOutput.js";import{parameter as o}from"../../../core/shaderTechnique/ShaderTechniqueConfiguration.js";import{SphereDepthInterpolateConfiguration as i}from"../../../shaders/SphereDepthInterpolate.glsl.js";class s extends i{constructor(e){super(),this.sphericalSR=e,this.output=0,this.textureCoordinateType=0,this.componentDataType=0,this.cullFace=2,this.vertexDiscardMode=0,this.doubleSidedMode=2,this.alphaDiscardMode=1,this.integratedMeshMode=0,this.oitPass=0,this.pbrMode=0,this.normalType=0,this.emissionSource=0,this.shadeNormals=1,this.hasEmission=!1,this.hasVertexColors=!1,this.hasSlicePlane=!1,this.isGroundSlice=!1,this.hasColorTexture=!1,this.hasHighlightMixTexture=!1,this.receiveAmbientOcclusion=!0,this.receiveShadows=!0,this.blendingEnabled=!0,this.screenSpaceReflections=!1,this.hasPolygonOffset=!1,this.hasMetallicRoughnessTexture=!1,this.hasOcclusionTexture=!1,this.hasNormalTexture=!1,this.hasOccludees=!1,this.terrainDepthTest=!1,this.cullAboveTerrain=!1,this.hasNormalTextureTransform=!1,this.cloudReflections=!0,this.snowCover=!1,this.renderOccluded=!1,this.sphereDepthInterpolate=!1,this.vertexPositionRotationType=1,this.vertexNormalRotationType=0,this.discardInvisibleFragments=!1,this.oitPremultipliedAlpha=!1,this.occlusionPass=!1,this.bindType=2,this.useCustomDTRExponentForWater=!1,this.hasVertexTangents=!1,this.hasSliceTranslatedView=!1,this.highStepCount=!1,this.instanced=!1,this.instancedDoublePrecision=!1,this.hasModelTransformation=!1,this.useFillLights=!0,this.draped=!1,this.useTransformationTexture=!0}get spherical(){return 0!==this.sphericalSR}get overlayEnabled(){return(2===this.integratedMeshMode||3===this.integratedMeshMode)&&t(this.output)}get hasWater(){return 3===this.pbrMode||4===this.pbrMode||6===this.pbrMode}}e([o({count:10})],s.prototype,"output",void 0),e([o({count:3})],s.prototype,"textureCoordinateType",void 0),e([o({count:2})],s.prototype,"componentDataType",void 0),e([o({count:3})],s.prototype,"cullFace",void 0),e([o({count:3})],s.prototype,"vertexDiscardMode",void 0),e([o({count:3})],s.prototype,"doubleSidedMode",void 0),e([o({count:4})],s.prototype,"alphaDiscardMode",void 0),e([o({count:4})],s.prototype,"integratedMeshMode",void 0),e([o({count:3})],s.prototype,"oitPass",void 0),e([o({count:7})],s.prototype,"pbrMode",void 0),e([o({count:3})],s.prototype,"normalType",void 0),e([o({count:8})],s.prototype,"emissionSource",void 0),e([o({count:3})],s.prototype,"shadeNormals",void 0),e([o()],s.prototype,"hasEmission",void 0),e([o()],s.prototype,"hasVertexColors",void 0),e([o()],s.prototype,"hasSlicePlane",void 0),e([o()],s.prototype,"isGroundSlice",void 0),e([o()],s.prototype,"hasColorTexture",void 0),e([o()],s.prototype,"hasHighlightMixTexture",void 0),e([o()],s.prototype,"receiveAmbientOcclusion",void 0),e([o()],s.prototype,"receiveShadows",void 0),e([o()],s.prototype,"blendingEnabled",void 0),e([o()],s.prototype,"screenSpaceReflections",void 0),e([o()],s.prototype,"hasPolygonOffset",void 0),e([o()],s.prototype,"hasMetallicRoughnessTexture",void 0),e([o()],s.prototype,"hasOcclusionTexture",void 0),e([o()],s.prototype,"hasNormalTexture",void 0),e([o()],s.prototype,"hasOccludees",void 0),e([o()],s.prototype,"terrainDepthTest",void 0),e([o()],s.prototype,"cullAboveTerrain",void 0),e([o()],s.prototype,"hasNormalTextureTransform",void 0),e([o()],s.prototype,"cloudReflections",void 0),e([o()],s.prototype,"snowCover",void 0),e([o()],s.prototype,"renderOccluded",void 0),e([o()],s.prototype,"sphereDepthInterpolate",void 0),e([o({count:2})],s.prototype,"vertexPositionRotationType",void 0),e([o({count:2})],s.prototype,"vertexNormalRotationType",void 0);export{s as ComponentTechniqueConfiguration};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{newLayout as e}from"../../../support/buffer/InterleavedLayout.js";import{NoParameters as t}from"../../../../webgl/NoParameters.js";class o{constructor(e,t,o,
|
|
2
|
+
import{newLayout as e}from"../../../support/buffer/InterleavedLayout.js";import{NoParameters as t}from"../../../../webgl/NoParameters.js";class o{constructor(e,t,o,r){this.renderGeometryData=e,this.positions=t,this.componentOffsets=o,this.parameters=r}}class r extends t{constructor(e,t,o,r,s){super(),this.layout=e,this.shadeNormals=t,this.textureCoordinateType=o,this.vertexPositionRotationType=r,this.vertexNormalRotationType=s}get hasVertexColors(){return this.layout.some(({name:e})=>"color"===e)}get hasNormals(){return this.layout.some(({name:e})=>"normalCompressed"===e)}}class s extends t{constructor(e,t,o){super(),this.hasVertexColors=e,this.hasNormals=t,this.textureCoordinateType=o}}function a(t){const o=e().vec3f("position");return t.hasNormals&&o.vec2i16("normalCompressed",{glNormalized:!0}),1===t.textureCoordinateType?o.vec2f("uv0"):2===t.textureCoordinateType&&(o.vec2f("uv0"),o.vec4u16("uvRegion",{glNormalized:!0})),t.hasVertexColors&&o.vec4u8("color",{glNormalized:!0}),o.freeze()}export{r as ComponentGeometryParameters,o as SourceGeometry,s as VertexBufferLayoutCreationParameters,a as createVertexBufferLayout};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{__decorate as s}from"tslib";import{disposeMaybe as e}from"../../../../../core/maybe.js";import{subclass as t}from"../../../../../core/accessorSupport/decorators.js";import{fromMat4 as r,transpose as a,invert as i}from"../../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as o}from"../../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{set as h,copy as n}from"../../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as m}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{MaterialPassParameters as d,ShadowMapPassParameters as c,HighlightPassParameters as u,ViewshedShadowMapPassParameters as p,AllRenderPasses as l}from"./AllRenderPasses.js";import{TwoVectorPosition as _}from"../util/TwoVectorPosition.js";import{SyncRenderPlugin as w}from"../../effects/RenderPlugin.js";import{DepthRange as f}from"../../lib/DepthRange.js";import{SizedPixelFormat as P,DataType as g}from"../../../../webgl/enums.js";import x from"../../../../webgl/Texture.js";import{TextureDescriptor as T}from"../../../../webgl/TextureDescriptor.js";let y=class extends w{constructor(){super(...arguments),this.produces=new Map([[2,s=>this._produces(s,2)],[4,s=>this._produces(s,4)],[0,s=>this._produces(s,0)],[8,s=>this._produces(s,8)],[10,s=>this._produces(s,10)]]),this._drawParametersIdMap=new Map,this._drawParametersArray=new Array,this._drawTransformationTexture=null,this._materialPassParameters=new d,this._shadowPassParameters=new c,this._highlightPassParameters=new u,this._viewshedPassParameters=new p,this._systems=new Set}initializeRenderContext(s){this._context=s,this._passes=new l(s,this)}get rctx(){return this._context.renderContext.rctx}uninitializeRenderContext(){}dispose(){this._context=null,this._systems.clear(),this._drawTransformationTexture=e(this._drawTransformationTexture),this._passes?.opaque.destroy(),this._passes?.transparent.destroy(),this._passes?.integratedMesh.destroy(),this._passes?.transparentIntegratedMesh.destroy(),this._passes?.occludedGround.destroy(),this._passes?.shadowMap.destroy(),this._passes?.highlight.destroy(),this._passes?.highlightIntegratedMesh.destroy(),this._passes?.highlightShadowMap.destroy(),this._passes?.viewshedShadowMap.destroy(),this._passes?.defaultShadowMap.destroy(),this._passes=null}register(s){this._systems.add(s)}_produces(s,e){return!!this._invoke(s,e,s=>s.count>0)}prepareRender(s){const{_systems:t,_passes:r}=this;if(0!==t.size&&null!=r){this._drawParametersIdMap.clear(),this._drawParametersArray.length=0,this._drawTransformationTexture=e(this._drawTransformationTexture);for(const s of Object.values(r))s.prepareSubmit();t.forEach(e=>e.submit(r,s.bind)),this._createTransformationTexture();for(const s of Object.values(r))s.finishSubmit();this._context.techniques.frameUpdate()}}acquireTechniques(s){if(0===this._systems.size)return null;const e=3===s.output||4===s.output||5===s.output?this._shadowPassParameters:6===s.output?this._viewshedPassParameters:8===s.output?this._highlightPassParameters:this._materialPassParameters,{bind:t}=s;return this._updateParameters(t.camera,e,t.slot),this._materialPassParameters.output=s.output,this._invoke(s.output,s.bind.slot,(e,t)=>e.acquire(t,s.bind))}render(s,e){this._invoke(s.output,s.bind.slot,(t,r)=>t.dispatch(r,s.bind,e))}_invoke(s,e,t){if(null==this._passes)return null;switch(e){case 2:switch(s){case 0:case 1:case 2:case 9:return t(this._passes.opaque,this._materialPassParameters);case 8:return t(this._passes.highlight,this._highlightPassParameters);case 3:return t(this._passes.shadowMap,this._shadowPassParameters);case 4:return t(this._passes.highlightShadowMap,this._shadowPassParameters);case 5:return t(this._passes.defaultShadowMap,this._shadowPassParameters);case 6:return t(this._passes.viewshedShadowMap,this._viewshedPassParameters)}break;case 4:switch(s){case 0:case 1:case 2:case 9:return t(this._passes.transparent,this._materialPassParameters)}break;case 0:switch(s){case 0:case 1:case 2:case 9:case 7:return t(this._passes.integratedMesh,this._materialPassParameters);case 8:return t(this._passes.highlightIntegratedMesh,this._highlightPassParameters)}break;case 8:if(0===s)return t(this._passes.transparentIntegratedMesh,this._materialPassParameters);break;case 10:switch(s){case 0:case 1:case 2:case 9:return t(this._passes.occludedGround,this._materialPassParameters)}}return null}notifyDirty(){this._context.requestRender()}queryDepthRange(s){const e=new f;return this._systems.forEach(t=>e.union(t.queryDepthRange(s))),e}get hasEmitters(){let s=!1;return this._systems.forEach(e=>s=e.hasEmissions||s),s}_updateParameters(s,e,t){const o=s.viewInverseTransposeMatrix,m=4===t,d=10===t;h(M,o[3],o[7],o[11]),v.set(M),n(e.transformWorldFromViewTH,v.high),n(e.transformWorldFromViewTL,v.low),n(e.slicePlaneLocalOrigin,M),r(e.transformViewFromCameraRelativeRS,s.viewMatrix),0===e.identifier&&(this._materialPassParameters.transparent=m,this._materialPassParameters.occludedGround=d,a(b,e.transformViewFromCameraRelativeRS),i(e.transformNormalViewFromGlobal,b))}hasHighlight(s){for(const e of this._systems)if(e.hasHighlight(s))return!0;return!1}registerDrawParameters(s){this._drawParametersIdMap.has(s)||(this._drawParametersIdMap.set(s,this._drawParametersArray.length),this._drawParametersArray.push(s))}getDrawParametersId(s){const e=this._drawParametersIdMap.get(s);if(null==e)throw new Error("Draw parameters not registered");return e}_createTransformationTexture(){const s=this._drawParametersIdMap.size;if(0===s)return;const e=
|
|
2
|
+
import{__decorate as s}from"tslib";import{disposeMaybe as e}from"../../../../../core/maybe.js";import{subclass as t}from"../../../../../core/accessorSupport/decorators.js";import{fromMat4 as r,transpose as a,invert as i}from"../../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as o}from"../../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{set as h,copy as n}from"../../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as m}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{MaterialPassParameters as d,ShadowMapPassParameters as c,HighlightPassParameters as u,ViewshedShadowMapPassParameters as p,AllRenderPasses as l}from"./AllRenderPasses.js";import{TwoVectorPosition as _}from"../util/TwoVectorPosition.js";import{SyncRenderPlugin as w}from"../../effects/RenderPlugin.js";import{DepthRange as f}from"../../lib/DepthRange.js";import{SizedPixelFormat as P,DataType as g}from"../../../../webgl/enums.js";import x from"../../../../webgl/Texture.js";import{TextureDescriptor as T}from"../../../../webgl/TextureDescriptor.js";let y=class extends w{constructor(){super(...arguments),this.produces=new Map([[2,s=>this._produces(s,2)],[4,s=>this._produces(s,4)],[0,s=>this._produces(s,0)],[8,s=>this._produces(s,8)],[10,s=>this._produces(s,10)]]),this._drawParametersIdMap=new Map,this._drawParametersArray=new Array,this._drawTransformationTexture=null,this._materialPassParameters=new d,this._shadowPassParameters=new c,this._highlightPassParameters=new u,this._viewshedPassParameters=new p,this._systems=new Set}initializeRenderContext(s){this._context=s,this._passes=new l(s,this)}get rctx(){return this._context.renderContext.rctx}uninitializeRenderContext(){}dispose(){this._context=null,this._systems.clear(),this._drawTransformationTexture=e(this._drawTransformationTexture),this._passes?.opaque.destroy(),this._passes?.transparent.destroy(),this._passes?.integratedMesh.destroy(),this._passes?.transparentIntegratedMesh.destroy(),this._passes?.occludedGround.destroy(),this._passes?.shadowMap.destroy(),this._passes?.highlight.destroy(),this._passes?.highlightIntegratedMesh.destroy(),this._passes?.highlightShadowMap.destroy(),this._passes?.viewshedShadowMap.destroy(),this._passes?.defaultShadowMap.destroy(),this._passes=null}register(s){this._systems.add(s)}_produces(s,e){return!!this._invoke(s,e,s=>s.count>0)}prepareRender(s){const{_systems:t,_passes:r}=this;if(0!==t.size&&null!=r){this._drawParametersIdMap.clear(),this._drawParametersArray.length=0,this._drawTransformationTexture=e(this._drawTransformationTexture);for(const s of Object.values(r))s.prepareSubmit();t.forEach(e=>e.submit(r,s.bind)),this._createTransformationTexture();for(const s of Object.values(r))s.finishSubmit();this._context.techniques.frameUpdate()}}acquireTechniques(s){if(0===this._systems.size)return null;const e=3===s.output||4===s.output||5===s.output?this._shadowPassParameters:6===s.output?this._viewshedPassParameters:8===s.output?this._highlightPassParameters:this._materialPassParameters,{bind:t}=s;return this._updateParameters(t.camera,e,t.slot),this._materialPassParameters.output=s.output,this._invoke(s.output,s.bind.slot,(e,t)=>e.acquire(t,s.bind))}render(s,e){this._invoke(s.output,s.bind.slot,(t,r)=>t.dispatch(r,s.bind,e))}_invoke(s,e,t){if(null==this._passes)return null;switch(e){case 2:switch(s){case 0:case 1:case 2:case 9:return t(this._passes.opaque,this._materialPassParameters);case 8:return t(this._passes.highlight,this._highlightPassParameters);case 3:return t(this._passes.shadowMap,this._shadowPassParameters);case 4:return t(this._passes.highlightShadowMap,this._shadowPassParameters);case 5:return t(this._passes.defaultShadowMap,this._shadowPassParameters);case 6:return t(this._passes.viewshedShadowMap,this._viewshedPassParameters)}break;case 4:switch(s){case 0:case 1:case 2:case 9:return t(this._passes.transparent,this._materialPassParameters)}break;case 0:switch(s){case 0:case 1:case 2:case 9:case 7:return t(this._passes.integratedMesh,this._materialPassParameters);case 8:return t(this._passes.highlightIntegratedMesh,this._highlightPassParameters)}break;case 8:if(0===s)return t(this._passes.transparentIntegratedMesh,this._materialPassParameters);break;case 10:switch(s){case 0:case 1:case 2:case 9:return t(this._passes.occludedGround,this._materialPassParameters)}}return null}notifyDirty(){this._context.requestRender()}queryDepthRange(s){const e=new f;return this._systems.forEach(t=>e.union(t.queryDepthRange(s))),e}get hasEmitters(){let s=!1;return this._systems.forEach(e=>s=e.hasEmissions||s),s}_updateParameters(s,e,t){const o=s.viewInverseTransposeMatrix,m=4===t,d=10===t;h(M,o[3],o[7],o[11]),v.set(M),n(e.transformWorldFromViewTH,v.high),n(e.transformWorldFromViewTL,v.low),n(e.slicePlaneLocalOrigin,M),r(e.transformViewFromCameraRelativeRS,s.viewMatrix),0===e.identifier&&(this._materialPassParameters.transparent=m,this._materialPassParameters.occludedGround=d,a(b,e.transformViewFromCameraRelativeRS),i(e.transformNormalViewFromGlobal,b))}hasHighlight(s){for(const e of this._systems)if(e.hasHighlight(s))return!0;return!1}registerDrawParameters(s){this._drawParametersIdMap.has(s)||(this._drawParametersIdMap.set(s,this._drawParametersArray.length),this._drawParametersArray.push(s))}getDrawParametersId(s){const e=this._drawParametersIdMap.get(s);if(null==e)throw new Error("Draw parameters not registered");return e}_createTransformationTexture(){const s=this._drawParametersIdMap.size;if(0===s)return;const e=5,t=3*e,r=2**Math.ceil(Math.log2(s)),a=new Float32Array(r*t),{rctx:i}=this._context.renderContext;for(let o=0;o<s;o++){const s=this._drawParametersArray[o];s.setTransformationDrawId(o);const e=o*t;a.set(s.transformationFloats,e)}if(this._drawTransformationTexture&&this._drawTransformationTexture.descriptor.height>=s)this._drawTransformationTexture.updateData(0,0,0,e,s,a);else{this._drawTransformationTexture?.dispose();const s=new T(e,r);s.internalFormat=P.RGB32F,s.dataType=g.FLOAT,s.hasMipmap=!1,s.isImmutable=!0,s.pixelFormat=6407,s.samplingMode=9728,this._drawTransformationTexture=new x(i,s,a)}}get drawTransformationTexture(){return this._drawTransformationTexture}};y=s([t("esri.views.3d.webgl-engine.core.renderPasses.RenderPassManager")],y);const M=m(),b=o(),v=new _;export{y as RenderPassManager};
|
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{create as r}from"../../../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as o}from"../../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{NormalAttribute as a}from"./NormalAttribute.glsl.js";import{VertexPositionPassParameters as
|
|
3
|
-
${s(
|
|
2
|
+
import{create as r}from"../../../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as o}from"../../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{NormalAttribute as a}from"./NormalAttribute.glsl.js";import{VertexPositionPassParameters as l,VertexPositionDrawParameters as m}from"./VertexPosition.glsl.js";import{glsl as e,If as s}from"../../shaderModules/glsl.js";import{Matrix3DrawUniform as t}from"../../shaderModules/Matrix3DrawUniform.js";import{Matrix3PassUniform as i}from"../../shaderModules/Matrix3PassUniform.js";function d(r,o){const{vertex:l,varyings:m}=r;switch(o.normalType){case 0:case 1:{r.include(a,o),m.add("vNormalWorld","vec3"),m.add("vNormalView","vec3"),l.uniforms.add(new i("transformNormalViewFromGlobal",r=>r.transformNormalViewFromGlobal));const{vertexNormalRotationType:d}=o,n=1===d;n&&l.uniforms.add(new t("transformNormalGlobalFromModel",r=>r.transformNormalGlobalFromModel)),l.code.add(e`
|
|
3
|
+
${s(n,e`
|
|
4
4
|
mat3 normalModelTransformation() {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
texelFetch(transformationTexture, ivec2(6, transformationDrawId), 0).xyz,
|
|
9
|
-
texelFetch(transformationTexture, ivec2(7, transformationDrawId), 0).xyz
|
|
10
|
-
);`,m`return transformNormalGlobalFromModel;`)}
|
|
11
|
-
}`)}
|
|
5
|
+
return transformNormalGlobalFromModel;
|
|
6
|
+
}
|
|
7
|
+
`)}
|
|
12
8
|
|
|
13
9
|
void forwardNormal() {
|
|
14
|
-
vNormalWorld = ${s(
|
|
10
|
+
vNormalWorld = ${s(n,e`normalModelTransformation() * `)}normalModel();
|
|
15
11
|
vNormalView = transformNormalViewFromGlobal * vNormalWorld;
|
|
16
12
|
}
|
|
17
|
-
`);break}case 2:r.vertex.code.add(
|
|
13
|
+
`);break}case 2:r.vertex.code.add(e`void forwardNormal() {}`);break;default:o.normalType;case 3:}}class n extends l{constructor(){super(...arguments),this.transformNormalViewFromGlobal=r()}}class f extends m{constructor(){super(...arguments),this.transformNormalGlobalFromModel=r(),this.toMapSpace=o()}}export{d as VertexNormal,f as VertexNormalDrawParameters,n as VertexNormalPassParameters};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{create as r}from"../../../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as o}from"../../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{DoublePrecision as e}from"../util/DoublePrecision.glsl.js";import{Float3DrawUniform as t}from"../../shaderModules/Float3DrawUniform.js";import{Float3PassUniform as a}from"../../shaderModules/Float3PassUniform.js";import{If as i,glsl as s}from"../../shaderModules/glsl.js";import{IntegerDrawUniform as m}from"../../shaderModules/IntegerDrawUniform.js";import{Matrix3DrawUniform as n}from"../../shaderModules/Matrix3DrawUniform.js";import{Matrix3PassUniform as d}from"../../shaderModules/Matrix3PassUniform.js";import{Matrix4BindUniform as l}from"../../shaderModules/Matrix4BindUniform.js";import{Texture2DPassUniform as f}from"../../shaderModules/Texture2DPassUniform.js";import{NoParameters as v}from"../../../../../webgl/NoParameters.js";function c(r,o){const{attributes:v,vertex:c,varyings:w,fragment:u}=r;c.include(e),v.add("position","vec3"),w.add("vPositionWorldCameraRelative","vec3"),w.add("vPosition_view","vec3",{invariant:!0}),c.uniforms.add(new a("transformWorldFromViewTH",r=>r.transformWorldFromViewTH),new a("transformWorldFromViewTL",r=>r.transformWorldFromViewTL),new d("transformViewFromCameraRelativeRS",r=>r.transformViewFromCameraRelativeRS),new l("transformProjFromView",r=>r.camera.projectionMatrix));const{
|
|
2
|
+
import{create as r}from"../../../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as o}from"../../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{DoublePrecision as e}from"../util/DoublePrecision.glsl.js";import{Float3DrawUniform as t}from"../../shaderModules/Float3DrawUniform.js";import{Float3PassUniform as a}from"../../shaderModules/Float3PassUniform.js";import{If as i,glsl as s}from"../../shaderModules/glsl.js";import{IntegerDrawUniform as m}from"../../shaderModules/IntegerDrawUniform.js";import{Matrix3DrawUniform as n}from"../../shaderModules/Matrix3DrawUniform.js";import{Matrix3PassUniform as d}from"../../shaderModules/Matrix3PassUniform.js";import{Matrix4BindUniform as l}from"../../shaderModules/Matrix4BindUniform.js";import{Texture2DPassUniform as f}from"../../shaderModules/Texture2DPassUniform.js";import{NoParameters as v}from"../../../../../webgl/NoParameters.js";function c(r,o){const{attributes:v,vertex:c,varyings:w,fragment:u}=r;c.include(e),v.add("position","vec3"),w.add("vPositionWorldCameraRelative","vec3"),w.add("vPosition_view","vec3",{invariant:!0}),c.uniforms.add(new a("transformWorldFromViewTH",r=>r.transformWorldFromViewTH),new a("transformWorldFromViewTL",r=>r.transformWorldFromViewTL),new d("transformViewFromCameraRelativeRS",r=>r.transformViewFromCameraRelativeRS),new l("transformProjFromView",r=>r.camera.projectionMatrix));const{vertexPositionRotationType:F,useTransformationTexture:W}=o,T=1===F;W?c.uniforms.add(new m("transformationDrawId",r=>r.transformationDrawId),new f("transformationTexture",r=>r.transformationTexture)):(c.uniforms.add(new t("transformWorldFromModelTH",r=>r.transformWorldFromModelTH),new t("transformWorldFromModelTL",r=>r.transformWorldFromModelTL)),T&&c.uniforms.add(new n("transformWorldFromModelRS",r=>r.transformWorldFromModelRS))),c.code.add(s`
|
|
3
3
|
mat3 modelTransformation() {
|
|
4
4
|
${i(W,s`
|
|
5
5
|
return mat3(
|
|
@@ -19,7 +19,7 @@ import{create as r}from"../../../../../../core/libs/gl-matrix-2/factories/mat3f6
|
|
|
19
19
|
|
|
20
20
|
vec3 positionWorldCameraRelative() {
|
|
21
21
|
|
|
22
|
-
vec3 rotatedModelPosition = ${i(
|
|
22
|
+
vec3 rotatedModelPosition = ${i(T,s`modelTransformation() *`)} position;
|
|
23
23
|
|
|
24
24
|
vec3 transform_CameraRelativeFromModel = dpAdd(
|
|
25
25
|
originL(),
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{watch as t}from"../../../../core/reactiveUtils.js";import{property as s,subclass as
|
|
2
|
+
import{__decorate as e}from"tslib";import{watch as t}from"../../../../core/reactiveUtils.js";import{property as s,subclass as i}from"../../../../core/accessorSupport/decorators.js";import{set as a}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{copy as r,scale as o,floor as n,subtract as h}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as p}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{InternalRenderCategory as l}from"../../webgl.js";import m from"../../webgl/RenderNode.js";import{G as u}from"../../../../chunks/GaussianSplat.glsl.js";import{G as c}from"../../../../chunks/GaussianSplatComposition.glsl.js";import{GaussianSplatCompositionTechnique as d}from"../shaders/GaussianSplatCompositionTechnique.js";import{G as _}from"../../../../chunks/GaussianSplatDepthComposition.glsl.js";import{GaussianSplatDepthCompositionTechnique as g}from"../shaders/GaussianSplatDepthCompositionTechnique.js";import{GaussianSplatTechnique as f}from"../shaders/GaussianSplatTechnique.js";import{GaussianSplatTechniqueConfiguration as P}from"../shaders/GaussianSplatTechniqueConfiguration.js";import{DepthStencilAttachment as C,ColorAttachment1 as b,PrimitiveType as v}from"../../../webgl/enums.js";var q;let S=class extends m{static{q=this}constructor(e){super(e),this.produces=l.PRE_TRANSPARENT,this.consumes={required:[l.PRE_TRANSPARENT]},this._slicePlaneEnabled=!1,this.layerView=null,this._passParameters=new u,this._compositionPassParameters=new c,this._depthCompositionPassParameters=new _,this._previousCameraDirection=p(),this._previousSortRequestCameraDirection=p(),this._sortRequestDirectionEpsilon=.01,this._directionChangeEpsilon=.001,this._configuration=new P(e.view.state.isGlobal)}async initialize(){this.addHandles([t(()=>this.view.state.camera,()=>this._onCameraChange())])}precompile(){this._configuration.alphaCutoff=this.view.qualitySettings.gaussianSplat.minimumOpacity,this._configuration.terrainDepthTest=this.bindParameters.terrainDepthTest,this._configuration.fadingEnabled=this._fadeHelper.fadingEnabled,this.techniques.precompile(f,this._configuration),this.techniques.precompile(d),this.techniques.precompile(g)}render(e){const t=e.find(({name:e})=>e===this.produces);if(this._handleFading(),!this._data.visibleGaussians||!this._data.orderTexture.texture||!this._data.textureAtlas.texture)return t;const s=this.techniques.getCompiled(f,this._configuration),i=this.techniques.getCompiled(d),a=this.techniques.getCompiled(g);if(!s||!a||!i)return this.requestRender(1),t;const{fullWidth:r,fullHeight:o}=this.bindParameters.camera;this._prepareParameters(o,r);const n=this.renderingContext,h=this.fboCache,p=h.acquire(r,o,"gaussian color output"),l=t.getAttachment(C);p.attachDepth(l),this._renderGaussianColorAndDepth(p,s);const m=h.acquire(r,o,this.produces);return this._depthCompositionPassParameters.splatDepth=p.getTexture(b),m.attachDepth(t.getAttachment(C)),n.bindFramebuffer(m.fbo),n.bindTechnique(a,this.bindParameters,this._depthCompositionPassParameters),n.screen.draw(),this._compositionPassParameters.color=t.getTexture(),this._compositionPassParameters.splatColor=p.getTexture(),n.bindFramebuffer(m.fbo),n.bindTechnique(i,this.bindParameters,this._compositionPassParameters),n.screen.draw(),p.release(),m}get slicePlaneEnabled(){return this._slicePlaneEnabled}set slicePlaneEnabled(e){this._slicePlaneEnabled!==e&&(this._slicePlaneEnabled=e,this.requestRender(1))}get _data(){return this.layerView.data}get _fadeHelper(){return this.layerView.fadeHelper}destroy(){super.destroy()}_onCameraChange(){const e=this.view.state.camera.ray.direction;if(!this._directionChanged(e))return;if(r(this._previousCameraDirection,e),!this._shouldRequestSort(e))return;this._data.requestSort()&&r(this._previousSortRequestCameraDirection,e)}_directionChanged(e){return Math.abs(e[0]-this._previousCameraDirection[0])>this._directionChangeEpsilon||Math.abs(e[1]-this._previousCameraDirection[1])>this._directionChangeEpsilon||Math.abs(e[2]-this._previousCameraDirection[2])>this._directionChangeEpsilon}_shouldRequestSort(e){return Math.abs(e[0]-this._previousSortRequestCameraDirection[0])>this._sortRequestDirectionEpsilon||Math.abs(e[1]-this._previousSortRequestCameraDirection[1])>this._sortRequestDirectionEpsilon||Math.abs(e[2]-this._previousSortRequestCameraDirection[2])>this._sortRequestDirectionEpsilon}_prepareParameters(e,t){this._passParameters.splatOrder=this._data.orderTexture.texture,this._passParameters.splatFading=this._data.fadingTexture.texture,this._passParameters.splatAtlas=this._data.textureAtlas.texture;const s=Math.tan(.5*this.camera.fovY),i=s/e*t;a(this._passParameters.tanFov,i,s),this._passParameters.focalLength=e/(2*s);const r=this.view.qualitySettings.gaussianSplat.minimumSplatPixelRadius;this._passParameters.minSplatRadius=r*Math.sqrt(t*e)/Math.sqrt(2073600),this._prepareHighPrecisionCameraPosition()}_renderGaussianColorAndDepth(e,t){const s=this.renderingContext;e.acquireColor(b,5,"gaussian depth output"),s.bindFramebuffer(e.fbo),s.setClearColor(0,0,0,0),s.clear(16384),this.renderingContext.bindTechnique(t,this.bindParameters,this._passParameters),this.renderingContext.drawArraysInstanced(v.TRIANGLE_STRIP,0,4,this._data.visibleGaussians)}_prepareHighPrecisionCameraPosition(){o(this._passParameters.tileCameraPosition,this.camera.eye,1/q.tileSize),n(this._passParameters.tileCameraPosition,this._passParameters.tileCameraPosition),o(this._passParameters.cameraDelta,this._passParameters.tileCameraPosition,q.tileSize),h(this._passParameters.cameraDelta,this.camera.eye,this._passParameters.cameraDelta)}_handleFading(){if(0===this._fadeHelper.numFadingTiles)return void(this._previousFrameStart=null);this._previousFrameStart??=this.view.stage.renderer.renderContext.time;const e=this.view.stage?.renderer.renderContext.time-this._previousFrameStart;this._fadeHelper.updateAllTileFading(e),this._previousFrameStart=this.view.stage.renderer.renderContext.time,this._data.fadingTexture.updateTexture(this._data.textureAtlas.pageAllocator.pageCount)}static{this.tileSize=2.048}};e([s()],S.prototype,"produces",void 0),e([s()],S.prototype,"consumes",void 0),e([s({constructOnly:!0})],S.prototype,"layerView",void 0),S=q=e([i("esri.views.3d.webgl-engine.lib.GaussianSplatRenderNode")],S);export{S as GaussianSplatRenderNode};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{clamp as t}from"../../../../core/mathUtils.js";import{normalize as r,transformMat3 as o}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{newFloatArray as a}from"../../../../geometry/support/FloatArray.js";import{newShortArray as e}from"../../../../geometry/support/ShortArray.js";function s(t,r,o,n,a,e=2,s=0){const c=1/(Math.abs(o)+Math.abs(n)+Math.abs(a)),i=o*c,f=n*c,h=a<=0?(i>=0?1:-1)*(1-Math.abs(f)):i,u=a<=0?(f>=0?1:-1)*(1-Math.abs(i)):f,l=r*e+s;t[l]=m(h),t[l+1]=m(u)}function c(t){const r=t.length/3,o=e(2*r);let n=0;for(let a=0;a<r;++a)s(o,a,t[n++],t[n++],t[n++]);return o}function i(t,r){const a=t.length/3,e=new Int16Array(2*a);let c=0;const i=n();for(let n=0;n<a;++n)i[0]=t[c++],i[1]=t[c++],i[2]=t[c++],o(i,i,r),s(e,n,i[0],i[1],i[2]);return e}function f(t,o,n,a=2){const
|
|
2
|
+
import{clamp as t}from"../../../../core/mathUtils.js";import{normalize as r,transformMat3 as o}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{newFloatArray as a}from"../../../../geometry/support/FloatArray.js";import{newShortArray as e}from"../../../../geometry/support/ShortArray.js";function s(t,r,o,n,a,e=2,s=0){const c=1/(Math.abs(o)+Math.abs(n)+Math.abs(a)),i=o*c,f=n*c,h=a<=0?(i>=0?1:-1)*(1-Math.abs(f)):i,u=a<=0?(f>=0?1:-1)*(1-Math.abs(i)):f,l=r*e+s;t[l]=m(h),t[l+1]=m(u)}function c(t){const r=t.length/3,o=e(2*r);let n=0;for(let a=0;a<r;++a)s(o,a,t[n++],t[n++],t[n++]);return o}function i(t,r){const a=t.length/3,e=new Int16Array(2*a);let c=0;const i=n();for(let n=0;n<a;++n)i[0]=t[c++],i[1]=t[c++],i[2]=t[c++],o(i,i,r),s(e,n,i[0],i[1],i[2]);return e}function f(t,o,n,a=2,e=0){const s=n*a+e,c=u(o[s]),i=u(o[s+1]),f=1-Math.abs(c)-Math.abs(i);return t[2]=f,f<0?(t[0]=(c>=0?1:-1)*(1-Math.abs(i)),t[1]=(i>=0?1:-1)*(1-Math.abs(c))):(t[0]=c,t[1]=i),r(t,t)}function h(t,r=2){const o=t.length/r,e=a(3*o),s=n();let c=0;for(let n=0;n<o;++n)f(s,t,n,r),e[c++]=s[0],e[c++]=s[1],e[c++]=s[2];return e}function m(r){return t(Math.round(32767*r),-32767,32767)}function u(r){return t(r/32767,-1,1)}export{i as compressAndTransformNormals,s as compressNormal,c as compressNormals,u as decodeInt16,f as decompressNormal,h as decompressNormals,m as encodeInt16};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{update as t}from"../../../../core/arrayUtils.js";import{createTask as s}from"../../../../core/asyncUtils.js";import"../../../../core/has.js";import{removeMaybe as r,abortMaybe as i,destroyMaybe as a,releaseMaybe as n}from"../../../../core/maybe.js";import{throwIfAborted as h}from"../../../../core/promiseUtils.js";import{watch as o,syncAndInitial as d,initial as _,sync as l}from"../../../../core/reactiveUtils.js";import{signal as u}from"../../../../core/signal.js";import{property as p,subclass as c}from"../../../../core/accessorSupport/decorators.js";import{equals as m,invert as f,multiply as g}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as b,create as P}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as E}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{fromValues as w,ZEROS as T}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{pruneIndexArrays as C}from"../../../../geometry/support/Indices.js";import{RenderNodeOutput as x,InternalRenderCategory as A,AllRenderNodeOutputs as R,AllInternalRenderNodeOutputs as S}from"../../webgl.js";import{innerAtmosphereFadeStart as D}from"../../environment/atmosphereUtils.js";import{minNearDistanceInMeters as O}from"../../state/NearFarHeuristic.js";import{debugFlags as I}from"../../support/debugFlags.js";import{FBOCache as H}from"../core/FBOCache.js";import{RenderPassManager as y}from"../core/renderPasses/RenderPassManager.js";import{isColor as v}from"../core/shaderLibrary/ShaderOutput.js";import{distanceFadeEnd as F}from"../core/shaderLibrary/shading/ScreenSpaceConstants.js";import{RenderNodes as M}from"../effects/RenderNodes.js";import{RenderPluginManager as N}from"../effects/RenderPluginManager.js";import{Blit as q}from"../effects/blit/Blit.js";import{maxHighlightsPerChannel as G,renderHighlightBuffer as L}from"../effects/highlight/Highlight.js";import{OITBlend as U}from"../effects/transparency/OITBlend.js";import{AnimationTimer as j}from"./AnimationTimer.js";import{AnimationTimeStep as V}from"./AnimationTimeStep.js";import{BoundingInfo as B}from"./BoundingInfo.js";import{Compositor as k}from"./Compositor.js";import{DepthRange as z}from"./DepthRange.js";import{depthRangeFromScene as W}from"./depthRangeUtils.js";import{MainFramebuffer as Q}from"./MainFramebuffer.js";import{RenderContext as Y,defaultRenderOccludedMask as J}from"./RenderContext.js";import{RendererBase as K}from"./RendererBase.js";import{setupFeatureDefaults as Z}from"./RenderFeature.js";import{RenderPluginInput as $}from"./RenderPluginInput.js";import{ShadowAccumulator as X}from"./ShadowAccumulator.js";import{ShadowMap as ee}from"./ShadowMap.js";import te from"./SliceHelper.js";import{MergedRenderer as se}from"../materials/renderers/MergedRenderer.js";import{RenderSceneResult as re}from"../parts/renderUtils.js";import{RendererPerformanceInfo as ie,PerformanceCategory as ae}from"../statistics/RendererPerformanceInfo.js";import{PixelType as ne,ColorAttachment1 as he,ColorAttachment2 as oe,ColorAttachment0 as de}from"../../../webgl/enums.js";let _e=class extends K{constructor(e,t,s,r,i){super({stage:e}),this._techniques=s,this._rctx=r,this._requestRender=i,this._pluginsHas={occludedHudElements:!1,hudElements:!1,water:!1},this.renderPassManager=new y,this._isRendering=!1,this._inGlobeView=!1,this._backgroundColor=w(0,0,0,1),this._sliceHelper=new te,this.sceneDepthRange=u(z.Infinite),this._state=u(2),this._hasAnimations=!1,this._animationTimestep=new V,this._loadEdgeViewTask=null,this._edgeViewCallbacks=[],this._reprojectionMatrixVersion=u(0),this._renderHiddenTransparentEdges=()=>{},this._pluginInput=new $,this._oitCallouts=!1,this._releaseNodeInputs=e=>{for(const t of we)e.some(({name:e})=>e===t)&&this._pluginInput.release(t)},this._debugNeedsDepth=!1,this._fboCache=new H(r),this._compositor=new k(r,s),this._renderStateFeatures=u(Z(e.view.qualityProfile)),this._framebuffer=new Q(this.fboCache),this._performanceInfo=new ie(this._rctx),this._shadowMap=new ee(this.fboCache,e.viewingMode),this._blit=new q(s),this._shadowAccumulator=new X(this.fboCache,s,e,e=>{const t=this.shadowsEnabled;this._shadowMap.enabled=!0,this._ensureBindParametersCamera(e.camera,e.contentCamera),this._plugins.prepareRender(),this._shadowMap.enabled=t},(t,s,r)=>{const i=e.view.qualitySettings.maximumPixelRatio;t.shadowMap.start(t.camera,s,r,!0,i),this._renderShadowCascades(3,t.shadowMap),t.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(t.camera,t.contentCamera)},i),this._renderContext=new Y(this._rctx,this._shadowMap,s),this._nodes=new M(this._renderContext),this._plugins=new N({renderContext:this._renderContext,techniques:s,materials:t,requestRender:i,controller:e,fbos:this.fboCache,isFeatureEnabled:e=>this.isFeatureEnabled(e)}),this._plugins.add(this.renderPassManager),this.addHandles([o(()=>e.view.state.camera,()=>i(),d),o(()=>I.EDGES_SHOW_HIDDEN_TRANSPARENT_EDGES,e=>{this._renderHiddenTransparentEdges=e?()=>this._renderEdges(0):()=>{},i()},_),o(()=>e.view.environment.background?.color,e=>{const t=e?e.toUnitRGBA():T;E(this._backgroundColor,t[0]*t[3],t[1]*t[3],t[2]*t[3],t[3]),i()},d),o(()=>e.view.state.camera.relativeElevation,e=>this._inGlobeView=(e??1/0)>=F,d),o(()=>this._bindParameters.clouds.fadeFactor,()=>{this._bindParameters.fadeLighting(),this._requestRender(2)},l),o(()=>this._bindParameters.clouds.data?.state,()=>i(),l),o(()=>e.view.state.highlights,e=>{this._bindParameters.highlights=e,i()},_)])}destroy(){this._gpuTimerHandle=r(this._gpuTimerHandle),this._nodes.destroy(),this._framebuffer.dispose(),this._shadowMap.dispose(),this._shadowAccumulator.destroy(),this._shadowAccumulator=null,this._loadEdgeViewTask=i(this._loadEdgeViewTask),this._edgeView=a(this._edgeView),this.renderPassManager.dispose(),this._releaseFBOs(),this._disposeOffscreenBuffers(),this._fboCache.destroy(),this._fboCache=null,this._plugins.destroy(),this._plugins=null,this._pluginInput=null,this._oitBlendOrNil=null,this._nodes=null,this._framebuffer=null,this._shadowMap=null,this._renderContext=null,this._performanceInfo=null,B.prune(),se.prune(),C()}get renderContext(){return this._renderContext}get _bindParameters(){return this._renderContext.bind}get _oitBlend(){return this._oitBlendOrNil??=new U(this._techniques),this._oitBlendOrNil}get performanceInfo(){return this._performanceInfo}updateRenderFeatures(e){this._renderStateFeatures.value=Z(e),this._requestRender()}isFeatureEnabled(e,t=this._state.value){return this._renderStateFeatures.value.get(t,e)??!1}setFeatureEnabled(e,t,s){this._renderStateFeatures.mutate(r=>r.set(t,e,s)),this._requestRender()}get _highQualityTransparency(){return this.isFeatureEnabled(1)}get hasReflections(){return this._pluginsHas.water&&this.isFeatureEnabled(6)}get _hasHighlights(){return this._plugins.produces(8,2,4,20,14,15,16)}hasHighlight(e){return this._plugins.hasHighlight(e)}get _hasHUDHighlights(){return this._plugins.produces(8,14,15,16)}get hasSSAO(){return this.isFeatureEnabled(5)&&!this._inGlobeView}get hasSMAA(){return this.isFeatureEnabled(0)}get _hasEmission(){return this._plugins.hasEmitters&&this._hasFloatBufferBlendSupport}get highResolutionAtmosphere(){return this.isFeatureEnabled(4)}get fboCache(){return this._fboCache}_releaseFBOs(){this._bindParameters.ssr.lastFrameColor=n(this._bindParameters.ssr.lastFrameColor),this._bindParameters.terrainDepth=n(this._bindParameters.terrainDepth),this._bindParameters.geometryDepth=n(this._bindParameters.geometryDepth),this._bindParameters.hudOcclusion=n(this._bindParameters.hudOcclusion)}_disposeOffscreenBuffers(){this._framebuffer.dispose(),this._disposeBindBuffers()}_disposeBindBuffers(){this._shadowMap.disposeOutputs(),this._bindParameters.depth=n(this._bindParameters.depth)}get updating(){return this._loadEdgeViewTask&&!this._loadEdgeViewTask.finished||this._edgeView?.updating||this._shadowAccumulator.readyToRun||this._plugins.updating||!this.isCameraFinal}loadEdgeView(){return this._loadEdgeViewTask||(this._loadEdgeViewTask=s(async e=>{const{EdgeView:t}=await import("./edgeRendering/EdgeView.js");h(e);const s=this._edgeView=new t({rctx:this._rctx,renderSR:this.stage.view.renderSpatialReference,viewingMode:this.stage.view.stage.viewingMode,techniques:this._techniques,setNeedsRender:()=>this._requestRender(),schedule:Ae(this.stage.view.resourceController)});return this.addHandles(o(()=>s.updating,()=>this._requestRender(),l)),this._requestRender(),this._edgeViewCallbacks.forEach(e=>e(s)),this._edgeViewCallbacks.length=0,s})),this._loadEdgeViewTask.promise}withEdgeView(e){this.loadEdgeView(),null==this._edgeView?this._edgeViewCallbacks.push(e):e(this._edgeView)}get edgeView(){return this._edgeView}get isCameraFinal(){return this._reprojectionMatrixVersion.value>=0&&m(this._bindParameters.ssr.reprojectionMatrix,b)}set _reprojectionMatrix(e){t(this._bindParameters.ssr.reprojectionMatrix,e)&&this._reprojectionMatrixVersion.value++}get shadowsEnabled(){return!!this._shadowMap?.enabled}setParameters(e){const{_shadowMap:t,_bindParameters:s}=this;if(void 0!==e.shadowMap&&this._shadowMap.enabled!==e.shadowMap&&(this._shadowMap.enabled=e.shadowMap,this._requestRender()),void 0!==e.shadowMapMaxCascades&&t.maxCascades!==e.shadowMapMaxCascades&&(t.maxCascades=e.shadowMapMaxCascades,this._requestRender()),e.environment){void 0!==e.environment.weather&&(this._bindParameters.weather=e.environment.weather);const t="virtual"!==e.environment.lighting.type;s.enableFillLights!==t&&(s.enableFillLights=t,this._requestRender())}e.shadowCast&&this._shadowAccumulator.setParameters(e.shadowCast)}set slice(e){this._sliceHelper.update(e)&&this._requestRender()}get plugins(){return this._plugins}get _hasFloatBufferBlendSupport(){return this._rctx.driverTest.floatBufferBlend.result}get oitEnabled(){return this.isFeatureEnabled(2)&&this._hasFloatBufferBlendSupport}commit(e,t){return this._isRendering&&console.warn("Renderer.modify called while rendering"),!!super.commit(e,t,this._plugins.context)&&(this.updateHasFlags(),!0)}rendererAdded(e){this._plugins.add(e)}rendererRemoved(e){this._plugins.remove(e)}get occludedRequiresStencil(){return this.occludedRequiresOccludeeStencil||this.occludedRequiresIntegratedMeshStencil}get occludedRequiresOccludeeStencil(){return this._bindParameters.hasOccludees&&!!(8&this.plugins.renderOccludedFlags)}get occludedRequiresIntegratedMeshStencil(){return this._plugins.produces(0,0)&&this._plugins.produces(0,10)}updateHasFlags(){const has=this._pluginsHas;has.occludedHudElements=this._plugins.produces(0,15),has.hudElements=has.occludedHudElements||this._plugins.produces(0,...ge),has.water=this._plugins.produces(2,21),this._bindParameters.hasOccludees=this._plugins.hasOccludees,this._requestRender()}updateAnimation(e,t){this._animationTimer??=new j(e.camera,t),this._animationTimer.advance(e.camera,t,this._animationTimeDilation);const s=this._hasAnimations;return this._hasAnimations=this._plugins.updateAnimation(this._animationTimer),this._hasAnimations=this._nodes.updateAnimation(this._animationTimer)||this._hasAnimations,this._hasAnimations!==s&&(this._gpuTimerHandle=s?r(this._gpuTimerHandle):this.performanceInfo.enableGPUPerformanceInfo()),this._hasAnimations}get animationTimestep(){return this._animationTimestep.value}get _animationTimeDilation(){return this._animationTimestep.timeDilation}resetAnimation(){this._animationTimestep.clear()}tick(){this.fboCache.clean()}render(e,t,s,r=!1){try{return this._isRendering=!0,this._render(e,t,s,r)}catch(i){console.error(`Exception during rendering: ${i}`)}finally{this._isRendering=!1}return new re(this._pluginInput.get(x.FINAL),null)}_render(e,t,s,r){const i=0===s;this.performanceInfo.startFrame(),this.fboCache.frameStart(),this.fboCache.interactive=i,this._disposeBindBuffers();const{camera:a,contentCamera:n,mode:h,alignPixelEnabled:o}=e;this._state.value=h,this._renderContext.time=t,this._rctx.output=0,this._bindParameters.hasEmission=this._hasEmission,this._bindParameters.oitPass=0,this._bindParameters.alignPixelEnabled=o,this._bindParameters.decorations=!r,this._bindParameters.mainDepth=null;const d=!r||!this._sliceHelper.isDecoration;this._bindParameters.slicePlane=d?this._sliceHelper.plane:null,this._bindParameters.viewshedEnabled=this._nodes.produces(A.VIEWSHED),this._bindParameters.cutFillEnabled=this._nodes.produces(A.CUTFILL_DEPTH),this._renderOverlay(),a.setGLViewport(this._rctx);const _=this._framebuffer,l=_.initialize(a.fullWidth,a.fullHeight,this._backgroundColor,this._bindParameters.hasEmission);this.hasReflections?(l?.setName("last frame color"),this._bindParameters.ssr.lastFrameColor=l):l?.release(),this._ensureBindParametersCamera(a,n),this._plugins.sortTestsTransparentOrderedSlots(Pe),this._plugins.prepareRender(),this._bindParameters.shadowHighlightsVisible=this._needsShadowHighlight&&!r;const u=this._plugins.produces(0,...ue);this._precompilePrepasses(),this.performanceInfo.advance(ae.PREPARE);const p=this._computeShadowDepthRange(a);this._renderShadowMap(a,this._bindParameters.lighting.mainLight.direction,p),this._pluginInput.set("normals",this._renderNormals()),this._renderRemainingGeometryDepth(),this._renderShadowAccumulation(p,!i),this._oitCallouts=u&&this.oitEnabled,this._ensureBindParametersSSR(t),this._precompileShaders(u),this._rctx.output=0,_.bind(),this._bindParameters.mainDepth=_.depth.attachment,this._renderOpaque(),this._renderTransparent(u),this._shadowMap.disposeOutput(3),this._pluginInput.set(A.FOCUSAREA,this._renderFocusAreaGeometry()),this._pluginInput.set(A.CUTFILL_DEPTH,this._renderCutFillDepth()),_.update(e=>this._renderNodes(A.TRANSPARENT_ENVIRONMENT,e)),_.update(e=>this._renderNodes(A.VIEWSHED,e)),_.update(e=>this._renderNodes(A.LASERLINES,e)),_.update(e=>this._renderNodes(A.FOCUSAREA_COLOR,e)),this._pluginInput.release(A.FOCUSAREA),this._pluginInput.release(A.CUTFILL_DEPTH),_.update(e=>this._renderNodes(A.OCCLUDED,e)),this._pluginInput.set("highlights",this._renderHighlightPrepass());const c=2===s?this._renderObjectAndLayerIdColor():null;_.update(e=>this._renderNodes(x.COMPOSITE,e)),this._shadowMap.disposeOutputs(),_.update(e=>this._renderNodes(A.ANTIALIASING,e));const m=this._hasPhotoshopTerrain||!u?1:2;let f;return this._bindParameters.hasEmission=!1,this._hasHUDHighlights&&_.update(e=>this._renderHUD(m,e)),_.update(e=>this._renderNodes(A.HIGHLIGHT_COLOR,e)),this._hasHUDHighlights||_.update(e=>this._renderHUD(m,e)),this._bindParameters.hasEmission=this._hasEmission,_.update(e=>this._renderNodes(A.MAGNIFIER,e)),_.update(e=>this._renderNodes(x.FINAL,e)),i&&this._blit.toFramebuffer(this._rctx,_.color,this._bindParameters),this.onPostRender?.(),this._releaseFBOs(),_.releaseDepth(),this._renderContext.lastFrameCamera.copyFrom(this._bindParameters.camera),this.fboCache.frameEnd(),i||(f=_.color,f.retain(),this._releaseFBOs(),this._disposeOffscreenBuffers()),this.performanceInfo.finishFrame(),new re(f,c)}_precompileShaders(e){++this._plugins.context.techniques.precompiling,this._rctx.output=0;const t=this._bindParameters.hasEmission;this._precompileOpaqueGeometry(),this._nodes.precompile(t,A.OPAQUE_ENVIRONMENT,A.PRE_TRANSPARENT);const s=this._bindParameters;s.terrainDepthTest=s.cullAboveTerrain=this._needsTerrainDepth,this._rctx.output=1,this._plugins.precompile(...pe),this._needsTerrainDepth&&(this._precompileOpaqueGeometry(),this._precompileTransparentGeometry()),this._rctx.output=0,this._plugins.precompile(...pe),e&&this.oitEnabled&&this._oitBlend.precompile(t,this._pluginsHas.occludedHudElements,0),e&&(this._precompileTransparentGeometry(),this._hasPhotoshopTerrain&&(s.cullAboveTerrain=!1,this._precompileTransparentGeometry(),s.cullAboveTerrain=this._needsTerrainDepth)),this._nodes.precompile(t,A.FOCUSAREA);const r=this._hasPhotoshopTerrain&&!this._needsTerrainDepth;this._compositor.precompile(this._usesPremultipliedAlphaBlit,!!this._needsEdges,r,t),this._oitCallouts||this._plugins.precompile(17),s.terrainDepthTest=s.cullAboveTerrain=!1,this._nodes.precompile(t,A.TRANSPARENT_ENVIRONMENT,A.VIEWSHED,A.CUTFILL_DEPTH,A.CUTFILL_COLOR,A.LASERLINES,A.FOCUSAREA_COLOR,A.OCCLUDED,A.ANTIALIASING),s.highlightMixTexture=s.highlights.length>1?this._rctx.emptyTexture:null,this._precompileHUD(0),s.hasEmission=!1,this._precompileHUD(0),this._precompileHUD(1),s.hasEmission=this._hasEmission,this._hasHighlights&&(s.highlights.forEach((e,t)=>{s.highlightLevel=t,this._precompileAllGeometry(8),this._hasHUDHighlights&&this._plugins.precompile(15,14)}),s.highlightLevel=null,this._nodes.precompile(t,A.HIGHLIGHT_COLOR)),s.highlightMixTexture=null,this._nodes.precompile(t,x.COMPOSITE,A.MAGNIFIER),this._shadowAccumulator.precompile(),this._plugins.precompile(9),--this._plugins.context.techniques.precompiling}_renderFocusAreaGeometry(){const e=this._nodes.produce(A.FOCUSAREA,this._pluginInput);return e&&this.performanceInfo.advance(ae.FOCUS_AREA_MASK),e}_renderObjectAndLayerIdColor(){if(!this._nodes.produces("olid"))return null;const e=this._rctx.output;++this._techniques.precompiling;const{width:t,height:s}=this._framebuffer.size;let r=this.fboCache.acquire(t,s,"olid");return r.acquireDepth(13),r=this._nodes.render(r,this._pluginInput),--this._techniques.precompiling,this.performanceInfo.advance(ae.OBJECT_AND_LAYER_ID_COLOR),this._rctx.output=e,r}finish(e){this._hasAnimations||this._animationTimestep.clear();const t=this.performanceInfo.gpuSamplingEnabled,s=0===e;if(s||t){const e=s?this.performanceInfo.elapsedTime:0;let r=0;t?r=this.performanceInfo.totalGPUTimeSampler.last:this._rctx.gl.finish();const i=Math.max(e,r);this._animationTimestep.frame(i,s)}}readMainDepth(e,t){const{mainDepth:s,camera:r}=this._bindParameters;if(!s)return;const i=this.fboCache.acquire(this._framebuffer.size.width,this._framebuffer.size.height,"linear depth");this._rctx.bindFramebuffer(i.fbo),r.setGLViewport(this._rctx),this._rctx.setScissorRect(e[0],e[1],e[2],e[3]),this._rctx.setScissorTestEnabled(!0),this._rctx.clearFramebuffer(T),this._compositor.blitDepthToLinearDepth(this._bindParameters,s),this._rctx.setScissorTestEnabled(!1),this._rctx.setScissorRect(0,0,this._rctx.gl.canvas.width,this._rctx.gl.canvas.width),i.fbo?.readPixels(e[0],e[1],e[2],e[3],6408,ne.UNSIGNED_BYTE,t),i.release()}readAccumulatedShadow(e){return this._shadowAccumulator.readAccumulatedShadow(e[0],e[1])}get _needsEdges(){return this._edgeView?.shouldRender()?this._edgeView:null}_renderEdges(e){const t=this._needsEdges;if(!t)return;const{width:s,height:r}=this._framebuffer.size,i=this.fboCache.acquire(s,r,"edges"),a=this._bindParameters.geometryDepth,n=()=>t.render(this._bindParameters,e);this._renderToTargets(n,i,a??this._framebuffer.depth,T),this._framebuffer.bind(),this._compositor.composite(this._bindParameters,i.getTexture()),i.release(),this.performanceInfo.advance(1===e?ae.OPAQUE_EDGES:ae.TRANSPARENT_EDGES)}_renderOverlay(){this._bindParameters.overlay=this.overlay?.render(this._renderContext.time),this._bindParameters.overlay&&this.performanceInfo.advance(ae.OVERLAY)}_renderShadowMap(e,t,s){if(!this.shadowsEnabled)return;const r=this._shadowMap;r.start(e,t,s,this.isFeatureEnabled(7),this.stage.view.qualitySettings.maximumPixelRatio),this._needsShadowHighlight?(this._renderShadowCascades(5,this._shadowMap),r.clear(),this._renderShadowCascades(4,this._shadowMap)):this._renderShadowCascades(3),e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,this._bindParameters.contentCamera),this.performanceInfo.advance(ae.SHADOW_MAP)}_renderCutFillDepth(){return this._nodes.produce(A.CUTFILL_DEPTH,this._pluginInput)}_precompileShadowCascades(e){0!==this._shadowMap.cascades.length&&this._precompileAllGeometry(e)}_renderShadowCascades(e,t=this._shadowMap){const s=this._rctx.output;t.bindFramebuffer();for(const r of t.cascades)r.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(r.camera,r.camera),this.renderAllGeometry(e);t.finish(e),this._rctx.output=s}get _needsDepth(){return this._plugins.consumes(1)||this._nodes.requireGeometryDepth()||this.hasReflections||this._needsShadowHighlight||this._shadowAccumulator.active||this._debugNeedsDepth}get _usesPremultipliedAlphaBlit(){return this._pluginsHas.hudElements&&this.oitEnabled||this._hasPhotoshopTerrain}_renderRemainingGeometryDepth(){const e=this._pluginInput.get("normals");e?(this._pluginInput.set(A.SSAO,this._renderSSAO()),this._needsDepth?(this._rctx.bindFramebuffer(e.fbo),this._rctx.clear(1024),this._renderGeometryWithoutNormals(1),this._bindParameters.depth?.release(),this._bindParameters.depth=e.obtainDepthTexture(),this.performanceInfo.advance(ae.DEPTH)):(e.detachDepth(),this._bindParameters.depth=n(this._bindParameters.depth)),this.hasSSAO&&this._pluginInput.release("normals")):this._renderAllGeometryDepth()}_renderAllGeometryDepth(){if(this._bindParameters.depth=n(this._bindParameters.depth),!this._needsDepth)return;const{width:e,height:t}=this._framebuffer.size,s=this.fboCache.acquire(e,t,"geometry depth",13);this._rctx.bindFramebuffer(s.fbo),this._rctx.clear(1280),this.renderAllGeometry(1),this._bindParameters.depth=s.obtainDepthTexture(),s.release(),this.performanceInfo.advance(ae.DEPTH)}_renderTerrainDepth(){if(this._bindParameters.terrainDepth=n(this._bindParameters.terrainDepth),this._bindParameters.terrainDepthTest=this._bindParameters.cullAboveTerrain=this._needsTerrainDepth,!this._needsTerrainDepth)return;const e=this._rctx.output;this._rctx.output=1;const{width:t,height:s}=this._framebuffer.size,r=this.fboCache.acquire(t,s,"terrain depth",13);this._rctx.bindFramebuffer(r.fbo),this._rctx.clear(1280),this._renderTransparentGround(),this._bindParameters.terrainDepth=r.obtainDepthTexture(),r.release(),this._rctx.output=e}_renderGeometryDepth(){if(this._bindParameters.geometryDepth=n(this._bindParameters.geometryDepth),!this._needsTerrainDepth)return;const e=this._rctx.output,{width:t,height:s}=this._framebuffer.size,r=this.fboCache.acquire(t,s,"geometry depth",13);this._rctx.bindFramebuffer(r.fbo),this._rctx.clear(1280),this._renderOpaqueAndTransparentGeometry(1),this._rctx.output=e,this._bindParameters.geometryDepth=r.obtainDepthTexture(),r.release()}get _needsShadowDepthRange(){return this._shadowMap.enabled||this._shadowAccumulator.active}_computeShadowDepthRange(e){if(!this._needsShadowDepthRange)return z.Zero;const t=W(e,this._plugins.plugins,this.stage.layers,0);return t.union(this._plugins.queryDepthRange(e)),t.near=Math.max(e.near,t.near),t.far=Math.min(e.far,t.far),t}updateSceneDepthRange(e){if(!this.stage.view.state.isGlobal)return void(this.sceneDepthRange.value=z.Infinite);if((this.stage.view.renderCoordsHelper?.getAltitude(e.eye)??0)<D)return void(this.sceneDepthRange.value=z.Infinite);const t=e.clone();t.near=O,t.far=1e10;const s=W(t,this._plugins.plugins,this.stage.layers,1);s.union(this._plugins.queryDepthRange(t)),this.sceneDepthRange.value.equals(s)||(this.sceneDepthRange.value=s)}get _normalsRequired(){const e=this._nodes.require("normals",...R,A.VIEWSHED,A.LASERLINES);return(this.hasSSAO?1:0)+e}_precompilePrepasses(){this._normalsRequired&&this._precompileAllGeometry(2),this._needsDepth&&this._precompileAllGeometry(1),this.shadowsEnabled&&(this._needsShadowHighlight?(this._precompileShadowCascades(4),this._precompileShadowCascades(5)):this._precompileShadowCascades(3)),this._shadowAccumulator.active&&this._precompileAllGeometry(3),this.hasSSAO&&this._normalsRequired&&this._nodes.precompile(this._bindParameters.hasEmission,A.SSAO)}_renderNormals(){const e=this._normalsRequired;if(0===e)return;const{width:t,height:s}=this._framebuffer.size,r=this.fboCache.acquire(t,s,"normals",5);r.acquireDepth(13),this._rctx.bindFramebuffer(r.fbo),this._rctx.clearFramebuffer(T,!0,!0),this._rctx.output=2,this._plugins.render(...ce);const i=this._nodes.optional("normals",...R,A.VIEWSHED);return r.retain(e+i-1),this.performanceInfo.advance(ae.NORMALS),r}_renderSSAO(){const e=this._pluginInput.get("normals");if(this.hasSSAO&&e)return this._bindParameters.ssao=this._nodes.produce(A.SSAO,this._pluginInput),this._bindParameters.ssao&&this.performanceInfo.advance(ae.SSAO),this._bindParameters.ssao}_precompileAllGeometry(e){const t=this._rctx.output;this._rctx.output=e,this._precompileOpaqueGeometry(),this._precompileTransparentGeometry(),this._plugins.precompile(...pe),this._rctx.output=t}renderAllGeometry(e){this._rctx.output=e,this._renderOpaqueAndTransparentGeometry(e),this._renderTransparentGround()}precompileSlots(e,...t){for(const s of t)this._bindParameters.slot=s,e.precompile(this._renderContext)}precompileOccludedSlots(e,t){for(const s of t)this._renderContext.renderOccludedMask=s,this.precompileSlots(e,...fe);this._renderContext.renderOccludedMask=J}renderSlots(e,...t){for(const s of t)this._bindParameters.slot=s,e.forAll(e=>{const t=e.acquireTechniques(this._renderContext);t&&e.render(this._renderContext,t)})}renderOccludedSlots(e,t){this._renderContext.renderOccludedMask=t,this.plugins.renderOccludedFlags>1&&this._plugins.render(10),this.renderSlots(e,...fe),this._renderContext.renderOccludedMask=J}renderHUD(e){this._bindParameters.hudRenderStyle=e,this._plugins.render(...Ee[e])}_renderHUDElements(e){this._bindParameters.hudRenderStyle=e,this._plugins.render(18),this.renderHUD(e),this._bindParameters.hudRenderStyle=e,this._plugins.render(16)}precompileViewshedShadowMap(){this._precompileAllGeometry(6)}precompileCutFill(){const e=7,t=this._rctx.output;this._rctx.output=e,this._plugins.precompile(0,1,...pe),this._rctx.output=t}renderViewshedShadowMap(e){const{camera:t,contentCamera:s}=this._bindParameters,r=this._rctx.output;e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,e),this.renderAllGeometry(6),this._ensureBindParametersCamera(t,s),this._bindParameters.camera.setGLViewport(this._rctx),this._rctx.output=r}renderCutFillReferenceDepth(e){const{camera:t,contentCamera:s}=this._bindParameters,r=this._rctx.output;e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,e),this._rctx.output=7,this._plugins.render(0,1,...pe),this._ensureBindParametersCamera(t,s),t.setGLViewport(this._rctx),this._rctx.output=r}_renderOpaqueAndTransparentGeometry(e){this._rctx.output=e,this._renderOpaqueGeometry(),this._renderTransparentGeometry()}_renderGeometryWithoutNormals(e){this._rctx.output=e,this._plugins.render(...me)}_precompileOpaqueGeometry(){this._plugins.precompile(...le),this._nodes.precompile(this._bindParameters.hasEmission,"opaque-color")}_renderOpaqueGeometry(){this._plugins.render(...le)}_renderTransparentGeometry(){this._plugins.render(...ue),this._oitCallouts&&this._plugins.render(17)}get _hasPhotoshopTerrain(){return this._plugins.produces(0,6)}get _needsTerrainDepth(){return this._highQualityTransparency&&this._hasPhotoshopTerrain}_renderPhotoshopTerrain(){if(!this._hasPhotoshopTerrain)return null;const{width:e,height:t}=this._framebuffer.size,s=this.fboCache.acquire(e,t,"transparent terrain"),r=()=>this._plugins.render(6);return this._renderToTargets(r,s,this._framebuffer.depth,T),this.performanceInfo.advance(ae.TRANSPARENT_TERRAIN),s}_renderTransparentGround(){this._plugins.render(...pe)}_renderLineCallouts(e){if(this._bindParameters.hudRenderStyle=e,0===e){const e=()=>this._plugins.render(17),{width:t,height:s}=this._framebuffer.size,r=this.fboCache.acquireDepth(12,t,s,"line callouts");this._renderToTargets(e,this._framebuffer.color,r,void 0,!0,!0),r.release()}else this._plugins.render(17)}_precompileHUD(e){if(this._pluginsHas.hudElements&&(this._precompileHUDOutput(e),this._hasHighlights)){const t=this._rctx.output;this._rctx.output=8,this._precompileHUDOutput(e),this._rctx.output=t}}_precompileHUDOutput(e){const t=this._bindParameters.hudRenderStyle;this._bindParameters.hudRenderStyle=e,this.oitEnabled&&v(this._rctx.output)?(this._bindParameters.oitPass=1,this._plugins.precompile(...ge),this._bindParameters.oitPass=2,this._plugins.precompile(...ge),this._bindParameters.oitPass=0,this._oitBlend.precompile(this._bindParameters.hasEmission,!1,1)):this._plugins.precompile(...ge),this._bindParameters.hudRenderStyle=t}_renderHUD(e,t){if(!this._pluginsHas.hudElements)return t;if(this.oitEnabled){const s=this._renderOIT(1,e);this._rctx.bindFramebuffer(t.fbo);const r=!!t.getTexture(he);this._compositor.compositePreMultipliedAlpha(this._bindParameters,s.getTexture(),r),s.release()}else if(this._rctx.output=0,0===e){const t=()=>this._renderHUDElements(e),{width:s,height:r}=this._framebuffer.size,i=this.fboCache.acquireDepth(12,s,r,"hud");this._renderToTargets(t,this._framebuffer.color,i,void 0,!0,!0),i.release()}else t.acquireDepth(12),this._rctx.bindFramebuffer(t.fbo),this._rctx.clear(256),this._renderHUDElements(e),t.detachDepth();return this.performanceInfo.advance(0===e?ae.HUD_OCCLUDED:ae.HUD),t}get _needsShadowHighlight(){return this.shadowsEnabled&&this._plugins.produces(4,2)}_renderHighlightPrepass(){if(!this._hasHighlights)return;const{fboCache:e,_rctx:t,_bindParameters:s}=this,{width:r,height:i}=this._framebuffer.size,{highlights:a}=s,n=a.length>G?3:1,h=e.acquire(r,i,"highlights",n);h.acquireDepth(13);const o=this._plugins.produces(8,0);return o&&this._framebuffer.color.fbo&&h.fbo&&t.blitFramebuffer(this._framebuffer.color.fbo,h.fbo,1024),t.bindFramebuffer(h.fbo),t.gl.clearBufferuiv(6144,0,[0,0,0,0]),o||t.clear(1024),this._rctx.output=8,t.bindFramebuffer(h.fbo),L(t,e,r,i,s,()=>this._renderHighlightGeometries()),h.detachDepth(),this.performanceInfo.advance(ae.HIGHLIGHTS),h.retain(this._nodes.require("highlights",...S)+this._nodes.optional("highlights",...S)-1),h}_renderHighlightGeometries(){this._plugins.render(...be),this._rctx.clear(256),this._renderHUDElements(2)}_renderShadowAccumulation(e,t){this._shadowAccumulator.updateDepthRange(e);const{depth:s,camera:r,contentCamera:i}=this._bindParameters;this._rctx.output=0,this._shadowAccumulator.accumulating&&s&&this._shadowAccumulator.renderAccumulation(s,r,i,t)&&this.performanceInfo.advance(ae.ACCUMULATED_SHADOWS)}_precompileTransparentGeometry(){this.oitEnabled&&v(this._rctx.output)?(this._bindParameters.oitPass=1,this._plugins.precompile(...ue),this._oitCallouts&&this._plugins.precompile(17),this._bindParameters.oitPass=2,this._plugins.precompile(...ue),this._oitCallouts&&this._plugins.precompile(17),this._bindParameters.oitPass=0):this._plugins.precompile(...ue)}_renderOIT(e,t=2){const s=1===e,{width:r,height:i}=this._framebuffer.size,a=s?()=>this._renderHUDElements(t):()=>this._renderTransparentGeometry(),h=this._bindParameters,o=this._rctx.output;this._rctx.output=0,h.oitPass=1;const d=s?"oit hud":"oit",_=this.fboCache.acquire(r,i,d,8),l=this._bindParameters.hasEmission&&(0===e||1!==t);l&&_.acquireColor(he,8,"oit emissive");const u=l?oe:he;_.acquireColor(u,7,"oit alpha"),s||_.attachDepth(this._framebuffer.depth),this._rctx.bindFramebuffer(_.fbo),this._rctx.clearFramebuffer([0,0,0,1]),l&&this._rctx.clearBuffer(1,T),a(),_.detachDepth(),h.oitPass=2;const p=this.fboCache.acquire(r,i,s?"oit hud front":"oit front");l&&p.acquireColor(he,8,"oit emissive front"),s?p.acquireDepth(12):p.attachDepth(this._framebuffer.depth),this._rctx.bindFramebuffer(p.fbo),this._rctx.clearFramebuffer(T,s),a(),p.detachDepth();const c=this._pluginsHas.occludedHudElements&&!s;let m;return this._bindParameters.hudOcclusion=n(this._bindParameters.hudOcclusion),h.oitPass=0,s?(m=this.fboCache.acquire(r,i,"oit hud composite"),this._rctx.bindFramebuffer(m.fbo),this._rctx.setClearColor(0,0,0,1e-13),this._rctx.clear(16384)):(c&&(this._framebuffer.color.acquireColor(u,0,"hud occlusion"),this._rctx.clearBuffer(u-de,T)),this._framebuffer.bind()),this._oitBlend.blend(this._rctx,_,p,h,l,c,e),m?.detachDepth(),s||(this._rctx.bindFramebuffer(p.fbo),this._framebuffer.bind(),c&&(this._bindParameters.hudOcclusion=this._framebuffer.color.obtainAttachment(u))),p.release(),_.release(),this._rctx.output=o,m}_renderOpaque(){const e=this.plugins.produces(0,...le);e&&(this._plugins.render(0,1),this._framebuffer.update(e=>this._renderNodes(A.CUTFILL_COLOR,e)),this._framebuffer.bind(),this._plugins.render(2,3));const t=this._framebuffer;this._renderTerrainDepth(),t.update(t=>this._renderNodes(x.OPAQUE,t,e)),this.fboCache.debugCallback?.(x.OPAQUE,t.color.fbo),t.update(e=>this._renderNodes(A.OPAQUE_ENVIRONMENT,e)),this.fboCache.debugCallback?.(A.OPAQUE_ENVIRONMENT,t.color.fbo),this._renderEdges(1)}_renderTransparent(e){const t=this._framebuffer;t.bind(),t.update(e=>this._renderNodes(A.PRE_TRANSPARENT,e)),this.fboCache.debugCallback?.(A.PRE_TRANSPARENT,t.color.fbo),this._renderHiddenTransparentEdges(),e&&(this.oitEnabled?this._renderOIT(0):this._renderTransparentGeometry()),t.update(t=>this._renderNodes(x.TRANSPARENT,t,e)),this.fboCache.debugCallback?.(x.TRANSPARENT,t.color.fbo),this._renderGeometryDepth(),this._needsTerrainDepth||this._oitCallouts||this._plugins.render(17),this._renderEdges(0);const s=this._renderPhotoshopTerrain(),r=s?.getTexture();r&&this._renderHUD(0,t.color),this._bindParameters.cullAboveTerrain=!1,r&&(t.bind(),this._compositor.compositePreMultipliedAlpha(this._bindParameters,r),s?.release(),this._needsTerrainDepth&&(this._renderEdges(1),e&&(this.oitEnabled?this._renderOIT(0):this._renderTransparentGeometry(),this.performanceInfo.advance(ae.TRANSPARENT)),this._renderEdges(0))),this._bindParameters.ssao=n(this._bindParameters.ssao),this._needsTerrainDepth&&this._renderLineCallouts(1),this._bindParameters.terrainDepthTest=!1,this._renderTransparentEnvironment()}_renderTransparentEnvironment(){this._shadowAccumulator.render(this._bindParameters),this.performanceInfo.advance(ae.APPLY_ACCUMULATED_SHADOWS),this._framebuffer.bind(),this._plugins.render(9),this.performanceInfo.advance(ae.TRANSPARENT_MATERIAL_WITHOUT_DEPTH)}_renderNodes(e,t,s=!1){const r=t.name;if(t.setName(e),this._pluginInput.set(e,t),!this._nodes.produces(e))return s&&this.performanceInfo.advance(e),t;this._fboCache.debugCallback?.(r,t.fbo);const i=this._nodes.render(t,this._pluginInput,this._releaseNodeInputs);return this.performanceInfo.advance(e),i}_ensureBindParametersCamera(e,t){this._bindParameters.camera=e,this._bindParameters.contentCamera=t}_ensureBindParametersSSR(e){if(this._bindParameters.ssr.lastFrameColor){null==this._ssrEnableTime&&(this._ssrEnableTime=e),this._renderContext.lastFrameCamera.equals(this._bindParameters.camera)?this._reprojectionMatrix=b:(f(Ce,this._bindParameters.camera.viewMatrix),f(Te,this._bindParameters.camera.projectionMatrix),g(xe,Ce,Te),g(xe,this._renderContext.lastFrameCamera.viewMatrix,xe),g(xe,this._renderContext.lastFrameCamera.projectionMatrix,xe),this._reprojectionMatrix=xe);const t=this.stage.view.qualitySettings.fadeDuration;this._bindParameters.ssr.fadeFactor=t>0?Math.min(t,e-this._ssrEnableTime)/t:1,this._bindParameters.ssr.fadeFactor<1&&this._requestRender()}else this._reprojectionMatrix=b,this._ssrEnableTime=null}addRenderNode(e){this._nodes.add(e),this._requestRender()}removeRenderNode(e){this._nodes.remove(e),this._requestRender()}updateLighting(e,t,s,r){this._bindParameters.updateLighting(e,t,s,r),this._requestRender(1)}get usedMemory(){return{fbos:this.fboCache.usedMemory,plugins:this._plugins.usedMemory,edges:this.edgeView?.usedMemory??0}}_renderToTargets(e,t,s,r,i=!1,a=!1){t.attachDepth(s),this._rctx.bindFramebuffer(t.fbo),this._rctx.clearFramebuffer(r,i,a),e(),t.detachDepth()}get test(){}};e([p({readOnly:!0})],_e.prototype,"highResolutionAtmosphere",null),e([p()],_e.prototype,"_edgeView",void 0),e([p()],_e.prototype,"updating",null),_e=e([c("esri.views.3d.webgl-engine.lib.Renderer")],_e);const le=[0,1,2,3],ue=[7,8,4,5],pe=[6,7,8],ce=[0,1,2,4,...pe],me=[3,5],fe=[2,4,9],ge=[18,14,16,15],be=[4,5,2,3,0,1,...pe],Pe=[4,9,5,12],Ee={0:[15],1:[14],2:[15,14],3:[15,14]},we=["normals","highlights"],Te=P(),Ce=P(),xe=P();function Ae(e){return t=>e.immediate.schedule(t)}export{_e as Renderer};
|
|
2
|
+
import{__decorate as e}from"tslib";import{update as t}from"../../../../core/arrayUtils.js";import{createTask as s}from"../../../../core/asyncUtils.js";import"../../../../core/has.js";import{removeMaybe as r,abortMaybe as i,destroyMaybe as a,releaseMaybe as n}from"../../../../core/maybe.js";import{throwIfAborted as h}from"../../../../core/promiseUtils.js";import{watch as o,syncAndInitial as d,initial as _,sync as l}from"../../../../core/reactiveUtils.js";import{signal as u}from"../../../../core/signal.js";import{property as p,subclass as c}from"../../../../core/accessorSupport/decorators.js";import{equals as m,invert as f,multiply as g}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as b,create as P}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as E}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{fromValues as T,ZEROS as w}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{pruneIndexArrays as C}from"../../../../geometry/support/Indices.js";import{RenderNodeOutput as x,InternalRenderCategory as A,AllRenderNodeOutputs as S,AllInternalRenderNodeOutputs as R}from"../../webgl.js";import{innerAtmosphereFadeStart as D}from"../../environment/atmosphereUtils.js";import{minNearDistanceInMeters as O}from"../../state/NearFarHeuristic.js";import{debugFlags as I}from"../../support/debugFlags.js";import{FBOCache as H}from"../core/FBOCache.js";import{RenderPassManager as y}from"../core/renderPasses/RenderPassManager.js";import{isColor as v}from"../core/shaderLibrary/ShaderOutput.js";import{distanceFadeEnd as F}from"../core/shaderLibrary/shading/ScreenSpaceConstants.js";import{RenderNodes as N}from"../effects/RenderNodes.js";import{RenderPluginManager as M}from"../effects/RenderPluginManager.js";import{Blit as q}from"../effects/blit/Blit.js";import{maxHighlightsPerChannel as G,renderHighlightBuffer as L}from"../effects/highlight/Highlight.js";import{OITBlend as U}from"../effects/transparency/OITBlend.js";import{AnimationTimer as j}from"./AnimationTimer.js";import{AnimationTimeStep as V}from"./AnimationTimeStep.js";import{BoundingInfo as B}from"./BoundingInfo.js";import{Compositor as k}from"./Compositor.js";import{DepthRange as z}from"./DepthRange.js";import{depthRangeFromScene as W}from"./depthRangeUtils.js";import{MainFramebuffer as Q}from"./MainFramebuffer.js";import{RenderContext as Y,defaultRenderOccludedMask as J}from"./RenderContext.js";import{RendererBase as K}from"./RendererBase.js";import{setupFeatureDefaults as Z}from"./RenderFeature.js";import{RenderPluginInput as $}from"./RenderPluginInput.js";import{ShadowAccumulator as X}from"./ShadowAccumulator.js";import{ShadowMap as ee}from"./ShadowMap.js";import te from"./SliceHelper.js";import{MergedRenderer as se}from"../materials/renderers/MergedRenderer.js";import{RenderSceneResult as re}from"../parts/renderUtils.js";import{RendererPerformanceInfo as ie,PerformanceCategory as ae}from"../statistics/RendererPerformanceInfo.js";import{PixelType as ne,ColorAttachment1 as he,ColorAttachment2 as oe,ColorAttachment0 as de}from"../../../webgl/enums.js";let _e=class extends K{constructor(e,t,s,r,i){super({stage:e}),this._techniques=s,this._rctx=r,this._requestRender=i,this._pluginsHas={occludedHudElements:!1,hudElements:!1,water:!1},this.renderPassManager=new y,this._isRendering=!1,this._inGlobeView=!1,this._backgroundColor=T(0,0,0,1),this._sliceHelper=new te,this.sceneDepthRange=u(z.Infinite),this._state=u(2),this._hasAnimations=!1,this._animationTimestep=new V,this._loadEdgeViewTask=null,this._edgeViewCallbacks=[],this._reprojectionMatrixVersion=u(0),this._renderHiddenTransparentEdges=()=>{},this._pluginInput=new $,this._oitCallouts=!1,this._releaseNodeInputs=e=>{for(const t of Te)e.some(({name:e})=>e===t)&&this._pluginInput.release(t)},this._debugNeedsDepth=!1,this._fboCache=new H(r),this._compositor=new k(r,s),this._renderStateFeatures=u(Z(e.view.qualityProfile)),this._framebuffer=new Q(this.fboCache),this._performanceInfo=new ie(this._rctx),this._shadowMap=new ee(this.fboCache,e.viewingMode),this._blit=new q(s),this._shadowAccumulator=new X(this.fboCache,s,e,e=>{const t=this.shadowsEnabled;this._shadowMap.enabled=!0,this._ensureBindParametersCamera(e.camera,e.contentCamera),this._plugins.prepareRender(),this._shadowMap.enabled=t},(t,s,r)=>{const i=e.view.qualitySettings.maximumPixelRatio;t.shadowMap.start(t.camera,s,r,!0,i),this._renderShadowCascades(3,t.shadowMap),t.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(t.camera,t.contentCamera)},i),this._renderContext=new Y(this._rctx,this._shadowMap,s),this._nodes=new N(this._renderContext),this._plugins=new M({renderContext:this._renderContext,techniques:s,materials:t,requestRender:i,controller:e,fbos:this.fboCache,isFeatureEnabled:e=>this.isFeatureEnabled(e)}),this._plugins.add(this.renderPassManager),this.addHandles([o(()=>e.view.state.camera,()=>i(),d),o(()=>I.EDGES_SHOW_HIDDEN_TRANSPARENT_EDGES,e=>{this._renderHiddenTransparentEdges=e?()=>this._renderEdges(0):()=>{},i()},_),o(()=>e.view.environment.background?.color,e=>{const t=e?e.toUnitRGBA():w;E(this._backgroundColor,t[0]*t[3],t[1]*t[3],t[2]*t[3],t[3]),i()},d),o(()=>e.view.state.camera.relativeElevation,e=>this._inGlobeView=(e??1/0)>=F,d),o(()=>this._bindParameters.clouds.fadeFactor,()=>{this._bindParameters.fadeLighting(),this._requestRender(2)},l),o(()=>this._bindParameters.clouds.data?.state,()=>i(),l),o(()=>e.view.state.highlights,e=>{this._bindParameters.highlights=e,i()},_)])}destroy(){this._gpuTimerHandle=r(this._gpuTimerHandle),this._nodes.destroy(),this._framebuffer.dispose(),this._shadowMap.dispose(),this._shadowAccumulator.destroy(),this._shadowAccumulator=null,this._loadEdgeViewTask=i(this._loadEdgeViewTask),this._edgeView=a(this._edgeView),this.renderPassManager.dispose(),this._releaseFBOs(),this._disposeOffscreenBuffers(),this._fboCache.destroy(),this._fboCache=null,this._plugins.destroy(),this._plugins=null,this._pluginInput=null,this._oitBlendOrNil=null,this._nodes=null,this._framebuffer=null,this._shadowMap=null,this._renderContext=null,this._performanceInfo=null,B.prune(),se.prune(),C()}get renderContext(){return this._renderContext}get _bindParameters(){return this._renderContext.bind}get _oitBlend(){return this._oitBlendOrNil??=new U(this._techniques),this._oitBlendOrNil}get performanceInfo(){return this._performanceInfo}updateRenderFeatures(e){this._renderStateFeatures.value=Z(e),this._requestRender()}isFeatureEnabled(e,t=this._state.value){return this._renderStateFeatures.value.get(t,e)??!1}setFeatureEnabled(e,t,s){this._renderStateFeatures.mutate(r=>r.set(t,e,s)),this._requestRender()}get _highQualityTransparency(){return this.isFeatureEnabled(1)}get hasReflections(){return this._pluginsHas.water&&this.isFeatureEnabled(6)}get _hasHighlights(){return this._plugins.produces(8,2,4,20,14,15,16)}hasHighlight(e){return this._plugins.hasHighlight(e)}get _hasHUDHighlights(){return this._plugins.produces(8,14,15,16)}get hasSSAO(){return this.isFeatureEnabled(5)&&!this._inGlobeView}get hasSMAA(){return this.isFeatureEnabled(0)}get _hasEmission(){return this._plugins.hasEmitters&&this._hasFloatBufferBlendSupport}get highResolutionAtmosphere(){return this.isFeatureEnabled(4)}get fboCache(){return this._fboCache}_releaseFBOs(){this._bindParameters.ssr.lastFrameColor=n(this._bindParameters.ssr.lastFrameColor),this._bindParameters.terrainDepth=n(this._bindParameters.terrainDepth),this._bindParameters.geometryDepth=n(this._bindParameters.geometryDepth),this._bindParameters.hudOcclusion=n(this._bindParameters.hudOcclusion)}_disposeOffscreenBuffers(){this._framebuffer.dispose(),this._disposeBindBuffers()}_disposeBindBuffers(){this._shadowMap.disposeOutputs(),this._bindParameters.depth=n(this._bindParameters.depth)}get updating(){return this._loadEdgeViewTask&&!this._loadEdgeViewTask.finished||this._edgeView?.updating||this._shadowAccumulator.readyToRun||this._plugins.updating||!this.isCameraFinal}loadEdgeView(){return this._loadEdgeViewTask||(this._loadEdgeViewTask=s(async e=>{const{EdgeView:t}=await import("./edgeRendering/EdgeView.js");h(e);const s=this._edgeView=new t({rctx:this._rctx,renderSR:this.stage.view.renderSpatialReference,viewingMode:this.stage.view.stage.viewingMode,techniques:this._techniques,setNeedsRender:()=>this._requestRender(),schedule:Ae(this.stage.view.resourceController)});return this.addHandles(o(()=>s.updating,()=>this._requestRender(),l)),this._requestRender(),this._edgeViewCallbacks.forEach(e=>e(s)),this._edgeViewCallbacks.length=0,s})),this._loadEdgeViewTask.promise}withEdgeView(e){this.loadEdgeView(),null==this._edgeView?this._edgeViewCallbacks.push(e):e(this._edgeView)}get edgeView(){return this._edgeView}get isCameraFinal(){return this._reprojectionMatrixVersion.value>=0&&m(this._bindParameters.ssr.reprojectionMatrix,b)}set _reprojectionMatrix(e){t(this._bindParameters.ssr.reprojectionMatrix,e)&&this._reprojectionMatrixVersion.value++}get shadowsEnabled(){return!!this._shadowMap?.enabled}setParameters(e){const{_bindParameters:t}=this;if(void 0!==e.shadowMap&&this._shadowMap.enabled!==e.shadowMap&&(this._shadowMap.enabled=e.shadowMap,this._requestRender()),e.environment){void 0!==e.environment.weather&&(this._bindParameters.weather=e.environment.weather);const s="virtual"!==e.environment.lighting.type;t.enableFillLights!==s&&(t.enableFillLights=s,this._requestRender())}e.shadowCast&&this._shadowAccumulator.setParameters(e.shadowCast)}set slice(e){this._sliceHelper.update(e)&&this._requestRender()}get plugins(){return this._plugins}get _hasFloatBufferBlendSupport(){return this._rctx.driverTest.floatBufferBlend.result}get oitEnabled(){return this.isFeatureEnabled(2)&&this._hasFloatBufferBlendSupport}commit(e,t){return this._isRendering&&console.warn("Renderer.modify called while rendering"),!!super.commit(e,t,this._plugins.context)&&(this.updateHasFlags(),!0)}rendererAdded(e){this._plugins.add(e)}rendererRemoved(e){this._plugins.remove(e)}get occludedRequiresStencil(){return this.occludedRequiresOccludeeStencil||this.occludedRequiresIntegratedMeshStencil}get occludedRequiresOccludeeStencil(){return this._bindParameters.hasOccludees&&!!(8&this.plugins.renderOccludedFlags)}get occludedRequiresIntegratedMeshStencil(){return this._plugins.produces(0,0)&&this._plugins.produces(0,10)}updateHasFlags(){const has=this._pluginsHas;has.occludedHudElements=this._plugins.produces(0,15),has.hudElements=has.occludedHudElements||this._plugins.produces(0,...ge),has.water=this._plugins.produces(2,21),this._bindParameters.hasOccludees=this._plugins.hasOccludees,this._requestRender()}updateAnimation(e,t){this._animationTimer??=new j(e.camera,t),this._animationTimer.advance(e.camera,t,this._animationTimeDilation);const s=this._hasAnimations;return this._hasAnimations=this._plugins.updateAnimation(this._animationTimer),this._hasAnimations=this._nodes.updateAnimation(this._animationTimer)||this._hasAnimations,this._hasAnimations!==s&&(this._gpuTimerHandle=s?r(this._gpuTimerHandle):this.performanceInfo.enableGPUPerformanceInfo()),this._hasAnimations}get animationTimestep(){return this._animationTimestep.value}get _animationTimeDilation(){return this._animationTimestep.timeDilation}resetAnimation(){this._animationTimestep.clear()}tick(){this.fboCache.clean()}render(e,t,s,r=!1){try{return this._isRendering=!0,this._render(e,t,s,r)}catch(i){console.error(`Exception during rendering: ${i}`)}finally{this._isRendering=!1}return new re(this._pluginInput.get(x.FINAL),null)}_render(e,t,s,r){const i=0===s;this.performanceInfo.startFrame(),this.fboCache.frameStart(),this.fboCache.interactive=i,this._disposeBindBuffers();const{camera:a,contentCamera:n,mode:h,alignPixelEnabled:o}=e;this._state.value=h,this._renderContext.time=t,this._rctx.output=0,this._bindParameters.hasEmission=this._hasEmission,this._bindParameters.oitPass=0,this._bindParameters.alignPixelEnabled=o,this._bindParameters.decorations=!r,this._bindParameters.mainDepth=null;const d=!r||!this._sliceHelper.isDecoration;this._bindParameters.slicePlane=d?this._sliceHelper.plane:null,this._bindParameters.viewshedEnabled=this._nodes.produces(A.VIEWSHED),this._bindParameters.cutFillEnabled=this._nodes.produces(A.CUTFILL_DEPTH),this._renderOverlay(),a.setGLViewport(this._rctx);const _=this._framebuffer,l=_.initialize(a.fullWidth,a.fullHeight,this._backgroundColor,this._bindParameters.hasEmission);this.hasReflections?(l?.setName("last frame color"),this._bindParameters.ssr.lastFrameColor=l):l?.release(),this._ensureBindParametersCamera(a,n),this._plugins.sortTestsTransparentOrderedSlots(Pe),this._plugins.prepareRender(),this._bindParameters.shadowHighlightsVisible=this._needsShadowHighlight&&!r;const u=this._plugins.produces(0,...ue);this._precompilePrepasses(),this.performanceInfo.advance(ae.PREPARE);const p=this._computeShadowDepthRange(a);this._renderShadowMap(a,this._bindParameters.lighting.mainLight.direction,p),this._pluginInput.set("normals",this._renderNormals()),this._renderRemainingGeometryDepth(),this._renderShadowAccumulation(p,!i),this._oitCallouts=u&&this.oitEnabled,this._ensureBindParametersSSR(t),this._precompileShaders(u),this._rctx.output=0,_.bind(),this._bindParameters.mainDepth=_.depth.attachment,this._renderOpaque(),this._renderTransparent(u),this._shadowMap.disposeOutput(3),this._pluginInput.set(A.FOCUSAREA,this._renderFocusAreaGeometry()),this._pluginInput.set(A.CUTFILL_DEPTH,this._renderCutFillDepth()),_.update(e=>this._renderNodes(A.TRANSPARENT_ENVIRONMENT,e)),_.update(e=>this._renderNodes(A.VIEWSHED,e)),_.update(e=>this._renderNodes(A.LASERLINES,e)),_.update(e=>this._renderNodes(A.FOCUSAREA_COLOR,e)),this._pluginInput.release(A.FOCUSAREA),this._pluginInput.release(A.CUTFILL_DEPTH),_.update(e=>this._renderNodes(A.OCCLUDED,e)),this._pluginInput.set("highlights",this._renderHighlightPrepass());const c=2===s?this._renderObjectAndLayerIdColor():null;_.update(e=>this._renderNodes(x.COMPOSITE,e)),this._shadowMap.disposeOutputs(),_.update(e=>this._renderNodes(A.ANTIALIASING,e));const m=this._hasPhotoshopTerrain||!u?1:2;let f;return this._bindParameters.hasEmission=!1,this._hasHUDHighlights&&_.update(e=>this._renderHUD(m,e)),_.update(e=>this._renderNodes(A.HIGHLIGHT_COLOR,e)),this._hasHUDHighlights||_.update(e=>this._renderHUD(m,e)),this._bindParameters.hasEmission=this._hasEmission,_.update(e=>this._renderNodes(A.MAGNIFIER,e)),_.update(e=>this._renderNodes(x.FINAL,e)),i&&this._blit.toFramebuffer(this._rctx,_.color,this._bindParameters),this.onPostRender?.(),this._releaseFBOs(),_.releaseDepth(),this._renderContext.lastFrameCamera.copyFrom(this._bindParameters.camera),this.fboCache.frameEnd(),i||(f=_.color,f.retain(),this._releaseFBOs(),this._disposeOffscreenBuffers()),this.performanceInfo.finishFrame(),new re(f,c)}_precompileShaders(e){++this._plugins.context.techniques.precompiling,this._rctx.output=0;const t=this._bindParameters.hasEmission;this._precompileOpaqueGeometry(),this._nodes.precompile(t,A.OPAQUE_ENVIRONMENT,A.PRE_TRANSPARENT);const s=this._bindParameters;s.terrainDepthTest=s.cullAboveTerrain=this._needsTerrainDepth,this._rctx.output=1,this._plugins.precompile(...pe),this._needsTerrainDepth&&(this._precompileOpaqueGeometry(),this._precompileTransparentGeometry()),this._rctx.output=0,this._plugins.precompile(...pe),e&&this.oitEnabled&&this._oitBlend.precompile(t,this._pluginsHas.occludedHudElements,0),e&&(this._precompileTransparentGeometry(),this._hasPhotoshopTerrain&&(s.cullAboveTerrain=!1,this._precompileTransparentGeometry(),s.cullAboveTerrain=this._needsTerrainDepth)),this._nodes.precompile(t,A.FOCUSAREA);const r=this._hasPhotoshopTerrain&&!this._needsTerrainDepth;this._compositor.precompile(this._usesPremultipliedAlphaBlit,!!this._needsEdges,r,t),this._oitCallouts||this._plugins.precompile(17),s.terrainDepthTest=s.cullAboveTerrain=!1,this._nodes.precompile(t,A.TRANSPARENT_ENVIRONMENT,A.VIEWSHED,A.CUTFILL_DEPTH,A.CUTFILL_COLOR,A.LASERLINES,A.FOCUSAREA_COLOR,A.OCCLUDED,A.ANTIALIASING),s.highlightMixTexture=s.highlights.length>1?this._rctx.emptyTexture:null,this._precompileHUD(0),s.hasEmission=!1,this._precompileHUD(0),this._precompileHUD(1),s.hasEmission=this._hasEmission,this._hasHighlights&&(s.highlights.forEach((e,t)=>{s.highlightLevel=t,this._precompileAllGeometry(8),this._hasHUDHighlights&&this._plugins.precompile(15,14)}),s.highlightLevel=null,this._nodes.precompile(t,A.HIGHLIGHT_COLOR)),s.highlightMixTexture=null,this._nodes.precompile(t,x.COMPOSITE,A.MAGNIFIER),this._shadowAccumulator.precompile(),this._plugins.precompile(9),--this._plugins.context.techniques.precompiling}_renderFocusAreaGeometry(){const e=this._nodes.produce(A.FOCUSAREA,this._pluginInput);return e&&this.performanceInfo.advance(ae.FOCUS_AREA_MASK),e}_renderObjectAndLayerIdColor(){if(!this._nodes.produces("olid"))return null;const e=this._rctx.output;++this._techniques.precompiling;const{width:t,height:s}=this._framebuffer.size;let r=this.fboCache.acquire(t,s,"olid");return r.acquireDepth(13),r=this._nodes.render(r,this._pluginInput),--this._techniques.precompiling,this.performanceInfo.advance(ae.OBJECT_AND_LAYER_ID_COLOR),this._rctx.output=e,r}finish(e){this._hasAnimations||this._animationTimestep.clear();const t=this.performanceInfo.gpuSamplingEnabled,s=0===e;if(s||t){const e=s?this.performanceInfo.elapsedTime:0;let r=0;t?r=this.performanceInfo.totalGPUTimeSampler.last:this._rctx.gl.finish();const i=Math.max(e,r);this._animationTimestep.frame(i,s)}}readMainDepth(e,t){const{mainDepth:s,camera:r}=this._bindParameters;if(!s)return;const i=this.fboCache.acquire(this._framebuffer.size.width,this._framebuffer.size.height,"linear depth");this._rctx.bindFramebuffer(i.fbo),r.setGLViewport(this._rctx),this._rctx.setScissorRect(e[0],e[1],e[2],e[3]),this._rctx.setScissorTestEnabled(!0),this._rctx.clearFramebuffer(w),this._compositor.blitDepthToLinearDepth(this._bindParameters,s),this._rctx.setScissorTestEnabled(!1),this._rctx.setScissorRect(0,0,this._rctx.gl.canvas.width,this._rctx.gl.canvas.width),i.fbo?.readPixels(e[0],e[1],e[2],e[3],6408,ne.UNSIGNED_BYTE,t),i.release()}readAccumulatedShadow(e){return this._shadowAccumulator.readAccumulatedShadow(e[0],e[1])}get _needsEdges(){return this._edgeView?.shouldRender()?this._edgeView:null}_renderEdges(e){const t=this._needsEdges;if(!t)return;const{width:s,height:r}=this._framebuffer.size,i=this.fboCache.acquire(s,r,"edges"),a=this._bindParameters.geometryDepth,n=()=>t.render(this._bindParameters,e);this._renderToTargets(n,i,a??this._framebuffer.depth,w),this._framebuffer.bind(),this._compositor.composite(this._bindParameters,i.getTexture()),i.release(),this.performanceInfo.advance(1===e?ae.OPAQUE_EDGES:ae.TRANSPARENT_EDGES)}_renderOverlay(){this._bindParameters.overlay=this.overlay?.render(this._renderContext.time),this._bindParameters.overlay&&this.performanceInfo.advance(ae.OVERLAY)}_renderShadowMap(e,t,s){if(!this.shadowsEnabled)return;const r=this._shadowMap;r.start(e,t,s,this.isFeatureEnabled(7),this.stage.view.qualitySettings.maximumPixelRatio),this._needsShadowHighlight?(this._renderShadowCascades(5,this._shadowMap),r.clear(),this._renderShadowCascades(4,this._shadowMap)):this._renderShadowCascades(3),e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,this._bindParameters.contentCamera),this.performanceInfo.advance(ae.SHADOW_MAP)}_renderCutFillDepth(){return this._nodes.produce(A.CUTFILL_DEPTH,this._pluginInput)}_precompileShadowCascades(e){0!==this._shadowMap.cascades.length&&this._precompileAllGeometry(e)}_renderShadowCascades(e,t=this._shadowMap){const s=this._rctx.output;t.bindFramebuffer();for(const r of t.cascades)r.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(r.camera,r.camera),this.renderAllGeometry(e);t.finish(e),this._rctx.output=s}get _needsDepth(){return this._plugins.consumes(1)||this._nodes.requireGeometryDepth()||this.hasReflections||this._needsShadowHighlight||this._shadowAccumulator.active||this._debugNeedsDepth}get _usesPremultipliedAlphaBlit(){return this._pluginsHas.hudElements&&this.oitEnabled||this._hasPhotoshopTerrain}_renderRemainingGeometryDepth(){const e=this._pluginInput.get("normals");e?(this._pluginInput.set(A.SSAO,this._renderSSAO()),this._needsDepth?(this._rctx.bindFramebuffer(e.fbo),this._rctx.clear(1024),this._renderGeometryWithoutNormals(1),this._bindParameters.depth?.release(),this._bindParameters.depth=e.obtainDepthTexture(),this.performanceInfo.advance(ae.DEPTH)):(e.detachDepth(),this._bindParameters.depth=n(this._bindParameters.depth)),this.hasSSAO&&this._pluginInput.release("normals")):this._renderAllGeometryDepth()}_renderAllGeometryDepth(){if(this._bindParameters.depth=n(this._bindParameters.depth),!this._needsDepth)return;const{width:e,height:t}=this._framebuffer.size,s=this.fboCache.acquire(e,t,"geometry depth",13);this._rctx.bindFramebuffer(s.fbo),this._rctx.clear(1280),this.renderAllGeometry(1),this._bindParameters.depth=s.obtainDepthTexture(),s.release(),this.performanceInfo.advance(ae.DEPTH)}_renderTerrainDepth(){if(this._bindParameters.terrainDepth=n(this._bindParameters.terrainDepth),this._bindParameters.terrainDepthTest=this._bindParameters.cullAboveTerrain=this._needsTerrainDepth,!this._needsTerrainDepth)return;const e=this._rctx.output;this._rctx.output=1;const{width:t,height:s}=this._framebuffer.size,r=this.fboCache.acquire(t,s,"terrain depth",13);this._rctx.bindFramebuffer(r.fbo),this._rctx.clear(1280),this._renderTransparentGround(),this._bindParameters.terrainDepth=r.obtainDepthTexture(),r.release(),this._rctx.output=e}_renderGeometryDepth(){if(this._bindParameters.geometryDepth=n(this._bindParameters.geometryDepth),!this._needsTerrainDepth)return;const e=this._rctx.output,{width:t,height:s}=this._framebuffer.size,r=this.fboCache.acquire(t,s,"geometry depth",13);this._rctx.bindFramebuffer(r.fbo),this._rctx.clear(1280),this._renderOpaqueAndTransparentGeometry(1),this._rctx.output=e,this._bindParameters.geometryDepth=r.obtainDepthTexture(),r.release()}get _needsShadowDepthRange(){return this._shadowMap.enabled||this._shadowAccumulator.active}_computeShadowDepthRange(e){if(!this._needsShadowDepthRange)return z.Zero;const t=W(e,this._plugins.plugins,this.stage.layers,0);return t.union(this._plugins.queryDepthRange(e)),t.near=Math.max(e.near,t.near),t.far=Math.min(e.far,t.far),t}updateSceneDepthRange(e){if(!this.stage.view.state.isGlobal)return void(this.sceneDepthRange.value=z.Infinite);if((this.stage.view.renderCoordsHelper?.getAltitude(e.eye)??0)<D)return void(this.sceneDepthRange.value=z.Infinite);const t=e.clone();t.near=O,t.far=1e10;const s=W(t,this._plugins.plugins,this.stage.layers,1);s.union(this._plugins.queryDepthRange(t)),this.sceneDepthRange.value.equals(s)||(this.sceneDepthRange.value=s)}get _normalsRequired(){const e=this._nodes.require("normals",...S,A.VIEWSHED,A.LASERLINES);return(this.hasSSAO?1:0)+e}_precompilePrepasses(){this._normalsRequired&&this._precompileAllGeometry(2),this._needsDepth&&this._precompileAllGeometry(1),this.shadowsEnabled&&(this._needsShadowHighlight?(this._precompileShadowCascades(4),this._precompileShadowCascades(5)):this._precompileShadowCascades(3)),this._shadowAccumulator.active&&this._precompileAllGeometry(3),this.hasSSAO&&this._normalsRequired&&this._nodes.precompile(this._bindParameters.hasEmission,A.SSAO)}_renderNormals(){const e=this._normalsRequired;if(0===e)return;const{width:t,height:s}=this._framebuffer.size,r=this.fboCache.acquire(t,s,"normals",5);r.acquireDepth(13),this._rctx.bindFramebuffer(r.fbo),this._rctx.clearFramebuffer(w,!0,!0),this._rctx.output=2,this._plugins.render(...ce);const i=this._nodes.optional("normals",...S,A.VIEWSHED);return r.retain(e+i-1),this.performanceInfo.advance(ae.NORMALS),r}_renderSSAO(){const e=this._pluginInput.get("normals");if(this.hasSSAO&&e)return this._bindParameters.ssao=this._nodes.produce(A.SSAO,this._pluginInput),this._bindParameters.ssao&&this.performanceInfo.advance(ae.SSAO),this._bindParameters.ssao}_precompileAllGeometry(e){const t=this._rctx.output;this._rctx.output=e,this._precompileOpaqueGeometry(),this._precompileTransparentGeometry(),this._plugins.precompile(...pe),this._rctx.output=t}renderAllGeometry(e){this._rctx.output=e,this._renderOpaqueAndTransparentGeometry(e),this._renderTransparentGround()}precompileSlots(e,...t){for(const s of t)this._bindParameters.slot=s,e.precompile(this._renderContext)}precompileOccludedSlots(e,t){for(const s of t)this._renderContext.renderOccludedMask=s,this.precompileSlots(e,...fe);this._renderContext.renderOccludedMask=J}renderSlots(e,...t){for(const s of t)this._bindParameters.slot=s,e.forAll(e=>{const t=e.acquireTechniques(this._renderContext);t&&e.render(this._renderContext,t)})}renderOccludedSlots(e,t){this._renderContext.renderOccludedMask=t,this.plugins.renderOccludedFlags>1&&this._plugins.render(10),this.renderSlots(e,...fe),this._renderContext.renderOccludedMask=J}renderHUD(e){this._bindParameters.hudRenderStyle=e,this._plugins.render(...Ee[e])}_renderHUDElements(e){this._bindParameters.hudRenderStyle=e,this._plugins.render(18),this.renderHUD(e),this._bindParameters.hudRenderStyle=e,this._plugins.render(16)}precompileViewshedShadowMap(){this._precompileAllGeometry(6)}precompileCutFill(){const e=7,t=this._rctx.output;this._rctx.output=e,this._plugins.precompile(0,1,...pe),this._rctx.output=t}renderViewshedShadowMap(e){const{camera:t,contentCamera:s}=this._bindParameters,r=this._rctx.output;e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,e),this.renderAllGeometry(6),this._ensureBindParametersCamera(t,s),this._bindParameters.camera.setGLViewport(this._rctx),this._rctx.output=r}renderCutFillReferenceDepth(e){const{camera:t,contentCamera:s}=this._bindParameters,r=this._rctx.output;e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,e),this._rctx.output=7,this._plugins.render(0,1,...pe),this._ensureBindParametersCamera(t,s),t.setGLViewport(this._rctx),this._rctx.output=r}_renderOpaqueAndTransparentGeometry(e){this._rctx.output=e,this._renderOpaqueGeometry(),this._renderTransparentGeometry()}_renderGeometryWithoutNormals(e){this._rctx.output=e,this._plugins.render(...me)}_precompileOpaqueGeometry(){this._plugins.precompile(...le),this._nodes.precompile(this._bindParameters.hasEmission,"opaque-color")}_renderOpaqueGeometry(){this._plugins.render(...le)}_renderTransparentGeometry(){this._plugins.render(...ue),this._oitCallouts&&this._plugins.render(17)}get _hasPhotoshopTerrain(){return this._plugins.produces(0,6)}get _needsTerrainDepth(){return this._highQualityTransparency&&this._hasPhotoshopTerrain}_renderPhotoshopTerrain(){if(!this._hasPhotoshopTerrain)return null;const{width:e,height:t}=this._framebuffer.size,s=this.fboCache.acquire(e,t,"transparent terrain"),r=()=>this._plugins.render(6);return this._renderToTargets(r,s,this._framebuffer.depth,w),this.performanceInfo.advance(ae.TRANSPARENT_TERRAIN),s}_renderTransparentGround(){this._plugins.render(...pe)}_renderLineCallouts(e){if(this._bindParameters.hudRenderStyle=e,0===e){const e=()=>this._plugins.render(17),{width:t,height:s}=this._framebuffer.size,r=this.fboCache.acquireDepth(12,t,s,"line callouts");this._renderToTargets(e,this._framebuffer.color,r,void 0,!0,!0),r.release()}else this._plugins.render(17)}_precompileHUD(e){if(this._pluginsHas.hudElements&&(this._precompileHUDOutput(e),this._hasHighlights)){const t=this._rctx.output;this._rctx.output=8,this._precompileHUDOutput(e),this._rctx.output=t}}_precompileHUDOutput(e){const t=this._bindParameters.hudRenderStyle;this._bindParameters.hudRenderStyle=e,this.oitEnabled&&v(this._rctx.output)?(this._bindParameters.oitPass=1,this._plugins.precompile(...ge),this._bindParameters.oitPass=2,this._plugins.precompile(...ge),this._bindParameters.oitPass=0,this._oitBlend.precompile(this._bindParameters.hasEmission,!1,1)):this._plugins.precompile(...ge),this._bindParameters.hudRenderStyle=t}_renderHUD(e,t){if(!this._pluginsHas.hudElements)return t;if(this.oitEnabled){const s=this._renderOIT(1,e);this._rctx.bindFramebuffer(t.fbo);const r=!!t.getTexture(he);this._compositor.compositePreMultipliedAlpha(this._bindParameters,s.getTexture(),r),s.release()}else if(this._rctx.output=0,0===e){const t=()=>this._renderHUDElements(e),{width:s,height:r}=this._framebuffer.size,i=this.fboCache.acquireDepth(12,s,r,"hud");this._renderToTargets(t,this._framebuffer.color,i,void 0,!0,!0),i.release()}else t.acquireDepth(12),this._rctx.bindFramebuffer(t.fbo),this._rctx.clear(256),this._renderHUDElements(e),t.detachDepth();return this.performanceInfo.advance(0===e?ae.HUD_OCCLUDED:ae.HUD),t}get _needsShadowHighlight(){return this.shadowsEnabled&&this._plugins.produces(4,2)}_renderHighlightPrepass(){if(!this._hasHighlights)return;const{fboCache:e,_rctx:t,_bindParameters:s}=this,{width:r,height:i}=this._framebuffer.size,{highlights:a}=s,n=a.length>G?3:1,h=e.acquire(r,i,"highlights",n);h.acquireDepth(13);const o=this._plugins.produces(8,0);return o&&this._framebuffer.color.fbo&&h.fbo&&t.blitFramebuffer(this._framebuffer.color.fbo,h.fbo,1024),t.bindFramebuffer(h.fbo),t.gl.clearBufferuiv(6144,0,[0,0,0,0]),o||t.clear(1024),this._rctx.output=8,t.bindFramebuffer(h.fbo),L(t,e,r,i,s,()=>this._renderHighlightGeometries()),h.detachDepth(),this.performanceInfo.advance(ae.HIGHLIGHTS),h.retain(this._nodes.require("highlights",...R)+this._nodes.optional("highlights",...R)-1),h}_renderHighlightGeometries(){this._plugins.render(...be),this._rctx.clear(256),this._renderHUDElements(2)}_renderShadowAccumulation(e,t){this._shadowAccumulator.updateDepthRange(e);const{depth:s,camera:r,contentCamera:i}=this._bindParameters;this._rctx.output=0,this._shadowAccumulator.accumulating&&s&&this._shadowAccumulator.renderAccumulation(s,r,i,t)&&this.performanceInfo.advance(ae.ACCUMULATED_SHADOWS)}_precompileTransparentGeometry(){this.oitEnabled&&v(this._rctx.output)?(this._bindParameters.oitPass=1,this._plugins.precompile(...ue),this._oitCallouts&&this._plugins.precompile(17),this._bindParameters.oitPass=2,this._plugins.precompile(...ue),this._oitCallouts&&this._plugins.precompile(17),this._bindParameters.oitPass=0):this._plugins.precompile(...ue)}_renderOIT(e,t=2){const s=1===e,{width:r,height:i}=this._framebuffer.size,a=s?()=>this._renderHUDElements(t):()=>this._renderTransparentGeometry(),h=this._bindParameters,o=this._rctx.output;this._rctx.output=0,h.oitPass=1;const d=s?"oit hud":"oit",_=this.fboCache.acquire(r,i,d,8),l=this._bindParameters.hasEmission&&(0===e||1!==t);l&&_.acquireColor(he,8,"oit emissive");const u=l?oe:he;_.acquireColor(u,7,"oit alpha"),s||_.attachDepth(this._framebuffer.depth),this._rctx.bindFramebuffer(_.fbo),this._rctx.clearFramebuffer([0,0,0,1]),l&&this._rctx.clearBuffer(1,w),a(),_.detachDepth(),h.oitPass=2;const p=this.fboCache.acquire(r,i,s?"oit hud front":"oit front");l&&p.acquireColor(he,8,"oit emissive front"),s?p.acquireDepth(12):p.attachDepth(this._framebuffer.depth),this._rctx.bindFramebuffer(p.fbo),this._rctx.clearFramebuffer(w,s),a(),p.detachDepth();const c=this._pluginsHas.occludedHudElements&&!s;let m;return this._bindParameters.hudOcclusion=n(this._bindParameters.hudOcclusion),h.oitPass=0,s?(m=this.fboCache.acquire(r,i,"oit hud composite"),this._rctx.bindFramebuffer(m.fbo),this._rctx.setClearColor(0,0,0,1e-13),this._rctx.clear(16384)):(c&&(this._framebuffer.color.acquireColor(u,0,"hud occlusion"),this._rctx.clearBuffer(u-de,w)),this._framebuffer.bind()),this._oitBlend.blend(this._rctx,_,p,h,l,c,e),m?.detachDepth(),s||(this._rctx.bindFramebuffer(p.fbo),this._framebuffer.bind(),c&&(this._bindParameters.hudOcclusion=this._framebuffer.color.obtainAttachment(u))),p.release(),_.release(),this._rctx.output=o,m}_renderOpaque(){const e=this.plugins.produces(0,...le);e&&(this._plugins.render(0,1),this._framebuffer.update(e=>this._renderNodes(A.CUTFILL_COLOR,e)),this._framebuffer.bind(),this._plugins.render(2,3));const t=this._framebuffer;this._renderTerrainDepth(),t.update(t=>this._renderNodes(x.OPAQUE,t,e)),this.fboCache.debugCallback?.(x.OPAQUE,t.color.fbo),t.update(e=>this._renderNodes(A.OPAQUE_ENVIRONMENT,e)),this.fboCache.debugCallback?.(A.OPAQUE_ENVIRONMENT,t.color.fbo),this._renderEdges(1)}_renderTransparent(e){const t=this._framebuffer;t.bind(),t.update(e=>this._renderNodes(A.PRE_TRANSPARENT,e)),this.fboCache.debugCallback?.(A.PRE_TRANSPARENT,t.color.fbo),this._renderHiddenTransparentEdges(),e&&(this.oitEnabled?this._renderOIT(0):this._renderTransparentGeometry()),t.update(t=>this._renderNodes(x.TRANSPARENT,t,e)),this.fboCache.debugCallback?.(x.TRANSPARENT,t.color.fbo),this._renderGeometryDepth(),this._needsTerrainDepth||this._oitCallouts||this._plugins.render(17),this._renderEdges(0);const s=this._renderPhotoshopTerrain(),r=s?.getTexture();r&&this._renderHUD(0,t.color),this._bindParameters.cullAboveTerrain=!1,r&&(t.bind(),this._compositor.compositePreMultipliedAlpha(this._bindParameters,r),s?.release(),this._needsTerrainDepth&&(this._renderEdges(1),e&&(this.oitEnabled?this._renderOIT(0):this._renderTransparentGeometry(),this.performanceInfo.advance(ae.TRANSPARENT)),this._renderEdges(0))),this._bindParameters.ssao=n(this._bindParameters.ssao),this._needsTerrainDepth&&this._renderLineCallouts(1),this._bindParameters.terrainDepthTest=!1,this._renderTransparentEnvironment()}_renderTransparentEnvironment(){this._shadowAccumulator.render(this._bindParameters),this.performanceInfo.advance(ae.APPLY_ACCUMULATED_SHADOWS),this._framebuffer.bind(),this._plugins.render(9),this.performanceInfo.advance(ae.TRANSPARENT_MATERIAL_WITHOUT_DEPTH)}_renderNodes(e,t,s=!1){const r=t.name;if(t.setName(e),this._pluginInput.set(e,t),!this._nodes.produces(e))return s&&this.performanceInfo.advance(e),t;this._fboCache.debugCallback?.(r,t.fbo);const i=this._nodes.render(t,this._pluginInput,this._releaseNodeInputs);return this.performanceInfo.advance(e),i}_ensureBindParametersCamera(e,t){this._bindParameters.camera=e,this._bindParameters.contentCamera=t}_ensureBindParametersSSR(e){if(this._bindParameters.ssr.lastFrameColor){null==this._ssrEnableTime&&(this._ssrEnableTime=e),this._renderContext.lastFrameCamera.equals(this._bindParameters.camera)?this._reprojectionMatrix=b:(f(Ce,this._bindParameters.camera.viewMatrix),f(we,this._bindParameters.camera.projectionMatrix),g(xe,Ce,we),g(xe,this._renderContext.lastFrameCamera.viewMatrix,xe),g(xe,this._renderContext.lastFrameCamera.projectionMatrix,xe),this._reprojectionMatrix=xe);const t=this.stage.view.qualitySettings.fadeDuration;this._bindParameters.ssr.fadeFactor=t>0?Math.min(t,e-this._ssrEnableTime)/t:1,this._bindParameters.ssr.fadeFactor<1&&this._requestRender()}else this._reprojectionMatrix=b,this._ssrEnableTime=null}addRenderNode(e){this._nodes.add(e),this._requestRender()}removeRenderNode(e){this._nodes.remove(e),this._requestRender()}updateLighting(e,t,s,r){this._bindParameters.updateLighting(e,t,s,r),this._requestRender(1)}get usedMemory(){return{fbos:this.fboCache.usedMemory,plugins:this._plugins.usedMemory,edges:this.edgeView?.usedMemory??0}}_renderToTargets(e,t,s,r,i=!1,a=!1){t.attachDepth(s),this._rctx.bindFramebuffer(t.fbo),this._rctx.clearFramebuffer(r,i,a),e(),t.detachDepth()}get test(){}};e([p({readOnly:!0})],_e.prototype,"highResolutionAtmosphere",null),e([p()],_e.prototype,"_edgeView",void 0),e([p()],_e.prototype,"updating",null),_e=e([c("esri.views.3d.webgl-engine.lib.Renderer")],_e);const le=[0,1,2,3],ue=[7,8,4,5],pe=[6,7,8],ce=[0,1,2,4,...pe],me=[3,5],fe=[2,4,9],ge=[18,14,16,15],be=[4,5,2,3,0,1,...pe],Pe=[4,9,5,12],Ee={0:[15],1:[14],2:[15,14],3:[15,14]},Te=["normals","highlights"],we=P(),Ce=P(),xe=P();function Ae(e){return t=>e.immediate.schedule(t)}export{_e as Renderer};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{__decorate as t}from"tslib";import e from"../../../core/Error.js";import{makeHandle as i}from"../../../core/handleUtils.js";import{watch as r}from"../../../core/reactiveUtils.js";import{property as n,subclass as o}from"../../../core/accessorSupport/decorators.js";import{geometryToCoordinates as s}from"../../../geometry/support/coordsUtils.js";import{
|
|
2
|
+
import{__decorate as t}from"tslib";import e from"../../../core/Error.js";import{makeHandle as i}from"../../../core/handleUtils.js";import{watch as r}from"../../../core/reactiveUtils.js";import{property as n,subclass as o}from"../../../core/accessorSupport/decorators.js";import{geometryToCoordinates as s}from"../../../geometry/support/coordsUtils.js";import{pointNear as a}from"../../../layers/graphics/dehydratedFeatureComparison.js";import{PluginBase as p}from"./PluginBase.js";const c=Symbol("left-anchor-vertex"),h=Symbol("right-vertex"),l=Symbol("anchor"),d=Symbol("endpoint"),u=Symbol("interior-point");let _=class extends p{constructor(){super(...arguments),this.arcDrawingMode="interior-first",this.state="placing-anchor"}get helpMessageKey(){switch(this.state){case"placing-interior":return"curveInteriorPoint";case"placing-endpoint":return"curvePlaceEndPoint";default:return"point"}}get test(){return{state:this.state,captureState:()=>this._captureState()}}start(t,e){super.start(t,e);const i=t.session;i.preserveSharedRedoAfterOperation=!0,this.ownPlacedLeftAnchor=e?.ownPlacedLeftAnchor,this.leftAnchor=i.getInformationAboutPoint(-1,-1)?.point;let n=e?.state;!this.leftAnchor&&this.ownPlacedLeftAnchor?(this.leftAnchor=this.ownPlacedLeftAnchor,i.appendOrReplacePoint(c,this.leftAnchor),i?.groupGeometryChanges()):this.leftAnchor&&"placing-anchor"===e?.state&&(n=this._getNextState("placing-anchor"),this.ownPlacedLeftAnchor=null),this.state=this.leftAnchor?n??this._getNextState("placing-anchor"):"placing-anchor",this.interiorPoint=e?.interiorPoint,this.endpoint=e?.endpoint,this.addHandles([r(()=>this._anchorCursor?.outputMapPosition,t=>{t&&(this.leftAnchor=this.ownPlacedLeftAnchor=t,this._session?.appendOrReplacePoint(c,t))}),r(()=>this._interiorPointCursor?.outputMapPosition,t=>{t&&(this.interiorPoint=t,this._recomputeAndApply())}),r(()=>this._endpointCursor?.outputMapPosition,t=>{t&&(this.endpoint=t,this._recomputeAndApply())})],this._ownHandlesKey),this._applyState(this.state)}async completeStep(){if(this._isComplete)return;if(!this._isCurrentStepValid())return;const t=this._session?.peekUndoStep();if(t){const e=this._captureState();t&&t.state===e.state&&(t.leftAnchor=e.leftAnchor,t.interiorPoint=e.interiorPoint,t.endpoint=e.endpoint)}else this._session?.pushUndoStep(this._captureState());"placing-anchor"===this.state&&this.ownPlacedLeftAnchor&&this._session?.groupGeometryChanges();try{this._session.preserveSharedRedoAfterOperation=!1;const t=this._getNextState(this.state);null===t?this._context?.requestComplete():this._applyState(this.state=t)}finally{this._session.preserveSharedRedoAfterOperation=!0}this._session?.pushUndoStep(this._captureState())}beforeAttachPlugin(t){return{useStandaloneSession:!0}}suspend(){return this._captureState()}_applyState(t){const i=this._session;if(!i)throw new e("drawTool:invalid-state","Circular Arc: attempted to apply state while context invalid");this.removeHandles(l),this.removeHandles(d),this.removeHandles(u),i.automaticRestart=this._computeAutomaticRestart(),"placing-anchor"!==t?("placing-interior"!==t&&"interior-first"!==this.arcDrawingMode||this._setupInteriorPointCursor(),"placing-endpoint"!==t&&"end-first"!==this.arcDrawingMode||this._setupEndpointCursor()):this._setupAnchorCursor()}_setupAnchorCursor(){this._anchorCursor=this._context.createInteractiveHandle({defaultCaptureMode:"capture-always",inputMapPosition:this._context.positionOfLastUserInput,role:"primary",selfSnappingEnabled:!1,snappingEnabled:!0}),this.addHandles(i(()=>{this._anchorCursor&&(this._context?.removeInteractiveHandle(this._anchorCursor),this._anchorCursor=null)}),l)}_setupInteriorPointCursor(){const t="placing-interior"===this.state?"capture-always":"grabbable-object";this._interiorPointCursor=this._context.createInteractiveHandle({defaultCaptureMode:t,inputMapPosition:"capture-always"===t?void 0:this.interiorPoint??this.endpoint,role:"secondary",selfSnappingEnabled:!1,snappingEnabled:!0}),this.addHandles(i(()=>{this._interiorPointCursor&&(this._context?.removeInteractiveHandle(this._interiorPointCursor),this._interiorPointCursor=null)}),u)}_setupEndpointCursor(){const t="placing-endpoint"===this.state?"capture-always":"grabbable-object";this._endpointCursor=this._context.createInteractiveHandle({defaultCaptureMode:t,inputMapPosition:"capture-always"===t?void 0:this.endpoint??this.interiorPoint,role:"primary",selfSnappingEnabled:!0,snappingEnabled:!0}),this.addHandles(i(()=>{this._endpointCursor&&(this._context?.removeInteractiveHandle(this._endpointCursor),this._endpointCursor=null)}),d)}_captureState(){const{state:t,endpoint:e,interiorPoint:i,leftAnchor:r,ownPlacedLeftAnchor:n}=this;return{state:t,endpoint:e,interiorPoint:i,leftAnchor:r,ownPlacedLeftAnchor:n}}_computeAutomaticRestart(){return"placing-anchor"===this.state||("placing-interior"===this.state?"interior-first"===this.arcDrawingMode&&!this.ownPlacedLeftAnchor:"end-first"===this.arcDrawingMode&&!this.ownPlacedLeftAnchor)}_makeCurve(){const{interiorPoint:t,endpoint:e}=this;if(!t&&!e)return null;const i=e??t,r=s(t??e);return{c:[s(i),g(r)]}}_recomputeAndApply(){const t=this._makeCurve();t&&this._session?.appendOrReplaceCurve(h,t)}_isCurrentStepValid(){const{interiorPoint:t,endpoint:e,leftAnchor:i}=this;return"placing-interior"===this.state?!!t&&((!i||!a(t,i))&&!(e&&a(t,e))):"placing-endpoint"===this.state?!!e&&!(t&&a(e,t)):"placing-anchor"!==this.state||null!=this.ownPlacedLeftAnchor}_getNextState(t){switch(t){case"placing-anchor":return"interior-first"===this.arcDrawingMode?"placing-interior":"placing-endpoint";case"placing-interior":return"interior-first"===this.arcDrawingMode?"placing-endpoint":null;case"placing-endpoint":return"end-first"===this.arcDrawingMode?"placing-interior":null}}};function g(t){return 2===t.length?t:[t[0]??0,t[1]??0]}t([n()],_.prototype,"_anchorCursor",void 0),t([n()],_.prototype,"_endpointCursor",void 0),t([n()],_.prototype,"_interiorPointCursor",void 0),t([n()],_.prototype,"arcDrawingMode",void 0),t([n()],_.prototype,"interiorPoint",void 0),t([n()],_.prototype,"endpoint",void 0),t([n()],_.prototype,"leftAnchor",void 0),t([n()],_.prototype,"ownPlacedLeftAnchor",void 0),t([n()],_.prototype,"state",void 0),t([n()],_.prototype,"helpMessageKey",null),_=t([o("esri.views.draw.plugins.CircularArcSegmentPlugin")],_);export{_ as CircularArcSegmentPlugin};
|