@arcgis/core 6.0.0-next.56 → 6.0.0-next.57
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/00c227bcecc28fe278bb.js +1 -0
- package/assets/esri/core/workers/chunks/{88df1b8b295d3aed649f.js → 10499abb7678e95d9f05.js} +1 -1
- package/assets/esri/core/workers/chunks/1afc8820c283ef785729.js +1 -0
- package/assets/esri/core/workers/chunks/1c874f86bfd0963aa3d2.js +1 -0
- package/assets/esri/core/workers/chunks/2a84c9a81ec2bed3d4e5.js +1 -0
- package/assets/esri/core/workers/chunks/2f31766bc0f9d1d70c5a.js +1 -0
- package/assets/esri/core/workers/chunks/35109db6a6be66f895f7.js +1 -0
- package/assets/esri/core/workers/chunks/373b140f92eda3857f82.js +1 -0
- package/assets/esri/core/workers/chunks/38bba952c38af5a150e7.js +1 -0
- package/assets/esri/core/workers/chunks/3aea09191b737dc1de70.js +1 -0
- package/assets/esri/core/workers/chunks/3fc4b7d0ee460fc96176.js +1 -0
- package/assets/esri/core/workers/chunks/457bd1bd37c67b61efe8.js +1 -0
- package/assets/esri/core/workers/chunks/601d668e70c5d72fe58c.js +1 -0
- package/assets/esri/core/workers/chunks/651e33be8bb3995d749f.js +1 -0
- package/assets/esri/core/workers/chunks/721f43554b9654481de7.js +1 -0
- package/assets/esri/core/workers/chunks/75274ac3ddf7c45f47d7.js +1 -0
- package/assets/esri/core/workers/chunks/80d1267606383ae537f2.js +1 -0
- package/assets/esri/core/workers/chunks/8920d0b11951b57d6a66.js +1 -0
- package/assets/esri/core/workers/chunks/92d97e0fcc20dd5f5ac4.js +1 -0
- package/assets/esri/core/workers/chunks/9ca84fa9423654061d05.js +1 -0
- package/assets/esri/core/workers/chunks/9e372af03d62fa5ad10e.js +1 -0
- package/assets/esri/core/workers/chunks/b10c534cbe311d17b7d5.js +1 -0
- package/assets/esri/core/workers/chunks/{dfa1b0308e5e82d1ddfe.js → be0133fa63c5d6545a7f.js} +1 -1
- package/assets/esri/core/workers/chunks/cb0e3614b78c78040662.js +1 -0
- package/assets/esri/core/workers/chunks/d22e3b5d836dffdf91cc.js +1 -0
- package/assets/esri/core/workers/chunks/e0341def2d81e679a200.js +1 -0
- package/assets/esri/core/workers/chunks/e42e9dd3c933f5f864ab.js +1 -0
- package/assets/esri/core/workers/chunks/f4fcf87da4495584223d.js +1 -0
- package/assets/esri/core/workers/chunks/f989588dfdbb69056491.js +1 -0
- package/assets/esri/core/workers/chunks/fc5b920f9756e11c2f88.js +1 -0
- package/chunks/Component.glsl.js +1 -0
- package/chunks/GlobalIllumination.glsl.js +12 -11
- package/chunks/GlobalIlluminationBlur.glsl.js +6 -4
- package/chunks/Terrain.glsl.js +24 -23
- package/chunks/Water.glsl.js +24 -23
- package/config.js +1 -1
- package/core/memoryEstimations.js +1 -1
- package/interfaces.d.ts +0 -1
- package/kernel.js +1 -1
- package/layers/LinkChartLayer.js +1 -1
- package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
- package/layers/graphics/dehydratedFeatures.js +1 -1
- package/layers/graphics/transferFeatures.js +1 -1
- package/layers/support/fieldUtils.d.ts +129 -57
- package/layers/support/fieldUtils.js +1 -1
- package/networks/Network.js +1 -1
- package/networks/support/TopologyValidationJobInfo.js +1 -1
- package/package.json +2 -2
- package/views/3d/GroundView3D.js +1 -1
- package/views/3d/layers/I3SMeshView3D.js +1 -1
- package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
- package/views/3d/layers/i3s/I3SIntersectionHandler.js +1 -1
- package/views/3d/layers/support/Tiles3DBVH.js +1 -1
- package/views/3d/layers/support/Tiles3DMeshIntersectionHandler.js +1 -1
- package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
- package/views/3d/support/GroundAndIMSurface.js +1 -1
- package/views/3d/support/pointsOfInterest/CenterOnSurface.js +1 -1
- package/views/3d/support/pointsOfInterest/PointsOfInterest.js +1 -1
- package/views/3d/terrain/TerrainRenderer.js +1 -1
- package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
- package/views/3d/webgl-engine/collections/Component/ComponentObjectFixedBVH.js +1 -1
- package/views/3d/webgl-engine/collections/Component/IntersectionGeometry.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/lastFrameUniforms.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js +15 -12
- package/views/3d/webgl-engine/effects/globalIllumination/GlobalIllumination.glsl.js +1 -1
- package/views/3d/webgl-engine/effects/globalIllumination/GlobalIllumination.js +1 -1
- package/views/3d/webgl-engine/effects/globalIllumination/GlobalIlluminationBlur.glsl.js +1 -1
- package/views/3d/webgl-engine/effects/globalIllumination/globalIlluminationUniforms.js +1 -1
- package/views/3d/webgl-engine/lib/RayIntersections.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/TriangleIntersectionData.js +1 -1
- package/views/3d/webgl-engine/materials/Water.glsl.js +1 -1
- package/views/3d/webgl-engine/materials/WaterMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/WaterTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/materials/getWaterColor.glsl.js +89 -0
- package/views/3d/webgl-engine/shaders/TerrainTechniqueConfiguration.js +1 -1
- package/assets/esri/core/workers/chunks/193a73a2c7f4f8482c21.js +0 -1
- package/assets/esri/core/workers/chunks/20acb6f3ed5140b6c6c6.js +0 -1
- package/assets/esri/core/workers/chunks/2d4788be418a4e5f6606.js +0 -1
- package/assets/esri/core/workers/chunks/333140b18aeb5a50b654.js +0 -1
- package/assets/esri/core/workers/chunks/4761cd436abceee858bf.js +0 -1
- package/assets/esri/core/workers/chunks/4de08ead94660025075b.js +0 -1
- package/assets/esri/core/workers/chunks/56f227e1a9e51d1fd742.js +0 -1
- package/assets/esri/core/workers/chunks/5bd451c7db17ee8f0315.js +0 -1
- package/assets/esri/core/workers/chunks/5c34d49a6c9cc34b7626.js +0 -1
- package/assets/esri/core/workers/chunks/62ddd3a82864e26f009a.js +0 -1
- package/assets/esri/core/workers/chunks/703373f529c1c334cfad.js +0 -1
- package/assets/esri/core/workers/chunks/733c32d8091427d84de7.js +0 -1
- package/assets/esri/core/workers/chunks/860552f49f17de2f3353.js +0 -1
- package/assets/esri/core/workers/chunks/9b727f45dfea84357b57.js +0 -1
- package/assets/esri/core/workers/chunks/a05a2c2aaf0c288f9681.js +0 -1
- package/assets/esri/core/workers/chunks/ab76170c374fd67ce8cd.js +0 -1
- package/assets/esri/core/workers/chunks/aebd12488b4004e207a3.js +0 -1
- package/assets/esri/core/workers/chunks/c7b1c6d57603fa385c54.js +0 -1
- package/assets/esri/core/workers/chunks/cd8181600623e18f511c.js +0 -1
- package/assets/esri/core/workers/chunks/cef537fa9705dd1cf685.js +0 -1
- package/assets/esri/core/workers/chunks/d33403d578fbeecaf844.js +0 -1
- package/assets/esri/core/workers/chunks/ddbfa664e69612295785.js +0 -1
- package/assets/esri/core/workers/chunks/ded81c504bf44806ca7d.js +0 -1
- package/assets/esri/core/workers/chunks/e0466387b2ab54d706ca.js +0 -1
- package/assets/esri/core/workers/chunks/ee70be138831cc2a0f56.js +0 -1
- package/assets/esri/core/workers/chunks/efd6ea0966f60ab19520.js +0 -1
- package/assets/esri/core/workers/chunks/f23c4fd014126ea7abc6.js +0 -1
- package/assets/esri/core/workers/chunks/f6e40f3faf0c80cf1b3a.js +0 -1
- package/views/3d/webgl-engine/core/shaderLibrary/shading/WaterColor.glsl.js +0 -70
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{sub as e,normalize as t,len as n,dot as r}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{fromValues as i,create as a}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import o from"../../../../core/Logger.js";import{getOrCreateMapValue as s}from"../../../../core/MapUtils.js";import{fromValues as c,isEmpty as l,containedBySphere as u,setEmpty as d,intersectsSphere as f,intersectsRay as p,copy as m,exactEquals as h}from"../../../../geometry/support/aaBoundingBox.js";import{fromValues as g}from"../../../../geometry/support/aaBoundingRect.js";import{earth as _}from"../../../../geometry/support/Ellipsoid.js";import{ElevationRange as v}from"../../support/ElevationRange.js";function y(e,t){return e?new S(t):new x(t)}class b{constructor(e,t){this.isGlobal=e,this.layerExtent=t,this._rootNode=null,this._intersectionGeneration=0,this._tileMap=new Map}get elevationRange(){return this._rootNode?.subtreeElevationRange}destroy(){this._rootNode?.clear(),this._tileMap.clear()}_nextIntersectionGeneration(){return this._intersectionGeneration++,this._intersectionGeneration}addTile(e){let{obb:t}=e,n=[this._ensureRootNode()],r=[],i=s(this._tileMap,e,()=>new Set),a=t=>{if(i.has(t))return;let n=t.addOwnTile(e);T(r,t.parent,n),i.add(t)};for(;n.length>0;){let r=n.pop(),i=this._getSizeStopLength(r);if(r.treeDepth>=U||A(e.obb)>=.5*i){a(r);continue}let{hPlane:o,vPlane:s}=r,c=t.signedDistancePlane(o.normal,o.distance),l=t.signedDistancePlane(s.normal,s.distance);c===0&&l===0?a(r):w(r,c,l,(e,t)=>{n.push(this._ensureChild(e,t))})}this._propagateSummaryUpdates(r)}removeTile(e){if(!this._rootNode){o.getLogger(`Tiles3DBVH`).error(`Tiles3DBVH: Attempted to remove a tile that is not loaded (no root node)`);return}let t=this._tileMap.get(e);if(!t||t.size===0){o.getLogger(`Tiles3DBVH`).error(`Tiles3DBVH internal error: Attempted to remove a tile that is not loaded (not in tile map)`);return}let n=[];this._tileMap.delete(e);for(let r of t){r.removeOwnTile(e);let t=r.updateOwnSummaries();T(n,r.parent,t)}this._propagateSummaryUpdates(n)}_propagateSummaryUpdates(e){if(e.length===0)return;e.sort((e,t)=>e.node.treeDepth-t.node.treeDepth);let t=new Map,n=-1,r=()=>e.length>0?e[e.length-1].node.treeDepth:-1;for(;e.length>0||t.size>0;){let i=t.size>0?n:r(),a=t;for(t=new Map;e.length>0&&r()===i;){let{node:t,childrenUpdateKind:n}=e.pop();E(a,t,n)}for(let[e,n]of a){let r=0;for(let t=0;t<4;t++){let n=e.children[t];n&&n.isLeaf&&!n.hasTiles&&(n.clear(),e.children[t]=null,r=3)}r|=e.updateSubtreeSummaries(n|r),E(t,e.parent,r)}t.size>0&&(n=i-1)}}forEachTileIntersectingRay(e,t,n,r){r?this._forEachTileIntersectingVerticalRay(e,t,n):this._forEachTileIntersectingRayGeneral(e,t,n)}_forEachTileIntersectingRayGeneral(n,r,i){let a=this._rootNode;if(!a)return;e(B,r,n);let o=t(B,B);if(!a.subtreeIntersectsRay(n,o,{tMin:0,tMax:1/0}))return;let s=this._nextIntersectionGeneration(),c=[a],l=H;l.length=0,l.push(0,1/0);let u={tMin:0,tMax:1/0};for(;c.length>0;){let e=c.pop();u.tMax=l.pop(),u.tMin=l.pop(),e.forEachOwnTileIntersectingRay(n,o,u,s,i);let{hPlane:t,vPlane:r}=e;for(let i=0;i<4;i++){let a=e.children[i];if(a==null)continue;let s=i,d=s===0||s===2,f=s===0||s===1,p=N(n,o,N(n,o,u,r,!d),t,!f);p&&a.subtreeIntersectsRay(n,o,p)&&(c.push(a),l.push(p.tMin,p.tMax))}}}_forEachTileIntersectingVerticalRay(r,i,a){let o=this._rootNode;if(!o)return;e(B,i,r);let s=t(B,B),c={tMin:0,tMax:this.isGlobal?n(r):1/0};if(!o.subtreeIntersectsRay(r,s,c))return;let l=this._nextIntersectionGeneration(),u=[o];for(;u.length>0;){let e=u.pop();e.forEachOwnTileIntersectingRay(r,s,c,l,a),e.isLeaf||w(e,k(e.hPlane,r),k(e.vPlane,r),(e,t)=>{let n=e.children[t];n&&n.subtreeIntersectsRay(r,s,c)&&u.push(n)},1)}}getElevationRangeIntersectingSphere(e){let t=this._rootNode;if(!t||!t.subtreeIntersectsSphere(e))return null;let n=this._nextIntersectionGeneration(),r=new v,i=[t];for(;i.length>0;){let t=i.pop();if(!r.contains(t.subtreeElevationRange)){if(t.subtreeContainedBySphere(e))r.expandElevationRange(t.subtreeElevationRange);else{if(t.ownIntersectsSphere(e))for(let i of t.ownTiles){if(i.bvhIntersectionGeneration===n||(i.bvhIntersectionGeneration=n,!(i.boundingVolumeIntersectsSphere?.(e)??i.obb.intersectSphere(e))))continue;let t=i.elevationRange;r.contains(t)||r.expandElevationRange(t)}t.isLeaf||w(t,O(e.center,e.radius,t.hPlane),O(e.center,e.radius,t.vPlane),(t,n)=>{let a=t.children[n];if(a&&a.subtreeIntersectsSphere(e)){if(r.contains(a.subtreeElevationRange))return;i.push(a)}})}}}return r.isEmpty?null:r}}class x extends b{constructor(e){super(!1,e)}_getSizeStopLength(e){return e.sideLength}_ensureRootNode(){if(!this._rootNode){let e=this.layerExtent,t=Math.max(Math.abs(e[0]),Math.abs(e[1]),Math.abs(e[2]),Math.abs(e[3])),n=2**Math.max(1,Math.ceil(Math.log2(t))),r=new C(null,0,g(-n,-n,n,n),new D(i(0,1,0),0),new D(i(1,0,0),0),n*2,c(-n,-n,-1/0,n,n,1/0));this._rootNode=r}return this._rootNode}_ensureChild(e,t){if(e.treeDepth>=U){let e=`Internal error: attempted to create a child node for a node that is already at max depth`;throw o.getLogger(`Tiles3DBVH`).error(e),Error(e)}let n=e.children[t];if(n===null){let{extent:r,hPlane:i,vPlane:a,treeDepth:o,sideLength:s}=e,l=.5*(r[0]+r[2]),u=.5*(r[1]+r[3]),d=t===0||t===1,f=t===2||t===0,p=g(f?r[0]:l,d?r[1]:u,f?l:r[2],d?u:r[3]),m=new D(i.normal,-.5*(p[1]+p[3])),h=new D(a.normal,-.5*(p[0]+p[2]));n=new C(e,o+1,p,m,h,s*.5,c(p[0],p[1],-1/0,p[2],p[3],1/0)),e.children[t]=n}return n}}class S extends b{constructor(e){super(!0,e)}_getSizeStopLength(e){return M(e.extent)}_ensureRootNode(){if(!this._rootNode){let e=new C(null,0,g(-Math.PI,-Math.PI/2,Math.PI,Math.PI/2),new D(i(0,0,1),0),new D(i(0,1,0),0),Math.PI*_.radius);this._rootNode=e}return this._rootNode}_ensureChild(e,t){if(e.treeDepth>=U){let e=`Attempted to create a child node for a node that is already at max depth`;throw o.getLogger(`Tiles3DBVH`).error(e),Error(e)}let n=e.children[t];if(n===null){let{extent:r,treeDepth:a}=e,o=.5*(r[0]+r[2]),s=.5*(r[1]+r[3]),c=t===0||t===1,l=t===2||t===0,u=g(l?r[0]:o,c?r[1]:s,l?o:r[2],c?s:r[3]),d=.5*(u[0]+u[2]),f=.5*(u[1]+u[3]),p=Math.cos(d),m=Math.sin(d),h=Math.cos(f),_=Math.sin(f),v=i(-_*p,-_*m,h),y=new D(v,0),b=new D(i(-m,p,0),0),x=j(u);n=new C(e,a+1,u,y,b,x),e.children[t]=n}return n}}class C{constructor(e,t,n,r,i,a,o){this.parent=e,this._treeDepth=t,this.extent=n,this.hPlane=r,this.vPlane=i,this.sideLength=a,this.bounds=o,this._ownAABB=c(1/0,1/0,1/0,-1/0,-1/0,-1/0),this._subtreeAABB=c(1/0,1/0,1/0,-1/0,-1/0,-1/0),this._ownElevationRange=new v,this._subtreeElevationRange=new v,this._ownTiles=[],this.children=[null,null,null,null]}get subtreeAABB(){return this._subtreeAABB}get subtreeElevationRange(){return this._subtreeElevationRange}subtreeContainedBySphere(e){let t=this._subtreeAABB;return l(t)?!0:u(t,e)}clear(){for(let e=0;e<4;e++)this.children[e]?.clear(),this.children[e]=null;this._ownTiles.length=0,d(this._ownAABB),d(this._subtreeAABB),this._ownElevationRange.initializeEmpty(),this._subtreeElevationRange.initializeEmpty()}get isLeaf(){return this.children.every(e=>e==null)}get treeDepth(){return this._treeDepth}subtreeIntersectsSphere(e){return f(this.subtreeAABB,e)}ownIntersectsSphere(e){return this.hasTiles&&f(this._ownAABB,e)}subtreeIntersectsRay(e,t,n){return p(this._subtreeAABB,e,t,n)}ownIntersectsRay(e,t,n){return this.hasTiles?p(this._ownAABB,e,t,n):null}forEachOwnTileIntersectingRay(e,t,n,r,i){if(this.ownIntersectsRay(e,t,n))for(let n of this.ownTiles)n.bvhIntersectionGeneration!==r&&(n.bvhIntersectionGeneration=r,(n.boundingVolumeIntersectsRay?.(e,t)??n.obb.intersectRay(e,t))&&i(n))}addOwnTile(e){this._ownTiles.push(e);let t=P(this._ownAABB,e,this.bounds)&&F(this._subtreeAABB,this._ownAABB,this.bounds),n=this._ownElevationRange.expandElevationRange(e.elevationRange)&&this._subtreeElevationRange.expandElevationRange(e.elevationRange);return!!t|(n?2:0)}removeOwnTile(e){let t=this._ownTiles,n=t.indexOf(e);if(n===-1){o.getLogger(`Tiles3DBVH`).error(`BVNode: Attempted to remove a tile that is not in the node`);return}let r=t.length-1;n<r&&(t[n]=t[r]),t.length=r}updateOwnSummaries(){let e=I(this._ownAABB,this.ownTiles,this.bounds),t=L(this._ownElevationRange,this.ownTiles),n=!!e|(t?2:0);return this.updateSubtreeSummaries(n)}updateSubtreeSummaries(e){if(this.isLeaf&&!this.hasTiles)return d(this._subtreeAABB),this._subtreeElevationRange.initializeEmpty(),3;let t=0;if(e&1){m(R,this._subtreeAABB),d(this._subtreeAABB),F(this._subtreeAABB,this._ownAABB,this.bounds);for(let e of this.children)e&&F(this._subtreeAABB,e.subtreeAABB,this.bounds);h(this._subtreeAABB,R)||(t|=1)}if(e&2){z.setElevationRange(this._subtreeElevationRange),this._subtreeElevationRange.initializeEmpty(),this._subtreeElevationRange.expandElevationRange(this._ownElevationRange);for(let e of this.children)e&&this._subtreeElevationRange.expandElevationRange(e.subtreeElevationRange);this._subtreeElevationRange.equals(z)||(t|=2)}return t}get ownTiles(){return this._ownTiles}get hasTiles(){return this._ownTiles.length>0}}function w(e,t,n,r,i=1e-12){t<=i&&(n<=i&&r(e,0),n>=-i&&r(e,1)),t>=-i&&(n<=i&&r(e,2),n>=-i&&r(e,3))}function T(e,t,n){t!=null&&n!==0&&e.push({node:t,childrenUpdateKind:n})}function E(e,t,n){if(t==null||n===0)return;let r=e.get(t)??0;e.set(t,r|n)}class D{constructor(e=[0,0,0],t=0){this.normal=e,this.distance=t}}function O(e,t,n){let i=r(n.normal,e)+n.distance;return i<0?Math.min(i+t,0):Math.max(i-t,0)}function k(e,t){return r(e.normal,t)+e.distance}function A(e){return 2*Math.max(e.halfSizeX,e.halfSizeY,e.halfSizeZ)}function j(e){let t=Math.abs(e[2]-e[0]),n=Math.abs(e[3]-e[1]),r=.5*(e[1]+e[3]),i=_.radius*Math.abs(Math.cos(r))*t,a=_.radius*n;return Math.max(i,a)}function M(e){let t=Math.abs(e[2]-e[0]),n=Math.abs(e[3]-e[1]),r=.5*(e[1]+e[3]),i=_.radius*Math.abs(Math.cos(r))*t,a=_.radius*n;return Math.min(i,a)}function N(e,t,n,i,a){if(!n)return null;let o=1e-12,s=r(i.normal,t),c=k(i,e)+n.tMin*s;if(Math.abs(s)<o)return(a?c>=-1e-12:c<=o)?n:null;let l=n.tMin-c/s,u=a===s>0?{tMin:Math.max(n.tMin,l),tMax:n.tMax}:{tMin:n.tMin,tMax:Math.min(n.tMax,l)};return u.tMin<=u.tMax?u:null}function P(e,t,n){let{obb:r}=t,a=[i(1,0,0),i(0,1,0),i(0,0,1)],o=r.getCenter(V),s=!1;for(let t=0;t<3;t++){let i=r.projectedRadius(a[t]),c=Math.max(n?.[t]??-1/0,o[t]-i),l=Math.min(n?.[t+3]??1/0,o[t]+i);c<e[t]&&(e[t]=c,s=!0),l>e[t+3]&&(e[t+3]=l,s=!0)}return s}function F(e,t,n){if(l(t))return!1;let r=!1;for(let i=0;i<3;i++){let a=Math.max(n?.[i]??-1/0,t[i]),o=Math.min(n?.[i+3]??1/0,t[i+3]);a<e[i]&&(e[i]=a,r=!0),o>e[i+3]&&(e[i+3]=o,r=!0)}return r}function I(e,t,n){m(R,e),d(e);for(let r of t)P(e,r,n);return!h(e,R)}function L(e,t){z.setElevationRange(e),e.initializeEmpty();for(let n of t)e.expandElevationRange(n.elevationRange);return!e.equals(z)}const R=c(0,0,0,0,0,0),z=new v,B=a(),V=a(),H=[],U=30;export{y as createTileBVH};
|
|
2
|
+
import{sub as e,normalize as t,len as n,dot as r}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{fromValues as i,create as a}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import o from"../../../../core/Logger.js";import{getOrCreateMapValue as s}from"../../../../core/MapUtils.js";import{fromValues as c,isEmpty as l,containedBySphere as u,setEmpty as d,intersectsSphere as f,intersectsRay as p,copy as m,exactEquals as h}from"../../../../geometry/support/aaBoundingBox.js";import{fromValues as g}from"../../../../geometry/support/aaBoundingRect.js";import{earth as _}from"../../../../geometry/support/Ellipsoid.js";import{ElevationRange as v}from"../../support/ElevationRange.js";function y(e,t){return e?new S(t):new x(t)}class b{constructor(e,t){this.isGlobal=e,this.layerExtent=t,this._rootNode=null,this._intersectionGeneration=0,this._tileMap=new Map}get elevationRange(){return this._rootNode?.subtreeElevationRange}destroy(){this._rootNode?.clear(),this._tileMap.clear()}_nextIntersectionGeneration(){return this._intersectionGeneration++,this._intersectionGeneration}addTile(e){let{obb:t}=e,n=[this._ensureRootNode()],r=[],i=s(this._tileMap,e,()=>new Set),a=t=>{if(i.has(t))return;let n=t.addOwnTile(e);T(r,t.parent,n),i.add(t)};for(;n.length>0;){let r=n.pop(),i=this._getSizeStopLength(r);if(r.treeDepth>=U||A(e.obb)>=.5*i){a(r);continue}let{hPlane:o,vPlane:s}=r,c=t.signedDistancePlane(o.normal,o.distance),l=t.signedDistancePlane(s.normal,s.distance);c===0&&l===0?a(r):w(r,c,l,(e,t)=>{n.push(this._ensureChild(e,t))})}this._propagateSummaryUpdates(r)}removeTile(e){if(!this._rootNode){o.getLogger(`Tiles3DBVH`).error(`Tiles3DBVH: Attempted to remove a tile that is not loaded (no root node)`);return}let t=this._tileMap.get(e);if(!t||t.size===0){o.getLogger(`Tiles3DBVH`).error(`Tiles3DBVH internal error: Attempted to remove a tile that is not loaded (not in tile map)`);return}let n=[];this._tileMap.delete(e);for(let r of t){r.removeOwnTile(e);let t=r.updateOwnSummaries();T(n,r.parent,t)}this._propagateSummaryUpdates(n)}_propagateSummaryUpdates(e){if(e.length===0)return;e.sort((e,t)=>e.node.treeDepth-t.node.treeDepth);let t=new Map,n=-1,r=()=>e.length>0?e[e.length-1].node.treeDepth:-1;for(;e.length>0||t.size>0;){let i=t.size>0?n:r(),a=t;for(t=new Map;e.length>0&&r()===i;){let{node:t,childrenUpdateKind:n}=e.pop();E(a,t,n)}for(let[e,n]of a){let r=0;for(let t=0;t<4;t++){let n=e.children[t];n&&n.isLeaf&&!n.hasTiles&&(n.clear(),e.children[t]=null,r=3)}r|=e.updateSubtreeSummaries(n|r),E(t,e.parent,r)}t.size>0&&(n=i-1)}}forEachTileIntersectingRay(e,t,n,r){return r?this._forEachTileIntersectingVerticalRay(e,t,n):this._forEachTileIntersectingRayGeneral(e,t,n)}_forEachTileIntersectingRayGeneral(n,r,i){let a=this._rootNode;if(!a)return!0;e(B,r,n);let o=t(B,B);if(!a.subtreeIntersectsRay(n,o,{tMin:0,tMax:1/0}))return!0;let s=this._nextIntersectionGeneration(),c=[a],l=H;l.length=0,l.push(0,1/0);let u={tMin:0,tMax:1/0};for(;c.length>0;){let e=c.pop();if(u.tMax=l.pop(),u.tMin=l.pop(),!e.forEachOwnTileIntersectingRay(n,o,u,s,i))return!1;let{hPlane:t,vPlane:r}=e;for(let i=0;i<4;i++){let a=e.children[i];if(a==null)continue;let s=i,d=s===0||s===2,f=s===0||s===1,p=N(n,o,N(n,o,u,r,!d),t,!f);p&&a.subtreeIntersectsRay(n,o,p)&&(c.push(a),l.push(p.tMin,p.tMax))}}return!0}_forEachTileIntersectingVerticalRay(r,i,a){let o=this._rootNode;if(!o)return!0;e(B,i,r);let s=t(B,B),c={tMin:0,tMax:this.isGlobal?n(r):1/0};if(!o.subtreeIntersectsRay(r,s,c))return!0;let l=this._nextIntersectionGeneration(),u=[o];for(;u.length>0;){let e=u.pop();if(!e.forEachOwnTileIntersectingRay(r,s,c,l,a))return!1;e.isLeaf||w(e,k(e.hPlane,r),k(e.vPlane,r),(e,t)=>{let n=e.children[t];n&&n.subtreeIntersectsRay(r,s,c)&&u.push(n)},1)}return!0}getElevationRangeIntersectingSphere(e){let t=this._rootNode;if(!t||!t.subtreeIntersectsSphere(e))return null;let n=this._nextIntersectionGeneration(),r=new v,i=[t];for(;i.length>0;){let t=i.pop();if(!r.contains(t.subtreeElevationRange)){if(t.subtreeContainedBySphere(e))r.expandElevationRange(t.subtreeElevationRange);else{if(t.ownIntersectsSphere(e))for(let i of t.ownTiles){if(i.bvhIntersectionGeneration===n||(i.bvhIntersectionGeneration=n,!(i.boundingVolumeIntersectsSphere?.(e)??i.obb.intersectSphere(e))))continue;let t=i.elevationRange;r.contains(t)||r.expandElevationRange(t)}t.isLeaf||w(t,O(e.center,e.radius,t.hPlane),O(e.center,e.radius,t.vPlane),(t,n)=>{let a=t.children[n];if(a&&a.subtreeIntersectsSphere(e)){if(r.contains(a.subtreeElevationRange))return;i.push(a)}})}}}return r.isEmpty?null:r}}class x extends b{constructor(e){super(!1,e)}_getSizeStopLength(e){return e.sideLength}_ensureRootNode(){if(!this._rootNode){let e=this.layerExtent,t=Math.max(Math.abs(e[0]),Math.abs(e[1]),Math.abs(e[2]),Math.abs(e[3])),n=2**Math.max(1,Math.ceil(Math.log2(t))),r=new C(null,0,g(-n,-n,n,n),new D(i(0,1,0),0),new D(i(1,0,0),0),n*2,c(-n,-n,-1/0,n,n,1/0));this._rootNode=r}return this._rootNode}_ensureChild(e,t){if(e.treeDepth>=U){let e=`Internal error: attempted to create a child node for a node that is already at max depth`;throw o.getLogger(`Tiles3DBVH`).error(e),Error(e)}let n=e.children[t];if(n===null){let{extent:r,hPlane:i,vPlane:a,treeDepth:o,sideLength:s}=e,l=.5*(r[0]+r[2]),u=.5*(r[1]+r[3]),d=t===0||t===1,f=t===2||t===0,p=g(f?r[0]:l,d?r[1]:u,f?l:r[2],d?u:r[3]),m=new D(i.normal,-.5*(p[1]+p[3])),h=new D(a.normal,-.5*(p[0]+p[2]));n=new C(e,o+1,p,m,h,s*.5,c(p[0],p[1],-1/0,p[2],p[3],1/0)),e.children[t]=n}return n}}class S extends b{constructor(e){super(!0,e)}_getSizeStopLength(e){return M(e.extent)}_ensureRootNode(){if(!this._rootNode){let e=new C(null,0,g(-Math.PI,-Math.PI/2,Math.PI,Math.PI/2),new D(i(0,0,1),0),new D(i(0,1,0),0),Math.PI*_.radius);this._rootNode=e}return this._rootNode}_ensureChild(e,t){if(e.treeDepth>=U){let e=`Attempted to create a child node for a node that is already at max depth`;throw o.getLogger(`Tiles3DBVH`).error(e),Error(e)}let n=e.children[t];if(n===null){let{extent:r,treeDepth:a}=e,o=.5*(r[0]+r[2]),s=.5*(r[1]+r[3]),c=t===0||t===1,l=t===2||t===0,u=g(l?r[0]:o,c?r[1]:s,l?o:r[2],c?s:r[3]),d=.5*(u[0]+u[2]),f=.5*(u[1]+u[3]),p=Math.cos(d),m=Math.sin(d),h=Math.cos(f),_=Math.sin(f),v=i(-_*p,-_*m,h),y=new D(v,0),b=new D(i(-m,p,0),0),x=j(u);n=new C(e,a+1,u,y,b,x),e.children[t]=n}return n}}class C{constructor(e,t,n,r,i,a,o){this.parent=e,this._treeDepth=t,this.extent=n,this.hPlane=r,this.vPlane=i,this.sideLength=a,this.bounds=o,this._ownAABB=c(1/0,1/0,1/0,-1/0,-1/0,-1/0),this._subtreeAABB=c(1/0,1/0,1/0,-1/0,-1/0,-1/0),this._ownElevationRange=new v,this._subtreeElevationRange=new v,this._ownTiles=[],this.children=[null,null,null,null]}get subtreeAABB(){return this._subtreeAABB}get subtreeElevationRange(){return this._subtreeElevationRange}subtreeContainedBySphere(e){let t=this._subtreeAABB;return l(t)?!0:u(t,e)}clear(){for(let e=0;e<4;e++)this.children[e]?.clear(),this.children[e]=null;this._ownTiles.length=0,d(this._ownAABB),d(this._subtreeAABB),this._ownElevationRange.initializeEmpty(),this._subtreeElevationRange.initializeEmpty()}get isLeaf(){return this.children.every(e=>e==null)}get treeDepth(){return this._treeDepth}subtreeIntersectsSphere(e){return f(this.subtreeAABB,e)}ownIntersectsSphere(e){return this.hasTiles&&f(this._ownAABB,e)}subtreeIntersectsRay(e,t,n){return p(this._subtreeAABB,e,t,n)}ownIntersectsRay(e,t,n){return this.hasTiles?p(this._ownAABB,e,t,n):null}forEachOwnTileIntersectingRay(e,t,n,r,i){if(!this.ownIntersectsRay(e,t,n))return!0;for(let n of this.ownTiles)if(n.bvhIntersectionGeneration!==r&&(n.bvhIntersectionGeneration=r,(n.boundingVolumeIntersectsRay?.(e,t)??n.obb.intersectRay(e,t))&&i(n)===!1))return!1;return!0}addOwnTile(e){this._ownTiles.push(e);let t=P(this._ownAABB,e,this.bounds)&&F(this._subtreeAABB,this._ownAABB,this.bounds),n=this._ownElevationRange.expandElevationRange(e.elevationRange)&&this._subtreeElevationRange.expandElevationRange(e.elevationRange);return!!t|(n?2:0)}removeOwnTile(e){let t=this._ownTiles,n=t.indexOf(e);if(n===-1){o.getLogger(`Tiles3DBVH`).error(`BVNode: Attempted to remove a tile that is not in the node`);return}let r=t.length-1;n<r&&(t[n]=t[r]),t.length=r}updateOwnSummaries(){let e=I(this._ownAABB,this.ownTiles,this.bounds),t=L(this._ownElevationRange,this.ownTiles),n=!!e|(t?2:0);return this.updateSubtreeSummaries(n)}updateSubtreeSummaries(e){if(this.isLeaf&&!this.hasTiles)return d(this._subtreeAABB),this._subtreeElevationRange.initializeEmpty(),3;let t=0;if(e&1){m(R,this._subtreeAABB),d(this._subtreeAABB),F(this._subtreeAABB,this._ownAABB,this.bounds);for(let e of this.children)e&&F(this._subtreeAABB,e.subtreeAABB,this.bounds);h(this._subtreeAABB,R)||(t|=1)}if(e&2){z.setElevationRange(this._subtreeElevationRange),this._subtreeElevationRange.initializeEmpty(),this._subtreeElevationRange.expandElevationRange(this._ownElevationRange);for(let e of this.children)e&&this._subtreeElevationRange.expandElevationRange(e.subtreeElevationRange);this._subtreeElevationRange.equals(z)||(t|=2)}return t}get ownTiles(){return this._ownTiles}get hasTiles(){return this._ownTiles.length>0}}function w(e,t,n,r,i=1e-12){t<=i&&(n<=i&&r(e,0),n>=-i&&r(e,1)),t>=-i&&(n<=i&&r(e,2),n>=-i&&r(e,3))}function T(e,t,n){t!=null&&n!==0&&e.push({node:t,childrenUpdateKind:n})}function E(e,t,n){if(t==null||n===0)return;let r=e.get(t)??0;e.set(t,r|n)}class D{constructor(e=[0,0,0],t=0){this.normal=e,this.distance=t}}function O(e,t,n){let i=r(n.normal,e)+n.distance;return i<0?Math.min(i+t,0):Math.max(i-t,0)}function k(e,t){return r(e.normal,t)+e.distance}function A(e){return 2*Math.max(e.halfSizeX,e.halfSizeY,e.halfSizeZ)}function j(e){let t=Math.abs(e[2]-e[0]),n=Math.abs(e[3]-e[1]),r=.5*(e[1]+e[3]),i=_.radius*Math.abs(Math.cos(r))*t,a=_.radius*n;return Math.max(i,a)}function M(e){let t=Math.abs(e[2]-e[0]),n=Math.abs(e[3]-e[1]),r=.5*(e[1]+e[3]),i=_.radius*Math.abs(Math.cos(r))*t,a=_.radius*n;return Math.min(i,a)}function N(e,t,n,i,a){if(!n)return null;let o=1e-12,s=r(i.normal,t),c=k(i,e)+n.tMin*s;if(Math.abs(s)<o)return(a?c>=-1e-12:c<=o)?n:null;let l=n.tMin-c/s,u=a===s>0?{tMin:Math.max(n.tMin,l),tMax:n.tMax}:{tMin:n.tMin,tMax:Math.min(n.tMax,l)};return u.tMin<=u.tMax?u:null}function P(e,t,n){let{obb:r}=t,a=[i(1,0,0),i(0,1,0),i(0,0,1)],o=r.getCenter(V),s=!1;for(let t=0;t<3;t++){let i=r.projectedRadius(a[t]),c=Math.max(n?.[t]??-1/0,o[t]-i),l=Math.min(n?.[t+3]??1/0,o[t]+i);c<e[t]&&(e[t]=c,s=!0),l>e[t+3]&&(e[t+3]=l,s=!0)}return s}function F(e,t,n){if(l(t))return!1;let r=!1;for(let i=0;i<3;i++){let a=Math.max(n?.[i]??-1/0,t[i]),o=Math.min(n?.[i+3]??1/0,t[i+3]);a<e[i]&&(e[i]=a,r=!0),o>e[i+3]&&(e[i+3]=o,r=!0)}return r}function I(e,t,n){m(R,e),d(e);for(let r of t)P(e,r,n);return!h(e,R)}function L(e,t){z.setElevationRange(e),e.initializeEmpty();for(let n of t)e.expandElevationRange(n.elevationRange);return!e.equals(z)}const R=c(0,0,0,0,0,0),z=new v,B=a(),V=a(),H=[],U=30;export{y as createTileBVH};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{create as e}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ElevationRange as t}from"../../support/ElevationRange.js";import{IntersectorResultRay as n}from"../../webgl-engine/lib/IntersectorResult.js";import{MeshIntersectionOptions as r,computeInvDir as i,intersectAabbInvDir as a}from"../../webgl-engine/lib/RayIntersections.js";import{Tiles3DTarget as o}from"../i3s/Intersector.js";import{createTileBVHForLayer as s}from"./createTileBVHForLayer.js";class c{constructor(e,t){this.layerView=e,this.integratedMeshSemantics=t,this.type=8,this.slicePlaneEnabled=!1,this.layerViewUid=e.uid,this._bvh=s(e)}destroy(){this._bvh.destroy()}addTile(e){this._bvh.addTile(e)}removeTile(e){this._bvh.removeTile(e)}get isGround(){return this.integratedMeshSemantics.shouldIntersectAsGround}intersectRay(e,t,s,c,u,d){if(e.options.filteredLayerViewUids.includes(this.layerView.uid))return;let{results:
|
|
2
|
+
import{create as e}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ElevationRange as t}from"../../support/ElevationRange.js";import{IntersectorResultRay as n}from"../../webgl-engine/lib/IntersectorResult.js";import{MeshIntersectionOptions as r,computeInvDir as i,intersectAabbInvDir as a}from"../../webgl-engine/lib/RayIntersections.js";import{Tiles3DTarget as o}from"../i3s/Intersector.js";import{createTileBVHForLayer as s}from"./createTileBVHForLayer.js";class c{constructor(e,t){this.layerView=e,this.integratedMeshSemantics=t,this.type=8,this.slicePlaneEnabled=!1,this.layerViewUid=e.uid,this._bvh=s(e)}destroy(){this._bvh.destroy()}addTile(e){this._bvh.addTile(e)}removeTile(e){this._bvh.removeTile(e)}get isGround(){return this.integratedMeshSemantics.shouldIntersectAsGround}intersectRay(e,t,s,c,u,d,f){if(e.options.filteredLayerViewUids.includes(this.layerView.uid))return!0;let{results:p,tolerance:m}=e,h=e.options.store===2,{componentObjectCollection:g}=this.layerView.view.stage.renderView,_=new r(m,d,e.options.normalRequired,f),v=i(s,c,l),y=(r,i,a)=>{if(i<0||t!=null&&!t(s,c,r))return;let l=e=>{let t=new o(this.layerView.uid);e.set(this.type,t,r,i,a)};if(this.isGround&&(p.ground.renderDistance==null||i<p.ground.renderDistance)&&l(p.ground),!e.options.isFiltered&&((p.min.renderDistance==null||i<p.min.renderDistance)&&l(p.min),(p.max.renderDistance==null||i>p.max.renderDistance)&&l(p.max),h)){let t=new n(e.ray);l(t),e.results.all.push(t)}};return this._bvh.forEachTileIntersectingRay(s,c,e=>{let{componentObjects:t}=e;for(let e of t)if(a(e.aabbInWorldCoordinates,s,v,0)&&!g.intersectRay(e,s,c,null,_,y))return!1;return!0},d)}get elevationRange(){let e=this._bvh.elevationRange;return e!=null&&!e.isEmpty?new t(e.minElevation,e.maxElevation):null}getElevationRange(e){return this._bvh.getElevationRangeIntersectingSphere(e)??new t(0,0)}}const l=e();export{c as Tiles3DMeshIntersectionHandler};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{set as e}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{fromValues as t}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{add as n,normalize as r,dot as i,distance as a}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as o,clone as s}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{lerp as c}from"../../../../core/mathUtils.js";import l from"../../../../core/PooledArray.js";import{castRenderScreenPointArray3 as u,createRenderScreenPointArray3 as d,createScreenPointArray as f}from"../../../../core/screenUtils.js";import{getMetersPerVerticalUnitForSR as p}from"../../../../core/units.js";import{create as m,copy as h,negativeInfinity as g,expandWithNestedArray as _}from"../../../../geometry/support/aaBoundingRect.js";import{createSpatialReferenceCyclical as v}from"../../../../geometry/support/normalizeUtils.js";import{create as y}from"../../../../geometry/support/ray.js";import{sv3d as b}from"../../../../geometry/support/vectorStacks.js";import{getElevationOffsetInMeters as x}from"../../../../support/elevationInfoUtils.js";import{TaskPriority as S}from"../../../support/Scheduler.js";import{g as C}from"../../../../chunks/cameraUtilsSpherical.js";import{fromRenderAtEye as w,fromScreen as T}from"../../support/geometryUtils/ray.js";import{computeMapPointFromVec3d as E}from"../../support/hitTest.js";import{defaultTolerance as D,Intersector as O,defaultScreenPolygonPrimitiveProcessor as k}from"../../webgl-engine/lib/Intersector.js";import{RayIntersectionQuery as A,DrapedScreenPolygonIntersectionQuery as j}from"../../webgl-engine/lib/IntersectorInterfaces.js";import{isValidIntersectorResult as M}from"../../webgl-engine/lib/IntersectorResult.js";import{SliceScreenPolygonPrimitiveProcessor as N,createSliceExtrusionHalfspacePlanes as P,clipPolygonAgainstSlicedAwayHalfspaces as F,sliceFilterPredicate as I}from"../../webgl-engine/lib/intersectorUtils.js";import{prepareScreenPolygonIntersectionQuery as L}from"../../webgl-engine/lib/screenPolygonIntersectionUtils.js";class R{constructor(e,t,n){this.isGlobal=e,this._forEachLayer=t,this._view=n,this._externalIntersectionHandlers=new l,this._tolerance=D,this._tmpRay=y(),this._tmpRegion=m(),this._validateHUDIntersector=new O(this.isGlobal),this._validateHUDIntersector.options.hud=!1,this._screenPolygonIntersectionTask=this._view.resourceController.scheduler.registerTask(S.SCREEN_POLYGON_INTERSECTION)}destroy(){this._screenPolygonIntersectionTask.remove(),this._externalIntersectionHandlers.prune()}get screenPolygonIntersectionTask(){return this._screenPolygonIntersectionTask}intersectScreen(e,t,n){return this.intersectRay(this._getPickRay(e,this._tmpRay),H(this.isGlobal),t,n)}intersectScreenFreePointFallback(e,t,n){return this.intersectRayFreePointFallback(this._getPickRay(e,this._tmpRay),t,n)}intersectRayFreePointFallback(e,t,n){return this.intersectRay(e,H(this.isGlobal),t,n)||this._intersectRayFreePointLocal(e,t)}intersectRay(e,t,n,r){return t.options.selectionMode=!1,t.options.store=0,this.computeIntersection(e,t,!1,r),t.results.min?t.results.min.getIntersectionPoint(n):!1}getCenterRayWithSubpixelOffset(e,t,n=.5,r=.5){return e.getRenderCenter(Z,n,r),Z[0]+=.0466,Z[1]-=.0123,w(e,Z,t)}intersectIntersectorScreen(e,t,n){this.computeIntersection(this._getPickRay(e,this._tmpRay),t,!1,n)}async intersectIntersectorScreenPolygon(e,t,n){t.polygonResults.init();let r=this._view.state.camera,i=await L(r,e);i!=null&&await this._screenPolygonIntersectionTask.scheduleGenerator(e=>this._intersectIntersectorScreenPolygon(r,t,i,n,e))}*_intersectIntersectorScreenPolygon(e,t,n,r,i){let a=new U(r,this._forEachLayer);t.options.selectOpaqueTerrainOnly=!r||!(`include`in r||`exclude`in r),t.camera=e,t.metersPerRenderUnit=this._view.renderCoordsHelper.unitInMeters,t.point=null,t.screenPolygonPrimitiveProcessor=k,yield*t.intersectScreenPolygon(a.layers,n);let o=this._view.slice.plane,s=o?new N(o):null;t.screenPolygonPrimitiveProcessor=s??k,yield*t.intersectScreenPolygon(a.sliceableLayers,n),t.screenPolygonPrimitiveProcessor=k,yield*this._intersectPolygonHandlersGenerator(t,a,n,null,s,void 0,!0,i),yield*this._intersectDrapedScreenPolygon(t,a,n,r),yield*t.intersectHUDScreenPolygon(a.layers,n),t.screenPolygonPrimitiveProcessor=s??k,yield*t.intersectHUDScreenPolygon(a.sliceableLayers,n),t.polygonResults.sortResults()}intersectToolIntersectorScreen(e,t,n){let r=this._getPickRay(e,this._tmpRay);this.intersectToolIntersectorRay(r,t,n)}intersectToolIntersectorRay(e,t,n){t.options.selectionMode=!0,this.computeIntersection(e,t,!1,n);let r=t.results.min;this._view.groundView.opaque||M(r)&&r.intersector!==7||(t.options.selectionMode=!1,this.computeIntersection(e,t,!1,n))}setTolerance(e=D){this._tolerance=e}addIntersectionHandler(e){this._externalIntersectionHandlers.push(e),this._externalIntersectionHandlers.sort((e,t)=>e.type===7?1:t.type===7?-1:0)}removeIntersectionHandler(e){this._externalIntersectionHandlers.removeUnordered(e)!=null&&this._externalIntersectionHandlers.sort((e,t)=>e.type===7?1:t.type===7?-1:0)}_getPickRay(e,t){let n=this._view.state.camera;return T(n,e,t)}_intersectRayFreePointLocal(e,t){return this.isGlobal||e==null||n(t,e.origin,r(b.get(),e.direction)),!1}intersectElevationFromScreen(e,t,n=0,r=null){return this._intersectElevation(this._getPickRay(e,this._tmpRay),t,n,r)}_intersectElevation(e,t,n=0,a=null){if(e==null)return null;let o=this._view,{renderCoordsHelper:s}=o,c=p(o.spatialReference),l=t==null?`absolute-height`:t.mode,d=x(t)/c,f=(l===`on-the-ground`?0:d+n)*c/s.unitInMeters,{camera:m}=o.state;if(l===`absolute-height`){let t=s.getAltitude(m.eye),n=i(r(K,e.direction),s.worldUpAtPosition(m.eye,q));if(t<f&&n<0||t>=f&&n>0)return null;if(s.intersectInfiniteManifold(e,f,K)){let e=E(o,K);return e.z??=0,e.z-=d,e}return null}let h=m.projectToRenderScreen(e.origin,u(b.get())),g=new U(null,this._forEachLayer),_=o.slice.plane,v=_?I(_):null,y=new O(this.isGlobal);y.options.store=0,y.options.verticalOffset=f,y.options.normalRequired=!1;let S=this._createRayIntersectionQuery(e,h,!1);y.metersPerRenderUnit=this._view.renderCoordsHelper.unitInMeters,y.reset(S.beginPoint,S.endPoint,m),y.point=h;let C=null;if(a&&`type`in a&&a.type===`graphics`){let e=o.allLayerViews.find(e=>e.layer===a)?.uid;C=e?t=>t.layerViewUid===e:null}else a&&(C=e=>e.graphicUid!==a.uid);switch(l){case`relative-to-scene`:y.intersect(g.layers,S.screenPoint,this._tolerance,null,e=>(!C||C(e))&&!!e.lastValidElevationBB),this._intersectRayHandlers(y,g,S,v,!1,e=>e.type===2||e.type===7||e.type===8,!1);break;case`on-the-ground`:case`relative-to-ground`:this._intersectRayHandlers(y,g,S,v,!1,e=>e.isGround,!1)}if(y.results.min.getIntersectionPoint(K)){let e=E(o,K);return e.z=n,e}return null}computeIntersection(e,t,n,r){if(e==null)return;let i=this._view.state.camera,a=i.projectToRenderScreen(e.origin,u(b.get())),o=new U(r,this._forEachLayer);t.options.selectOpaqueTerrainOnly=!r||!(`include`in r||`exclude`in r);let s=this._createRayIntersectionQuery(e,a,n);t.metersPerRenderUnit=this._view.renderCoordsHelper.unitInMeters,t.reset(s.beginPoint,s.endPoint,i),t.intersect(o.layers,s.screenPoint,this._tolerance,null,o.objectFilter);let c=this._view.slice.plane,l=c?I(c):null;t.intersect(o.sliceableLayers,s.screenPoint,this._tolerance,l,o.objectFilter);let d=r&&(r.requiresGroundFeedback||r.enableDraped);this._intersectRayHandlers(t,o,s,l,!!d,e=>o.allowedIntersectorTypes==null||o.allowedIntersectorTypes.has(e.type));let f=b.get(),p=this._view,m=p.groundView.spatialReference;if(r&&r.enableDraped&&m!=null&&t.results.ground.getIntersectionPoint(f)){let e=p.overlayManager.renderer,n=p.renderCoordsHelper.spatialReference,r=b.get();p.renderCoordsHelper.fromRenderCoords(f,r,m),r[2]=p.elevationProvider?.getElevation(f[0],f[1],f[2],n,`ground`)??0,e.intersectRay(t,r,t.results.ground,e=>o.filterRenderGeometry(e))}t.sortResults(),this._processHUDResults(t)}_processHUDResults(e){let t=e.results.hud;h(this._tmpRegion,g);let n=[],r=this._tmpRegion,i=e=>{n.push(new z(e))};e.sortResults(t.all),t.min.distance!=null&&i(t.min);for(let e of t.all)t.min.target.object!==e.target.object&&t.max.target.object!==e.target.object&&i(e);if(t.max.distance!=null&&t.max.target.object!==t.min.target.object&&i(t.max),!n.length)return;r[0]===r[2]&&(r[2]+=1),r[1]===r[3]&&(r[3]+=1);let a=!0,o=e.results.max.distance==null,s=0;for(let t of n)a&&=(e.results.min.copy(t.result),!1),o&&e.results.max.copy(t.result),e.options.store===2&&e.results.all.splice(s++,0,t.result)}_createRayIntersectionQuery(e,t,r){return new A(e.origin,n(o(),e.origin,e.direction),t,r)}_intersectRayHandlers(e,t,n,r,i,a=()=>!0,o=!0){let{options:s}=e,c=s.isFiltered,l=s.filteredLayerViewUids;for(let{handler:c,filterPredicate:l,isFiltered:u,filteredLayerViewUids:d}of this._getFilteredIntersectionHandlers(t,r,null,a,o))(!u||c.isGround&&i)&&(s.isFiltered=u,s.filteredLayerViewUids=d,c.intersectRay(e,l,e.rayBegin,e.rayEnd,n.screenPoint,n.isVerticalRay));s.isFiltered=c,s.filteredLayerViewUids=l}*_intersectPolygonHandlersGenerator(e,t,n,r,i,a=()=>!0,o=!0,s){let{options:c}=e,l=c.isFiltered,u=c.filteredLayerViewUids,d=e.screenPolygonPrimitiveProcessor;for(let{handler:l,screenPolygonPrimitiveProcessor:u,isFiltered:d,filteredLayerViewUids:f}of this._getFilteredIntersectionHandlers(t,r,i,a,o))d||l.intersectScreenPolygon==null||(c.isFiltered=d,c.filteredLayerViewUids=f,e.screenPolygonPrimitiveProcessor=u??k,yield*l.intersectScreenPolygon(e,n,s));c.isFiltered=l,c.filteredLayerViewUids=u,e.screenPolygonPrimitiveProcessor=d}*_intersectDrapedScreenPolygon(e,t,n,r){let{basemapTerrain:i,overlayManager:a}=this._view,o=this._view.groundView.spatialReference!=null&&!a.renderer.isEmpty;if(!e.options.selectionMode||!r?.enableDraped||!o)return;let s=yield*this._createDrapedPolygonIntersectionQueries(n,i.slicePlaneEnabled?this._view.slice.plane:null);s!=null&&(yield*this._view.overlayManager.renderer.intersectScreenPolygon(e,s,e=>t.filterRenderGeometry(e)))}*_createDrapedPolygonIntersectionQueries(n,r){let{state:{camera:{eye:i}},pointsOfInterest:o}=this._view,l=this._view.groundView.spatialReference,u=[],d=r?[]:null,f=C(this._view,o.focus.renderLocation),p=v(l),m=1/0,h=null,g=K,_=q,y=e=>{if(!this._intersectDrapedScreenPolygonPoint(g,_,e))return!1;let n=h!=null&&p?h+p.shortestSignedDiff(h,g[0]):g[0];return h=n,u.push(t(n,g[1])),d&&d.push(s(_)),m=Math.min(m,a(i,_)),!0},{points:b}=n,{length:x}=b;for(let t=0;t<x;t++){let n=b[t],r=b[(t+1)%x];for(let t=0;t<f;t++){let i=t/f;if(!y(t===0?n:e(Y,c(n[0],r[0],i),c(n[1],r[1],i))))return null;yield}}if(!Number.isFinite(m))return null;if(r==null||!d)return[G(u,m)];let S=this._clipDrapedScreenPolygonIntersectionQueries(d,r,p,i);return S.length>0?S:null}_clipDrapedScreenPolygonIntersectionQueries(e,t,n,r){let i=[],a=P(t);for(let t of F(a,e)){let e=this._createDrapedQueryFromRenderPolygon(t,n,r);e!=null&&i.push(e)}return i.sort((e,t)=>e.distance-t.distance),i}_createDrapedQueryFromRenderPolygon(e,n,r){let{renderCoordsHelper:i}=this._view,o=this._view.groundView.spatialReference,s=[],c=1/0,l=null;for(let u of e){if(!i.fromRenderCoords(u,X,o))return null;let e=l!=null&&n?l+n.shortestSignedDiff(l,X[0]):X[0];l=e,s.push(t(e,X[1])),c=Math.min(c,a(r,u))}return s.length>=3&&Number.isFinite(c)?G(s,c):null}_intersectDrapedScreenPolygonPoint(e,t,n){let r=this._getPickRay(n,this._tmpRay);if(r==null)return!1;let{renderCoordsHelper:i}=this._view;this._intersectGroundPoint(t,r,n)||i.intersectManifoldClosestSilhouette(r,0,t);let a=this._view.groundView.spatialReference;return!!i.fromRenderCoords(t,e,a)}_intersectGroundPoint(e,t,n){let r=this._view.state.camera,i=new U(null,this._forEachLayer),a=new O(this.isGlobal);J[0]=n[0],J[1]=n[1],J[2]=0;let o=this._createRayIntersectionQuery(t,J,!1);return a.options.selectionMode=!0,a.options.store=0,a.options.normalRequired=!1,a.options.selectOpaqueTerrainOnly=!1,a.reset(o.beginPoint,o.endPoint,r),this._intersectRayHandlers(a,i,o,null,!0,e=>e.isGround,!1),a.results.ground.getIntersectionPoint(e)}*_getFilteredIntersectionHandlers(e,t,n,r=()=>!0,i=!0){for(let a of this._externalIntersectionHandlers){if(!r(a))continue;let o=!1,s=[];if(i){let t=a.layerViewUid,n=a.sublayerId,r=Array.isArray(t),i=r?t:[t],c=!1;for(let t of i)e.filterLayerViewUid(t,n)?c=!0:r&&s.push(t);o=!c}yield new B(a,a.slicePlaneEnabled?t:null,a.slicePlaneEnabled?n:null,o,s)}}}class z{constructor(e){this.result=e,this.screenPoint=d()}}class B{constructor(e,t,n,r,i){this.handler=e,this.filterPredicate=t,this.screenPolygonPrimitiveProcessor=n,this.isFiltered=r,this.filteredLayerViewUids=i}}let V;function H(e){return V&&V.isGlobal===e||(V=new O(e)),V}class U{constructor(e,t){this.layers=[],this.sliceableLayers=[],this.include=e?.include,this.exclude=e?.exclude,this.objectFilter=e?.objectFilter,this.allowedIntersectorTypes=e?.allowedIntersectorTypes,t(e=>{e.pickable&&this.filterLayerViewUid(e.apiLayerViewUid)&&(e.sliceable?this.sliceableLayers:this.layers).push(e)})}filterLayerViewUid(e,t){let{include:n,exclude:r}=this;if(e==null)return n==null&&r==null;let i=n instanceof Map?n.get(e)??!1:n?.has(e),a=r instanceof Map?r.get(e)??!1:r?.has(e);return(i==null||(typeof i==`boolean`?i:t!=null&&i.has(t)))&&(a==null||!(typeof a==`boolean`?a:t!=null&&a.has(t)))}filterRenderGeometry(e){return this.filterLayerViewUid(e.layerViewUid)}}function W(e){return typeof e==`object`&&!!e&&`intersectRay`in e}function G(e,t){return new j(e,_(m(g),e),t)}const K=o(),q=o(),J=d(),Y=f(),X=o(),Z=d();export{R as SceneIntersectionHelper,W as isIntersectionHandler};
|
|
2
|
+
import{set as e}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{fromValues as t}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{add as n,normalize as r,dot as i,distance as a}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as o,clone as s}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{lerp as c}from"../../../../core/mathUtils.js";import l from"../../../../core/PooledArray.js";import{castRenderScreenPointArray3 as u,createRenderScreenPointArray3 as d,createScreenPointArray as f}from"../../../../core/screenUtils.js";import{getMetersPerVerticalUnitForSR as p}from"../../../../core/units.js";import{create as m,copy as h,negativeInfinity as g,expandWithNestedArray as _}from"../../../../geometry/support/aaBoundingRect.js";import{createSpatialReferenceCyclical as v}from"../../../../geometry/support/normalizeUtils.js";import{create as y}from"../../../../geometry/support/ray.js";import{sv3d as b}from"../../../../geometry/support/vectorStacks.js";import{getElevationOffsetInMeters as x}from"../../../../support/elevationInfoUtils.js";import{TaskPriority as S,noBudget as C}from"../../../support/Scheduler.js";import{Yield as w}from"../../../support/Yield.js";import{g as T}from"../../../../chunks/cameraUtilsSpherical.js";import{fromRenderAtEye as E,fromScreen as D}from"../../support/geometryUtils/ray.js";import{computeMapPointFromVec3d as O}from"../../support/hitTest.js";import{defaultTolerance as k,Intersector as A,defaultScreenPolygonPrimitiveProcessor as j}from"../../webgl-engine/lib/Intersector.js";import{RayIntersectionQuery as M,DrapedScreenPolygonIntersectionQuery as N}from"../../webgl-engine/lib/IntersectorInterfaces.js";import{isValidIntersectorResult as P}from"../../webgl-engine/lib/IntersectorResult.js";import{SliceScreenPolygonPrimitiveProcessor as F,createSliceExtrusionHalfspacePlanes as I,clipPolygonAgainstSlicedAwayHalfspaces as L,sliceFilterPredicate as R}from"../../webgl-engine/lib/intersectorUtils.js";import{prepareScreenPolygonIntersectionQuery as z}from"../../webgl-engine/lib/screenPolygonIntersectionUtils.js";class B{constructor(e,t,n){this.isGlobal=e,this._forEachLayer=t,this._view=n,this._externalIntersectionHandlers=new l,this._tolerance=k,this._tmpRay=y(),this._tmpRegion=m(),this._validateHUDIntersector=new A(this.isGlobal),this._validateHUDIntersector.options.hud=!1,this._screenPolygonIntersectionTask=this._view.resourceController.scheduler.registerTask(S.SCREEN_POLYGON_INTERSECTION)}destroy(){this._screenPolygonIntersectionTask.remove(),this._externalIntersectionHandlers.prune()}get screenPolygonIntersectionTask(){return this._screenPolygonIntersectionTask}intersectScreen(e,t,n){return this.intersectRay(this._getPickRay(e,this._tmpRay),W(this.isGlobal),t,n)}intersectScreenFreePointFallback(e,t,n){return this.intersectRayFreePointFallback(this._getPickRay(e,this._tmpRay),t,n)}intersectRayFreePointFallback(e,t,n){return this.intersectRay(e,W(this.isGlobal),t,n)||this._intersectRayFreePointLocal(e,t)}intersectRay(e,t,n,r){return this.intersectRayBudgeted(e,t,n,C,r)===!0}intersectRayBudgeted(e,t,n,r,i){return e?(t.options.selectionMode=!1,t.options.store=0,this.computeIntersection(e,t,!1,i,r)?t.results.min?t.results.min.getIntersectionPoint(n):!1:w):!1}getCenterRayWithSubpixelOffset(e,t,n=.5,r=.5){return e.getRenderCenter($,n,r),$[0]+=.0466,$[1]-=.0123,E(e,$,t)}intersectIntersectorScreen(e,t,n){this.computeIntersection(this._getPickRay(e,this._tmpRay),t,!1,n)}async intersectIntersectorScreenPolygon(e,t,n){t.polygonResults.init();let r=this._view.state.camera,i=await z(r,e);i!=null&&await this._screenPolygonIntersectionTask.scheduleGenerator(e=>this._intersectIntersectorScreenPolygon(r,t,i,n,e))}*_intersectIntersectorScreenPolygon(e,t,n,r,i){let a=new G(r,this._forEachLayer);t.options.selectOpaqueTerrainOnly=!r||!(`include`in r||`exclude`in r),t.camera=e,t.metersPerRenderUnit=this._view.renderCoordsHelper.unitInMeters,t.point=null,t.screenPolygonPrimitiveProcessor=j,yield*t.intersectScreenPolygon(a.layers,n);let o=this._view.slice.plane,s=o?new F(o):null;t.screenPolygonPrimitiveProcessor=s??j,yield*t.intersectScreenPolygon(a.sliceableLayers,n),t.screenPolygonPrimitiveProcessor=j,yield*this._intersectPolygonHandlersGenerator(t,a,n,null,s,void 0,!0,i),yield*this._intersectDrapedScreenPolygon(t,a,n,r),yield*t.intersectHUDScreenPolygon(a.layers,n),t.screenPolygonPrimitiveProcessor=s??j,yield*t.intersectHUDScreenPolygon(a.sliceableLayers,n),t.polygonResults.sortResults()}intersectToolIntersectorScreen(e,t,n){let r=this._getPickRay(e,this._tmpRay);this.intersectToolIntersectorRay(r,t,n)}intersectToolIntersectorRay(e,t,n){t.options.selectionMode=!0,this.computeIntersection(e,t,!1,n);let r=t.results.min;this._view.groundView.opaque||P(r)&&r.intersector!==7||(t.options.selectionMode=!1,this.computeIntersection(e,t,!1,n))}setTolerance(e=k){this._tolerance=e}addIntersectionHandler(e){this._externalIntersectionHandlers.push(e),this._externalIntersectionHandlers.sort((e,t)=>e.type===7?1:t.type===7?-1:0)}removeIntersectionHandler(e){this._externalIntersectionHandlers.removeUnordered(e)!=null&&this._externalIntersectionHandlers.sort((e,t)=>e.type===7?1:t.type===7?-1:0)}_getPickRay(e,t){let n=this._view.state.camera;return D(n,e,t)}_intersectRayFreePointLocal(e,t){return this.isGlobal||e==null||n(t,e.origin,r(b.get(),e.direction)),!1}intersectElevationFromScreen(e,t,n=0,r=null){return this._intersectElevation(this._getPickRay(e,this._tmpRay),t,n,r)}_intersectElevation(e,t,n=0,a=null){if(e==null)return null;let o=this._view,{renderCoordsHelper:s}=o,c=p(o.spatialReference),l=t==null?`absolute-height`:t.mode,d=x(t)/c,f=(l===`on-the-ground`?0:d+n)*c/s.unitInMeters,{camera:m}=o.state;if(l===`absolute-height`){let t=s.getAltitude(m.eye),n=i(r(J,e.direction),s.worldUpAtPosition(m.eye,Y));if(t<f&&n<0||t>=f&&n>0)return null;if(s.intersectInfiniteManifold(e,f,J)){let e=O(o,J);return e.z??=0,e.z-=d,e}return null}let h=m.projectToRenderScreen(e.origin,u(b.get())),g=new G(null,this._forEachLayer),_=o.slice.plane,v=_?R(_):null,y=new A(this.isGlobal);y.options.store=0,y.options.verticalOffset=f,y.options.normalRequired=!1;let S=this._createRayIntersectionQuery(e,h,!1);y.metersPerRenderUnit=this._view.renderCoordsHelper.unitInMeters,y.reset(S.beginPoint,S.endPoint,m),y.point=h;let C=null;if(a&&`type`in a&&a.type===`graphics`){let e=o.allLayerViews.find(e=>e.layer===a)?.uid;C=e?t=>t.layerViewUid===e:null}else a&&(C=e=>e.graphicUid!==a.uid);switch(l){case`relative-to-scene`:y.intersect(g.layers,S.screenPoint,this._tolerance,null,e=>(!C||C(e))&&!!e.lastValidElevationBB),this._intersectRayHandlers(y,g,S,v,!1,e=>e.type===2||e.type===7||e.type===8,!1);break;case`on-the-ground`:case`relative-to-ground`:this._intersectRayHandlers(y,g,S,v,!1,e=>e.isGround,!1)}if(y.results.min.getIntersectionPoint(J)){let e=O(o,J);return e.z=n,e}return null}computeIntersection(e,t,n,r,i){if(e==null)return!0;let a=this._view.state.camera,o=a.projectToRenderScreen(e.origin,u(b.get())),s=new G(r,this._forEachLayer);t.options.selectOpaqueTerrainOnly=!r||!(`include`in r||`exclude`in r);let c=this._createRayIntersectionQuery(e,o,n);t.metersPerRenderUnit=this._view.renderCoordsHelper.unitInMeters,t.reset(c.beginPoint,c.endPoint,a),t.intersect(s.layers,c.screenPoint,this._tolerance,null,s.objectFilter);let l=this._view.slice.plane,d=l?R(l):null;t.intersect(s.sliceableLayers,c.screenPoint,this._tolerance,d,s.objectFilter);let f=r&&(r.requiresGroundFeedback||r.enableDraped);if(!this._intersectRayHandlers(t,s,c,d,!!f,e=>s.allowedIntersectorTypes==null||s.allowedIntersectorTypes.has(e.type),!0,i))return!1;let p=b.get(),m=this._view,h=m.groundView.spatialReference;if(r&&r.enableDraped&&h!=null&&t.results.ground.getIntersectionPoint(p)){let e=m.overlayManager.renderer,n=m.renderCoordsHelper.spatialReference,r=b.get();m.renderCoordsHelper.fromRenderCoords(p,r,h),r[2]=m.elevationProvider?.getElevation(p[0],p[1],p[2],n,`ground`)??0,e.intersectRay(t,r,t.results.ground,e=>s.filterRenderGeometry(e))}return t.sortResults(),this._processHUDResults(t),!0}_processHUDResults(e){let t=e.results.hud;h(this._tmpRegion,g);let n=[],r=this._tmpRegion,i=e=>{n.push(new V(e))};e.sortResults(t.all),t.min.distance!=null&&i(t.min);for(let e of t.all)t.min.target.object!==e.target.object&&t.max.target.object!==e.target.object&&i(e);if(t.max.distance!=null&&t.max.target.object!==t.min.target.object&&i(t.max),!n.length)return;r[0]===r[2]&&(r[2]+=1),r[1]===r[3]&&(r[3]+=1);let a=!0,o=e.results.max.distance==null,s=0;for(let t of n)a&&=(e.results.min.copy(t.result),!1),o&&e.results.max.copy(t.result),e.options.store===2&&e.results.all.splice(s++,0,t.result)}_createRayIntersectionQuery(e,t,r){return new M(e.origin,n(o(),e.origin,e.direction),t,r)}_intersectRayHandlers(e,t,n,r,i,a=()=>!0,o=!0,s){let{options:c}=e,l=c.isFiltered,u=c.filteredLayerViewUids,d=!0;for(let{handler:l,filterPredicate:u,isFiltered:f,filteredLayerViewUids:p}of this._getFilteredIntersectionHandlers(t,r,null,a,o))if((!f||l.isGround&&i)&&(c.isFiltered=f,c.filteredLayerViewUids=p,l.intersectRay(e,u,e.rayBegin,e.rayEnd,n.screenPoint,n.isVerticalRay,s)===!1)){d=!1;break}return c.isFiltered=l,c.filteredLayerViewUids=u,d}*_intersectPolygonHandlersGenerator(e,t,n,r,i,a=()=>!0,o=!0,s){let{options:c}=e,l=c.isFiltered,u=c.filteredLayerViewUids,d=e.screenPolygonPrimitiveProcessor;for(let{handler:l,screenPolygonPrimitiveProcessor:u,isFiltered:d,filteredLayerViewUids:f}of this._getFilteredIntersectionHandlers(t,r,i,a,o))d||l.intersectScreenPolygon==null||(c.isFiltered=d,c.filteredLayerViewUids=f,e.screenPolygonPrimitiveProcessor=u??j,yield*l.intersectScreenPolygon(e,n,s));c.isFiltered=l,c.filteredLayerViewUids=u,e.screenPolygonPrimitiveProcessor=d}*_intersectDrapedScreenPolygon(e,t,n,r){let{basemapTerrain:i,overlayManager:a}=this._view,o=this._view.groundView.spatialReference!=null&&!a.renderer.isEmpty;if(!e.options.selectionMode||!r?.enableDraped||!o)return;let s=yield*this._createDrapedPolygonIntersectionQueries(n,i.slicePlaneEnabled?this._view.slice.plane:null);s!=null&&(yield*this._view.overlayManager.renderer.intersectScreenPolygon(e,s,e=>t.filterRenderGeometry(e)))}*_createDrapedPolygonIntersectionQueries(n,r){let{state:{camera:{eye:i}},pointsOfInterest:o}=this._view,l=this._view.groundView.spatialReference,u=[],d=r?[]:null,f=T(this._view,o.focus.renderLocation),p=v(l),m=1/0,h=null,g=J,_=Y,y=e=>{if(!this._intersectDrapedScreenPolygonPoint(g,_,e))return!1;let n=h!=null&&p?h+p.shortestSignedDiff(h,g[0]):g[0];return h=n,u.push(t(n,g[1])),d&&d.push(s(_)),m=Math.min(m,a(i,_)),!0},{points:b}=n,{length:x}=b;for(let t=0;t<x;t++){let n=b[t],r=b[(t+1)%x];for(let t=0;t<f;t++){let i=t/f;if(!y(t===0?n:e(Z,c(n[0],r[0],i),c(n[1],r[1],i))))return null;yield}}if(!Number.isFinite(m))return null;if(r==null||!d)return[q(u,m)];let S=this._clipDrapedScreenPolygonIntersectionQueries(d,r,p,i);return S.length>0?S:null}_clipDrapedScreenPolygonIntersectionQueries(e,t,n,r){let i=[],a=I(t);for(let t of L(a,e)){let e=this._createDrapedQueryFromRenderPolygon(t,n,r);e!=null&&i.push(e)}return i.sort((e,t)=>e.distance-t.distance),i}_createDrapedQueryFromRenderPolygon(e,n,r){let{renderCoordsHelper:i}=this._view,o=this._view.groundView.spatialReference,s=[],c=1/0,l=null;for(let u of e){if(!i.fromRenderCoords(u,Q,o))return null;let e=l!=null&&n?l+n.shortestSignedDiff(l,Q[0]):Q[0];l=e,s.push(t(e,Q[1])),c=Math.min(c,a(r,u))}return s.length>=3&&Number.isFinite(c)?q(s,c):null}_intersectDrapedScreenPolygonPoint(e,t,n){let r=this._getPickRay(n,this._tmpRay);if(r==null)return!1;let{renderCoordsHelper:i}=this._view;this._intersectGroundPoint(t,r,n)||i.intersectManifoldClosestSilhouette(r,0,t);let a=this._view.groundView.spatialReference;return!!i.fromRenderCoords(t,e,a)}_intersectGroundPoint(e,t,n){let r=this._view.state.camera,i=new G(null,this._forEachLayer),a=new A(this.isGlobal);X[0]=n[0],X[1]=n[1],X[2]=0;let o=this._createRayIntersectionQuery(t,X,!1);return a.options.selectionMode=!0,a.options.store=0,a.options.normalRequired=!1,a.options.selectOpaqueTerrainOnly=!1,a.reset(o.beginPoint,o.endPoint,r),this._intersectRayHandlers(a,i,o,null,!0,e=>e.isGround,!1),a.results.ground.getIntersectionPoint(e)}*_getFilteredIntersectionHandlers(e,t,n,r=()=>!0,i=!0){for(let a of this._externalIntersectionHandlers){if(!r(a))continue;let o=!1,s=[];if(i){let t=a.layerViewUid,n=a.sublayerId,r=Array.isArray(t),i=r?t:[t],c=!1;for(let t of i)e.filterLayerViewUid(t,n)?c=!0:r&&s.push(t);o=!c}yield new H(a,a.slicePlaneEnabled?t:null,a.slicePlaneEnabled?n:null,o,s)}}}class V{constructor(e){this.result=e,this.screenPoint=d()}}class H{constructor(e,t,n,r,i){this.handler=e,this.filterPredicate=t,this.screenPolygonPrimitiveProcessor=n,this.isFiltered=r,this.filteredLayerViewUids=i}}let U;function W(e){return U&&U.isGlobal===e||(U=new A(e)),U}class G{constructor(e,t){this.layers=[],this.sliceableLayers=[],this.include=e?.include,this.exclude=e?.exclude,this.objectFilter=e?.objectFilter,this.allowedIntersectorTypes=e?.allowedIntersectorTypes,t(e=>{e.pickable&&this.filterLayerViewUid(e.apiLayerViewUid)&&(e.sliceable?this.sliceableLayers:this.layers).push(e)})}filterLayerViewUid(e,t){let{include:n,exclude:r}=this;if(e==null)return n==null&&r==null;let i=n instanceof Map?n.get(e)??!1:n?.has(e),a=r instanceof Map?r.get(e)??!1:r?.has(e);return(i==null||(typeof i==`boolean`?i:t!=null&&i.has(t)))&&(a==null||!(typeof a==`boolean`?a:t!=null&&a.has(t)))}filterRenderGeometry(e){return this.filterLayerViewUid(e.layerViewUid)}}function K(e){return typeof e==`object`&&!!e&&`intersectRay`in e}function q(e,t){return new N(e,_(m(g),e),t)}const J=o(),Y=o(),X=d(),Z=f(),Q=o(),$=d();export{B as SceneIntersectionHelper,K as isIntersectionHandler};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{property as t}from"../../../core/accessorSupport/decorators/property.js";import{subclass as n}from"../../../core/accessorSupport/decorators/subclass.js";import{EventedAccessor as r}from"../../../core/Evented.js";import{on as i}from"../../../core/reactiveUtils.js";import{IntegratedMeshSemantics as a}from"../../../layers/support/IntegratedMeshSemantics.js";import{isIntegratedMeshLayerView as o}from"../../support/layerViewUtils.js";import{noBudget as s}from"../../support/Scheduler.js";let c=class extends r{constructor(e){super(e),this._integratedMeshElevationUpdateHandles=new Map}initialize(){let e=this._integratedMeshElevationUpdateHandles;this.addHandles([i(()=>this.view.groundView,`elevation-change`,e=>this._elevationChange(e)),this.view.allLayerViews.on(`change`,t=>{t.added.forEach(t=>{if(!o(t)||a.contributesToGroundElevation(t.layer,t.replacesTerrain))return;let n=t.elevationProvider.on(`elevation-change`,e=>this._elevationChange(e));e.set(t,n),this.addHandles(n,t)}),t.removed.forEach(t=>{o(t)&&(this.removeHandles(t),e.delete(t))})})])}intersect(e,t,n,r){this.intersectBudgeted(e,t,n,r,s)}intersectBudgeted(e,t,n,r,i){if(!this.view.groundView.intersectBudgeted(e,t,n,r,i))return!1;for(let
|
|
2
|
+
import{__decorate as e}from"tslib";import{property as t}from"../../../core/accessorSupport/decorators/property.js";import{subclass as n}from"../../../core/accessorSupport/decorators/subclass.js";import{EventedAccessor as r}from"../../../core/Evented.js";import{on as i}from"../../../core/reactiveUtils.js";import{IntegratedMeshSemantics as a}from"../../../layers/support/IntegratedMeshSemantics.js";import{isIntegratedMeshLayerView as o}from"../../support/layerViewUtils.js";import{noBudget as s}from"../../support/Scheduler.js";let c=class extends r{constructor(e){super(e),this._integratedMeshElevationUpdateHandles=new Map}initialize(){let e=this._integratedMeshElevationUpdateHandles;this.addHandles([i(()=>this.view.groundView,`elevation-change`,e=>this._elevationChange(e)),this.view.allLayerViews.on(`change`,t=>{t.added.forEach(t=>{if(!o(t)||a.contributesToGroundElevation(t.layer,t.replacesTerrain))return;let n=t.elevationProvider.on(`elevation-change`,e=>this._elevationChange(e));e.set(t,n),this.addHandles(n,t)}),t.removed.forEach(t=>{o(t)&&(this.removeHandles(t),e.delete(t))})})])}intersect(e,t,n,r){this.intersectBudgeted(e,t,n,r,s)}intersectBudgeted(e,t,n,r,i){if(!this.view.groundView.intersectBudgeted(e,t,n,r,i))return!1;for(let a of this._integratedMeshElevationUpdateHandles.keys())if(!a.intersect(e,t,n,r,i))return!1;return!0}_elevationChange(e){this.emit(`elevation-change`,e)}};e([t({constructOnly:!0})],c.prototype,`view`,void 0),c=e([n(`esri.views.3d.support.GroundAndIMSurface`)],c);export{c as GroundAndIMSurface};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{property as t,subclass as n}from"../../../../core/accessorSupport/decorators.js";import{copy as r,distance as i,scale as a,add as o,exactEquals as s,squaredLength as c}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as l}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{clamp as u}from"../../../../core/mathUtils.js";import{removeMaybe as d,destroyMaybe as f}from"../../../../core/maybe.js";import{getReferenceEllipsoid as p}from"../../../../geometry/ellipsoidUtils.js";import m from"../../../../geometry/Point.js";import{projectBoundingRect as h}from"../../../../geometry/projection/projectBoundingRect.js";import{create as g}from"../../../../geometry/support/aaBoundingRect.js";import{PropertiesPool as _}from"../../../support/PropertiesPool.js";import{noBudget as v}from"../../../support/Scheduler.js";import{Yield as y}from"../../../support/Yield.js";import{debugFlags as b}from"../debugFlags.js";import{PointOfInterest as x}from"./PointOfInterest.js";let S=class extends x{constructor(e){super(e),this._propertiesPool=new _({location:()=>new m,renderLocation:()=>l()},this),this._currentSurfaceAltitude=0,this._latestSurfaceAltitude=0,this.distance=0,this.renderLocation=l(),this._updatingType=
|
|
2
|
+
import{__decorate as e}from"tslib";import{property as t,subclass as n}from"../../../../core/accessorSupport/decorators.js";import{copy as r,distance as i,scale as a,add as o,exactEquals as s,squaredLength as c}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as l}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{clamp as u}from"../../../../core/mathUtils.js";import{removeMaybe as d,destroyMaybe as f}from"../../../../core/maybe.js";import{getReferenceEllipsoid as p}from"../../../../geometry/ellipsoidUtils.js";import m from"../../../../geometry/Point.js";import{projectBoundingRect as h}from"../../../../geometry/projection/projectBoundingRect.js";import{create as g}from"../../../../geometry/support/aaBoundingRect.js";import{PropertiesPool as _}from"../../../support/PropertiesPool.js";import{noBudget as v}from"../../../support/Scheduler.js";import{Yield as y}from"../../../support/Yield.js";import{debugFlags as b}from"../debugFlags.js";import{PointOfInterest as x}from"./PointOfInterest.js";let S=class extends x{constructor(e){super(e),this._propertiesPool=new _({location:()=>new m,renderLocation:()=>l()},this),this._currentSurfaceAltitude=0,this._latestSurfaceAltitude=0,this.distance=0,this.renderLocation=l(),this._updatingType=null}initialize(){this._frameWorker=this.scheduler.registerTask(this.task,this),this.runTask()}destroy(){this._frameWorker=d(this._frameWorker),this._propertiesPool=f(this._propertiesPool)}get _camera(){return this.state.contentCamera}get location(){let e=this._propertiesPool?.get(`location`);return e?(e.spatialReference=this.state.spatialReference,this.renderCoordsHelper.fromRenderCoords(this.renderLocation,e),e):new m}get updating(){return this._updatingType!==null}updateRenderLocation(){this._updatingType=`all-content`,this._updateRenderLocation()}get estimatedSurfaceAltitude(){return this._latestSurfaceAltitude}get readyToRun(){return this.updating}runTask(e=v){let t=this.estimateSurfaceAltitudeAtCenter(e,this._updatingType??`all-content`);return typeof t==`number`?(this._latestSurfaceAltitude=t,this._updateRenderLocation(),this._updatingType=null,e.madeProgress(),y):(this._updatingType=t,y)}_updateRenderLocation(){let e=C,t=this._calculateSurfaceIntersection(this._currentSurfaceAltitude,e),n=this._currentSurfaceAltitude!==this._latestSurfaceAltitude;!t&&n&&(t=this._calculateSurfaceIntersection(this._latestSurfaceAltitude,e),t&&(this._currentSurfaceAltitude=this._latestSurfaceAltitude));let c=w;t&&this._latestSurfaceAltitudeChangesDistance(e,c)&&(r(e,c),this._currentSurfaceAltitude=this._latestSurfaceAltitude),t?this.distance=i(this._camera.eye,e):(a(e,this._camera.viewForward,this._get(`distance`)),o(e,e,this._camera.eye)),s(this._get(`renderLocation`),e)||this._set(`renderLocation`,r(this._propertiesPool.get(`renderLocation`),e))}_calculateSurfaceIntersection(e,t){let n=this._camera;if(!this.renderCoordsHelper.intersectInfiniteManifold(n.ray,e,t))return!1;if(this.state.isGlobal){let r=p(this.renderCoordsHelper.spatialReference).radius,s=r+e,l=c(n.eye),u=l<s*s,d=i(n.eye,t);if(u&&d>r/4){let e=s-Math.sqrt(l);return a(t,n.viewForward,e),o(t,t,n.eye),!0}}else{let e=this.surface?.ready?this.surface.groundExtent:null;e!=null&&h(e,this.surface?.spatialReference,T,this.renderCoordsHelper.spatialReference)&&(t[0]=u(t[0],T[0],T[2]),t[1]=u(t[1],T[1],T[3]))}return!0}_latestSurfaceAltitudeChangesDistance(e,t){if(this._latestSurfaceAltitude===this._currentSurfaceAltitude||e==null)return!1;if(this._calculateSurfaceIntersection(this._latestSurfaceAltitude,t)){if(!b.ENABLE_OPTIMIZATIONS)return!0;let n=this._camera.eye;if(i(n,e)!==i(n,t))return!0}return!1}};e([t({constructOnly:!0})],S.prototype,`scheduler`,void 0),e([t({constructOnly:!0})],S.prototype,`surface`,void 0),e([t({constructOnly:!0})],S.prototype,`task`,void 0),e([t()],S.prototype,`distance`,void 0),e([t({constructOnly:!0})],S.prototype,`estimateSurfaceAltitudeAtCenter`,void 0),e([t({readOnly:!0})],S.prototype,`location`,null),e([t({readOnly:!0})],S.prototype,`renderLocation`,void 0),e([t()],S.prototype,`_updatingType`,void 0),e([t()],S.prototype,`updating`,null),S=e([n(`esri.views.3d.support.pointsOfInterest.CenterOnSurface`)],S);const C=l(),w=l(),T=g();export{S as CenterOnSurface};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{property as n,subclass as r}from"../../../../core/accessorSupport/decorators.js";import"../../../../core/has.js";import{add as i,exactEquals as a,copy as o}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{watch as c,sync as l,initial as u,when as d,on as f}from"../../../../core/reactiveUtils.js";import{UpdatingHandles as p}from"../../../../core/support/UpdatingHandles.js";import{create as m}from"../../../../geometry/support/ray.js";import{PropertiesPool as h}from"../../../support/PropertiesPool.js";import{TaskPriority as g,noBudget as _}from"../../../support/Scheduler.js";import{Yield as v}from"../../../support/Yield.js";import{Intersector as y}from"../../webgl-engine/lib/Intersector.js";import{terrainId as b}from"../../webgl-engine/lib/verticalOffsetUtils.js";import{debugFlags as x}from"../debugFlags.js";import{DebugPoint as S}from"../debugUtils.js";import{fromRenderAtEye as C}from"../geometryUtils/ray.js";import{CameraOnSurface as w}from"./CameraOnSurface.js";import{CenterOnSurface as T}from"./CenterOnSurface.js";import{ContentGeometryUpdates as E}from"./ContentGeometryUpdates.js";import{Focus as D}from"./Focus.js";import{StableSurfaceCenter as O}from"./StableSurfaceCenter.js";import{SurfaceGeometryUpdates as k}from"./SurfaceGeometryUpdates.js";let A=class extends t{constructor(e){super(e),this.renderPointOfView=s(),this._pois=[],this._updatingHandles=new p,this._debugCenters=null,this._tmpRay=m(),this._centerRayDirty=!0,this._surfaceAltitudeAtCenter=0,this._surfaceAltitudeAtCenterDirty=!0,this._contentAltitudeAtCenter=0,this._contentAltitudeAtCenterDirty=!0,this._contentChangedSinceLastUpdate=!0,this._geometryPois=[],this._propertiesPool=new h({renderPointOfView:()=>s()},this),this._contentIntersector=new y(e.view.state.isGlobal),this._surfaceIntersector=new y(e.view.state.isGlobal),this._surfaceIntersector.options.invisibleTerrain=!1,this._surfaceIntersector.options.store=0}initialize(){let{state:e,groundView:t,renderCoordsHelper:n,map:r}=this.view,i=this.view.groundAndIMSurface,a=e=>this._estimateSurfaceAltitudeAtCenter(e),o=this.view.resourceController.scheduler,s=t?.elevationQueryCache,p={state:e,scheduler:o,renderCoordsHelper:n},m={...p,surface:t};this._set(`centerOnSurfaceInfrequent`,new T({...m,task:g.POINT_OF_INTEREST_INFREQUENT,estimateSurfaceAltitudeAtCenter:a})),this._set(`centerOnSurfaceFrequent`,new T({...m,task:g.POINT_OF_INTEREST_FREQUENT,estimateSurfaceAltitudeAtCenter:a})),this._set(`centerOnContent`,new T({...m,task:g.POINT_OF_INTEREST_FREQUENT,estimateSurfaceAltitudeAtCenter:(e,t)=>this._estimateContentAltitudeAtCenter(e,t)})),this._set(`cameraOnSurface`,new w({...m,cache:s,task:g.POINT_OF_INTEREST_INFREQUENT,map:r})),this._set(`surfaceGeometryUpdates`,new k({...p,surface:i,centerOnSurfaces:[this.centerOnSurfaceFrequent,this.centerOnContent,this.centerOnSurfaceInfrequent]})),this._set(`contentGeometryUpdates`,new E(this.view.allLayerViews,()=>this.view.graphicsView)),this._set(`surfaceOrigin`,new O({cache:s,view:this.view})),this._set(`focus`,new D({...p,centerOnSurface:this.centerOnSurfaceFrequent,estimateSurfaceIntersectionAtRenderPoint:(e,t,n)=>this._estimateSurfaceIntersectionAtRenderPoint(e,this.view.state.contentCamera,t,n)})),this._pois.push(this.centerOnContent,this.centerOnSurfaceFrequent,this.centerOnSurfaceInfrequent,this.cameraOnSurface,this.focus),this._geometryPois.push(this.centerOnContent,this.centerOnSurfaceFrequent,this.centerOnSurfaceInfrequent,this.focus),this.addHandles([c(()=>e.contentCamera,e=>this._cameraChanged(e),l),this._updatingHandles.add(()=>t.groundExtent,()=>this._updateGeometryPointsOfInterest()),this._updatingHandles.add(()=>this.view.map?.ground?.navigationConstraint?.type,e=>{this._surfaceIntersector.options.backfacesTerrain=e===`none`},u),d(()=>!t.updating&&this._contentChangedSinceLastUpdate,()=>{this._updateGeometryPointsOfInterest(),this._contentChangedSinceLastUpdate=!1},l),f(()=>this.surfaceGeometryUpdates.events,`request-update`,()=>this._updateGeometryPointsOfInterest()),f(()=>this.contentGeometryUpdates.events,`request-update`,()=>{this._contentChangedSinceLastUpdate=!0,this._updateCenterOnContent()}),this._updatingHandles.add(()=>x.SHOW_POI,e=>this._setDebug(e),u)]),this._cameraChanged(this.view.state.contentCamera);for(let e of this._pois)e.runTask()}destroy(){this._setDebug(!1),this._propertiesPool.destroy();for(let e of this._pois)e.destroy();this._pois.length=0,this.surfaceOrigin.destroy(),this._updatingHandles.destroy(),this._set(`centerOnSurfaceInfrequent`,null),this._set(`centerOnSurfaceFrequent`,null),this._set(`centerOnContent`,null),this._set(`cameraOnSurface`,null),this._set(`surfaceGeometryUpdates`,null),this._set(`contentGeometryUpdates`,null),this._set(`surfaceOrigin`,null),this._set(`focus`,null)}get updating(){return!!(this.surfaceGeometryUpdates?.updating||this._pois.some(e=>e.updating))||this._updatingHandles.updating}get _centerRay(){return this._centerRayDirty&&=(this._centerRayCached=this.view.sceneIntersectionHelper.getCenterRayWithSubpixelOffset(this.view.state.contentCamera,this._tmpRay),!1),this._centerRayCached}_estimateContentAltitudeAtCenter(e,t){if(!this._contentAltitudeAtCenterDirty)return this._contentAltitudeAtCenter;let n=this._centerRay;if(n==null)return this._contentAltitudeAtCenter;if(t
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{property as n,subclass as r}from"../../../../core/accessorSupport/decorators.js";import"../../../../core/has.js";import{add as i,exactEquals as a,copy as o}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{watch as c,sync as l,initial as u,when as d,on as f}from"../../../../core/reactiveUtils.js";import{UpdatingHandles as p}from"../../../../core/support/UpdatingHandles.js";import{create as m}from"../../../../geometry/support/ray.js";import{PropertiesPool as h}from"../../../support/PropertiesPool.js";import{TaskPriority as g,noBudget as _}from"../../../support/Scheduler.js";import{Yield as v}from"../../../support/Yield.js";import{Intersector as y}from"../../webgl-engine/lib/Intersector.js";import{terrainId as b}from"../../webgl-engine/lib/verticalOffsetUtils.js";import{debugFlags as x}from"../debugFlags.js";import{DebugPoint as S}from"../debugUtils.js";import{fromRenderAtEye as C}from"../geometryUtils/ray.js";import{CameraOnSurface as w}from"./CameraOnSurface.js";import{CenterOnSurface as T}from"./CenterOnSurface.js";import{ContentGeometryUpdates as E}from"./ContentGeometryUpdates.js";import{Focus as D}from"./Focus.js";import{StableSurfaceCenter as O}from"./StableSurfaceCenter.js";import{SurfaceGeometryUpdates as k}from"./SurfaceGeometryUpdates.js";let A=class extends t{constructor(e){super(e),this.renderPointOfView=s(),this._pois=[],this._updatingHandles=new p,this._debugCenters=null,this._tmpRay=m(),this._centerRayDirty=!0,this._surfaceAltitudeAtCenter=0,this._surfaceAltitudeAtCenterDirty=!0,this._contentIntersectorOptions={exclude:new Set([b])},this._contentAltitudeAtCenter=0,this._contentAltitudeAtCenterDirty=!0,this._contentChangedSinceLastUpdate=!0,this._geometryPois=[],this._propertiesPool=new h({renderPointOfView:()=>s()},this),this._contentIntersector=new y(e.view.state.isGlobal),this._surfaceIntersector=new y(e.view.state.isGlobal),this._surfaceIntersector.options.invisibleTerrain=!1,this._surfaceIntersector.options.store=0}initialize(){let{state:e,groundView:t,renderCoordsHelper:n,map:r}=this.view,i=this.view.groundAndIMSurface,a=e=>this._estimateSurfaceAltitudeAtCenter(e),o=this.view.resourceController.scheduler,s=t?.elevationQueryCache,p={state:e,scheduler:o,renderCoordsHelper:n},m={...p,surface:t};this._set(`centerOnSurfaceInfrequent`,new T({...m,task:g.POINT_OF_INTEREST_INFREQUENT,estimateSurfaceAltitudeAtCenter:a})),this._set(`centerOnSurfaceFrequent`,new T({...m,task:g.POINT_OF_INTEREST_FREQUENT,estimateSurfaceAltitudeAtCenter:a})),this._set(`centerOnContent`,new T({...m,task:g.POINT_OF_INTEREST_FREQUENT,estimateSurfaceAltitudeAtCenter:(e,t)=>this._estimateContentAltitudeAtCenter(e,t)})),this._set(`cameraOnSurface`,new w({...m,cache:s,task:g.POINT_OF_INTEREST_INFREQUENT,map:r})),this._set(`surfaceGeometryUpdates`,new k({...p,surface:i,centerOnSurfaces:[this.centerOnSurfaceFrequent,this.centerOnContent,this.centerOnSurfaceInfrequent]})),this._set(`contentGeometryUpdates`,new E(this.view.allLayerViews,()=>this.view.graphicsView)),this._set(`surfaceOrigin`,new O({cache:s,view:this.view})),this._set(`focus`,new D({...p,centerOnSurface:this.centerOnSurfaceFrequent,estimateSurfaceIntersectionAtRenderPoint:(e,t,n)=>this._estimateSurfaceIntersectionAtRenderPoint(e,this.view.state.contentCamera,t,n)})),this._pois.push(this.centerOnContent,this.centerOnSurfaceFrequent,this.centerOnSurfaceInfrequent,this.cameraOnSurface,this.focus),this._geometryPois.push(this.centerOnContent,this.centerOnSurfaceFrequent,this.centerOnSurfaceInfrequent,this.focus),this.addHandles([c(()=>e.contentCamera,e=>this._cameraChanged(e),l),this._updatingHandles.add(()=>t.groundExtent,()=>this._updateGeometryPointsOfInterest()),this._updatingHandles.add(()=>this.view.map?.ground?.navigationConstraint?.type,e=>{this._surfaceIntersector.options.backfacesTerrain=e===`none`},u),d(()=>!t.updating&&this._contentChangedSinceLastUpdate,()=>{this._updateGeometryPointsOfInterest(),this._contentChangedSinceLastUpdate=!1},l),f(()=>this.surfaceGeometryUpdates.events,`request-update`,()=>this._updateGeometryPointsOfInterest()),f(()=>this.contentGeometryUpdates.events,`request-update`,()=>{this._contentChangedSinceLastUpdate=!0,this._updateCenterOnContent()}),this._updatingHandles.add(()=>x.SHOW_POI,e=>this._setDebug(e),u)]),this._cameraChanged(this.view.state.contentCamera);for(let e of this._pois)e.runTask()}destroy(){this._setDebug(!1),this._propertiesPool.destroy();for(let e of this._pois)e.destroy();this._pois.length=0,this.surfaceOrigin.destroy(),this._updatingHandles.destroy(),this._set(`centerOnSurfaceInfrequent`,null),this._set(`centerOnSurfaceFrequent`,null),this._set(`centerOnContent`,null),this._set(`cameraOnSurface`,null),this._set(`surfaceGeometryUpdates`,null),this._set(`contentGeometryUpdates`,null),this._set(`surfaceOrigin`,null),this._set(`focus`,null)}get updating(){return!!(this.surfaceGeometryUpdates?.updating||this._pois.some(e=>e.updating))||this._updatingHandles.updating}get _centerRay(){return this._centerRayDirty&&=(this._centerRayCached=this.view.sceneIntersectionHelper.getCenterRayWithSubpixelOffset(this.view.state.contentCamera,this._tmpRay),!1),this._centerRayCached}_estimateContentAltitudeAtCenter(e,t){if(!this._contentAltitudeAtCenterDirty)return this._contentAltitudeAtCenter;let n=this._centerRay;if(n==null)return this._contentAltitudeAtCenter;let r=!1;if(t===`all-content`&&(r=this.view.sceneIntersectionHelper.intersectRayBudgeted(n,this._contentIntersector,j,e,this._contentIntersectorOptions),r===v))return`all-content`;if(r)this._contentAltitudeAtCenter=this.view.renderCoordsHelper.getAltitude(j);else{let t=this._estimateSurfaceAltitudeAtCenter(e);if(t===`surface-only`)return t;this._contentAltitudeAtCenter=t}return this._contentAltitudeAtCenterDirty=!1,this._contentAltitudeAtCenter}_estimateSurfaceAltitudeAtCenter(e=_){let{view:t}=this,{groundAndIMSurface:n}=t;if(!n)return 0;if(!this._surfaceAltitudeAtCenterDirty)return this._surfaceAltitudeAtCenter;let r=this._centerRay;if(r==null)return this._surfaceAltitudeAtCenter;let a=r.origin,o=i(j,r.origin,r.direction);return this._surfaceIntersector.resetWithRay(r,t.state.contentCamera),n.intersectBudgeted(this._surfaceIntersector,null,a,o,e)?(this._surfaceIntersector.results.min.getIntersectionPoint(j)&&(this._surfaceAltitudeAtCenter=t.renderCoordsHelper.getAltitude(j)),this._surfaceAltitudeAtCenterDirty=!1,this._surfaceAltitudeAtCenter):`surface-only`}_estimateSurfaceIntersectionAtRenderPoint(e,t,n,r=_){let a=C(t,e,M);if(a==null)return null;let o=a.origin,s=i(j,a.origin,a.direction);return this._surfaceIntersector.resetWithRay(a,t),this.view.groundAndIMSurface.intersectBudgeted(this._surfaceIntersector,null,o,s,r)?this._surfaceIntersector.results.min.getIntersectionPoint(n)?n:null:v}_cameraChanged(e){this._updateAllPointsOfInterest();let t=e.eye;a(this.renderPointOfView,t)||this._set(`renderPointOfView`,o(this._propertiesPool.get(`renderPointOfView`),t))}_updateAllPointsOfInterest(){this._invalidateCenterEstimates();for(let e of this._pois)e.updateRenderLocation()}_updateGeometryPointsOfInterest(){this._invalidateCenterEstimates();for(let e of this._geometryPois)e.updateRenderLocation()}_invalidateCenterEstimates(){this._centerRayDirty=!0,this._surfaceAltitudeAtCenterDirty=!0,this._contentAltitudeAtCenterDirty=!0}_updateCenterOnContent(){this._contentAltitudeAtCenterDirty=!0,this.centerOnContent.updateRenderLocation()}_setDebug(e){if(!e)this._debugCenters?.forEach(e=>e.hide()),this.removeHandles(`debug`);else{if(!this._debugCenters){this._debugCenters=new Map;let e=this.view.graphics;this._debugCenters.set(this.centerOnContent,new S(e,`red`,`CenterOnContent`)),this._debugCenters.set(this.centerOnSurfaceFrequent,new S(e,`red`,`CenterOnSurface`)),this._debugCenters.set(this.centerOnSurfaceInfrequent,new S(e,`red`,`CenterOnSurface`)),this._debugCenters.set(this.cameraOnSurface,new S(e,`blue`,`CameraOnSurface`)),this._debugCenters.set(this.focus,new S(e,`green`,`Focus`))}for(let e of this._pois)this.addHandles(this._updatingHandles.add(()=>e.renderLocation,t=>this._debugCenters?.get(e)?.show(t,e.renderCoordsHelper.spatialReference),u),`debug`)}}get test(){}};e([n()],A.prototype,`centerOnContent`,void 0),e([n()],A.prototype,`centerOnSurfaceFrequent`,void 0),e([n()],A.prototype,`centerOnSurfaceInfrequent`,void 0),e([n()],A.prototype,`cameraOnSurface`,void 0),e([n()],A.prototype,`focus`,void 0),e([n()],A.prototype,`renderPointOfView`,void 0),e([n()],A.prototype,`surfaceOrigin`,void 0),e([n()],A.prototype,`contentGeometryUpdates`,void 0),e([n()],A.prototype,`surfaceGeometryUpdates`,void 0),e([n({constructOnly:!0})],A.prototype,`view`,void 0),e([n()],A.prototype,`updating`,null),A=e([r(`esri.views.3d.support.pointsOfInterest.PointsOfInterest`)],A);const j=s(),M=m();export{A as PointsOfInterest};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{property as t,subclass as n}from"../../../core/accessorSupport/decorators.js";import has from"../../../core/has.js";import{subtract as r,set as i,dot as a}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{ZEROS as o,fromValues as s,create as c}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as l,ZEROS as u}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{disposeMaybe as d}from"../../../core/maybe.js";import{MemCachePool as f}from"../../../core/MemCachePool.js";import p from"../../../core/ObjectPool.js";import{watch as m,sync as h}from"../../../core/reactiveUtils.js";import{create as g,set as _}from"../../../geometry/support/aaBoundingBox.js";import{BufferViewVec3f as v}from"../../../geometry/support/buffer/BufferView.js";import{noBudget as y}from"../../support/Scheduler.js";import{PrimitiveType as b}from"../../webgl/enums.js";import{getOverlayContentForOutputTerrain as x}from"../webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js";import{SyncRenderPlugin as S}from"../webgl-engine/effects/RenderPlugin.js";import{Vertices as C}from"../webgl-engine/lib/Attribute.js";import{IntersectorResultRay as w}from"../webgl-engine/lib/IntersectorResult.js";import{intersectAabbInvDirBefore as T,MeshIntersectionOptions as E,intersectTriangles as D}from"../webgl-engine/lib/RayIntersections.js";import{TriangleRangeBVH as O}from"../webgl-engine/lib/TriangleRangeBVH.js";import{terrainId as k,getVerticalOffsetTerrain as A}from"../webgl-engine/lib/verticalOffsetUtils.js";import{DrawParameters as j}from"../webgl-engine/materials/DrawParameters.js";import{hasShadowHighlights as M}from"../webgl-engine/shaders/ReceiveShadowsConfiguration.js";import{T as N}from"../../../chunks/Terrain.glsl.js";import{TerrainTechnique as P}from"../webgl-engine/shaders/TerrainTechnique.js";import{TerrainTechniqueConfiguration as F}from"../webgl-engine/shaders/TerrainTechniqueConfiguration.js";import{overlayRenderOccludedFlag as I}from"./OverlayRenderer.js";import{PatchRenderData as L}from"./PatchRenderData.js";import{TerrainAttributesCache as R}from"./TerrainAttributesCache.js";import{enableTerrainInternalChecks as z}from"./terrainUtils.js";import{TileRenderer as B}from"./TileRenderer.js";import{IteratorPreorder as V,fallsWithinLayerView as H,usesStencil as U,sortTiles as W,compareTiles as G}from"./tileUtils.js";const K=g();let q=class extends S{get visibleTiles(){return Array.from(this._visiblePatchesByOrigin.values()).flat()}get _isGlobal(){return this._view.stage.isGlobal}get _techniques(){return this._context.techniques}get _rctx(){return this._context.renderContext.rctx}get renderOccludedFlags(){return this._overlayRenderer.renderOccludedFlags}constructor(e,t,n,r,i){super(),this._surface=e,this._overlayRenderer=t,this._allTiles=n,this._compressionTracker=r,this.type=7,this.isGround=!0,this._passParameters=new N,this._drawParameters=new j,this._renderDataPool=new p(()=>new L),this._visiblePatchesByOrigin=new Map,this._allPatchesByOrigin=new Map,this._patchesByOriginDirty=!0,this._patchSortingDirty=!0,this._tileIterator=new V,this._castShadows=!1,this._inViewshed=!1,this._cutFillEnabled=!1,this._tileRenderer=null,this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0,this.produces=new Map([[1,()=>this._desiredSlot===1],[7,()=>this._desiredSlot===7],[9,()=>this._produces()&&this.renderOccludedFlags===I]]),this._tileSize=256,this._configuration=new F(i.state.isGlobal),this._tileTextureCache=new f((e,t)=>i.resourceController.memoryController.newCache(e,t),`TileTexture`),this.tileGeometryCache=new R(i.resourceController.memoryController)}initialize(){this.addHandles(m(()=>this._overlayRenderer.renderOccludedFlags,()=>this.requestRender(),h))}destroy(){this._tileTextureCache.destroy(),this.tileGeometryCache.destroy(),this._allTiles.prune(),this._tileRenderer=null}_produces(){return this.visible&&!!this._rootTiles&&!this.renderingDisabled}set renderingDisabled(e){this._set(`renderingDisabled`,!!e),this.setDirty()}set visible(e){this._set(`visible`,!!e),this.setDirty()}updateHeading(e){this._tileRenderer?.updateHeading(e)}set transparency(e){this._configuration.transparencyMode!==e&&(this._configuration.transparencyMode=e,this.requestRender())}get transparency(){return this._configuration.transparencyMode}get renderPatchBorders(){return this._configuration.tileBorders}set renderPatchBorders(e){this._configuration.tileBorders!==e&&(this._configuration.tileBorders=e,this.requestRender(),this.notifyChange(`renderPatchBorders`))}get layerViewUid(){return k}get slicePlaneEnabled(){return this._configuration.hasSlicePlane}set slicePlaneEnabled(e){this._configuration.hasSlicePlane!==e&&(this._configuration.hasSlicePlane=e,this.requestRender())}set textureFadingEnabled(e){this._configuration.textureFadingEnabled!==e&&(this._configuration.textureFadingEnabled=e,this.requestRender())}set pbrMode(e){this._configuration.pbrMode!==e&&(this._configuration.pbrMode=e,this.requestRender())}setRootTiles(e){this._rootTiles=e,this.setDirty()}setStencilEnabledLayerExtents(e){this._stencilEnabledLayerExtents=e,this._setSortingDirty()}set tileSize(e){this._tileSize=e,this._tileRenderer!=null&&(this._tileRenderer.tileSize=e),this.setDirty()}get tileSize(){return this._tileSize}_ensureRenderData(e){e.renderData||(e.renderData=this._renderDataPool.acquire(),e.renderData.init(e,this._getLocalOriginOfTile(e)),e.surface.tileElevationRangeChanged(e))}loadTile(e){this._ensureRenderData(e),this.updateTileGeometryState(e),this.reuseTextureFromParent(e)||this.updateTileTexture(e,32)}reuseTextureFromParent(e){let{parent:t}=e;if(!this._canReuseTextureFromParent(t,e))return!1;let n=l(e.lij[2]&1?.5:0,e.lij[1]&1?0:.5,.5,.5);return t.renderData?.reuseTexture(e.renderData,n)??!1}_canReuseTextureFromParent(e,t){if(!e)return!1;let{layerInfo:n,surface:r}=t;for(let i=0;i<n[1].length;i++){let n=r.layerViewByIndex(i,1);if(H(e,n)!==H(t,n))return!1}return!0}updateTileTexture(e,t){if(this._tileRenderer!=null){let n=t===32?0:2;if(!this._tileRenderer.updateTileTexture(e,n))return e.updateRenderData(1,n),!1;this.requestRender(),e.resetPendingUpdate(t)}return!0}updateTileGeometryState(e){for(let t of e.layerInfo[0])t.pendingUpdates&=-9;e.resetPendingUpdate(8);let t=e.renderData.updateGeometryState();return this._surface.updateElevationSources(e),t&&this.setDirty(),t}updateGeometryIfNeeded(e){e.loaded&&e.renderData.updateGeometryIfNeeded(this._rctx)}unloadTile(e){let t=e.renderData;t&&(t.releaseGeometry(),this._renderDataPool.release(t),t.dispose(),e.renderData=null,e.surface.tileElevationRangeChanged(e,e.elevationBoundsMin,e.elevationBoundsMax),e.setMemoryDirty(),this.setDirty())}_getLocalOriginOfTile(e){let t=Math.max(0,Math.floor((e.level-3)/7)*7);if(this._isGlobal&&t===0)return o;for(;e.parent&&e.level>t;)e=e.parent;return e.centerAtSeaLevel}getStats(){return{numTilesRendered:this._numTilesRendered,numTilesCulled:this._numTilesCulled,numOriginsRendered:this._numOriginsRendered}}set wireframe(e){this._get(`wireframe`)!==e&&(this._set(`wireframe`,e),this.requestRender())}setDirty(e=1){this._patchesByOriginDirty=!0,this._context.requestRender(e)}_setSortingDirty(e=1){this._patchSortingDirty=!0,this._context.requestRender(e)}requestRender(e=1){this._context.requestRender(e)}initializeRenderContext(e){this._context=e,this._tileRenderer=new B(this._surface,this._rctx,this._tileSize,this._techniques,this._tileTextureCache,this._compressionTracker),this.updateTileBackground()}uninitializeRenderContext(){this._tileRenderer=d(this._tileRenderer)}intersectRay(e,t,n,r){this.intersectRayBudgeted(e,t,n,r,y)}intersectRayBudgeted(e,t,n,o,s){let c=this._rootTiles;if(!c||e.options.selectOpaqueTerrainOnly&&e.options.selectionMode&&this.transparency!==0)return!0;let l=J,u=Y;r(l,o,n),i(u,1/l[0],1/l[1],1/l[2]);let d=e.results.min,f=e.results.max,p=e.results.ground,m=e.options.store===0,h=!!e.results.ground.target,g=A(e.verticalOffset),y=e.tolerance,b,x=m&&d.distance!=null?d.distance:1/0,S=e.options,k=S.normalRequired||!S.backfacesTerrain,j=new E(y,!1,k),M=i=>{let c=i.renderData;if(!c?.vao)return!0;let h=c.geometry;_(K,h.boundingBox);let E=c.localOrigin;if(g!=null&&(g.localOrigin=E,g.applyToAabb(K)),X[0]=n[0]-E[0],X[1]=n[1]-E[1],X[2]=n[2]-E[2],!T(K,X,u,y,x))return!0;let A=(e,t,n,r)=>{e.set(this.type,i,t,n,r),x=m&&d.renderDistance!=null?d.renderDistance:1/0},M=(r,i,s)=>{(!k||s!=null)&&i>=0&&(S.backfacesTerrain||a(s,l)<0)&&(S.invisibleTerrain||!S.selectionMode||t==null||t(n,o,i))&&((p.renderDistance==null||i<p.renderDistance)&&A(p,r,i,s),S.isFiltered||(S.store===2&&(b==null?(b=new w(e.ray),A(b,r,i,s),e.results.all.push(b)):i<b.renderDistance&&A(b,r,i,s)),(d.renderDistance==null||i<d.renderDistance)&&A(d,r,i,s),S.store!==0&&(f.renderDistance==null||i>f.renderDistance)&&A(f,r,i,s)))},N=Z;r(N,o,E);let{indices:P,indexCount:F}=h,I=h.vertexAttributes,L=I.getField(`position`,v),R=new C(L.typedBuffer,3,I.stride/4),z=F/3;if(!g&&z>200){if(c.intersectionData??=new O(P,z,R,!0,[h.poleIndicesStartIndex/3,h.edgeIndicesStartIndex/3]),c.intersectionData.advance(s),!c.intersectionData.ready||s.done)return!1;c.intersectionData.intersectRay(X,N,j,M)}else D(X,N,0,z,(e,t)=>L.getVec(P[t],e),g,j,M);return!0},N=this._tileIterator;N.reset(c);let P=e.options.invisibleTerrain;for(let e=N.next();e;e=N.next()){if(s.done)return!1;if((e.visible||P&&e.intersectsClippingArea)&&(g!=null||e.intersectsRay(n,l,y,x))&&(!h||!U(e,this._stencilEnabledLayerExtents))){if(!M(e))return!1}else N.skipSubtree()}return s.madeProgress(),!0}processScaleRangeQueries(e,t){if(!t.done&&e)for(this._updatePatchGroups();e.updating&&!t.done;){e.prepare();for(let t of this._visiblePatchesByOrigin.values())for(let n of t)n.renderData?.textureReference!=null&&e.queriesForTile(n);e.process(),t.madeProgress()}}get _view(){return this._surface.view}get _desiredSlot(){if(!this._produces())return null;switch(this.transparency){case 0:return 1;case 1:case 2:return 7;case 3:case 4:return null}}acquireTechniques(e){let{shadowMap:t,viewshedEnabled:n,cutFillComputationEnabled:r,slot:i,hasEmission:a,useFloatBlend:o}=e.bind,s=!!has(`enable-feature:terrain-shadows`)&&t.enabled;if(s!==this._castShadows&&(this._castShadows=s,this._patchesByOriginDirty=!0),this._inViewshed!==n&&(this._inViewshed=n,this._patchesByOriginDirty=!0),this._cutFillEnabled!==r&&(this._cutFillEnabled=r,this._patchesByOriginDirty=!0),this.transparency===3)return null;if(i===9){if((e.renderOccludedMask&I)===0)return null}else if(i!==this._desiredSlot)return null;let c=this._configuration;switch(c.receiveGlobalIllumination=c.screenSpaceReflections=c.cloudReflections=c.receiveShadows=c.hasShadowHighlights=c.receiveAmbientOcclusion=c.renderOccluded=c.hasHighlightMixTexture=!1,c.hasEmission=a,c.overlayMode=this._overlayRenderer.mode,c.useFloatBlend=o.value,e.output){case 0:case 1:case 2:{let n=e.bind;c.screenSpaceReflections=n.hasScreenSpaceReflections,c.cloudReflections=n.clouds.data!=null;let r=i===9;return c.receiveShadows=t.ready&&!r,c.hasShadowHighlights=M(c,e.bind),c.renderOccluded=r,c.receiveAmbientOcclusion=!r&&n.ssao!=null,c.receiveGlobalIllumination=!r&&n.globalIlluminationEnabled,this._acquireTechnique(e.output)}case 5:case 7:return this._castShadows?this._acquireTechnique(5):null;case 8:return this._inViewshed?this._acquireTechnique(8):null;case 9:return this._cutFillEnabled?this._acquireTechnique(9):null;case 3:case 4:case 11:return this._acquireTechnique(e.output);case 10:return c.hasHighlightMixTexture=e.bind.highlightMixTexture!=null,this._overlayRenderer.hasHighlights?this._acquireTechnique(10):null}return null}render(e,t){switch(this._updatePatchGroups(),this._passParameters.useStencil=!1,this._passParameters.overlayContent=x(e.output,e.bind),e.output){case 0:case 1:case 2:return this._renderMaterialPass(e,t);case 3:case 4:case 11:return this._renderAuxiliaryPass(e,t,this._visiblePatchesByOrigin);case 10:{let n=e.bind.highlight?.name;n&&this._overlayRenderer.hasHighlights&&this._overlayRenderer.renders(2)&&this._overlayRenderer.hasHighlight(n)&&this._renderAuxiliaryPass(e,t,this._visiblePatchesByOrigin);break}case 5:case 7:case 8:case 9:return this._renderAuxiliaryPass(e,t,this._allPatchesByOrigin)}}updateTileBackground(e){if(this._tileRenderer==null)return;let t=this._tileRenderer,n;if(e!=null){let t=e.toUnitRGBA();n=s(t[0]||0,t[1]||0,t[2]||0)}t.setBackground(n),this._allTiles.forAll(e=>{t.updateTileTexture(e,0)||e.updateRenderData(1,0)}),this._configuration.tileBlendInput=t.backgroundIsGrid?2:t.backgroundColor==null?0:1,this.requestRender()}_updatePatchGroups(){if(this._patchesByOriginDirty&&(this._rebuildPatchGroups(),this._patchesByOriginDirty=!1,this._patchSortingDirty=!0),this._patchSortingDirty){let e=Array.from(this._visiblePatchesByOrigin.values()),t=this._stencilEnabledLayerExtents;for(let n of e)W(n,t);e.sort((e,t)=>G(e[0],t[0])),this._visiblePatchesByOrigin=new Map(e.map(e=>[e[0].renderData.localOrigin,e])),this.notifyChange(`visibleTiles`),this._patchSortingDirty=!1}}_rebuildPatchGroups(){let e=this._rootTiles;if(e!=null){e[0]?.surface.checkAllTilesWaterproofness(`render-patch-groups`),this._visiblePatchesByOrigin.clear(),this._allPatchesByOrigin.clear();for(let t of e)this._rebuildPatchGroupsForRootTile(t)}}_rebuildPatchGroupsForRootTile(e){let t=this._tileIterator;for(t.resetOne(e);!t.done;){let e=t.next(),n=e.renderData;if(!n){this._numTilesCulled++;continue}let r=n.localOrigin;if(this._castShadows||this._inViewshed||this._cutFillEnabled){let t=this._allPatchesByOrigin.get(r);t||(t=[],this._allPatchesByOrigin.set(r,t)),t.push(e)}if(!e.visible){this._numTilesCulled++,t.skipSubtree();continue}let i=this._visiblePatchesByOrigin.get(r);i||(i=[],this._visiblePatchesByOrigin.set(r,i)),i.push(e),t.skipSubtree()}}_renderAuxiliaryPass(e,t,n){let{rctx:r,bind:i}=e;r.bindTechnique(t,i,this._passParameters);let a=!!this._stencilEnabledLayerExtents?.length;n.forEach(n=>{this._drawParameters.origin=n[0].renderData.localOrigin,t.program.bindDraw(i,this._passParameters,this._drawParameters);for(let r=0;r<n.length;r++)this._renderPatch(e,t,n[r],b.TRIANGLES,a,this._passParameters.overlayContent===null)}),r.bindVAO(null)}_renderMaterialPass(e,t){let{rctx:n,bind:r}=e,i=n.bindTechnique(t,r,this._passParameters);this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0;let a=r.slot===9;a&&(i.bindTexture(`tex`,n.emptyTexture),i.setUniform3fv(`textureOpacities`,o),i.setUniform4fv(`texOffsetAndScale`,u));let s=this._tileRenderer?.backgroundColor==null?o:this._tileRenderer.backgroundColor;this._configuration.tileBlendInput===1&&i.setUniform3fv(`backgroundColor`,s);let c=!!this._stencilEnabledLayerExtents?.length,l=this.wireframe?b.LINES:b.TRIANGLES;this._configuration.textureFadingEnabled&&i.bindTexture(`texNext`,n.emptyTexture);for(let n of this._visiblePatchesByOrigin.values()){this._drawParameters.origin=n[0].renderData.localOrigin,t.program.bindDraw(r,this._passParameters,this._drawParameters),this._numOriginsRendered++;for(let r of n){let n=r.renderData,o=n.textureReference;if(o!=null){if(!a){i.setUniform4fv(`texOffsetAndScale`,o.offsetAndScale),i.bindTexture(`tex`,o.texture.texture);let e=n.textureFadeFactor,t=e<1?n.nextTextureReference:null;this._configuration.textureFadingEnabled&&t&&e<1?(i.setUniform1f(`fadeFactor`,e),i.setUniform4fv(`nextTexOffsetAndScale`,t.offsetAndScale),i.setUniform3fv(`nextTexOpacities`,t.opacities),i.bindTexture(`texNext`,t.texture.texture)):i.setUniform1f(`fadeFactor`,1),n.textureIsFading&&this.requestRender(2),i.setUniform3fv(`textureOpacities`,o.opacities)}this._renderPatch(e,t,r,l,c),r.renderOrder=this._numTilesRendered,this._numTilesRendered++}}}n.bindVAO(null)}_renderPatch(e,t,n,r,i,a=!1){let o=n.renderData,s=o.vao,c=s?.indexBuffer;if(!s||c==null){z&&console.error(`Rendered tile with no indices: `,n.lij,` : `,o);return}let l=t.program;!a&&!this._overlayRenderer.isEmpty&&this._bindOverlayPatchData(l,o.overlay);let{rctx:u,bind:d}=e;i&&(this._passParameters.useStencil=U(n,this._stencilEnabledLayerExtents),u.setPipelineState(t.getPipeline(d,this._passParameters)));let f=o.geometry.indexCount;u.bindVAO(s),l.assertCompatibleVertexAttributeLocations(s),u.drawElements(r,f,c.indexType,0)}_bindOverlayPatchData(e,t){e.setUniform4fv(`overlayTexOffset`,t.offsets),e.setUniform4fv(`overlayTexScale`,t.scales)}_acquireTechnique(e){return this._configuration.output=e,this._techniques.get(P,this._configuration)}get test(){}hasHighlight(e){return this._overlayRenderer.hasHighlight(e)}};e([t({readOnly:!0})],q.prototype,`visibleTiles`,null),e([t({readOnly:!0})],q.prototype,`_isGlobal`,null),e([t()],q.prototype,`renderOccludedFlags`,null),e([t({value:!1})],q.prototype,`renderingDisabled`,null),e([t({value:!0})],q.prototype,`visible`,null),e([t()],q.prototype,`renderPatchBorders`,null),e([t()],q.prototype,`wireframe`,null),q=e([n(`esri.views.3d.terrain.TerrainRenderer`)],q);const J=c(),Y=c(),X=c(),Z=c();export{q as TerrainRenderer};
|
|
2
|
+
import{__decorate as e}from"tslib";import{property as t,subclass as n}from"../../../core/accessorSupport/decorators.js";import has from"../../../core/has.js";import{subtract as r,set as i,dot as a}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{ZEROS as o,fromValues as s,create as c}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as l,ZEROS as u}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{disposeMaybe as d}from"../../../core/maybe.js";import{MemCachePool as f}from"../../../core/MemCachePool.js";import p from"../../../core/ObjectPool.js";import{watch as m,sync as h}from"../../../core/reactiveUtils.js";import{create as g,set as _}from"../../../geometry/support/aaBoundingBox.js";import{BufferViewVec3f as v}from"../../../geometry/support/buffer/BufferView.js";import{noBudget as y}from"../../support/Scheduler.js";import{PrimitiveType as b}from"../../webgl/enums.js";import{getOverlayContentForOutputTerrain as x}from"../webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js";import{SyncRenderPlugin as S}from"../webgl-engine/effects/RenderPlugin.js";import{Vertices as C}from"../webgl-engine/lib/Attribute.js";import{IntersectorResultRay as w}from"../webgl-engine/lib/IntersectorResult.js";import{intersectAabbInvDirBefore as T,MeshIntersectionOptions as E,intersectTriangles as D}from"../webgl-engine/lib/RayIntersections.js";import{TriangleRangeBVH as O}from"../webgl-engine/lib/TriangleRangeBVH.js";import{terrainId as k,getVerticalOffsetTerrain as A}from"../webgl-engine/lib/verticalOffsetUtils.js";import{DrawParameters as j}from"../webgl-engine/materials/DrawParameters.js";import{hasShadowHighlights as M}from"../webgl-engine/shaders/ReceiveShadowsConfiguration.js";import{T as N}from"../../../chunks/Terrain.glsl.js";import{TerrainTechnique as P}from"../webgl-engine/shaders/TerrainTechnique.js";import{TerrainTechniqueConfiguration as F}from"../webgl-engine/shaders/TerrainTechniqueConfiguration.js";import{overlayRenderOccludedFlag as I}from"./OverlayRenderer.js";import{PatchRenderData as L}from"./PatchRenderData.js";import{TerrainAttributesCache as R}from"./TerrainAttributesCache.js";import{enableTerrainInternalChecks as z}from"./terrainUtils.js";import{TileRenderer as B}from"./TileRenderer.js";import{IteratorPreorder as V,fallsWithinLayerView as H,usesStencil as U,sortTiles as W,compareTiles as G}from"./tileUtils.js";const K=g();let q=class extends S{get visibleTiles(){return Array.from(this._visiblePatchesByOrigin.values()).flat()}get _isGlobal(){return this._view.stage.isGlobal}get _techniques(){return this._context.techniques}get _rctx(){return this._context.renderContext.rctx}get renderOccludedFlags(){return this._overlayRenderer.renderOccludedFlags}constructor(e,t,n,r,i){super(),this._surface=e,this._overlayRenderer=t,this._allTiles=n,this._compressionTracker=r,this.type=7,this.isGround=!0,this._passParameters=new N,this._drawParameters=new j,this._renderDataPool=new p(()=>new L),this._visiblePatchesByOrigin=new Map,this._allPatchesByOrigin=new Map,this._patchesByOriginDirty=!0,this._patchSortingDirty=!0,this._tileIterator=new V,this._castShadows=!1,this._inViewshed=!1,this._cutFillEnabled=!1,this._tileRenderer=null,this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0,this.produces=new Map([[1,()=>this._desiredSlot===1],[7,()=>this._desiredSlot===7],[9,()=>this._produces()&&this.renderOccludedFlags===I]]),this._tileSize=256,this._configuration=new F(i.state.isGlobal),this._tileTextureCache=new f((e,t)=>i.resourceController.memoryController.newCache(e,t),`TileTexture`),this.tileGeometryCache=new R(i.resourceController.memoryController)}initialize(){this.addHandles(m(()=>this._overlayRenderer.renderOccludedFlags,()=>this.requestRender(),h))}destroy(){this._tileTextureCache.destroy(),this.tileGeometryCache.destroy(),this._allTiles.prune(),this._tileRenderer=null}_produces(){return this.visible&&!!this._rootTiles&&!this.renderingDisabled}set renderingDisabled(e){this._set(`renderingDisabled`,!!e),this.setDirty()}set visible(e){this._set(`visible`,!!e),this.setDirty()}updateHeading(e){this._tileRenderer?.updateHeading(e)}set transparency(e){this._configuration.transparencyMode!==e&&(this._configuration.transparencyMode=e,this.requestRender())}get transparency(){return this._configuration.transparencyMode}get renderPatchBorders(){return this._configuration.tileBorders}set renderPatchBorders(e){this._configuration.tileBorders!==e&&(this._configuration.tileBorders=e,this.requestRender(),this.notifyChange(`renderPatchBorders`))}get layerViewUid(){return k}get slicePlaneEnabled(){return this._configuration.hasSlicePlane}set slicePlaneEnabled(e){this._configuration.hasSlicePlane!==e&&(this._configuration.hasSlicePlane=e,this.requestRender())}set textureFadingEnabled(e){this._configuration.textureFadingEnabled!==e&&(this._configuration.textureFadingEnabled=e,this.requestRender())}set pbrMode(e){this._configuration.pbrMode!==e&&(this._configuration.pbrMode=e,this.requestRender())}setRootTiles(e){this._rootTiles=e,this.setDirty()}setStencilEnabledLayerExtents(e){this._stencilEnabledLayerExtents=e,this._setSortingDirty()}set tileSize(e){this._tileSize=e,this._tileRenderer!=null&&(this._tileRenderer.tileSize=e),this.setDirty()}get tileSize(){return this._tileSize}_ensureRenderData(e){e.renderData||(e.renderData=this._renderDataPool.acquire(),e.renderData.init(e,this._getLocalOriginOfTile(e)),e.surface.tileElevationRangeChanged(e))}loadTile(e){this._ensureRenderData(e),this.updateTileGeometryState(e),this.reuseTextureFromParent(e)||this.updateTileTexture(e,32)}reuseTextureFromParent(e){let{parent:t}=e;if(!this._canReuseTextureFromParent(t,e))return!1;let n=l(e.lij[2]&1?.5:0,e.lij[1]&1?0:.5,.5,.5);return t.renderData?.reuseTexture(e.renderData,n)??!1}_canReuseTextureFromParent(e,t){if(!e)return!1;let{layerInfo:n,surface:r}=t;for(let i=0;i<n[1].length;i++){let n=r.layerViewByIndex(i,1);if(H(e,n)!==H(t,n))return!1}return!0}updateTileTexture(e,t){if(this._tileRenderer!=null){let n=t===32?0:2;if(!this._tileRenderer.updateTileTexture(e,n))return e.updateRenderData(1,n),!1;this.requestRender(),e.resetPendingUpdate(t)}return!0}updateTileGeometryState(e){for(let t of e.layerInfo[0])t.pendingUpdates&=-9;e.resetPendingUpdate(8);let t=e.renderData.updateGeometryState();return this._surface.updateElevationSources(e),t&&this.setDirty(),t}updateGeometryIfNeeded(e){e.loaded&&e.renderData.updateGeometryIfNeeded(this._rctx)}unloadTile(e){let t=e.renderData;t&&(t.releaseGeometry(),this._renderDataPool.release(t),t.dispose(),e.renderData=null,e.surface.tileElevationRangeChanged(e,e.elevationBoundsMin,e.elevationBoundsMax),e.setMemoryDirty(),this.setDirty())}_getLocalOriginOfTile(e){let t=Math.max(0,Math.floor((e.level-3)/7)*7);if(this._isGlobal&&t===0)return o;for(;e.parent&&e.level>t;)e=e.parent;return e.centerAtSeaLevel}getStats(){return{numTilesRendered:this._numTilesRendered,numTilesCulled:this._numTilesCulled,numOriginsRendered:this._numOriginsRendered}}set wireframe(e){this._get(`wireframe`)!==e&&(this._set(`wireframe`,e),this.requestRender())}setDirty(e=1){this._patchesByOriginDirty=!0,this._context.requestRender(e)}_setSortingDirty(e=1){this._patchSortingDirty=!0,this._context.requestRender(e)}requestRender(e=1){this._context.requestRender(e)}initializeRenderContext(e){this._context=e,this._tileRenderer=new B(this._surface,this._rctx,this._tileSize,this._techniques,this._tileTextureCache,this._compressionTracker),this.updateTileBackground()}uninitializeRenderContext(){this._tileRenderer=d(this._tileRenderer)}intersectRay(e,t,n,r){this.intersectRayBudgeted(e,t,n,r,y)}intersectRayBudgeted(e,t,n,o,s){let c=this._rootTiles;if(!c||e.options.selectOpaqueTerrainOnly&&e.options.selectionMode&&this.transparency!==0)return!0;let l=J,u=Y;r(l,o,n),i(u,1/l[0],1/l[1],1/l[2]);let d=e.results.min,f=e.results.max,p=e.results.ground,m=e.options.store===0,h=!!e.results.ground.target,g=A(e.verticalOffset),y=e.tolerance,b,x=m&&d.distance!=null?d.distance:1/0,S=e.options,k=S.normalRequired||!S.backfacesTerrain,j=new E(y,!1,k),M=i=>{let c=i.renderData;if(!c?.vao)return!0;let h=c.geometry;_(K,h.boundingBox);let E=c.localOrigin;if(g!=null&&(g.localOrigin=E,g.applyToAabb(K)),X[0]=n[0]-E[0],X[1]=n[1]-E[1],X[2]=n[2]-E[2],!T(K,X,u,y,x))return!0;let A=(e,t,n,r)=>{e.set(this.type,i,t,n,r),x=m&&d.renderDistance!=null?d.renderDistance:1/0},M=(r,i,s)=>{(!k||s!=null)&&i>=0&&(S.backfacesTerrain||a(s,l)<0)&&(S.invisibleTerrain||!S.selectionMode||t==null||t(n,o,i))&&((p.renderDistance==null||i<p.renderDistance)&&A(p,r,i,s),S.isFiltered||(S.store===2&&(b==null?(b=new w(e.ray),A(b,r,i,s),e.results.all.push(b)):i<b.renderDistance&&A(b,r,i,s)),(d.renderDistance==null||i<d.renderDistance)&&A(d,r,i,s),S.store!==0&&(f.renderDistance==null||i>f.renderDistance)&&A(f,r,i,s)))},N=Z;r(N,o,E);let{indices:P,indexCount:F}=h,I=h.vertexAttributes,L=I.getField(`position`,v),R=new C(L.typedBuffer,3,I.stride/4),z=F/3;if(!g&&z>200){if(c.intersectionData??=new O(P,z,R,!0,[h.poleIndicesStartIndex/3,h.edgeIndicesStartIndex/3]),c.intersectionData.advance(s),!c.intersectionData.ready||s.done)return!1;c.intersectionData.intersectRay(X,N,j,M)}else D(X,N,0,z,(e,t)=>L.getVec(P[t],e),g,j,M);return!0},N=this._tileIterator;N.reset(c);let P=e.options.invisibleTerrain;for(let e=N.next();e;e=N.next()){if(s.done)return!1;if((e.visible||P&&e.intersectsClippingArea)&&(g!=null||e.intersectsRay(n,l,y,x))&&(!h||!U(e,this._stencilEnabledLayerExtents))){if(!M(e))return!1}else N.skipSubtree()}return s.madeProgress(),!0}processScaleRangeQueries(e,t){if(!t.done&&e)for(this._updatePatchGroups();e.updating&&!t.done;){e.prepare();for(let t of this._visiblePatchesByOrigin.values())for(let n of t)n.renderData?.textureReference!=null&&e.queriesForTile(n);e.process(),t.madeProgress()}}get _view(){return this._surface.view}get _desiredSlot(){if(!this._produces())return null;switch(this.transparency){case 0:return 1;case 1:case 2:return 7;case 3:case 4:return null}}acquireTechniques(e){let{shadowMap:t,viewshedEnabled:n,cutFillComputationEnabled:r,slot:i,hasEmission:a,useFloatBlend:o}=e.bind,s=!!has(`enable-feature:terrain-shadows`)&&t.enabled;if(s!==this._castShadows&&(this._castShadows=s,this._patchesByOriginDirty=!0),this._inViewshed!==n&&(this._inViewshed=n,this._patchesByOriginDirty=!0),this._cutFillEnabled!==r&&(this._cutFillEnabled=r,this._patchesByOriginDirty=!0),this.transparency===3)return null;if(i===9){if((e.renderOccludedMask&I)===0)return null}else if(i!==this._desiredSlot)return null;let c=this._configuration;switch(c.receiveGlobalIllumination=c.screenSpaceReflections=c.cloudReflections=c.receiveShadows=c.hasShadowHighlights=c.receiveAmbientOcclusion=c.renderOccluded=c.hasHighlightMixTexture=!1,c.hasEmission=a,c.overlayMode=this._overlayRenderer.mode,c.useFloatBlend=o.value,e.output){case 0:case 1:case 2:{let n=e.bind;c.screenSpaceReflections=n.hasScreenSpaceReflections,c.cloudReflections=n.clouds.data!=null,c.emissionReflections=c.screenSpaceReflections&&a&&n.reprojection.lastFrameEmission!=null;let r=i===9;return c.receiveShadows=t.ready&&!r,c.hasShadowHighlights=M(c,e.bind),c.renderOccluded=r,c.receiveAmbientOcclusion=!r&&n.ssao!=null,c.receiveGlobalIllumination=!r&&n.globalIlluminationEnabled,this._acquireTechnique(e.output)}case 5:case 7:return this._castShadows?this._acquireTechnique(5):null;case 8:return this._inViewshed?this._acquireTechnique(8):null;case 9:return this._cutFillEnabled?this._acquireTechnique(9):null;case 3:case 4:case 11:return this._acquireTechnique(e.output);case 10:return c.hasHighlightMixTexture=e.bind.highlightMixTexture!=null,this._overlayRenderer.hasHighlights?this._acquireTechnique(10):null}return null}render(e,t){switch(this._updatePatchGroups(),this._passParameters.useStencil=!1,this._passParameters.overlayContent=x(e.output,e.bind),e.output){case 0:case 1:case 2:return this._renderMaterialPass(e,t);case 3:case 4:case 11:return this._renderAuxiliaryPass(e,t,this._visiblePatchesByOrigin);case 10:{let n=e.bind.highlight?.name;n&&this._overlayRenderer.hasHighlights&&this._overlayRenderer.renders(2)&&this._overlayRenderer.hasHighlight(n)&&this._renderAuxiliaryPass(e,t,this._visiblePatchesByOrigin);break}case 5:case 7:case 8:case 9:return this._renderAuxiliaryPass(e,t,this._allPatchesByOrigin)}}updateTileBackground(e){if(this._tileRenderer==null)return;let t=this._tileRenderer,n;if(e!=null){let t=e.toUnitRGBA();n=s(t[0]||0,t[1]||0,t[2]||0)}t.setBackground(n),this._allTiles.forAll(e=>{t.updateTileTexture(e,0)||e.updateRenderData(1,0)}),this._configuration.tileBlendInput=t.backgroundIsGrid?2:t.backgroundColor==null?0:1,this.requestRender()}_updatePatchGroups(){if(this._patchesByOriginDirty&&(this._rebuildPatchGroups(),this._patchesByOriginDirty=!1,this._patchSortingDirty=!0),this._patchSortingDirty){let e=Array.from(this._visiblePatchesByOrigin.values()),t=this._stencilEnabledLayerExtents;for(let n of e)W(n,t);e.sort((e,t)=>G(e[0],t[0])),this._visiblePatchesByOrigin=new Map(e.map(e=>[e[0].renderData.localOrigin,e])),this.notifyChange(`visibleTiles`),this._patchSortingDirty=!1}}_rebuildPatchGroups(){let e=this._rootTiles;if(e!=null){e[0]?.surface.checkAllTilesWaterproofness(`render-patch-groups`),this._visiblePatchesByOrigin.clear(),this._allPatchesByOrigin.clear();for(let t of e)this._rebuildPatchGroupsForRootTile(t)}}_rebuildPatchGroupsForRootTile(e){let t=this._tileIterator;for(t.resetOne(e);!t.done;){let e=t.next(),n=e.renderData;if(!n){this._numTilesCulled++;continue}let r=n.localOrigin;if(this._castShadows||this._inViewshed||this._cutFillEnabled){let t=this._allPatchesByOrigin.get(r);t||(t=[],this._allPatchesByOrigin.set(r,t)),t.push(e)}if(!e.visible){this._numTilesCulled++,t.skipSubtree();continue}let i=this._visiblePatchesByOrigin.get(r);i||(i=[],this._visiblePatchesByOrigin.set(r,i)),i.push(e),t.skipSubtree()}}_renderAuxiliaryPass(e,t,n){let{rctx:r,bind:i}=e;r.bindTechnique(t,i,this._passParameters);let a=!!this._stencilEnabledLayerExtents?.length;n.forEach(n=>{this._drawParameters.origin=n[0].renderData.localOrigin,t.program.bindDraw(i,this._passParameters,this._drawParameters);for(let r=0;r<n.length;r++)this._renderPatch(e,t,n[r],b.TRIANGLES,a,this._passParameters.overlayContent===null)}),r.bindVAO(null)}_renderMaterialPass(e,t){let{rctx:n,bind:r}=e,i=n.bindTechnique(t,r,this._passParameters);this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0;let a=r.slot===9;a&&(i.bindTexture(`tex`,n.emptyTexture),i.setUniform3fv(`textureOpacities`,o),i.setUniform4fv(`texOffsetAndScale`,u));let s=this._tileRenderer?.backgroundColor==null?o:this._tileRenderer.backgroundColor;this._configuration.tileBlendInput===1&&i.setUniform3fv(`backgroundColor`,s);let c=!!this._stencilEnabledLayerExtents?.length,l=this.wireframe?b.LINES:b.TRIANGLES;this._configuration.textureFadingEnabled&&i.bindTexture(`texNext`,n.emptyTexture);for(let n of this._visiblePatchesByOrigin.values()){this._drawParameters.origin=n[0].renderData.localOrigin,t.program.bindDraw(r,this._passParameters,this._drawParameters),this._numOriginsRendered++;for(let r of n){let n=r.renderData,o=n.textureReference;if(o!=null){if(!a){i.setUniform4fv(`texOffsetAndScale`,o.offsetAndScale),i.bindTexture(`tex`,o.texture.texture);let e=n.textureFadeFactor,t=e<1?n.nextTextureReference:null;this._configuration.textureFadingEnabled&&t&&e<1?(i.setUniform1f(`fadeFactor`,e),i.setUniform4fv(`nextTexOffsetAndScale`,t.offsetAndScale),i.setUniform3fv(`nextTexOpacities`,t.opacities),i.bindTexture(`texNext`,t.texture.texture)):i.setUniform1f(`fadeFactor`,1),n.textureIsFading&&this.requestRender(2),i.setUniform3fv(`textureOpacities`,o.opacities)}this._renderPatch(e,t,r,l,c),r.renderOrder=this._numTilesRendered,this._numTilesRendered++}}}n.bindVAO(null)}_renderPatch(e,t,n,r,i,a=!1){let o=n.renderData,s=o.vao,c=s?.indexBuffer;if(!s||c==null){z&&console.error(`Rendered tile with no indices: `,n.lij,` : `,o);return}let l=t.program;!a&&!this._overlayRenderer.isEmpty&&this._bindOverlayPatchData(l,o.overlay);let{rctx:u,bind:d}=e;i&&(this._passParameters.useStencil=U(n,this._stencilEnabledLayerExtents),u.setPipelineState(t.getPipeline(d,this._passParameters)));let f=o.geometry.indexCount;u.bindVAO(s),l.assertCompatibleVertexAttributeLocations(s),u.drawElements(r,f,c.indexType,0)}_bindOverlayPatchData(e,t){e.setUniform4fv(`overlayTexOffset`,t.offsets),e.setUniform4fv(`overlayTexScale`,t.scales)}_acquireTechnique(e){return this._configuration.output=e,this._techniques.get(P,this._configuration)}get test(){}hasHighlight(e){return this._overlayRenderer.hasHighlight(e)}};e([t({readOnly:!0})],q.prototype,`visibleTiles`,null),e([t({readOnly:!0})],q.prototype,`_isGlobal`,null),e([t()],q.prototype,`renderOccludedFlags`,null),e([t({value:!1})],q.prototype,`renderingDisabled`,null),e([t({value:!0})],q.prototype,`visible`,null),e([t()],q.prototype,`renderPatchBorders`,null),e([t()],q.prototype,`wireframe`,null),q=e([n(`esri.views.3d.terrain.TerrainRenderer`)],q);const J=c(),Y=c(),X=c(),Z=c();export{q as TerrainRenderer};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import t from"../../../../../core/Accessor.js";import{subclass as n}from"../../../../../core/accessorSupport/decorators/subclass.js";import"../../../../../core/has.js";import{clone as r}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import i from"../../../../../core/Logger.js";import a from"../../../../../core/PooledArray.js";import{watch as o,sync as s}from"../../../../../core/reactiveUtils.js";import{isTypedArray as c}from"../../../../../core/typedArrayUtil.js";import{create as l}from"../../../../../geometry/support/aaBoundingBox.js";import{d as u}from"../../../../../chunks/vec3.js";import{c as d}from"../../../../../chunks/vec32.js";import{compactIndices as f}from"../../../../../geometry/support/Indices.js";import{BufferObject as p}from"../../../../webgl/BufferObject.js";import{PrimitiveType as m}from"../../../../webgl/enums.js";import{VertexBuffer as h}from"../../../../webgl/VertexBuffer.js";import{SamplerRepository as g}from"../../lib/SamplerRepository.js";import{BufferManager as _}from"../../lib/TextureBackedBuffer/BufferManager.js";import{VertexArrayObject as v}from"../../lib/VertexArrayObject.js";import{getVerticalOffsetI3S as y}from"../../lib/verticalOffsetUtils.js";import{getComponentDataLayout as b,IndexGlLayout as x}from"../../materials/DefaultLayouts.js";import{ComponentData as S}from"./ComponentData.js";import{defaultComponentParameters as C,ComponentDrawParametersImplementation as w}from"./ComponentDrawParameters.js";import{ComponentObject as T}from"./ComponentObject.js";import{IntersectionGeometry as E}from"./IntersectionGeometry.js";import{ComponentMaterialParameters as D}from"./Material/ComponentMaterialInitParameters.js";import{ComponentMaterialRepository as O}from"./Material/ComponentMaterialRepository.js";import{RenderableMeta as k,Renderable as A}from"./Renderable.js";import{RenderGeometry as j}from"./RenderGeometry.js";import{RenderSubmitSystem as M}from"./RenderSubmitSystem.js";const N=()=>i.getLogger(`esri.views.3d.webgl-engine.collections.Component.ComponentObjectCollection`);let P=class extends t{constructor(e,t,n){super(),this._renderPassManager=e,this._isGlobal=t,this._elevationRangeCacheVerticalOffset=NaN,this._elevationRangeCacheMin=NaN,this._elevationRangeCacheMax=NaN,this._highlightsInOrder=[],this._highlights=null,this._activeHighlightOptions=new Map,this._visible=new a,this._hidden=new a,this._renderSubmit=new M(this),this._renderPassManager.register(this._renderSubmit);let{rctx:r,bind:i}=e;this._componentBufferManager=new _(r,b());let c=this._isGlobal?n?1:2:0;this.materials=new O(i,c),this.samplers=new g(r.gl),this.addHandles(o(()=>i.useFloatBlend.value,()=>{this._visible.forAll(e=>e.updateMaterial(this.materials.globals)),this._hidden.forAll(e=>e.updateMaterial(this.materials.globals)),this._requestRender()},s))}destroy(){this._componentBufferManager.destroy(),this._componentBufferManager=null,this._visible.forAll(e=>e.destroy()),this._visible.prune(),this._hidden.forAll(e=>e.destroy()),this._hidden.prune(),this._renderSubmit.destroy(),this.samplers.dispose(),this.materials.destroy()}createObject(e,t){let{geometry:n}=e,r=new S(this._componentBufferManager,f(n.componentOffsets)),i=this._createRenderable(e,t,r),a=new E(this._isGlobal,n.positions,r,e.elevationAlignable),o=new T(this,e.transform,e.obb.clone(),r,i,a,e.aabbInWorldCoordinates);return(o.visible?this._visible:this._hidden).push(o),o}destroyObject(e){let t=e;(t.visible?this._visible:this._hidden).removeUnordered(t),t.destroy(),this._requestRender()}setObjectVisibility(e,t){let n=e;t!==n.visible&&(t?(this._hidden.removeUnordered(n),this._visible.push(n)):(this._visible.removeUnordered(n),this._hidden.push(n)),n.visible=t,this._requestRender())}preSubmit(e){let{camera:t,highlights:n}=e;this._updateHighlightsInOrder(n),this._componentBufferManager.updateTextures(),this.visibleObjects.forAll(e=>e.updateCameraDerivedParameters(t))}getObjectOpacity(e){return e.renderable.drawParameters.opacity}updateObjectOpacity(e,t,n){let r=e;(r.opacity!==t||n!==void 0&&n!==r.renderable.material.parameters.groundTransparencyMode)&&(r.updateOpacity(t,n),this._requestRender())}isSliceplaneEnabled(e){return e.renderable.material.slicePlaneEnabled}setAllComponentVisibilities(e,t){let n=e;n.componentData.visibility.reset(t),n.componentData.markVisibilityDirty(),this._requestRender()}forEachVisibleComponent(e,t){return e.componentData.visibility.forEachComponent(t)}getComponentCount(e){let{componentData:t}=e,n=t.visibility.componentCount;return{visible:n,invisible:t.count-n}}setComponentData(e,t){e.setComponentData(t,this._isGlobal),this._elevationRangeCacheVerticalOffset=NaN,this._requestRender()}getComponentAabb(e,t,n,r=!1){e.intersectionGeometry.getComponentAabb(t,n);let i=e,a=i.componentData.verticalOffsets;if(r||a==null)return n;let o=a[t];if(!this._isGlobal||o===0)return n[2]+=o,n[5]+=o,n;let s=y(o);return s.localOrigin=i.transform.position,s.applyToAabb(n)}getComponentObb(e){return e.obb}getObjectTransform(e){return e.transform}getComponentPositions(e,t,n){return e.intersectionGeometry.getComponentPositions(t,n)}_updateHighlightsInOrder(e){if(this._highlights===e)return;let{_highlightsInOrder:t}=this,n=Math.min(e.length,8),r=t.length!==n;for(let i=0;i<n;++i)if(t[i]!==e[i].name){r=!0;break}if(this._highlights=e,r){t.length=n;for(let r=0;r<n;++r)t[r]=e[r].name;this._syncHighlightedObjectHighlightOrder()}}_syncHighlightedObjectHighlightOrder(){let e=this._highlightsInOrder,t=t=>{t.componentData.componentHighlights.size>0&&t.componentData.setHighlightsInOrder(e)};this._visible.forAll(t),this._hidden.forAll(t)}expandRangeWithComponentObjectElevationRange(e,t,n,r){!Number.isNaN(this._elevationRangeCacheVerticalOffset)&&this._elevationRangeCacheVerticalOffset===t&&r.expandElevationRangeValues(this._elevationRangeCacheMin,this._elevationRangeCacheMax);let i=e,{componentData:a}=i,o=a.count,{verticalOffsets:s}=a,{intersectionGeometry:c}=i,l=c.getComponentAabbs(),u=F,d=1/0,f=-1/0;for(let e=0;e<o;e++){let a=e*6,o=s?.[e]??0,c=1/0,p=-1/0;if(this._isGlobal){if(u[0]=l[a],u[1]=l[a+1],u[2]=l[a+2],u[3]=l[a+3],u[4]=l[a+4],u[5]=l[a+5],o!==0){let e=y(o);e.localOrigin=i.transform.position,e.applyToAabb(u)}let e=Math.max(Math.abs(u[3]),Math.abs(u[0])),s=Math.max(Math.abs(u[4]),Math.abs(u[1])),c=t+u[5]+n;r.expandElevationRangeValues(t+u[2],Math.sqrt(e*e+s*s+c*c)-n)}else c=l[a+2]+o+t,p=l[a+5]+o+t;r.expandElevationRangeValues(c,p),d=Math.min(d,c),f=Math.max(f,p)}this._elevationRangeCacheVerticalOffset=t,this._elevationRangeCacheMin=d,this._elevationRangeCacheMax=f}intersectRay(e,t,n,r,i,a){let{transform:o,componentData:s,intersectionGeometry:c}=e;r!=null&&(r.localOrigin=o.position),c.intersectRay(t,n,r,s.verticalOffsets,o,i,a)}*intersectScreenPolygon(e,t,n,r,i){let{transform:a,componentData:o,intersectionGeometry:s}=e;r!=null&&(r.localOrigin=a.position),yield*s.intersectScreenPolygon(t,n,r,o.verticalOffsets,a,i)}addEdges(e,t,n,r,i){let a=e,{indices:o,positions:s}=a.intersectionGeometry,c=a.componentData.offsets;return t.addComponentObject(a,s,o,c,n,r,i)}async extractEdgeInformation(e,t,n){let i=e,a=i.componentData.visibility;if(a.allInvisible()){let{extractComponentsEdgeLocationsLayout:e}=await import(`../../lib/edgeRendering/edgeProcessing.js`);return{buffer:e.createBuffer(0),origin:[0,0,0]}}let{indices:o,positions:s}=i.intersectionGeometry,c=i.componentData.offsets,{EdgeInputBufferLayout:l}=await import(`../../lib/edgeRendering/bufferLayouts.js`),f=l.createBuffer(s.length/3);d(f.position.typedBuffer,s,f.position.typedBufferStride,3),u(f.position,f.position,i.transform.rotationScale),this._setComponentIndices(f.componentIndex,o,c);let p=f.count,m=this._computeVisibilityIndices(o,a,c,p);return{origin:r(i.transform.position),buffer:await t.extractComponentsEdgeLocations({indices:m,indicesLength:m.length,skipDeduplicate:!0,data:f,writerSettings:{reducedPrecision:!1,variants:0}},n)}}_setComponentIndices(e,t,n){let r=0;for(let i=0;i<n.length-1;i++){let a=n[i],o=n[i+1];for(let n=a;n<o;n++){let i=t?t[n]:n;e.set(i,r)}r++}}_computeVisibilityIndices(e,t,n,r){if(e&&t.allVisible())return e;let i=0;t.forEachComponentRange((e,t)=>(i+=n[t]-n[e],!0));let a=c(e)?e?.BYTES_PER_ELEMENT===2||r<=65536?new Uint16Array(i):new Uint32Array(i):Array(i),o=0;return t.forEachComponentRange((t,r)=>{let i=n[t],s=n[r];for(let t=i;t<s;t++)a[o++]=e?e[t]:t;return!0}),a}addHighlight(e,t,n){let r=e,i=this._activeHighlightOptions.get(n)??0;this._activeHighlightOptions.set(n,i+1),r.componentData.setHighlightsInOrder(this._highlightsInOrder),r.addHighlight(t,n)&&this._requestRender()}removeHighlight(e,t,n){let r=e.removeHighlight(t,n);r!==`notfound`&&(this._removeActiveHighlight(n),r&&this._requestRender())}_removeActiveHighlight(e,t=1){let n=this._activeHighlightOptions.get(e);if(n===void 0)N().warn(`Removing non-existing highlight "${e}".`);else{let r=n-t;r<0&&N().warn(`Removing non-existing highlight "${e}".`),r<=0?this._activeHighlightOptions.delete(e):this._activeHighlightOptions.set(e,r)}}clearHighlights(e){let t=e,{componentData:n}=t,{componentHighlights:r}=t.componentData;if(r.size>0){for(let e of r)this._removeActiveHighlight(e[0],e[1][n.count]);t.clearHighlights(),this._requestRender()}}hasHighlight(e){return this._activeHighlightOptions.has(e)}getObjectGPUMemoryUsage(e){return e.renderable.meta.gpuMemoryEstimate}get visibleObjects(){return this._visible}_createRenderable(e,t,n){let r=this._renderPassManager.rctx,i=e.geometry,a=i.parameters.layout,{interleavedVertexData:o,indexData:s,vertexCount:c}=i.renderGeometryData,l=new h(r,a,o),u=s?p.createIndex(r,35044,s):null,d=0,f=[[`geometry`,l]];if(!t.isIntegratedMesh){let e=new Uint16Array(c);for(let t=0;t<n.count;t++){let r=n.offsets[t],i=n.offsets[t+1],a=n.materialDataIndices[t];if(s!=null)for(let t=r;t<i;t++){let n=s[t];e[n]=a}else for(let t=r;t<i;t++)e[t]=a}let t=new h(r,x,e.buffer);d+=t.usedMemory,f.push([`componentIndices`,t])}let g=new v(r,new Map(f),u),_=s?.length??c,y=new j(g,m.TRIANGLES,i.parameters,u!=null,_),b=new D(t),S=this.materials.acquire(b,y.parameters,C),T=new k(l.usedMemory+d+(u?.usedMemory??0)),E=this.samplers.addFromTexture(t.baseColorTexture?.texture),O=new w(e,t,E);return new A(S,O,y,T)}_requestRender(){this._renderPassManager.requestRender()}};P=e([n(`esri.views.3d.webgl-engine.collections.Component.ComponentObjectCollection`)],P);const F=l();export{P as ComponentObjectCollection};
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../../../../../core/Accessor.js";import{subclass as n}from"../../../../../core/accessorSupport/decorators/subclass.js";import"../../../../../core/has.js";import{clone as r}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import i from"../../../../../core/Logger.js";import a from"../../../../../core/PooledArray.js";import{watch as o,sync as s}from"../../../../../core/reactiveUtils.js";import{isTypedArray as c}from"../../../../../core/typedArrayUtil.js";import{create as l}from"../../../../../geometry/support/aaBoundingBox.js";import{d as u}from"../../../../../chunks/vec3.js";import{c as d}from"../../../../../chunks/vec32.js";import{compactIndices as f}from"../../../../../geometry/support/Indices.js";import{BufferObject as p}from"../../../../webgl/BufferObject.js";import{PrimitiveType as m}from"../../../../webgl/enums.js";import{VertexBuffer as h}from"../../../../webgl/VertexBuffer.js";import{SamplerRepository as g}from"../../lib/SamplerRepository.js";import{BufferManager as _}from"../../lib/TextureBackedBuffer/BufferManager.js";import{VertexArrayObject as v}from"../../lib/VertexArrayObject.js";import{getVerticalOffsetI3S as y}from"../../lib/verticalOffsetUtils.js";import{getComponentDataLayout as b,IndexGlLayout as x}from"../../materials/DefaultLayouts.js";import{ComponentData as S}from"./ComponentData.js";import{defaultComponentParameters as C,ComponentDrawParametersImplementation as w}from"./ComponentDrawParameters.js";import{ComponentObject as T}from"./ComponentObject.js";import{IntersectionGeometry as E}from"./IntersectionGeometry.js";import{ComponentMaterialParameters as D}from"./Material/ComponentMaterialInitParameters.js";import{ComponentMaterialRepository as O}from"./Material/ComponentMaterialRepository.js";import{RenderableMeta as k,Renderable as A}from"./Renderable.js";import{RenderGeometry as j}from"./RenderGeometry.js";import{RenderSubmitSystem as M}from"./RenderSubmitSystem.js";const N=()=>i.getLogger(`esri.views.3d.webgl-engine.collections.Component.ComponentObjectCollection`);let P=class extends t{constructor(e,t,n){super(),this._renderPassManager=e,this._isGlobal=t,this._elevationRangeCacheVerticalOffset=NaN,this._elevationRangeCacheMin=NaN,this._elevationRangeCacheMax=NaN,this._highlightsInOrder=[],this._highlights=null,this._activeHighlightOptions=new Map,this._visible=new a,this._hidden=new a,this._renderSubmit=new M(this),this._renderPassManager.register(this._renderSubmit);let{rctx:r,bind:i}=e;this._componentBufferManager=new _(r,b());let c=this._isGlobal?n?1:2:0;this.materials=new O(i,c),this.samplers=new g(r.gl),this.addHandles(o(()=>i.useFloatBlend.value,()=>{this._visible.forAll(e=>e.updateMaterial(this.materials.globals)),this._hidden.forAll(e=>e.updateMaterial(this.materials.globals)),this._requestRender()},s))}destroy(){this._componentBufferManager.destroy(),this._componentBufferManager=null,this._visible.forAll(e=>e.destroy()),this._visible.prune(),this._hidden.forAll(e=>e.destroy()),this._hidden.prune(),this._renderSubmit.destroy(),this.samplers.dispose(),this.materials.destroy()}createObject(e,t){let{geometry:n}=e,r=new S(this._componentBufferManager,f(n.componentOffsets)),i=this._createRenderable(e,t,r),a=new E(this._isGlobal,n.positions,r,e.elevationAlignable),o=new T(this,e.transform,e.obb.clone(),r,i,a,e.aabbInWorldCoordinates);return(o.visible?this._visible:this._hidden).push(o),o}destroyObject(e){let t=e;(t.visible?this._visible:this._hidden).removeUnordered(t),t.destroy(),this._requestRender()}setObjectVisibility(e,t){let n=e;t!==n.visible&&(t?(this._hidden.removeUnordered(n),this._visible.push(n)):(this._visible.removeUnordered(n),this._hidden.push(n)),n.visible=t,this._requestRender())}preSubmit(e){let{camera:t,highlights:n}=e;this._updateHighlightsInOrder(n),this._componentBufferManager.updateTextures(),this.visibleObjects.forAll(e=>e.updateCameraDerivedParameters(t))}getObjectOpacity(e){return e.renderable.drawParameters.opacity}updateObjectOpacity(e,t,n){let r=e;(r.opacity!==t||n!==void 0&&n!==r.renderable.material.parameters.groundTransparencyMode)&&(r.updateOpacity(t,n),this._requestRender())}isSliceplaneEnabled(e){return e.renderable.material.slicePlaneEnabled}setAllComponentVisibilities(e,t){let n=e;n.componentData.visibility.reset(t),n.componentData.markVisibilityDirty(),this._requestRender()}forEachVisibleComponent(e,t){return e.componentData.visibility.forEachComponent(t)}getComponentCount(e){let{componentData:t}=e,n=t.visibility.componentCount;return{visible:n,invisible:t.count-n}}setComponentData(e,t){e.setComponentData(t,this._isGlobal),this._elevationRangeCacheVerticalOffset=NaN,this._requestRender()}getComponentAabb(e,t,n,r=!1){e.intersectionGeometry.getComponentAabb(t,n);let i=e,a=i.componentData.verticalOffsets;if(r||a==null)return n;let o=a[t];if(!this._isGlobal||o===0)return n[2]+=o,n[5]+=o,n;let s=y(o);return s.localOrigin=i.transform.position,s.applyToAabb(n)}getComponentObb(e){return e.obb}getObjectTransform(e){return e.transform}getComponentPositions(e,t,n){return e.intersectionGeometry.getComponentPositions(t,n)}_updateHighlightsInOrder(e){if(this._highlights===e)return;let{_highlightsInOrder:t}=this,n=Math.min(e.length,8),r=t.length!==n;for(let i=0;i<n;++i)if(t[i]!==e[i].name){r=!0;break}if(this._highlights=e,r){t.length=n;for(let r=0;r<n;++r)t[r]=e[r].name;this._syncHighlightedObjectHighlightOrder()}}_syncHighlightedObjectHighlightOrder(){let e=this._highlightsInOrder,t=t=>{t.componentData.componentHighlights.size>0&&t.componentData.setHighlightsInOrder(e)};this._visible.forAll(t),this._hidden.forAll(t)}expandRangeWithComponentObjectElevationRange(e,t,n,r){!Number.isNaN(this._elevationRangeCacheVerticalOffset)&&this._elevationRangeCacheVerticalOffset===t&&r.expandElevationRangeValues(this._elevationRangeCacheMin,this._elevationRangeCacheMax);let i=e,{componentData:a}=i,o=a.count,{verticalOffsets:s}=a,{intersectionGeometry:c}=i,l=c.getComponentAabbs(),u=F,d=1/0,f=-1/0;for(let e=0;e<o;e++){let a=e*6,o=s?.[e]??0,c=1/0,p=-1/0;if(this._isGlobal){if(u[0]=l[a],u[1]=l[a+1],u[2]=l[a+2],u[3]=l[a+3],u[4]=l[a+4],u[5]=l[a+5],o!==0){let e=y(o);e.localOrigin=i.transform.position,e.applyToAabb(u)}let e=Math.max(Math.abs(u[3]),Math.abs(u[0])),s=Math.max(Math.abs(u[4]),Math.abs(u[1])),c=t+u[5]+n;r.expandElevationRangeValues(t+u[2],Math.sqrt(e*e+s*s+c*c)-n)}else c=l[a+2]+o+t,p=l[a+5]+o+t;r.expandElevationRangeValues(c,p),d=Math.min(d,c),f=Math.max(f,p)}this._elevationRangeCacheVerticalOffset=t,this._elevationRangeCacheMin=d,this._elevationRangeCacheMax=f}intersectRay(e,t,n,r,i,a){let{transform:o,componentData:s,intersectionGeometry:c}=e;return r!=null&&(r.localOrigin=o.position),c.intersectRay(t,n,r,s.verticalOffsets,o,i,a)}*intersectScreenPolygon(e,t,n,r,i){let{transform:a,componentData:o,intersectionGeometry:s}=e;r!=null&&(r.localOrigin=a.position),yield*s.intersectScreenPolygon(t,n,r,o.verticalOffsets,a,i)}addEdges(e,t,n,r,i){let a=e,{indices:o,positions:s}=a.intersectionGeometry,c=a.componentData.offsets;return t.addComponentObject(a,s,o,c,n,r,i)}async extractEdgeInformation(e,t,n){let i=e,a=i.componentData.visibility;if(a.allInvisible()){let{extractComponentsEdgeLocationsLayout:e}=await import(`../../lib/edgeRendering/edgeProcessing.js`);return{buffer:e.createBuffer(0),origin:[0,0,0]}}let{indices:o,positions:s}=i.intersectionGeometry,c=i.componentData.offsets,{EdgeInputBufferLayout:l}=await import(`../../lib/edgeRendering/bufferLayouts.js`),f=l.createBuffer(s.length/3);d(f.position.typedBuffer,s,f.position.typedBufferStride,3),u(f.position,f.position,i.transform.rotationScale),this._setComponentIndices(f.componentIndex,o,c);let p=f.count,m=this._computeVisibilityIndices(o,a,c,p);return{origin:r(i.transform.position),buffer:await t.extractComponentsEdgeLocations({indices:m,indicesLength:m.length,skipDeduplicate:!0,data:f,writerSettings:{reducedPrecision:!1,variants:0}},n)}}_setComponentIndices(e,t,n){let r=0;for(let i=0;i<n.length-1;i++){let a=n[i],o=n[i+1];for(let n=a;n<o;n++){let i=t?t[n]:n;e.set(i,r)}r++}}_computeVisibilityIndices(e,t,n,r){if(e&&t.allVisible())return e;let i=0;t.forEachComponentRange((e,t)=>(i+=n[t]-n[e],!0));let a=c(e)?e?.BYTES_PER_ELEMENT===2||r<=65536?new Uint16Array(i):new Uint32Array(i):Array(i),o=0;return t.forEachComponentRange((t,r)=>{let i=n[t],s=n[r];for(let t=i;t<s;t++)a[o++]=e?e[t]:t;return!0}),a}addHighlight(e,t,n){let r=e,i=this._activeHighlightOptions.get(n)??0;this._activeHighlightOptions.set(n,i+1),r.componentData.setHighlightsInOrder(this._highlightsInOrder),r.addHighlight(t,n)&&this._requestRender()}removeHighlight(e,t,n){let r=e.removeHighlight(t,n);r!==`notfound`&&(this._removeActiveHighlight(n),r&&this._requestRender())}_removeActiveHighlight(e,t=1){let n=this._activeHighlightOptions.get(e);if(n===void 0)N().warn(`Removing non-existing highlight "${e}".`);else{let r=n-t;r<0&&N().warn(`Removing non-existing highlight "${e}".`),r<=0?this._activeHighlightOptions.delete(e):this._activeHighlightOptions.set(e,r)}}clearHighlights(e){let t=e,{componentData:n}=t,{componentHighlights:r}=t.componentData;if(r.size>0){for(let e of r)this._removeActiveHighlight(e[0],e[1][n.count]);t.clearHighlights(),this._requestRender()}}hasHighlight(e){return this._activeHighlightOptions.has(e)}getObjectGPUMemoryUsage(e){return e.renderable.meta.gpuMemoryEstimate}get visibleObjects(){return this._visible}_createRenderable(e,t,n){let r=this._renderPassManager.rctx,i=e.geometry,a=i.parameters.layout,{interleavedVertexData:o,indexData:s,vertexCount:c}=i.renderGeometryData,l=new h(r,a,o),u=s?p.createIndex(r,35044,s):null,d=0,f=[[`geometry`,l]];if(!t.isIntegratedMesh){let e=new Uint16Array(c);for(let t=0;t<n.count;t++){let r=n.offsets[t],i=n.offsets[t+1],a=n.materialDataIndices[t];if(s!=null)for(let t=r;t<i;t++){let n=s[t];e[n]=a}else for(let t=r;t<i;t++)e[t]=a}let t=new h(r,x,e.buffer);d+=t.usedMemory,f.push([`componentIndices`,t])}let g=new v(r,new Map(f),u),_=s?.length??c,y=new j(g,m.TRIANGLES,i.parameters,u!=null,_),b=new D(t),S=this.materials.acquire(b,y.parameters,C),T=new k(l.usedMemory+d+(u?.usedMemory??0)),E=this.samplers.addFromTexture(t.baseColorTexture?.texture),O=new w(e,t,E);return new A(S,O,y,T)}_requestRender(){this._renderPassManager.requestRender()}};P=e([n(`esri.views.3d.webgl-engine.collections.Component.ComponentObjectCollection`)],P);const F=l();export{P as ComponentObjectCollection};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{Vertices as e}from"../../lib/Attribute.js";import{TriangleIntersectionData as t}from"../../lib/TriangleIntersectionData.js";class n{constructor(n,r,i,a,o){this._componentOffsets=o,this._intersectionData=new t(i,a,new e(n,3,r))}intersectRay(e,t,n,i){this._intersectionData.intersectRay(e,t,n,(e,t,n,a)=>{i(e,t,n,a,r(this._componentOffsets,a))})}*intersectScreenPolygon(e,t,n,i){this._intersectionData.forEachScreenPolygonHit(e,n,t,null,(e,t,n)=>{let a=r(this._componentOffsets,t);a<0||a>=this._componentOffsets.length-1||i(e,t,a,n)}),yield}}function r(e,t){let{length:n}=e;if(n===0||t<e[0])return-1;if(t>e[n-1])return n;let r=0,i=n-1;for(;i-r>1;){let n=Math.round(.5*(r+i));t<=e[n]?i=n:r=n}return r}export{n as ComponentObjectFixedBVH};
|
|
2
|
+
import{Vertices as e}from"../../lib/Attribute.js";import{TriangleIntersectionData as t}from"../../lib/TriangleIntersectionData.js";class n{constructor(n,r,i,a,o){this._componentOffsets=o,this._intersectionData=new t(i,a,new e(n,3,r),!0)}intersectRay(e,t,n,i){return n.budget&&(this._intersectionData.advance(n.budget),!this._intersectionData.ready)?!1:(this._intersectionData.intersectRay(e,t,n,(e,t,n,a)=>{i(e,t,n,a,r(this._componentOffsets,a))}),!0)}*intersectScreenPolygon(e,t,n,i){this._intersectionData.forEachScreenPolygonHit(e,n,t,null,(e,t,n)=>{let a=r(this._componentOffsets,t);a<0||a>=this._componentOffsets.length-1||i(e,t,a,n)}),yield}}function r(e,t){let{length:n}=e;if(n===0||t<e[0])return-1;if(t>e[n-1])return n;let r=0,i=n-1;for(;i-r>1;){let n=Math.round(.5*(r+i));t<=e[n]?i=n:r=n}return r}export{n as ComponentObjectFixedBVH};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{transpose as e,invert as t}from"../../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as n}from"../../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as r}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{sub as i,transformMat3 as a,negate as o}from"../../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as s}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as c}from"../../../../../geometry/support/aaBoundingBox.js";import{floatArrayFrom as l,floatArrayByteSize as u,newFloatArray as d}from"../../../../../geometry/support/FloatArray.js";import{indexArrayFrom as f,getContinuousIndexArray as p,indexArrayByteSize as m}from"../../../../../geometry/support/Indices.js";import{ComponentObjectElevationAgnosticComponentBVH as h}from"./ComponentObjectElevationAgnosticBVH.js";import{ComponentObjectFixedBVH as g}from"./ComponentObjectFixedBVH.js";class _{constructor(e,t,n,r){this.isGlobal=e,this._components=n,this._needsElevationAlignment=r,this.verticalOffset=null,this.componentVerticalOffsets=null,this._planetCenter=s(),this._componentBvh=null,this._aabb=c();let{indices:i,positions:a}=t,o=a.length/3;this._indices=i?f(i,o):p(o),this._positions=l(a)}get usedMemory(){return u(this._positions)+m(this._indices)}destroy(){this._positions=null,this._indices=null,this._perComponentAabbs=null,this._componentBvh=null}getComponentAabb(e,t){let n=this._ensureComponentAabbs(),r=e*6;return t[0]=n[r],t[1]=n[r+1],t[2]=n[r+2],t[3]=n[r+3],t[4]=n[r+4],t[5]=n[r+5],t}getComponentAabbs(){return this._ensureComponentAabbs()}_ensureComponentAabbs(){return this._perComponentAabbs||=this._computePerComponentAabbs(),this._perComponentAabbs}getComponentPositions(e,t){t.indices=this._indices,t.data=this._positions,t.stride=3,t.startIndex=this._components.offsets[e],t.endIndex=this._components.offsets[e+1]}intersectRay(t,n,r,s,c,l,u){let d=b;this._setupIntersect(r,s,c,d);let{position:f}=c,p=i(v,t,f),m=i(y,n,f);a(p,p,d),a(m,m,d);let h=e(C,d);if(this.isGlobal){let e=this._planetCenter;o(e,f),a(e,e,d)}this._intersectComponents(p,m,s,r,(e,t,n,r,i)=>{u(e,t,n?a(S,n,h):null,r,i)},l)}*intersectScreenPolygon(e,t,n,r,i,a){this._setupIntersect(n,r,i),yield*this._ensureComponentBvh().intersectScreenPolygon(e,t,i.toMat4(x),(e,t,n,r)=>a(n,e,r,t),r??void 0,n??void 0)}_setupIntersect(e,n,r,i=b){if(this.verticalOffset=e,this.componentVerticalOffsets=n,t(i,r.rotationScale),this.isGlobal){let e=this._planetCenter;o(e,r.position),a(e,e,i)}}_computePerComponentAabbs(){let e=this._aabb,t=.5*(e[0]+e[3]),n=.5*(e[1]+e[4]),r=.5*(e[2]+e[5]),i=this._components.count,a=d(i*6),o=this._indices,s=this._positions,c=this._components.offsets,l=0,u=1/0,f=1/0,p=1/0,m=-1/0,h=-1/0,g=-1/0;for(let e=0;e<i;e++){let i=c[e],d=c[e+1],_=1/0,v=1/0,y=1/0,b=-1/0,x=-1/0,S=-1/0;if(i<d)for(let e=i;e<d;e++){let t=o[e]*3,n=s[t],r=s[t+1],i=s[t+2];_=Math.min(_,n),v=Math.min(v,r),y=Math.min(y,i),b=Math.max(b,n),x=Math.max(x,r),S=Math.max(S,i)}else _=t,v=n,y=r,b=t,x=n,S=r;a[l++]=_,a[l++]=v,a[l++]=y,a[l++]=b,a[l++]=x,a[l++]=S,u=Math.min(u,_),f=Math.min(f,v),p=Math.min(p,y),m=Math.max(m,b),h=Math.max(h,x),g=Math.max(g,S)}return this._aabb[0]=u,this._aabb[1]=f,this._aabb[2]=p,this._aabb[3]=m,this._aabb[4]=h,this._aabb[5]=g,a}_intersectComponents(e,t,n,r,i,a){this._ensureComponentBvh().intersectRay(e,t,a,i,n??void 0,r??void 0)}_ensureComponentBvh(){let e=this._componentBvh;return e??(e=this._needsElevationAlignment?new h(this._positions,w,this._indices,this._components,this._ensureComponentAabbs(),this.geometryMinZ,this.planetCenterZ,this.isGlobal):new g(this._positions,w,this._indices,this.numTriangles,this._components.offsets),this._componentBvh=e),e}get geometryMinZ(){return this._aabb[2]}get planetCenterZ(){return this._planetCenter[2]}get numTriangles(){return this._indices.length/3}get positions(){return this._positions}get indices(){return this._indices}get aabb(){return this._ensureComponentAabbs(),this._aabb}}const v=s(),y=s(),b=n(),x=r(),S=s(),C=n(),w=3;export{_ as IntersectionGeometry};
|
|
2
|
+
import{transpose as e,invert as t}from"../../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as n}from"../../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as r}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{sub as i,transformMat3 as a,negate as o}from"../../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as s}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as c}from"../../../../../geometry/support/aaBoundingBox.js";import{floatArrayFrom as l,floatArrayByteSize as u,newFloatArray as d}from"../../../../../geometry/support/FloatArray.js";import{indexArrayFrom as f,getContinuousIndexArray as p,indexArrayByteSize as m}from"../../../../../geometry/support/Indices.js";import{ComponentObjectElevationAgnosticComponentBVH as h}from"./ComponentObjectElevationAgnosticBVH.js";import{ComponentObjectFixedBVH as g}from"./ComponentObjectFixedBVH.js";class _{constructor(e,t,n,r){this.isGlobal=e,this._components=n,this._needsElevationAlignment=r,this.verticalOffset=null,this.componentVerticalOffsets=null,this._planetCenter=s(),this._componentBvh=null,this._aabb=c();let{indices:i,positions:a}=t,o=a.length/3;this._indices=i?f(i,o):p(o),this._positions=l(a)}get usedMemory(){return u(this._positions)+m(this._indices)}destroy(){this._positions=null,this._indices=null,this._perComponentAabbs=null,this._componentBvh=null}getComponentAabb(e,t){let n=this._ensureComponentAabbs(),r=e*6;return t[0]=n[r],t[1]=n[r+1],t[2]=n[r+2],t[3]=n[r+3],t[4]=n[r+4],t[5]=n[r+5],t}getComponentAabbs(){return this._ensureComponentAabbs()}_ensureComponentAabbs(){return this._perComponentAabbs||=this._computePerComponentAabbs(),this._perComponentAabbs}getComponentPositions(e,t){t.indices=this._indices,t.data=this._positions,t.stride=3,t.startIndex=this._components.offsets[e],t.endIndex=this._components.offsets[e+1]}intersectRay(t,n,r,s,c,l,u){let d=b;this._setupIntersect(r,s,c,d);let{position:f}=c,p=i(v,t,f),m=i(y,n,f);a(p,p,d),a(m,m,d);let h=e(C,d);if(this.isGlobal){let e=this._planetCenter;o(e,f),a(e,e,d)}return this._intersectComponents(p,m,s,r,(e,t,n,r,i)=>{u(e,t,n?a(S,n,h):null,r,i)},l)}*intersectScreenPolygon(e,t,n,r,i,a){this._setupIntersect(n,r,i),yield*this._ensureComponentBvh().intersectScreenPolygon(e,t,i.toMat4(x),(e,t,n,r)=>a(n,e,r,t),r??void 0,n??void 0)}_setupIntersect(e,n,r,i=b){if(this.verticalOffset=e,this.componentVerticalOffsets=n,t(i,r.rotationScale),this.isGlobal){let e=this._planetCenter;o(e,r.position),a(e,e,i)}}_computePerComponentAabbs(){let e=this._aabb,t=.5*(e[0]+e[3]),n=.5*(e[1]+e[4]),r=.5*(e[2]+e[5]),i=this._components.count,a=d(i*6),o=this._indices,s=this._positions,c=this._components.offsets,l=0,u=1/0,f=1/0,p=1/0,m=-1/0,h=-1/0,g=-1/0;for(let e=0;e<i;e++){let i=c[e],d=c[e+1],_=1/0,v=1/0,y=1/0,b=-1/0,x=-1/0,S=-1/0;if(i<d)for(let e=i;e<d;e++){let t=o[e]*3,n=s[t],r=s[t+1],i=s[t+2];_=Math.min(_,n),v=Math.min(v,r),y=Math.min(y,i),b=Math.max(b,n),x=Math.max(x,r),S=Math.max(S,i)}else _=t,v=n,y=r,b=t,x=n,S=r;a[l++]=_,a[l++]=v,a[l++]=y,a[l++]=b,a[l++]=x,a[l++]=S,u=Math.min(u,_),f=Math.min(f,v),p=Math.min(p,y),m=Math.max(m,b),h=Math.max(h,x),g=Math.max(g,S)}return this._aabb[0]=u,this._aabb[1]=f,this._aabb[2]=p,this._aabb[3]=m,this._aabb[4]=h,this._aabb[5]=g,a}_intersectComponents(e,t,n,r,i,a){return this._ensureComponentBvh().intersectRay(e,t,a,i,n??void 0,r??void 0)!==!1}_ensureComponentBvh(){let e=this._componentBvh;return e??(e=this._needsElevationAlignment?new h(this._positions,w,this._indices,this._components,this._ensureComponentAabbs(),this.geometryMinZ,this.planetCenterZ,this.isGlobal):new g(this._positions,w,this._indices,this.numTriangles,this._components.offsets),this._componentBvh=e),e}get geometryMinZ(){return this._aabb[2]}get planetCenterZ(){return this._planetCenter[2]}get numTriangles(){return this._indices.length/3}get positions(){return this._positions}get indices(){return this._indices}get aabb(){return this._ensureComponentAabbs(),this._aabb}}const v=s(),y=s(),b=n(),x=r(),S=s(),C=n(),w=3;export{_ as IntersectionGeometry};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{MaterialBase as e}from"../../../core/material/MaterialBase.js";import{isColor as t}from"../../../core/shaderLibrary/ShaderOutput.js";import{getIMOverlayColorContent as n}from"../../../core/shaderLibrary/terrain/Overlay.glsl.js";import{hasShadowHighlights as r}from"../../../shaders/ReceiveShadowsConfiguration.js";import{isSphereDepthInterpolateActive as i}from"../../../shaders/SphereDepthInterpolate.glsl.js";import{ComponentTechnique as a}from"./ComponentTechnique.js";import{ComponentTechniqueConfiguration as o}from"./ComponentTechniqueConfiguration.js";class s extends e{constructor(e,t,n,r,i){super(),this.parameters=e,this.key=i;let a=u(e,n);this.usePBR=e.usePBR,this.hasParametersFromSource=e.hasParametersFromSource,this.slicePlaneEnabled=e.slicePlaneEnabled,this.isIntegratedMesh=e.isIntegratedMesh,this.applySSAO=e.applySSAO,this._emissions=a!==0,this.materialPass=c(e,n),this._configuration=new o(r),this._supportsSphereDepthInterpolate=e.sphereDepthInterpolate&&this._configuration.spherical,this._initializeMaterialConfiguration(e,t,n)}destroy(){}get emissions(){if(!this._emissions)return 0;switch(this.materialPass){case 0:case 3:return 1;case 1:case 4:return 2;case 2:return 3}}acquireTechnique(e,t,n,r){let o=this._updateConfiguration(t,n);if(this._supportsSphereDepthInterpolate&&e.precompiling>0){o.sphereDepthInterpolate=!1;let t=e.get(a,o,r.layout);o.sphereDepthInterpolate=!0;let s=e.get(a,o,r.layout);return i(n.camera,o)?s:t}return e.get(a,o,r.layout)}_initializeMaterialConfiguration(e,t,n){let r=this._configuration;r.hasMetallicRoughnessTexture=e.hasMetallicRoughnessTexture,r.hasOcclusionTexture=e.hasOcclusionTexture,r.hasNormalTexture=e.hasNormalTexture;let i=t.textureCoordinateType!==0;r.hasColorTextureTransform=i&&e.hasBaseColorTexture&&e.hasColorTextureTransform,r.hasNormalTextureTransform=i&&e.hasNormalTexture&&e.hasNormalTextureTransform,r.hasEmissiveTextureTransform=i&&e.hasEmissionTexture&&e.hasEmissiveTextureTransform,r.hasOcclusionTextureTransform=i&&e.hasOcclusionTexture&&e.hasOcclusionTextureTransform,r.hasMetallicRoughnessTextureTransform=i&&e.hasMetallicRoughnessTexture&&e.hasMetallicRoughnessTextureTransform,r.sphereDepthInterpolate=!1,r.ellipsoidMode=e.ellipsoidMode,r.doubleSidedMode=+!!e.doubleSided,r.hasColorTexture=e.hasBaseColorTexture,r.cullFace=e.cullFace,r.alphaDiscardMode=e.alphaDiscardMode,r.hasVertexColors=t.hasVertexColors,r.textureCoordinateType=t.textureCoordinateType,r.shadeNormals=t.shadeNormals,r.normalType=t.hasNormals?1:2,r.polygonOffset=e.polygonOffset,r.vertexPositionRotationType=t.vertexPositionRotationType,r.componentDataType=n.componentDataType,r.emissionSource=u(e,n),r.groundTransparencyMode=e.groundTransparencyMode}_updateConfiguration(e,n){let a=this._configuration,{identifier:o}=e,s=o===0;a.output=n.output,a.enableOITOffset=n.enableOITOffset,a.shouldDrapeRaster=this.parameters.integratedMeshSemantics.shouldDrapeRaster,a.sphereDepthInterpolate=this._supportsSphereDepthInterpolate&&i(n.camera,a),a.hasEmission=n.hasEmission,a.renderOccluded=n.slot===9;let c=this.parameters.integratedMeshSemantics.shouldStencilTerrain?this.parameters.integratedMeshSemantics.shouldDrape&&f(n,this.parameters.integratedMeshSemantics.shouldDrapeRaster)?d(n)?3:2:1:0;a.integratedMeshMode=c,a.pbrMode=c===3?4:this.usePBR?this.hasParametersFromSource?a.shadeNormals!==0&&this.isIntegratedMesh?0:2:1:0,a.hasSlicePlane=n.slicePlane!=null&&this.slicePlaneEnabled,a.isGroundSlice=a.hasSlicePlane&&this.parameters.integratedMeshSemantics.shouldFadeSlicedSurface;let{materialPass:l}=this;a.transparent=s&&(l===1||l===2&&e.transparent||l===4)||a.isGroundSlice,a.hasHighlightMixTexture=o===2&&n.highlightMixTexture!=null,a.snowCover=s&&n.snowCover>0,a.vertexDiscardMode=s&&l===2?e.transparent?2:1:0;let u=t(n.output);return a.receiveAmbientOcclusion=u&&this.applySSAO&&!a.renderOccluded&&n.ssao?.getTexture()!=null,a.receiveGlobalIllumination=u&&this.applySSAO&&!a.renderOccluded&&n.globalIlluminationEnabled,a.hasOccludees=u&&n.hasOccludees,a.receiveShadows=u&&n.shadowMap.ready,a.hasShadowHighlights=r(a,n),a.screenSpaceReflections=n.hasScreenSpaceReflections,a.cloudReflections=u&&n.clouds.data?.cubeMap?.colorTexture!=null,a}}function c(e,t){let{alphaDiscardMode:n,isIntegratedMesh:r,slicePlaneEnabled:i}=e,{transparent:a,opaqueOverride:o}=t,s=e.isObjectTransparent,c=e.hasBaseColorTransparency;if(r)return s||i&&e.integratedMeshSemantics.shouldRenderSliceAsTransparent?4:3;if(s)return 1;if(o===0)return 0;if(c||n===0||n===3)return 1;switch(a){case 2:return 0;case 0:return 1;case 1:return 2}}function l(e){return e.hasEmissionTexture||e.hasEmissiveBaseColor}function u(e,{emissiveSourceOverride:t,emissiveOverride:n}){let r=e.hasEmissionTexture,i=n!==2&&(l(e)||t!==2),a=t===1,o=t===2;return i?l(e)?o?r?4:2:a?r?5:7:6:a?7:6:0}function d(e){return e.overlay?.getTexture(3)!=null}function f(e,t){return e.overlay?.getTexture(n(t))!=null}export{s as ComponentMaterial,c as computeMaterialPass,u as getEmissionSource};
|
|
2
|
+
import{MaterialBase as e}from"../../../core/material/MaterialBase.js";import{isColor as t}from"../../../core/shaderLibrary/ShaderOutput.js";import{getIMOverlayColorContent as n}from"../../../core/shaderLibrary/terrain/Overlay.glsl.js";import{hasShadowHighlights as r}from"../../../shaders/ReceiveShadowsConfiguration.js";import{isSphereDepthInterpolateActive as i}from"../../../shaders/SphereDepthInterpolate.glsl.js";import{ComponentTechnique as a}from"./ComponentTechnique.js";import{ComponentTechniqueConfiguration as o}from"./ComponentTechniqueConfiguration.js";class s extends e{constructor(e,t,n,r,i){super(),this.parameters=e,this.key=i;let a=u(e,n);this.usePBR=e.usePBR,this.hasParametersFromSource=e.hasParametersFromSource,this.slicePlaneEnabled=e.slicePlaneEnabled,this.isIntegratedMesh=e.isIntegratedMesh,this.applySSAO=e.applySSAO,this._emissions=a!==0,this.materialPass=c(e,n),this._configuration=new o(r),this._supportsSphereDepthInterpolate=e.sphereDepthInterpolate&&this._configuration.spherical,this._initializeMaterialConfiguration(e,t,n)}destroy(){}get emissions(){if(!this._emissions)return 0;switch(this.materialPass){case 0:case 3:return 1;case 1:case 4:return 2;case 2:return 3}}acquireTechnique(e,t,n,r){let o=this._updateConfiguration(t,n);if(this._supportsSphereDepthInterpolate&&e.precompiling>0){o.sphereDepthInterpolate=!1;let t=e.get(a,o,r.layout);o.sphereDepthInterpolate=!0;let s=e.get(a,o,r.layout);return i(n.camera,o)?s:t}return e.get(a,o,r.layout)}_initializeMaterialConfiguration(e,t,n){let r=this._configuration;r.hasMetallicRoughnessTexture=e.hasMetallicRoughnessTexture,r.hasOcclusionTexture=e.hasOcclusionTexture,r.hasNormalTexture=e.hasNormalTexture;let i=t.textureCoordinateType!==0;r.hasColorTextureTransform=i&&e.hasBaseColorTexture&&e.hasColorTextureTransform,r.hasNormalTextureTransform=i&&e.hasNormalTexture&&e.hasNormalTextureTransform,r.hasEmissiveTextureTransform=i&&e.hasEmissionTexture&&e.hasEmissiveTextureTransform,r.hasOcclusionTextureTransform=i&&e.hasOcclusionTexture&&e.hasOcclusionTextureTransform,r.hasMetallicRoughnessTextureTransform=i&&e.hasMetallicRoughnessTexture&&e.hasMetallicRoughnessTextureTransform,r.sphereDepthInterpolate=!1,r.ellipsoidMode=e.ellipsoidMode,r.doubleSidedMode=+!!e.doubleSided,r.hasColorTexture=e.hasBaseColorTexture,r.cullFace=e.cullFace,r.alphaDiscardMode=e.alphaDiscardMode,r.hasVertexColors=t.hasVertexColors,r.textureCoordinateType=t.textureCoordinateType,r.shadeNormals=t.shadeNormals,r.normalType=t.hasNormals?1:2,r.polygonOffset=e.polygonOffset,r.vertexPositionRotationType=t.vertexPositionRotationType,r.componentDataType=n.componentDataType,r.emissionSource=u(e,n),r.groundTransparencyMode=e.groundTransparencyMode}_updateConfiguration(e,n){let a=this._configuration,{identifier:o}=e,s=o===0;a.output=n.output,a.enableOITOffset=n.enableOITOffset,a.shouldDrapeRaster=this.parameters.integratedMeshSemantics.shouldDrapeRaster,a.sphereDepthInterpolate=this._supportsSphereDepthInterpolate&&i(n.camera,a),a.hasEmission=n.hasEmission,a.renderOccluded=n.slot===9;let c=this.parameters.integratedMeshSemantics.shouldStencilTerrain?this.parameters.integratedMeshSemantics.shouldDrape&&f(n,this.parameters.integratedMeshSemantics.shouldDrapeRaster)?d(n)?3:2:1:0;a.integratedMeshMode=c,a.pbrMode=c===3?4:this.usePBR?this.hasParametersFromSource?a.shadeNormals!==0&&this.isIntegratedMesh?0:2:1:0,a.hasSlicePlane=n.slicePlane!=null&&this.slicePlaneEnabled,a.isGroundSlice=a.hasSlicePlane&&this.parameters.integratedMeshSemantics.shouldFadeSlicedSurface;let{materialPass:l}=this;a.transparent=s&&(l===1||l===2&&e.transparent||l===4)||a.isGroundSlice,a.hasHighlightMixTexture=o===2&&n.highlightMixTexture!=null,a.snowCover=s&&n.snowCover>0,a.vertexDiscardMode=s&&l===2?e.transparent?2:1:0;let u=t(n.output);return a.receiveAmbientOcclusion=u&&this.applySSAO&&!a.renderOccluded&&n.ssao?.getTexture()!=null,a.receiveGlobalIllumination=u&&this.applySSAO&&!a.renderOccluded&&n.globalIlluminationEnabled,a.hasOccludees=u&&n.hasOccludees,a.receiveShadows=u&&n.shadowMap.ready,a.hasShadowHighlights=u&&r(a,n),a.screenSpaceReflections=u&&n.hasScreenSpaceReflections,a.cloudReflections=u&&n.clouds.data?.cubeMap?.colorTexture!=null,a.emissionReflections=u&&a.screenSpaceReflections&&a.hasEmission&&n.reprojection.lastFrameEmission!=null,a}}function c(e,t){let{alphaDiscardMode:n,isIntegratedMesh:r,slicePlaneEnabled:i}=e,{transparent:a,opaqueOverride:o}=t,s=e.isObjectTransparent,c=e.hasBaseColorTransparency;if(r)return s||i&&e.integratedMeshSemantics.shouldRenderSliceAsTransparent?4:3;if(s)return 1;if(o===0)return 0;if(c||n===0||n===3)return 1;switch(a){case 2:return 0;case 0:return 1;case 1:return 2}}function l(e){return e.hasEmissionTexture||e.hasEmissiveBaseColor}function u(e,{emissiveSourceOverride:t,emissiveOverride:n}){let r=e.hasEmissionTexture,i=n!==2&&(l(e)||t!==2),a=t===1,o=t===2;return i?l(e)?o?r?4:2:a?r?5:7:6:a?7:6:0}function d(e){return e.overlay?.getTexture(3)!=null}function f(e,t){return e.overlay?.getTexture(n(t))!=null}export{s as ComponentMaterial,c as computeMaterialPass,u as getEmissionSource};
|
package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{isColorHighlightOrOLID as t}from"../../../core/shaderLibrary/ShaderOutput.js";import{parameter as n}from"../../../core/shaderTechnique/ShaderTechniqueConfiguration.js";import{SphereDepthInterpolateConfiguration as r}from"../../../shaders/SphereDepthInterpolate.glsl.js";class i extends r{constructor(e){super(),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.pbrMode=0,this.normalType=0,this.emissionSource=0,this.shadeNormals=1,this.polygonOffset=0,this.vertexPositionRotationType=1,this.hasEmission=!1,this.hasVertexColors=!1,this.hasSlicePlane=!1,this.shouldDrapeRaster=!1,this.isGroundSlice=!1,this.hasColorTexture=!1,this.hasHighlightMixTexture=!1,this.emissionDimmingPass=!1,this.receiveAmbientOcclusion=!0,this.receiveGlobalIllumination=!1,this.receiveShadows=!0,this.hasShadowHighlights=!1,this.transparent=!0,this.groundTransparencyMode=1,this.screenSpaceReflections=!1,this.hasMetallicRoughnessTexture=!1,this.hasOcclusionTexture=!1,this.hasNormalTexture=!1,this.hasOccludees=!1,this.terrainDepthTest=!1,this.cullAboveTerrain=!1,this.hasNormalTextureTransform=!1,this.hasColorTextureTransform=!1,this.hasEmissiveTextureTransform=!1,this.hasOcclusionTextureTransform=!1,this.hasMetallicRoughnessTextureTransform=!1,this.cloudReflections=!
|
|
2
|
+
import{__decorate as e}from"tslib";import{isColorHighlightOrOLID as t}from"../../../core/shaderLibrary/ShaderOutput.js";import{parameter as n}from"../../../core/shaderTechnique/ShaderTechniqueConfiguration.js";import{SphereDepthInterpolateConfiguration as r}from"../../../shaders/SphereDepthInterpolate.glsl.js";class i extends r{constructor(e){super(),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.pbrMode=0,this.normalType=0,this.emissionSource=0,this.shadeNormals=1,this.polygonOffset=0,this.vertexPositionRotationType=1,this.hasEmission=!1,this.hasVertexColors=!1,this.hasSlicePlane=!1,this.shouldDrapeRaster=!1,this.isGroundSlice=!1,this.hasColorTexture=!1,this.hasHighlightMixTexture=!1,this.emissionDimmingPass=!1,this.receiveAmbientOcclusion=!0,this.receiveGlobalIllumination=!1,this.receiveShadows=!0,this.hasShadowHighlights=!1,this.transparent=!0,this.groundTransparencyMode=1,this.screenSpaceReflections=!1,this.hasMetallicRoughnessTexture=!1,this.hasOcclusionTexture=!1,this.hasNormalTexture=!1,this.hasOccludees=!1,this.terrainDepthTest=!1,this.cullAboveTerrain=!1,this.hasNormalTextureTransform=!1,this.hasColorTextureTransform=!1,this.hasEmissiveTextureTransform=!1,this.hasOcclusionTextureTransform=!1,this.hasMetallicRoughnessTextureTransform=!1,this.cloudReflections=!1,this.emissionReflections=!1,this.snowCover=!1,this.renderOccluded=!1,this.enableOITOffset=!1,this.sphereDepthInterpolate=!1,this.writeDepth=!0,this.oitPremultipliedAlpha=!1,this.occlusionPass=!1,this.bindType=2,this.useCustomDTRExponentForWater=!1,this.hasVertexTangents=!1,this.hasSliceTranslatedView=!1,this.rayMarchMaxReach=1,this.rayMarchMaxSteps=75,this.useProjectedRayLength=!1,this.clampRayToScreen=!0,this.instanced=!1,this.instancedDoublePrecision=!1,this.hasModelTransformation=!1,this.useFillLights=!0,this.draped=!1,this.useTransformationTexture=!0,this.sphericalSR=e.sphericalSR,this.useFloatBlend=e.useFloatBlend}get spherical(){return this.sphericalSR!==0}get overlayEnabled(){return(this.integratedMeshMode===2||this.integratedMeshMode===3)&&t(this.output)}get hasWater(){return this.pbrMode===3||this.pbrMode===4||this.pbrMode===6}}e([n()],i.prototype,`useFloatBlend`,void 0),e([n({count:12})],i.prototype,`output`,void 0),e([n({count:3})],i.prototype,`textureCoordinateType`,void 0),e([n({count:2})],i.prototype,`componentDataType`,void 0),e([n({count:3})],i.prototype,`cullFace`,void 0),e([n({count:3})],i.prototype,`vertexDiscardMode`,void 0),e([n({count:3})],i.prototype,`doubleSidedMode`,void 0),e([n({count:4})],i.prototype,`alphaDiscardMode`,void 0),e([n({count:4})],i.prototype,`integratedMeshMode`,void 0),e([n({count:8})],i.prototype,`pbrMode`,void 0),e([n({count:3})],i.prototype,`normalType`,void 0),e([n({count:8})],i.prototype,`emissionSource`,void 0),e([n({count:3})],i.prototype,`shadeNormals`,void 0),e([n({count:5})],i.prototype,`polygonOffset`,void 0),e([n({count:3})],i.prototype,`vertexPositionRotationType`,void 0),e([n()],i.prototype,`hasEmission`,void 0),e([n()],i.prototype,`hasVertexColors`,void 0),e([n()],i.prototype,`hasSlicePlane`,void 0),e([n()],i.prototype,`shouldDrapeRaster`,void 0),e([n()],i.prototype,`isGroundSlice`,void 0),e([n()],i.prototype,`hasColorTexture`,void 0),e([n()],i.prototype,`hasHighlightMixTexture`,void 0),e([n()],i.prototype,`emissionDimmingPass`,void 0),e([n()],i.prototype,`receiveAmbientOcclusion`,void 0),e([n()],i.prototype,`receiveGlobalIllumination`,void 0),e([n()],i.prototype,`receiveShadows`,void 0),e([n()],i.prototype,`hasShadowHighlights`,void 0),e([n()],i.prototype,`transparent`,void 0),e([n({count:4})],i.prototype,`groundTransparencyMode`,void 0),e([n()],i.prototype,`screenSpaceReflections`,void 0),e([n()],i.prototype,`hasMetallicRoughnessTexture`,void 0),e([n()],i.prototype,`hasOcclusionTexture`,void 0),e([n()],i.prototype,`hasNormalTexture`,void 0),e([n()],i.prototype,`hasOccludees`,void 0),e([n()],i.prototype,`terrainDepthTest`,void 0),e([n()],i.prototype,`cullAboveTerrain`,void 0),e([n()],i.prototype,`hasNormalTextureTransform`,void 0),e([n()],i.prototype,`hasColorTextureTransform`,void 0),e([n()],i.prototype,`hasEmissiveTextureTransform`,void 0),e([n()],i.prototype,`hasOcclusionTextureTransform`,void 0),e([n()],i.prototype,`hasMetallicRoughnessTextureTransform`,void 0),e([n()],i.prototype,`cloudReflections`,void 0),e([n()],i.prototype,`emissionReflections`,void 0),e([n()],i.prototype,`snowCover`,void 0),e([n()],i.prototype,`renderOccluded`,void 0),e([n()],i.prototype,`enableOITOffset`,void 0),e([n()],i.prototype,`sphereDepthInterpolate`,void 0);export{i as ComponentTechniqueConfiguration};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{Texture2DBindUniform as e}from"../shaderModules/Texture2DBindUniform.js";const t=new e(`lastFrameColorTexture`,e=>e.reprojection.lastFrameColor?.getTexture());export{t as lastFrameColorTexture};
|
|
2
|
+
import{Texture2DBindUniform as e}from"../shaderModules/Texture2DBindUniform.js";const t=new e(`lastFrameColorTexture`,e=>e.reprojection.lastFrameColor?.getTexture()),n=new e(`lastFrameEmissionTexture`,e=>e.reprojection.lastFrameEmission?.getTexture());export{t as lastFrameColorTexture,n as lastFrameEmissionTexture};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{create as e}from"../../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{hasArea as t,width as n,height as r}from"../../../../../../geometry/support/aaBoundingRect.js";import{Uniform as i}from"../../../../../webgl/Uniform.js";import{
|
|
2
|
+
import{create as e}from"../../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{hasArea as t,width as n,height as r}from"../../../../../../geometry/support/aaBoundingRect.js";import{Uniform as i}from"../../../../../webgl/Uniform.js";import{getWaterColor as a}from"../../../materials/getWaterColor.glsl.js";import{Float4DrawUniform as o}from"../../shaderModules/Float4DrawUniform.js";import{FloatPassUniform as s}from"../../shaderModules/FloatPassUniform.js";import{glsl as c,If as l}from"../../shaderModules/glsl.js";import{Texture2DPassUniform as u}from"../../shaderModules/Texture2DPassUniform.js";import{Texture2DUintPassUniform as d}from"../../shaderModules/Texture2DUintPassUniform.js";import{isColor as f}from"../ShaderOutput.js";import{mainLightDirection as p,mainLightIntensity as m}from"../shading/lightingUniforms.js";import{BlendColorsPremultiplied as h}from"../util/BlendColorsPremultiplied.glsl.js";function g(e,t){let{vertex:n,fragment:r}=e;n.uniforms.add(new o(`overlayTexOffset`,(e,n)=>w(t.spherical,e,n)),new o(`overlayTexScale`,(e,n)=>T(t.spherical,e,n))),r.uniforms.add(new o(`overlayTexOffset`,(e,n)=>w(t.spherical,e,n)),new o(`overlayTexScale`,(e,n)=>T(t.spherical,e,n))),r.constants.add(`overlayOpacity`,`float`,1),r.uniforms.add(new u(`ovColorTex`,(e,n)=>_(e,n,t.shouldDrapeRaster===!0))),S(e,t)}function _(e,t,n){let r=v(e,t,n);return r==null?null:t.overlay?.getTexture(r)}function v(e,t,n){return e.identifier===0?f(t.output)?!e.occludedGround||t.overlay?.allSourcesOccluders?y(n):4:t.output===3||t.output===4?y(n):t.output===11?5:null:e.identifier===2?2:null}function y(e){return+!e}function b(e,t){let{vertex:n,fragment:r}=e;n.uniforms.add(new D(`overlayTexOffset`),new D(`overlayTexScale`)),r.uniforms.add(new s(`overlayOpacity`,e=>e.overlayOpacity)),t.output!==10&&r.uniforms.add(new u(`ovColorTex`,(e,t)=>t.overlay?.getTexture(e.overlayContent))),S(e,t)}function x(e,t){switch(e){case 0:case 1:case 2:return t.slot===9&&!t.overlay?.allSourcesOccluders?4:0;case 3:case 4:return 0;case 10:return 2;case 5:case 7:case 8:case 9:return null;case 11:return 5}return null}function S(e,t){let{hasWater:n,output:r}=t;n&&e.include(a,t);let{vertex:i,fragment:o,varyings:s}=e;s.add(`vtcOverlay`,`vec4`);let u=r===10;i.code.add(c`void setOverlayVTC(in vec2 uv) {
|
|
3
3
|
vtcOverlay = vec4(uv, uv) * overlayTexScale + overlayTexOffset;
|
|
4
|
-
}`),
|
|
4
|
+
}`),o.code.add(c`bool isValid(vec2 uv, vec2 dxdy) {
|
|
5
5
|
return (uv.x >= 0.0 + dxdy.x) && (uv.x <= 1.0 - dxdy.x) && (uv.y >= 0.0 + dxdy.y) && (uv.y <= 1.0 - dxdy.y);
|
|
6
6
|
}
|
|
7
7
|
vec4 getOverlayColor(sampler2D ov0Tex, vec4 texCoords) {
|
|
@@ -10,7 +10,7 @@ vec4 color1 = texture(ov0Tex, vec2(texCoords.z * 0.5 + 0.5, texCoords.w));
|
|
|
10
10
|
bool isValid0 = isValid(texCoords.xy, fwidth(texCoords.xy));
|
|
11
11
|
bool isValid1 = isValid(texCoords.zw, vec2(0.0, 0.0));
|
|
12
12
|
return mix(color1 * float(isValid1), color0, float(isValid0));
|
|
13
|
-
}`),
|
|
13
|
+
}`),u?o.uniforms.add(new d(`overlayHighlightTexture`,(e,t)=>t.overlay?.getTexture(2))).code.add(c`uvec2 getAllOverlayHighlightValuesEncoded(vec4 texCoords) {
|
|
14
14
|
vec2 uvInner = texCoords.xy;
|
|
15
15
|
vec2 uvOuter = texCoords.zw;
|
|
16
16
|
bool isValidInner = isValid(uvInner, fwidth(uvInner));
|
|
@@ -27,7 +27,7 @@ uvec2(0);
|
|
|
27
27
|
}
|
|
28
28
|
uvec2 getAllOverlayHighlightValuesEncoded() {
|
|
29
29
|
return getAllOverlayHighlightValuesEncoded(vtcOverlay);
|
|
30
|
-
}`):(
|
|
30
|
+
}`):(o.include(h),o.code.add(c`vec4 getCombinedOverlayColor(vec4 texCoords) {
|
|
31
31
|
return overlayOpacity * getOverlayColor(ovColorTex, texCoords);
|
|
32
32
|
}
|
|
33
33
|
vec4 getCombinedOverlayColor() {
|
|
@@ -41,7 +41,7 @@ vec4(baseColorUnpremultiplied.rgb * baseColorUnpremultiplied.a, baseColorUnpremu
|
|
|
41
41
|
return colorPremultiplied.a > 0.0
|
|
42
42
|
? vec4(colorPremultiplied.rgb / colorPremultiplied.a, colorPremultiplied.a)
|
|
43
43
|
: vec4(0.0);
|
|
44
|
-
}`),
|
|
44
|
+
}`),o.code.add(c`vec4 getOverlayColorTexel(vec4 texCoords) {
|
|
45
45
|
vec2 texDim = vec2(textureSize(ovColorTex, 0));
|
|
46
46
|
vec4 color0 = texelFetch(ovColorTex, ivec2(vec2(texCoords.x * 0.5, texCoords.y) * texDim), 0);
|
|
47
47
|
vec4 color1 = texelFetch(ovColorTex, ivec2(vec2(texCoords.z * 0.5 + 0.5, texCoords.w) * texDim), 0);
|
|
@@ -51,10 +51,13 @@ return mix(color1 * float(isValid1), color0, float(isValid0));
|
|
|
51
51
|
}
|
|
52
52
|
vec4 getOverlayColorTexel() {
|
|
53
53
|
return getOverlayColorTexel(vtcOverlay);
|
|
54
|
-
}`)),n&&
|
|
55
|
-
|
|
56
|
-
vec3
|
|
57
|
-
vec3
|
|
58
|
-
vec3
|
|
59
|
-
|
|
60
|
-
|
|
54
|
+
}`)),n&&o.uniforms.add(p,m).code.add(c`
|
|
55
|
+
vec4 getOverlayWaterColor(vec4 maskInput, vec4 colorInput, vec3 vposEyeDir,
|
|
56
|
+
float shadow, vec3 localUp, mat3 tbn, vec3 position, vec3 positionWorld) {
|
|
57
|
+
vec3 n = normalize(tbn * (2.0 * maskInput.rgb - vec3(1.0)));
|
|
58
|
+
vec3 v = vposEyeDir;
|
|
59
|
+
vec3 final = getWaterColor(n, v, mainLightDirection, colorInput.rgb, mainLightIntensity, localUp, 1.0 - shadow, maskInput.w, position, positionWorld);
|
|
60
|
+
${l(t.emissionReflections,`waterEmission *= colorInput.a;`)}
|
|
61
|
+
return vec4(final, colorInput.w);
|
|
62
|
+
}
|
|
63
|
+
`)}function C(e,t){return e.overlay?.overlays[t]?.extent}function w(e,i,a){let o=E,s=e&&!i.useENUForGlobalOverlayUV,c=s?0:i.toMapSpace[0],l=s?0:i.toMapSpace[1],u=(e,i)=>{let s=C(a,i);t(s)&&(o[e+0]=(c-s[0])/n(s),o[e+1]=(l-s[1])/r(s))};return u(0,0),u(2,1),o}function T(e,i,a){let o=E,s=e&&!i.useENUForGlobalOverlayUV,c=s?1:i.toMapSpace[2],l=s?1:i.toMapSpace[3],u=(e,i)=>{let s=C(a,i);t(s)&&(o[e+0]=c/n(s),o[e+1]=l/r(s))};return u(0,0),u(2,1),o}const E=e();class D extends i{constructor(e){super(e,`vec4`)}}export{g as OverlayIM,b as OverlayTerrain,_ as getIMColorTexture,y as getIMOverlayColorContent,x as getOverlayContentForOutputTerrain};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import"../../../../webgl/enums.js";import"../../../../webgl/NoParameters.js";import"../../../../webgl/ShaderBuilder.js";import"../../core/shaderLibrary/output/ReadDepthLastFrame.glsl.js";import"../../core/shaderLibrary/ScreenSpacePass.glsl.js";import"../../core/shaderLibrary/shading/lightingUniforms.js";import"../../core/shaderLibrary/shading/ScreenSpaceRayMarching.glsl.js";import"../../core/shaderLibrary/util/CameraSpace.glsl.js";import"../../core/shaderLibrary/util/cameraUniforms.js";import"../../core/shaderModules/FloatBindUniform.js";import"../../core/shaderModules/FloatPassUniform.js";import"../../core/shaderModules/glsl.js";import"../../core/shaderModules/Matrix4BindUniform.js";import"../../core/shaderModules/Texture2DBindUniform.js";import"../../core/shaderModules/Texture2DPassUniform.js";import"../../shaders/floatBlendScale.glsl.js";import"../../shaders/ToneMapping.glsl.js";import"./GlobalIlluminationColorQuantization.glsl.js";import"./globalIlluminationUniforms.js";export{G as GlobalIlluminationPassParameters,b as build}from"../../../../../chunks/GlobalIllumination.glsl.js";
|
|
2
|
+
import"../../../../webgl/enums.js";import"../../../../webgl/NoParameters.js";import"../../../../webgl/ShaderBuilder.js";import"../../core/shaderLibrary/lastFrameUniforms.js";import"../../core/shaderLibrary/output/ReadDepthLastFrame.glsl.js";import"../../core/shaderLibrary/ScreenSpacePass.glsl.js";import"../../core/shaderLibrary/shading/lightingUniforms.js";import"../../core/shaderLibrary/shading/ScreenSpaceRayMarching.glsl.js";import"../../core/shaderLibrary/util/CameraSpace.glsl.js";import"../../core/shaderLibrary/util/cameraUniforms.js";import"../../core/shaderModules/FloatBindUniform.js";import"../../core/shaderModules/FloatPassUniform.js";import"../../core/shaderModules/glsl.js";import"../../core/shaderModules/Matrix4BindUniform.js";import"../../core/shaderModules/Texture2DBindUniform.js";import"../../core/shaderModules/Texture2DPassUniform.js";import"../../shaders/floatBlendScale.glsl.js";import"../../shaders/ToneMapping.glsl.js";import"./GlobalIlluminationColorQuantization.glsl.js";import"./globalIlluminationUniforms.js";export{G as GlobalIlluminationPassParameters,b as build,m as movingOcclusionBlendFloor}from"../../../../../chunks/GlobalIllumination.glsl.js";
|