@arcgis/core 5.0.0-next.50 → 5.0.0-next.51
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/PopupTemplate.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/2c3b65a756439a93b4d6.js +1 -0
- package/assets/esri/core/workers/chunks/{ed550bf27f2bbf8d30fa.js → 45fe2b6cbb957c521291.js} +1 -1
- package/assets/esri/core/workers/chunks/{d8511e71c5108a0ba9eb.js → 99baa5f97131e8689887.js} +1 -1
- package/assets/esri/core/workers/chunks/a1b8722c6acafdf1c2bf.js +1 -0
- package/config.js +1 -1
- package/core/accessorSupport/Properties.js +1 -1
- package/core/accessorSupport/Property.js +1 -1
- package/core/accessorSupport/decorators/subclass.js +1 -1
- package/interfaces.d.ts +0 -12
- package/kernel.js +1 -1
- package/package.json +1 -1
- package/support/revision.js +1 -1
- package/views/2d/PaddedViewState.js +1 -1
- package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
- package/views/3d/camera/intersectionUtils.js +1 -1
- package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
- package/views/3d/state/NearFarHeuristic.js +1 -1
- package/views/3d/support/debugFlags.js +1 -1
- package/views/3d/terrain/TerrainRenderer.js +1 -1
- package/views/3d/webgl-engine/lib/GPUPointOcclusionQuery.js +1 -1
- package/views/3d/webgl-engine/shaders/TerrainTechnique.js +1 -1
- package/widgets/Sketch/SketchViewModel.js +1 -1
- package/assets/esri/core/workers/chunks/396a95b800a0bdc398b9.js +0 -1
- package/assets/esri/core/workers/chunks/bd4e959be3a0ce3ba41e.js +0 -1
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import has from"../../../core/has.js";import t from"../../../core/Logger.js";import{destroyMaybe as i,removeMaybe as s}from"../../../core/maybe.js";import{throwIfAborted as r}from"../../../core/promiseUtils.js";import{initial as o,watch as n,when as a}from"../../../core/reactiveUtils.js";import{schedule as l}from"../../../core/scheduling.js";import{property as d,subclass as c}from"../../../core/accessorSupport/decorators.js";import{fromMat4 as h,invert as m}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as u,IDENTITY as p}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as f}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as b}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{i as g,b as y,t as _}from"../../../chunks/vec32.js";import{freeze as v,create as w}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as j}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{SphericalECEFSpatialReferenceLike as x,getReferenceEllipsoid as O}from"../../../geometry/ellipsoidUtils.js";import{computeTranslationToOriginAndRotation as M}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{localLinearScaleFactors as C}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectVectorToVector as T}from"../../../geometry/projection/projectVectorToVector.js";import{create as E}from"../../../geometry/support/aaBoundingRect.js";import{BufferViewVec2f as R,BufferViewVec4f as U,BufferViewVec4u8 as H,BufferViewVec4u16 as P,BufferViewVec3f as A,BufferViewVec3u8 as S,BufferViewVec3u16 as V,BufferViewInt16 as L,BufferViewUint32 as k,BufferViewUint16 as I}from"../../../geometry/support/buffer/BufferView.js";import F from"../../../layers/support/SceneModification.js";import{getElevationOffsetInMeters as D}from"../../../support/elevationInfoUtils.js";import{toWasmModification as B}from"./I3SMeshWorkerHandle.js";import{LayerView3D as G}from"./LayerView3D.js";import{Lyr3DViewPerformanceInfo as N}from"./Lyr3DViewPerformanceInfo.js";import{addLayerViewToWasm as z,removeLayerViewFromWasm as W,getLyr3DWasm as $}from"./Lyr3DWasm.js";import{LayerElevationProvider as q}from"./i3s/LayerElevationProvider.js";import{primTypeConversion as J,alphaModeConversion as K,faceCullingConversion as Q,wrapModeConversion as X,lyr3DTypeToByteSize as Y}from"./support/lyr3dTypeConversions.js";import{Tiles3DIntersectionHandler as Z}from"./support/Tiles3DIntersectionHandler.js";import{Frustum as ee}from"../state/Frustum.js";import{ElevationRange as te}from"../support/ElevationRange.js";import{toBoundingRect as ie}from"../support/extentUtils.js";import{compute as se,Obb as re}from"../support/orientedBoundingBox.js";import{ObjectParameters as oe}from"../webgl-engine/collections/Component/ObjectParameters.js";import{GeometryParameters as ne,createVertexBufferLayout as ae,SourceGeometry as le}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as de}from"../webgl-engine/collections/Component/Transform.js";import{RenderTexture as ce}from"../webgl-engine/core/material/RenderTexture.js";import{getEllipsoidMode as he}from"../webgl-engine/core/shaderLibrary/util/EllipsoidMode.js";import{Attribute as me}from"../webgl-engine/lib/Attribute.js";import{ManagedTexture as ue}from"../webgl-engine/lib/ManagedTexture.js";import{compressAndTransformNormals as pe}from"../webgl-engine/lib/Normals.js";import{writeAttribute as fe,writeBufferVec2 as be}from"../webgl-engine/materials/internal/bufferWriterUtils.js";import ge from"../../layers/LayerView.js";import{spatialReferenceIncompatibleError as ye,isInEffectiveScaleRange as _e,validateScaleRange as ve}from"../../support/layerViewUtils.js";import{TextureCompressionTracker as we}from"../../support/TextureCompressionTracker.js";import{alphaCutoff as je}from"../../../webscene/support/AlphaCutoff.js";class xe{constructor(e,t,i,s,r,o,n,a,l,d){this.handle=e,this.componentObjects=t,this.textures=i,this.cpuMemoryUsage=s,this.vboMemoryUsage=r,this.textureMemoryUsage=o,this.obb=n,this.stableNodeId=a,this.nodeDepth=l,this.elevationRange=d,this.isLoaded=!1,this.isVisible=!1,this.usedMemory=this.textureMemoryUsage+this.vboMemoryUsage+this.cpuMemoryUsage;const c=w();n?.getCenter(c),this._obbCenter=c,this._obbRadius=n?.radius??0,this._obbRadiusSquared=this._obbRadius**2;const h=n?.halfSize;this._obbShortestHalfsize=h?Math.min(h[0],h[1],h[2]):0}boundingVolumeIntersectsRay(e,t){if(!this.obb)return!0;const i=this._obbCenter,s=i[0]-e[0],r=i[1]-e[1],o=i[2]-e[2],n=s*t[0]+r*t[1]+o*t[2];return s*s+r*r+o*o-n*n<=this._obbRadiusSquared&&this.obb.intersectRay(e,t)}boundingVolumeIntersectsSphere(e){const{obb:t}=this;if(!t)return!0;const i=e.center,s=this._obbCenter,r=s[0]-i[0],o=s[1]-i[1],n=s[2]-i[2],a=r*r+o*o+n*n,l=this._obbRadius,d=e.radius;if(a>(l+d)**2)return!1;if(a<=(this._obbShortestHalfsize+d)**2)return!0;return Math.sqrt(a)+l<=d||t.intersectSphere(e)}}function Oe(e){return Math.round(e/1048.576)/1e3}let Me=class extends(G(ge)){get hasModifications(){return this._modifications&&this._modifications.length>0}constructor(e){super(e),this.type="integrated-mesh-3dtiles",this._compressionTracker=new we,this._replacesTerrain=!1,this._isUsedAsGroundLayer=!1,this._modifications=new Array,this._visibleGeometryChangedSchedulerHandle=null,this._wasmLayerId=-1,this.ignoresMemoryFactor=!1,this._usedMemory=0,this._cacheMemory=0,this.drapeTargetType=1,this._applySSAO=!has("disable-feature:im-ssao"),this._shadeNormals=!!has("enable-feature:im-shading"),this._lyrHandleToObjects=new Map,this._visibleObjects=new Set,this._loadedObjects=new Set,this._suspendedHandle=null,this._dbgFlags=new Set,this._memCache=e.view.resourceController.memoryController.newCache(`IM3DTiles-${this.uid}`,e=>this._deletePerObjectData(e)),this._frustum=new ee(e.view.renderCoordsHelper)}tryRecycleWith(e,t){return this.canRecycleWith(e)?e.load(t).then(()=>{r(t),this.layer=e}):null}canRecycleWith(e){return e.url===this.layer.url&&"integrated-mesh-3dtiles"===e.type&&e.replacesTerrain===this._replacesTerrain&&e.isUsedAsGroundLayer===this._isUsedAsGroundLayer}initialize(){this._dbgFlags.add(3),this._dbg(2,"Tiles3DLayerView3D initialize() called");const{view:e}=this;if(this._replacesTerrain=this.layer.replacesTerrain,this._isUsedAsGroundLayer=this.layer.isUsedAsGroundLayer,this._updatingHandles.add(()=>this.layer.modifications,()=>this._loadModifications(),o),!this._canProjectWithoutEngine())throw ye("layer",this.layer.spatialReference.wkid,e.renderSpatialReference?.wkid);const t=z(this).then(t=>{this._wasmLayerId=t,this._intersectionHandler=new Z(this),e.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler),this._updatingHandles.add(()=>this.slicePlaneEnabled,e=>this._slicePlaneEnabledChange(e)),this._updatingHandles.add(()=>this._modifications,()=>this._modificationsChanged(),o),this._updatingHandles.add(()=>this.fullOpacity,()=>this._opacityChange()),this._updatingHandles.add(()=>e.clippingArea,()=>this._clippingAreaChanged(),o),this._updatingHandles.add(()=>e.state.contentCamera,()=>this._cameraChanged(),o),this._elevationProvider=new q({view:e,layerElevationSource:this,intersectionHandler:this._intersectionHandler}),e.elevationProvider.register(1,this._elevationProvider),e.overlayManager.registerDrapeTarget(this),this.addHandles([n(()=>this.layer.elevationInfo,e=>this._elevationInfoChanged(e)),a(()=>this.fullOpacity,()=>this._opacityChange())]),this._suspendedHandle=n(()=>this.suspended,e=>this._wasm?.setEnabled(this,!e),o)});this.addResolvingPromise(t)}get fullOpacity(){return this.layer.replacesTerrain&&has("enable-feature:oit-ground")?this.view.map.ground.opacity:1}_opacityChange(){const{fullOpacity:e}=this;this.forEachComponentObject(t=>this._collection.updateMaterial(t,t=>t.objectOpacity=e))}_cameraChanged(){const e=this._frustum;e.update(this.view.state.contentCamera);const t=this._visibleObjects;let i=!1;this._loadedObjects.forEach(s=>{const r=s.obb?.intersectsFrustum(e)??!1;r!==s.isVisible&&(s.isVisible=r,r?t.add(s):t.delete(s),s.componentObjects.forEach(e=>this._collection.setObjectVisibility(e,r)),i=!0)}),i&&this._setVisibleElevationRangeDirty()}intersect(e,t,i,s){this._intersectionHandler.intersect(e,t,i,s,null,!1)}get ready(){return!this.layer.replacesTerrain||!!this._wasm?.isTerrainReady}destroy(){this._dbg(2,"Tiles3DLayerView3D destroy() called"),W(this),this._suspendedHandle&&(this._suspendedHandle.remove(),this._suspendedHandle=null),this._intersectionHandler&&(this.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler=null),this._elevationProvider&&(this._elevationProvider.notifyObjectsChangedFunctional(e=>this.forEachComponentObject(t=>e(t.obb))),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this.view.overlayManager.unregisterDrapeTarget(this),this._lyrHandleToObjects.forEach(e=>this.freeObject(e)),this._lyrHandleToObjects.clear(),this._visibleObjects.clear(),this._loadedObjects.clear(),this._usedMemory=this._cacheMemory=0,this._memCache.destroy(),this._updatingHandles=i(this._updatingHandles),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=s(this._visibleGeometryChangedSchedulerHandle)}_modificationsChanged(){const e=this.layer.spatialReference,t=B(this._layerClippingArea,this._modifications,e);this._wasm?.setMeshModifications(this,t,e.wkid)}_clippingAreaChanged(){const e=this.layer.spatialReference,t=E();this._layerClippingArea=ie(this.view.clippingArea,t,e)?t:null,this._modificationsChanged()}_visibleGeometryChanged(){this._visibleGeometryChangedSchedulerHandle??=l(()=>{this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=null})}_slicePlaneEnabledChange(e){this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e&&!this.layer.replacesTerrain),this.forEachComponentObject(t=>this._collection.updateMaterial(t,t=>t.commonMaterialParameters.hasSlicePlane=e))}_elevationInfoChanged(e){this._wasm?.setLayerOffset(this,D(e))}get _wasm(){return $(this.view)}get wasmLayerId(){return this._wasmLayerId}get usedMemory(){return this._usedMemory}get unloadedMemory(){return 0}get cachedMemory(){return this._cacheMemory}get visibleAtCurrentScale(){return this.layer.isUsedAsGroundLayer||_e(this.layer.effectiveScaleRange,this.view.scale)}canResume(){const e=this.layer&&"effectiveScaleRange"in this.layer?this.layer.effectiveScaleRange:null;return this.visible&&this.layer?.loaded&&this.parent&&!this.parent.suspended&&this.view?.ready&&(this.layer.isUsedAsGroundLayer||ve(e)&&this.visibleAtCurrentScale)&&this.visibleAtCurrentTimeExtent||!1}get performanceInfo(){let e=0,t=0,i=0,s=0,r=0,o=0;return this._lyrHandleToObjects.forEach(n=>{n.isLoaded?(e+=n.textureMemoryUsage,t+=n.vboMemoryUsage,r++):(i+=n.textureMemoryUsage,s+=n.vboMemoryUsage,o++)}),new N(this.usedMemory,r,o,Oe(t),Oe(e),Oe(s),Oe(i))}_canProjectWithoutEngine(){if(2===this.view.state.viewingMode){const e=this.view.renderSpatialReference?.isWebMercator?3857:this.view.renderSpatialReference?.wkid??-1;if(3857!==e&&32662!==e)return!1}return!0}get _stage(){return this.view.stage}get _collection(){return this._stage.renderView.componentObjectCollection}get elevationProvider(){return this._elevationProvider}get elevationOffset(){return D(this.layer.elevationInfo)}get elevationRange(){const e=this.fullExtent;return e?.zmin&&e?.zmax?new te(e.zmin,e.zmax):null}getElevationRange(e){return this._intersectionHandler.getElevationRange(e)}get visibleElevationRange(){const e=new te;return 0===this._visibleObjects.size?e.setElevationRangeValues(0,0):(e.setElevationRangeValues(1/0,-1/0),this.forEachVisibleTile(t=>e.expandElevationRange(t.elevationRange))),e}_setVisibleElevationRangeDirty(){this.notifyChange("visibleElevationRange")}get fullExtent(){return this.layer.fullExtent}forEachComponentObject(e){this._forEachObject(this._lyrHandleToObjects.values(),e)}forEachVisibleTile(e){for(const t of this._visibleObjects)e(t)}forEachVisibleComponentObject(e){this._forEachObject(this._visibleObjects,e)}_forEachObject(e,t){for(const i of e)for(const e of i.componentObjects)t(e)}isUpdating(){const e=this._wasm;return this._wasmLayerId>=0&&null!=e&&(e.isUpdating(this._wasmLayerId)||this._compressionTracker.compressing)}updatingFlagChanged(){this.notifyChange("updating")}async createRenderable(e){if(this.destroyed){const e=`IntegratedMesh3DTilesLayerView3D[${this.layer?.title}]: createRenderable called on destroyed instance`;throw new Error(e)}let t=0;const{meshData:i}=e;if(null==i.data)throw new Error("meshData.data undefined");if(i.desc=JSON.parse(i.desc),null==i.desc)throw new Error("meshData.desc undefined");const s=v(...i.desc.origin),r=this.view.basemapTerrain.spatialReference;let o,n;if("global"===this.view.viewingMode){const e=f();M(x,s,e,r),o=h(u(),e),n=m(u(),o)}else o=p,n=p;const a=w(),l=Re(i.desc.obb);let d=0,c=0;const b={textureMemoryUsage:0},E=new Array,U=new Map,H=i.desc.prims.length,P=new Array,A=new te;try{const e="global"===this.view.viewingMode,t=e?O(this.view.spatialReference).radius:0;for(let h=0;h<H;h++){const m=i.desc.prims[h];this._dbg(2,JSON.stringify(m));if(null==J[m.ptype]||null==i.data){this._dbg(2,"[Unsupported Feature] Unsupported primitive mode ("+m.ptype+"). Skipping primitive.");continue}const u=i.desc?.materials&&null!=m.materialId?i.desc.materials[m.materialId]:null,f=null!=u?u.lightingModel:"Unlit",{positionView:v,positionAttr:x,normalsView:O,normalsAttr:M,colorAttr:H,texCoord0Attr:P,indicesView:S}=this.getBufferViews(m,i.data.buffer,o);if(null==x||null==v||null==S)continue;const V=x.data.length/x.size,L=(e,t)=>!e||e.data.length/e.size===V||(this._dbg(3,`${t} !== numPos. Skipping primitive.`),!1);if(!L(P,"numTexcoord")||!L(H,"numColors")||!L(M,"normals"))continue;const k=new ne(null!=H,P?1:0,null!=O,this._shadeNormals||this.layer.replacesTerrain,this._applySSAO),I=ae(k);for(let i=0;i<v.count;i++){v.getVec(i,a),g(a,a,s);const r=e?y(a)-t:a[2];A.expandElevationRangeValues(r,r)}const F=l?.clone()??Ee(x,s);if(o!==p)for(let e=0;e<v.count;e++)v.getVec(e,a),_(a,a,o),v.setVec(e,a);const D=I.createBuffer(x.data.length);if(fe("position",x,null,null,D,0),null!=P){const e=D.getField("uv0",R);be(P,e,0)}null!=H&&fe("color",H,null,null,D,0),null!=M&&fe("normalCompressed",M,null,null,D,0);const B=new Uint32Array([0,S.typedBuffer.length]),G=new le({data:D.buffer,count:D.byteLength/I.stride,layoutParameters:k},{positions:v.typedBuffer,indices:S.typedBuffer},S.typedBuffer,B);d+=v.count+S.count;const N=this.view.renderSpatialReference,z=w(),W=[1,1,1];C(s,N,W,r)||this._dbg(3,"Unsupported coordinate system for IM overlay"),T(s,N,z,r);let $=()=>{},q=Promise.resolve(He);if(u){const e=e=>this._getTexture(e,i,U,b),t=e(u.baseColorTex),s="Pbr"===f,r=s?e(u.metalTex):null,o=s?e(u.emissiveTex):null,n=s?e(u.occlusionTex):null,a=s?e(u.normalTex):null,l=[t,r,o,n,a].map(e=>e?.loadPromise??null);q=Promise.all(l),$=e=>{e.baseColor=u.baseColorFactor,e.usePBR="Pbr"===f,e.hasParametersFromSource=!1,e.baseColorTexture=t,e.usePBR&&(e.mrrFactors=[u.metallicFactor,u.roughnessFactor,0],e.emissiveBaseColor=u.emissiveFactor??[0,0,0],e.metallicRoughnessTexture=r,e.emissionTexture=o,e.occlusionTexture=n,e.normalTexture=a),e.alphaDiscardMode=K[u.alphaMode],e.objectOpacity=this.fullOpacity,b.textureMemoryUsage+=e.baseColorTexture?.texture?.usedMemory??0,e.usePBR&&(b.textureMemoryUsage+=(e.metallicRoughnessTexture?.texture?.usedMemory??0)+(e.emissionTexture?.texture?.usedMemory??0)+(e.occlusionTexture?.texture?.usedMemory??0)+(e.normalTexture?.texture?.usedMemory??0)),e.commonMaterialParameters.doubleSided=u.isDoubleSided,e.commonMaterialParameters.cullFace=Q[u.faceCulling??"NotSet"],e.commonMaterialParameters.isGround=this.layer.replacesTerrain,e.commonMaterialParameters.hasSlicePlane=this.slicePlaneEnabled,e.componentParameters.castShadows=0,e.textureAlphaCutoff=u.alphaCutoff??je,e.alphaDiscardMode=K[u.alphaMode],e.isIntegratedMesh=!0,e.sphereDepthInterpolate=this.layer.hasGoogleUrl,e.polygonOffsetEnabled=!1,e.hasOccludees=!1,e.ellipsoidMode=he(this.view.spatialReference)}}const X=q.then(()=>()=>{if(this.destroyed){const e="Trying to add object to destroyed layer view";throw this._dbg(3,`${e} !== numPos. Skipping primitive.`),new Error(e)}const e=this._collection.createObject(new oe(j(z[0],z[1],W[0],W[1]),new de(s,n),F,G,!1));return this._collection.updateMaterial(e,$),c+=this._collection.getObjectGPUMemoryUsage(e),e});E.push(X)}if(P.push(...await Promise.all(E)),this.destroyed){throw new Error("IntegratedMesh3DTilesLayerView3D: createRenderable object destroyed during call")}}catch(k){throw U.forEach(e=>this._stage.removeTexture(e)),k}const S=P.map(e=>e()),V=new Array;U.forEach(e=>V.push(e));const L=new xe(e.handle,S,V,d,c,b.textureMemoryUsage,l,e.stableNodeId,e.nodeDepth,A);return this._lyrHandleToObjects.set(e.handle,L),this._memCache.put(Ue(L.handle),L),t=L.usedMemory,this._cacheMemory+=t,{memUsageBytes:L.usedMemory}}freeRenderable(e){const t=this._lyrHandleToObjects.get(e);t?(t.isLoaded?(this._loadedObjects.delete(t),this._visibleObjects.delete(t),this._usedMemory-=t.usedMemory):this._cacheMemory-=t.usedMemory,this.freeObject(t),this._lyrHandleToObjects.delete(e)):this._dbg(3,`freeRendedrable on non-existent renderable ${e}`)}freeObject(e){const t=Ue(e.handle);this._memCache.pop(t),e.textures.forEach(e=>this._stage.removeTexture(e)),e.componentObjects.forEach(e=>this._collection.destroyObject(e))}setRenderableVisibility(e,t,i){if(this.destroyed||this.destroying)return;const s=this._frustum,r=new Array;let o=!1;for(let n=0;n<i;++n){if(!t[n])continue;const i=e[n],a=this._lyrHandleToObjects.get(i);if(a){if(a.isLoaded){this._dbg(3,`Already loaded object marked loaded again ${a.stableNodeId}`);continue}o=!0,a.isLoaded=!0,this._loadedObjects.add(a),this._usedMemory+=a.usedMemory,this._cacheMemory-=a.usedMemory;const e=a.obb?.intersectsFrustum(s)??!0;if(a.isVisible=e,e){this._visibleObjects.add(a);const{minElevation:e,maxElevation:t}=a.elevationRange;(e<this.visibleElevationRange.minElevation||t>this.visibleElevationRange.maxElevation)&&this._setVisibleElevationRangeDirty()}e&&a.obb&&r.push(a.obb),a.componentObjects.forEach(t=>{this._collection.setObjectVisibility(t,e)}),this._memCache.pop(Ue(i))}else this._dbg(3,`Tried to mark Non existent object ${i} as loaded`)}for(let n=0;n<i;++n){const i=e[n];if(t[n])continue;const s=this._lyrHandleToObjects.get(i);if(s){if(!s.isLoaded){this._dbg(3,`Tried to unload not-loaded object ${s.stableNodeId}`);continue}const e=this._visibleObjects.delete(s);if(s.isVisible=!1,s.isLoaded=!1,this._loadedObjects.delete(s),e){this._visibleGeometryChanged();const{minElevation:e,maxElevation:t}=s.elevationRange;e!==this.visibleElevationRange.minElevation&&t!==this.visibleElevationRange.maxElevation||this._setVisibleElevationRangeDirty()}this._usedMemory-=s.usedMemory,this._cacheMemory+=s.usedMemory,e&&s.obb&&r.push(s.obb),s.componentObjects.forEach(e=>{this._collection.setObjectVisibility(e,!1)}),this._memCache.put(Ue(i),s)}else this._dbg(3,`Tried to mark Non existent object ${i} as not loaded`)}o&&this._visibleGeometryChanged(),this._elevationProvider.notifyObjectsChanged(r),this._setVisibleElevationRangeDirty()}setLodPixelThreshold(e){this._wasm?.setLodPixelThreshold(this,e)}_getTexture(e,t,i,s){const r=e&&t.desc?.images?.[e.imageId];if(!r||!t.data?.buffer)return null;const o=i.get(r)??this._createTexture(e,t,i,s);return o?new ce(this._stage.renderView.textures,o.id):null}_createTexture(e,t,i,s){const r=e&&t.desc?.images?.[e.imageId];if(!r||!t.data?.buffer)return null;const o=this._stage,{renderView:n}=o,a=n.renderingContext.parameters.maxMaxAnisotropy,l=!!r.mipCount||a>1,d=X[e.wrapMode??"None"];let c=r.alpha?6408:6407;const h=new Uint8Array(t.data.buffer,r.data.byteOffset,r.data.byteCount);let m=null,u=null,p=null;switch(r.format){case"Raw":"R8"===r.pixelFormat?(m=h,c=6403,u=""):"Rgb8"===r.pixelFormat?(m=h,c=6407,u=""):"Rgba8"===r.pixelFormat&&(m=h,c=6408,u="");break;case"Dxt1":m=h,c=6407,u="image/vnd-ms.dds";break;case"Dxt5":m=h,c=6408,u="image/vnd-ms.dds";break;case"Basis":m=h,c=6407,u="image/ktx2";break;case"Png":u="image/png",p=document.createElement("img");break;case"Jpeg":u="image/jpeg",p=document.createElement("img");break;case"Etc2":u="image/ktx",p=document.createElement("img");break;case"Astc":this._dbg(3,"Astc texture not supported");break;case"Pvrtc":this._dbg(3,"Pvrtc texture not supported")}if(p&&u){const e=new Blob([h],{type:u});p.src=URL.createObjectURL(e),m=p}if(m&&null!=u){const e=has("enable-feature:esri-compress-IM-textures")?{compressionTracker:this._compressionTracker,compressionCallback:e=>{e&&e>0&&(s.textureMemoryUsage-=e)}}:void 0,t=new ue(m,{mipmap:l,maxAnisotropy:a,encoding:u,wrap:d,pixelFormat:c,compressionOptions:e,noUnpackFlip:!0,width:r.mip0Width,height:r.mip0Height});return this._stage.addTexture(t),i.set(r,t),t}return null}getBufferViews(e,t,i){let s,r,o,n,a,l,d,c=null;for(let m=0;m<e.atrbs.length;m++){const d=e.atrbs[m],{view:u}=d,p=void 0,f=u.byteOffset+u.byteCount,b=u.byteCount/Y[u.type],g=new(Pe(b))(b);for(let e=0;e<b;++e)g[e]=e;try{switch(d.sem){case"Position":3!==u.ncomp||"F32"!==u.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Position ("+u+")"):(s=new A(t,u.byteOffset,p,f),r=new me(s.typedBuffer,g,3));break;case"Normal":if(3!==u.ncomp||"F32"!==u.type)this._dbg(3,"[Unsupported Feature] Unsupported view for Normal ("+u+")");else{const e=new A(t,u.byteOffset,p,f),s=pe(e.typedBuffer,i);a=new L(s.buffer),l=new me(a.typedBuffer,g,2)}break;case"TexCoord":2!==u.ncomp||"F32"!==u.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Texcoord ("+u+")"):void 0===n&&(n=new me(new R(t,u.byteOffset,p,f).typedBuffer,g,2));break;case"Color":4===u.ncomp?("F32"===u.type&&(c=new U(t,u.byteOffset,p,f)),"U8"===u.type&&(c=new H(t,u.byteOffset,p,f)),"U16"===u.type&&(c=new P(t,u.byteOffset,p,f))):3===u.ncomp&&("F32"===u.type&&(c=new A(t,u.byteOffset,p,f)),"U8"===u.type&&(c=new S(t,u.byteOffset,p,f)),"U16"===u.type&&(c=new V(t,u.byteOffset,p,f))),null==c?this._dbg(2,"[Unsupported Feature] Unsupported view for Color ("+u+")"):o=new me(c.typedBuffer,g,u.ncomp);break;case"FeatureIndex":break;default:this._dbg(2,"[Unsupported Feature] Unsupported semantic ("+d.sem+"). Skipping vertex attribute.")}}catch(h){this._dbg(2,"Error Creating buffer ("+h+"). Skipping vertex attribute.")}}if(e.index){const i=e.index.view,s=void 0,r=i.byteOffset+i.byteCount;switch(e.index.view.type){case"U16":d=new I(t,i.byteOffset,s,r);break;case"U32":d=new k(t,i.byteOffset,s,r);break;default:this._dbg(3,"[Unsupported Feature] index type not supported ("+i.type+").")}}if(null==d&&null!=s){const e=s.count;d=d=e<65535?new I(new Uint16Array(e).buffer):new k(new Uint32Array(e).buffer);for(let t=0;t<e;t++)d.set(t,t)}return{positionView:s,positionAttr:r,colorAttr:o,texCoord0Attr:n,indicesView:d,normalsView:a,normalsAttr:l}}_loadModifications(){if(this.removeHandles("modifications"),null==this.layer.modifications)return void(this._modifications=[]);const e=this.layer.modifications;this.addHandles(this._updatingHandles.addOnCollectionChange(()=>e,()=>{this._modifications=e.filter(e=>!(this.layer.isUsedAsGroundLayer&&"replace"!==e.type)).toArray(),this._modifications.length<e.length&&t.getLogger(this).info("Ground layers only support replace modifications. Other modification types have been ignored.")},o),"modifications")}_deletePerObjectData(e){this._wasm?.onRenderableEvicted(this,e.handle,e.usedMemory),this.freeRenderable(e.handle)}_dbg(e,i){this._dbgFlags.has(e)&&(3===e?t.getLogger(this).error(i):t.getLogger(this).warn(i))}};e([d()],Me.prototype,"fullOpacity",null),e([d({readOnly:!0})],Me.prototype,"ready",null),e([d({type:[F]})],Me.prototype,"_modifications",void 0),e([d()],Me.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([d()],Me.prototype,"layer",void 0),e([d({readOnly:!0})],Me.prototype,"visibleAtCurrentScale",null),e([d({readOnly:!0})],Me.prototype,"_collection",null),e([d()],Me.prototype,"elevationOffset",null),e([d({readOnly:!0})],Me.prototype,"visibleElevationRange",null),Me=e([c("esri.views.3d.layers.IntegratedMesh3DTilesLayerView3D")],Me);const Ce=Me,Te=w();function Ee(e,t){const i=se(e);return g(Te,i.center,t),i.center=Te,i}function Re(e){return e?new re(e.center,e.halfSize,b(...e.quaternion)):null}function Ue(e){return`${e}`}const He=new Array;function Pe(e){return e<256?Uint8Array:e<65536?Uint16Array:Uint32Array}export{Ce as default};
|
|
5
|
+
import{__decorate as e}from"tslib";import has from"../../../core/has.js";import t from"../../../core/Logger.js";import{destroyMaybe as i,removeMaybe as s}from"../../../core/maybe.js";import{throwIfAborted as r}from"../../../core/promiseUtils.js";import{initial as o,watch as n,when as a}from"../../../core/reactiveUtils.js";import{schedule as l}from"../../../core/scheduling.js";import{property as d,subclass as c}from"../../../core/accessorSupport/decorators.js";import{fromMat4 as h,invert as m}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as u,IDENTITY as p}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as f}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as b}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{i as g,b as y,t as _}from"../../../chunks/vec32.js";import{freeze as v,create as w}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as j}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{SphericalECEFSpatialReferenceLike as x,getReferenceEllipsoid as M}from"../../../geometry/ellipsoidUtils.js";import{computeTranslationToOriginAndRotation as O}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{localLinearScaleFactors as C}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectVectorToVector as T}from"../../../geometry/projection/projectVectorToVector.js";import{create as E}from"../../../geometry/support/aaBoundingRect.js";import{BufferViewVec2f as R,BufferViewVec4f as U,BufferViewVec4u8 as H,BufferViewVec4u16 as P,BufferViewVec3f as A,BufferViewVec3u8 as S,BufferViewVec3u16 as V,BufferViewInt16 as L,BufferViewUint32 as k,BufferViewUint16 as I}from"../../../geometry/support/buffer/BufferView.js";import F from"../../../layers/support/SceneModification.js";import{getElevationOffsetInMeters as D}from"../../../support/elevationInfoUtils.js";import{toWasmModification as B}from"./I3SMeshWorkerHandle.js";import{LayerView3D as G}from"./LayerView3D.js";import{Lyr3DViewPerformanceInfo as z}from"./Lyr3DViewPerformanceInfo.js";import{addLayerViewToWasm as N,removeLayerViewFromWasm as W,getLyr3DWasm as $}from"./Lyr3DWasm.js";import{LayerElevationProvider as q}from"./i3s/LayerElevationProvider.js";import{primTypeConversion as J,alphaModeConversion as Z,faceCullingConversion as K,wrapModeConversion as Q,lyr3DTypeToByteSize as X}from"./support/lyr3dTypeConversions.js";import{Tiles3DIntersectionHandler as Y}from"./support/Tiles3DIntersectionHandler.js";import{Frustum as ee}from"../state/Frustum.js";import{ElevationRange as te}from"../support/ElevationRange.js";import{toBoundingRect as ie}from"../support/extentUtils.js";import{compute as se,Obb as re}from"../support/orientedBoundingBox.js";import{ObjectParameters as oe}from"../webgl-engine/collections/Component/ObjectParameters.js";import{GeometryParameters as ne,createVertexBufferLayout as ae,SourceGeometry as le}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as de}from"../webgl-engine/collections/Component/Transform.js";import{RenderTexture as ce}from"../webgl-engine/core/material/RenderTexture.js";import{getEllipsoidMode as he}from"../webgl-engine/core/shaderLibrary/util/EllipsoidMode.js";import{Attribute as me}from"../webgl-engine/lib/Attribute.js";import{ManagedTexture as ue}from"../webgl-engine/lib/ManagedTexture.js";import{compressAndTransformNormals as pe}from"../webgl-engine/lib/Normals.js";import{writeAttribute as fe,writeBufferVec2 as be}from"../webgl-engine/materials/internal/bufferWriterUtils.js";import ge from"../../layers/LayerView.js";import{spatialReferenceIncompatibleError as ye,isInEffectiveScaleRange as _e,validateScaleRange as ve}from"../../support/layerViewUtils.js";import{TextureCompressionTracker as we}from"../../support/TextureCompressionTracker.js";import{alphaCutoff as je}from"../../../webscene/support/AlphaCutoff.js";class xe{constructor(e,t,i,s,r,o,n,a,l,d){this.handle=e,this.componentObjects=t,this.textures=i,this.cpuMemoryUsage=s,this.vboMemoryUsage=r,this.textureMemoryUsage=o,this.obb=n,this.stableNodeId=a,this.nodeDepth=l,this.elevationRange=d,this.isLoaded=!1,this.isVisible=!1,this.usedMemory=this.textureMemoryUsage+this.vboMemoryUsage+this.cpuMemoryUsage;const c=w();n?.getCenter(c),this._obbCenter=c,this._obbRadius=n?.radius??0,this._obbRadiusSquared=this._obbRadius**2;const h=n?.halfSize;this._obbShortestHalfsize=h?Math.min(h[0],h[1],h[2]):0}boundingVolumeIntersectsRay(e,t){if(!this.obb)return!0;const i=this._obbCenter,s=i[0]-e[0],r=i[1]-e[1],o=i[2]-e[2],n=s*t[0]+r*t[1]+o*t[2];return s*s+r*r+o*o-n*n<=this._obbRadiusSquared&&this.obb.intersectRay(e,t)}boundingVolumeIntersectsSphere(e){const{obb:t}=this;if(!t)return!0;const i=e.center,s=this._obbCenter,r=s[0]-i[0],o=s[1]-i[1],n=s[2]-i[2],a=r*r+o*o+n*n,l=this._obbRadius,d=e.radius;if(a>(l+d)**2)return!1;if(a<=(this._obbShortestHalfsize+d)**2)return!0;return Math.sqrt(a)+l<=d||t.intersectSphere(e)}}function Me(e){return Math.round(e/1048.576)/1e3}let Oe=class extends(G(ge)){get hasModifications(){return this._modifications&&this._modifications.length>0}constructor(e){super(e),this.type="integrated-mesh-3dtiles",this._compressionTracker=new we,this._replacesTerrain=!1,this._isUsedAsGroundLayer=!1,this._modifications=new Array,this._visibleGeometryChangedSchedulerHandle=null,this._wasmLayerId=-1,this.ignoresMemoryFactor=!1,this._usedMemory=0,this._cacheMemory=0,this.drapeTargetType=1,this._applySSAO=!has("disable-feature:im-ssao"),this._shadeNormals=!!has("enable-feature:im-shading"),this._lyrHandleToObjects=new Map,this._visibleObjects=new Set,this._loadedObjects=new Set,this._suspendedHandle=null,this._dbgFlags=new Set,this._memCache=e.view.resourceController.memoryController.newCache(`IM3DTiles-${this.uid}`,e=>this._deletePerObjectData(e)),this._frustum=new ee(e.view.renderCoordsHelper)}tryRecycleWith(e,t){return this.canRecycleWith(e)?e.load(t).then(()=>{r(t),this.layer=e}):null}canRecycleWith(e){return e.url===this.layer.url&&"integrated-mesh-3dtiles"===e.type&&e.replacesTerrain===this._replacesTerrain&&e.isUsedAsGroundLayer===this._isUsedAsGroundLayer}initialize(){this._dbgFlags.add(3),this._dbg(2,"Tiles3DLayerView3D initialize() called");const{view:e}=this;if(this._replacesTerrain=this.layer.replacesTerrain,this._isUsedAsGroundLayer=this.layer.isUsedAsGroundLayer,this._updatingHandles.add(()=>this.layer.modifications,()=>this._loadModifications(),o),!this._canProjectWithoutEngine())throw ye("layer",this.layer.spatialReference.wkid,e.renderSpatialReference?.wkid);const t=N(this).then(t=>{this._wasmLayerId=t,this._intersectionHandler=new Y(this),e.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler),this._updatingHandles.add(()=>this.slicePlaneEnabled,e=>this._slicePlaneEnabledChange(e)),this._updatingHandles.add(()=>this._modifications,()=>this._modificationsChanged(),o),this._updatingHandles.add(()=>this.fullOpacity,()=>this._opacityChange()),this._updatingHandles.add(()=>e.clippingArea,()=>this._clippingAreaChanged(),o),this._updatingHandles.add(()=>e.state.contentCamera,()=>this._cameraChanged(),o),this._elevationProvider=new q({view:e,layerElevationSource:this,intersectionHandler:this._intersectionHandler}),e.elevationProvider.register(1,this._elevationProvider),e.overlayManager.registerDrapeTarget(this),this.addHandles([n(()=>this.layer.elevationInfo,e=>this._elevationInfoChanged(e)),a(()=>this.fullOpacity,()=>this._opacityChange())]),this._suspendedHandle=n(()=>this.suspended,e=>this._wasm?.setEnabled(this,!e),o)});this.addResolvingPromise(t)}get fullOpacity(){return this.layer.replacesTerrain&&has("enable-feature:oit-ground")?this.view.map.ground.opacity:1}_opacityChange(){const{fullOpacity:e}=this;this.forEachComponentObject(t=>this._collection.updateMaterial(t,t=>t.objectOpacity=e))}_cameraChanged(){const e=this._frustum;e.update(this.view.state.contentCamera);const t=this._visibleObjects;let i=!1;this._loadedObjects.forEach(s=>{const r=s.obb?.intersectsFrustum(e)??!1;r!==s.isVisible&&(s.isVisible=r,r?t.add(s):t.delete(s),s.componentObjects.forEach(e=>this._collection.setObjectVisibility(e,r)),i=!0)}),i&&this._setVisibleElevationRangeDirty()}intersect(e,t,i,s){this._intersectionHandler.intersect(e,t,i,s,null,!1)}get ready(){return!this.layer.replacesTerrain||!!this._wasm?.isTerrainReady}destroy(){this._dbg(2,"Tiles3DLayerView3D destroy() called"),W(this),this._suspendedHandle&&(this._suspendedHandle.remove(),this._suspendedHandle=null),this._intersectionHandler&&(this.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler=null),this._elevationProvider&&(this._elevationProvider.notifyObjectsChangedFunctional(e=>this.forEachComponentObject(t=>e(t.obb))),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this.view.overlayManager.unregisterDrapeTarget(this),this._lyrHandleToObjects.forEach(e=>this.freeObject(e)),this._lyrHandleToObjects.clear(),this._visibleObjects.clear(),this._loadedObjects.clear(),this._usedMemory=this._cacheMemory=0,this._memCache.destroy(),this._updatingHandles=i(this._updatingHandles),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=s(this._visibleGeometryChangedSchedulerHandle)}_modificationsChanged(){const e=this.layer.spatialReference,t=B(this._layerClippingArea,this._modifications,e);this._wasm?.setMeshModifications(this,t,e.wkid)}_clippingAreaChanged(){const e=this.layer.spatialReference,t=E();this._layerClippingArea=ie(this.view.clippingArea,t,e)?t:null,this._modificationsChanged()}_visibleGeometryChanged(){this._visibleGeometryChangedSchedulerHandle??=l(()=>{this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=null})}_slicePlaneEnabledChange(e){this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e&&!this.layer.replacesTerrain),this.forEachComponentObject(t=>this._collection.updateMaterial(t,t=>t.commonMaterialParameters.hasSlicePlane=e))}_elevationInfoChanged(e){this._wasm?.setLayerOffset(this,D(e))}get _wasm(){return $(this.view)}get wasmLayerId(){return this._wasmLayerId}get usedMemory(){return this._usedMemory}get unloadedMemory(){return 0}get cachedMemory(){return this._cacheMemory}get visibleAtCurrentScale(){return this.layer.isUsedAsGroundLayer||_e(this.layer.effectiveScaleRange,this.view.scale)}canResume(){const e=this.layer&&"effectiveScaleRange"in this.layer?this.layer.effectiveScaleRange:null;return this.visible&&this.layer?.loaded&&this.parent&&!this.parent.suspended&&this.view?.ready&&(this.layer.isUsedAsGroundLayer||ve(e)&&this.visibleAtCurrentScale)&&this.visibleAtCurrentTimeExtent||!1}get performanceInfo(){let e=0,t=0,i=0,s=0,r=0,o=0;return this._lyrHandleToObjects.forEach(n=>{n.isLoaded?(e+=n.textureMemoryUsage,t+=n.vboMemoryUsage,r++):(i+=n.textureMemoryUsage,s+=n.vboMemoryUsage,o++)}),new z(this.usedMemory,r,o,Me(t),Me(e),Me(s),Me(i))}_canProjectWithoutEngine(){if(2===this.view.state.viewingMode){const e=this.view.renderSpatialReference?.isWebMercator?3857:this.view.renderSpatialReference?.wkid??-1;if(3857!==e&&32662!==e)return!1}return!0}get _stage(){return this.view.stage}get _collection(){return this._stage.renderView.componentObjectCollection}get elevationProvider(){return this._elevationProvider}get elevationOffset(){return D(this.layer.elevationInfo)}get elevationRange(){const e=this.fullExtent;return e?.zmin&&e?.zmax?new te(e.zmin,e.zmax):null}getElevationRange(e){return this._intersectionHandler.getElevationRange(e)}get visibleElevationRange(){const e=new te;return 0===this._visibleObjects.size?e.setElevationRangeValues(0,0):(e.setElevationRangeValues(1/0,-1/0),this.forEachVisibleTile(t=>e.expandElevationRange(t.elevationRange))),e}_setVisibleElevationRangeDirty(){this.notifyChange("visibleElevationRange")}get fullExtent(){return this.layer.fullExtent}forEachComponentObject(e){this._forEachObject(this._lyrHandleToObjects.values(),e)}forEachVisibleTile(e){for(const t of this._visibleObjects)e(t)}forEachVisibleComponentObject(e){this._forEachObject(this._visibleObjects,e)}_forEachObject(e,t){for(const i of e)for(const e of i.componentObjects)t(e)}isUpdating(){const e=this._wasm;return this._wasmLayerId>=0&&null!=e&&(e.isUpdating(this._wasmLayerId)||this._compressionTracker.compressing)}updatingFlagChanged(){this.notifyChange("updating")}async createRenderable(e){if(this.destroyed){const e=`IntegratedMesh3DTilesLayerView3D[${this.layer?.title}]: createRenderable called on destroyed instance`;throw new Error(e)}let t=0;const{meshData:i}=e;if(null==i.data)throw new Error("meshData.data undefined");if(i.desc=JSON.parse(i.desc),null==i.desc)throw new Error("meshData.desc undefined");const s=v(...i.desc.origin),r=this.view.basemapTerrain.spatialReference;let o,n;if("global"===this.view.viewingMode){const e=f();O(x,s,e,r),o=h(u(),e),n=m(u(),o)}else o=p,n=p;const a=w(),l=Re(i.desc.obb);let d=0,c=0;const b={textureMemoryUsage:0},E=new Array,U=new Map,H=i.desc.prims.length,P=new Array,A=new te;try{const e="global"===this.view.viewingMode,t=e?M(this.view.spatialReference).radius:0;for(let h=0;h<H;h++){const m=i.desc.prims[h];this._dbg(2,JSON.stringify(m));if(null==J[m.ptype]||null==i.data){this._dbg(2,"[Unsupported Feature] Unsupported primitive mode ("+m.ptype+"). Skipping primitive.");continue}const u=i.desc?.materials&&null!=m.materialId?i.desc.materials[m.materialId]:null,f=null!=u?u.lightingModel:"Unlit",{positionView:v,positionAttr:x,normalsView:M,normalsAttr:O,colorAttr:H,texCoord0Attr:P,indicesView:S}=this.getBufferViews(m,i.data.buffer,o);if(null==x||null==v||null==S)continue;const V=x.data.length/x.size,L=(e,t)=>!e||e.data.length/e.size===V||(this._dbg(3,`${t} !== numPos. Skipping primitive.`),!1);if(!L(P,"numTexcoord")||!L(H,"numColors")||!L(O,"normals"))continue;const k=new ne(null!=H,P?1:0,null!=M,this._shadeNormals||this.layer.replacesTerrain,this._applySSAO),I=ae(k);for(let i=0;i<v.count;i++){v.getVec(i,a),g(a,a,s);const r=e?y(a)-t:a[2];A.expandElevationRangeValues(r,r)}const F=l?.clone()??Ee(x,s);if(o!==p)for(let e=0;e<v.count;e++)v.getVec(e,a),_(a,a,o),v.setVec(e,a);const D=I.createBuffer(x.data.length);if(fe("position",x,null,null,D,0),null!=P){const e=D.getField("uv0",R);be(P,e,0)}null!=H&&fe("color",H,null,null,D,0),null!=O&&fe("normalCompressed",O,null,null,D,0);const B=new Uint32Array([0,S.typedBuffer.length]),G=new le({data:D.buffer,count:D.byteLength/I.stride,layoutParameters:k},{positions:v.typedBuffer,indices:S.typedBuffer},S.typedBuffer,B);d+=v.count+S.count;const z=this.view.renderSpatialReference,N=w(),W=[1,1,1];C(s,z,W,r)||this._dbg(3,"Unsupported coordinate system for IM overlay"),T(s,z,N,r);let $=()=>{},q=Promise.resolve(He);if(u){const e=e=>this._getTexture(e,i,U,b),t=e(u.baseColorTex),s="Pbr"===f,r=s?e(u.metalTex):null,o=s?e(u.emissiveTex):null,n=s?e(u.occlusionTex):null,a=s?e(u.normalTex):null,l=[t,r,o,n,a].map(e=>e?.loadPromise??null);q=Promise.all(l),$=e=>{e.baseColor=u.baseColorFactor,e.usePBR="Pbr"===f,e.hasParametersFromSource=!1,e.baseColorTexture=t,e.usePBR&&(e.mrrFactors=[u.metallicFactor,u.roughnessFactor,0],e.emissiveBaseColor=u.emissiveFactor??[0,0,0],e.metallicRoughnessTexture=r,e.emissionTexture=o,e.occlusionTexture=n,e.normalTexture=a),e.alphaDiscardMode=Z[u.alphaMode],e.objectOpacity=this.fullOpacity,b.textureMemoryUsage+=e.baseColorTexture?.texture?.usedMemory??0,e.usePBR&&(b.textureMemoryUsage+=(e.metallicRoughnessTexture?.texture?.usedMemory??0)+(e.emissionTexture?.texture?.usedMemory??0)+(e.occlusionTexture?.texture?.usedMemory??0)+(e.normalTexture?.texture?.usedMemory??0)),e.commonMaterialParameters.doubleSided=u.isDoubleSided,e.commonMaterialParameters.cullFace=K[u.faceCulling??"NotSet"],e.commonMaterialParameters.isGround=this.layer.replacesTerrain,e.commonMaterialParameters.hasSlicePlane=this.slicePlaneEnabled,e.componentParameters.castShadows=0,e.textureAlphaCutoff=u.alphaCutoff??je,e.alphaDiscardMode=Z[u.alphaMode],e.isIntegratedMesh=!0,e.sphereDepthInterpolate=this.layer.hasGoogleUrl,e.polygonOffsetEnabled=!1,e.hasOccludees=!1,e.ellipsoidMode=he(this.view.spatialReference)}}const Q=q.then(()=>()=>{if(this.destroyed){const e="Trying to add object to destroyed layer view";throw this._dbg(3,`${e} !== numPos. Skipping primitive.`),new Error(e)}const e=this._collection.createObject(new oe(j(N[0],N[1],W[0],W[1]),new de(s,n),F,G,!1));return this._collection.updateMaterial(e,$),c+=this._collection.getObjectGPUMemoryUsage(e),e});E.push(Q)}if(P.push(...await Promise.all(E)),this.destroyed){throw new Error("IntegratedMesh3DTilesLayerView3D: createRenderable object destroyed during call")}}catch(I){throw U.forEach(e=>this._stage.removeTexture(e)),I}const S=P.map(e=>e()),V=new Array;U.forEach(e=>V.push(e));const{fullExtent:L}=this.layer;L?.hasZ&&L.zmax&&L.zmin&&(A.minElevation=Math.max(A.minElevation,L.zmin),A.maxElevation=Math.min(A.maxElevation,L.zmax));const k=new xe(e.handle,S,V,d,c,b.textureMemoryUsage,l,e.stableNodeId,e.nodeDepth,A);return this._lyrHandleToObjects.set(e.handle,k),this._memCache.put(Ue(k.handle),k),t=k.usedMemory,this._cacheMemory+=t,{memUsageBytes:k.usedMemory}}freeRenderable(e){const t=this._lyrHandleToObjects.get(e);t?(t.isLoaded?(this._loadedObjects.delete(t),this._visibleObjects.delete(t),this._usedMemory-=t.usedMemory):this._cacheMemory-=t.usedMemory,this.freeObject(t),this._lyrHandleToObjects.delete(e)):this._dbg(3,`freeRendedrable on non-existent renderable ${e}`)}freeObject(e){const t=Ue(e.handle);this._memCache.pop(t),e.textures.forEach(e=>this._stage.removeTexture(e)),e.componentObjects.forEach(e=>this._collection.destroyObject(e))}setRenderableVisibility(e,t,i){if(this.destroyed||this.destroying)return;const s=this._frustum,r=new Array;let o=!1;for(let n=0;n<i;++n){if(!t[n])continue;const i=e[n],a=this._lyrHandleToObjects.get(i);if(a){if(a.isLoaded){this._dbg(3,`Already loaded object marked loaded again ${a.stableNodeId}`);continue}o=!0,a.isLoaded=!0,this._loadedObjects.add(a),this._usedMemory+=a.usedMemory,this._cacheMemory-=a.usedMemory;const e=a.obb?.intersectsFrustum(s)??!0;if(a.isVisible=e,e){this._visibleObjects.add(a);const{minElevation:e,maxElevation:t}=a.elevationRange;(e<this.visibleElevationRange.minElevation||t>this.visibleElevationRange.maxElevation)&&this._setVisibleElevationRangeDirty()}e&&a.obb&&r.push(a.obb),a.componentObjects.forEach(t=>{this._collection.setObjectVisibility(t,e)}),this._memCache.pop(Ue(i))}else this._dbg(3,`Tried to mark Non existent object ${i} as loaded`)}for(let n=0;n<i;++n){const i=e[n];if(t[n])continue;const s=this._lyrHandleToObjects.get(i);if(s){if(!s.isLoaded){this._dbg(3,`Tried to unload not-loaded object ${s.stableNodeId}`);continue}const e=this._visibleObjects.delete(s);if(s.isVisible=!1,s.isLoaded=!1,this._loadedObjects.delete(s),e){this._visibleGeometryChanged();const{minElevation:e,maxElevation:t}=s.elevationRange;e!==this.visibleElevationRange.minElevation&&t!==this.visibleElevationRange.maxElevation||this._setVisibleElevationRangeDirty()}this._usedMemory-=s.usedMemory,this._cacheMemory+=s.usedMemory,e&&s.obb&&r.push(s.obb),s.componentObjects.forEach(e=>{this._collection.setObjectVisibility(e,!1)}),this._memCache.put(Ue(i),s)}else this._dbg(3,`Tried to mark Non existent object ${i} as not loaded`)}o&&this._visibleGeometryChanged(),this._elevationProvider.notifyObjectsChanged(r),this._setVisibleElevationRangeDirty()}setLodPixelThreshold(e){this._wasm?.setLodPixelThreshold(this,e)}_getTexture(e,t,i,s){const r=e&&t.desc?.images?.[e.imageId];if(!r||!t.data?.buffer)return null;const o=i.get(r)??this._createTexture(e,t,i,s);return o?new ce(this._stage.renderView.textures,o.id):null}_createTexture(e,t,i,s){const r=e&&t.desc?.images?.[e.imageId];if(!r||!t.data?.buffer)return null;const o=this._stage,{renderView:n}=o,a=n.renderingContext.parameters.maxMaxAnisotropy,l=!!r.mipCount||a>1,d=Q[e.wrapMode??"None"];let c=r.alpha?6408:6407;const h=new Uint8Array(t.data.buffer,r.data.byteOffset,r.data.byteCount);let m=null,u=null,p=null;switch(r.format){case"Raw":"R8"===r.pixelFormat?(m=h,c=6403,u=""):"Rgb8"===r.pixelFormat?(m=h,c=6407,u=""):"Rgba8"===r.pixelFormat&&(m=h,c=6408,u="");break;case"Dxt1":m=h,c=6407,u="image/vnd-ms.dds";break;case"Dxt5":m=h,c=6408,u="image/vnd-ms.dds";break;case"Basis":m=h,c=6407,u="image/ktx2";break;case"Png":u="image/png",p=document.createElement("img");break;case"Jpeg":u="image/jpeg",p=document.createElement("img");break;case"Etc2":u="image/ktx",p=document.createElement("img");break;case"Astc":this._dbg(3,"Astc texture not supported");break;case"Pvrtc":this._dbg(3,"Pvrtc texture not supported")}if(p&&u){const e=new Blob([h],{type:u});p.src=URL.createObjectURL(e),m=p}if(m&&null!=u){const e=has("enable-feature:esri-compress-IM-textures")?{compressionTracker:this._compressionTracker,compressionCallback:e=>{e&&e>0&&(s.textureMemoryUsage-=e)}}:void 0,t=new ue(m,{mipmap:l,maxAnisotropy:a,encoding:u,wrap:d,pixelFormat:c,compressionOptions:e,noUnpackFlip:!0,width:r.mip0Width,height:r.mip0Height});return this._stage.addTexture(t),i.set(r,t),t}return null}getBufferViews(e,t,i){let s,r,o,n,a,l,d,c=null;for(let m=0;m<e.atrbs.length;m++){const d=e.atrbs[m],{view:u}=d,p=void 0,f=u.byteOffset+u.byteCount,b=u.byteCount/X[u.type],g=new(Pe(b))(b);for(let e=0;e<b;++e)g[e]=e;try{switch(d.sem){case"Position":3!==u.ncomp||"F32"!==u.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Position ("+u+")"):(s=new A(t,u.byteOffset,p,f),r=new me(s.typedBuffer,g,3));break;case"Normal":if(3!==u.ncomp||"F32"!==u.type)this._dbg(3,"[Unsupported Feature] Unsupported view for Normal ("+u+")");else{const e=new A(t,u.byteOffset,p,f),s=pe(e.typedBuffer,i);a=new L(s.buffer),l=new me(a.typedBuffer,g,2)}break;case"TexCoord":2!==u.ncomp||"F32"!==u.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Texcoord ("+u+")"):void 0===n&&(n=new me(new R(t,u.byteOffset,p,f).typedBuffer,g,2));break;case"Color":4===u.ncomp?("F32"===u.type&&(c=new U(t,u.byteOffset,p,f)),"U8"===u.type&&(c=new H(t,u.byteOffset,p,f)),"U16"===u.type&&(c=new P(t,u.byteOffset,p,f))):3===u.ncomp&&("F32"===u.type&&(c=new A(t,u.byteOffset,p,f)),"U8"===u.type&&(c=new S(t,u.byteOffset,p,f)),"U16"===u.type&&(c=new V(t,u.byteOffset,p,f))),null==c?this._dbg(2,"[Unsupported Feature] Unsupported view for Color ("+u+")"):o=new me(c.typedBuffer,g,u.ncomp);break;case"FeatureIndex":break;default:this._dbg(2,"[Unsupported Feature] Unsupported semantic ("+d.sem+"). Skipping vertex attribute.")}}catch(h){this._dbg(2,"Error Creating buffer ("+h+"). Skipping vertex attribute.")}}if(e.index){const i=e.index.view,s=void 0,r=i.byteOffset+i.byteCount;switch(e.index.view.type){case"U16":d=new I(t,i.byteOffset,s,r);break;case"U32":d=new k(t,i.byteOffset,s,r);break;default:this._dbg(3,"[Unsupported Feature] index type not supported ("+i.type+").")}}if(null==d&&null!=s){const e=s.count;d=d=e<65535?new I(new Uint16Array(e).buffer):new k(new Uint32Array(e).buffer);for(let t=0;t<e;t++)d.set(t,t)}return{positionView:s,positionAttr:r,colorAttr:o,texCoord0Attr:n,indicesView:d,normalsView:a,normalsAttr:l}}_loadModifications(){if(this.removeHandles("modifications"),null==this.layer.modifications)return void(this._modifications=[]);const e=this.layer.modifications;this.addHandles(this._updatingHandles.addOnCollectionChange(()=>e,()=>{this._modifications=e.filter(e=>!(this.layer.isUsedAsGroundLayer&&"replace"!==e.type)).toArray(),this._modifications.length<e.length&&t.getLogger(this).info("Ground layers only support replace modifications. Other modification types have been ignored.")},o),"modifications")}_deletePerObjectData(e){this._wasm?.onRenderableEvicted(this,e.handle,e.usedMemory),this.freeRenderable(e.handle)}_dbg(e,i){this._dbgFlags.has(e)&&(3===e?t.getLogger(this).error(i):t.getLogger(this).warn(i))}};e([d()],Oe.prototype,"fullOpacity",null),e([d({readOnly:!0})],Oe.prototype,"ready",null),e([d({type:[F]})],Oe.prototype,"_modifications",void 0),e([d()],Oe.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([d()],Oe.prototype,"layer",void 0),e([d({readOnly:!0})],Oe.prototype,"visibleAtCurrentScale",null),e([d({readOnly:!0})],Oe.prototype,"_collection",null),e([d()],Oe.prototype,"elevationOffset",null),e([d({readOnly:!0})],Oe.prototype,"visibleElevationRange",null),Oe=e([c("esri.views.3d.layers.IntegratedMesh3DTilesLayerView3D")],Oe);const Ce=Oe,Te=w();function Ee(e,t){const i=se(e);return g(Te,i.center,t),i.center=Te,i}function Re(e){return e?new re(e.center,e.halfSize,b(...e.quaternion)):null}function Ue(e){return`${e}`}const He=new Array;function Pe(e){return e<256?Uint8Array:e<65536?Uint16Array:Uint32Array}export{Ce as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{acosClamped as e,lerp as t,clamp as i}from"../../../core/mathUtils.js";import{getMetersPerUnitForSR as r}from"../../../core/units.js";import{b as n,n as s,j as a,g as o,e as m}from"../../../chunks/vec32.js";import{create as c}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as
|
|
5
|
+
import{acosClamped as e,lerp as t,clamp as i}from"../../../core/mathUtils.js";import{getMetersPerUnitForSR as r}from"../../../core/units.js";import{b as n,n as s,j as a,g as o,e as m}from"../../../chunks/vec32.js";import{create as c}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as h}from"../../../geometry/ellipsoidUtils.js";import l from"../../../geometry/Extent.js";import{create as u,fromValues as p}from"../../../geometry/support/ray.js";import{Sphere as x}from"../../../geometry/support/sphere.js";import{computeInnerAltitudeFade as f}from"../environment/atmosphereUtils.js";import{DepthRange as M}from"../webgl-engine/lib/DepthRange.js";function _(e,t,i){return 1===e?new y(t,i):new d(t,i)}class d{constructor(e,t){this._elevationProvider=e,this._referenceEllipsoid=h(t),this._unitInMeters=r(t,this._referenceEllipsoid.metersPerDegree)}compute(e,r,n,a){const{eye:c,center:h}=e;let u=c[2]*this._unitInMeters;const p=u,x=u-a,f=this._elevationProvider?.visibleElevationRange;f&&(u=x>=0?p-this._unitInMeters*f.minElevation:this._unitInMeters*f.maxElevation-p),r??=new l({xmin:0,ymin:0,zmin:0,xmax:0,ymax:0,zmax:0});const M={x:r.xmax-r.xmin,y:r.ymax-r.ymin,z:4*Math.max(r.xmax-r.xmin,r.ymax-r.ymin)},_=Math.max(M.x,M.y,M.z);m(P,h,c),F[0]=P[0]>0?r.xmax:r.xmin,F[1]=P[1]>0?r.ymax:r.ymin,F[2]=P[2]>0?_/2:-_/2,m(F,F,c),s(P,P);const d=1.1*o(F,P)*this._unitInMeters,y=Math.sqrt(u*(u+2*this._referenceEllipsoid.radius)),E=Math.max(r.xmax-r.xmin,r.ymax-r.ymin),g=E*w*this._unitInMeters,I=E*D*this._unitInMeters,b=i((u-I)/(g-I),0,1)**3,R=Math.min(t(y,d,b),y)*Math.max(Math.log(Math.abs(x)),1);return v(Math.min(R,Math.max(34064e4,_))/this._unitInMeters,j,this._unitInMeters,z)}}class y{constructor(e,t){this._elevationProvider=e,this._referenceEllipsoid=h(t)}compute(r,c,h,l){const{eye:u}=r,x=n(u),_=x-this._referenceEllipsoid.radius,d=this._computeVirtualAltitude(_,l),y=this._elevationProvider?.visibleElevationRange.maxElevation??0,w=f(d),D=this._computeFarDistance(x,d,l,h.far),A=(Math.log(d)-E)/(g-E);v(D,i(j-A*(j-I),I,j),1,z);const V=this._referenceEllipsoid.radius+y,q=this._referenceEllipsoid.radius+this._referenceEllipsoid.atmosphereHeight,k=Math.max(V,q),H=x-k;if(w>0&&H>b){const i=s(F,a(F,r.eye,-1)),c=s(P,r.viewForward),l=e(o(i,c)),u=.5*r.fovY,x=Math.cos(u);let f=M.Infinite.near;if(l<=u)f=H*x;else{const e=s(F,r.viewUp),t=Math.tan(u),i=a(F,e,t),o=s(F,m(F,c,i)),h=p(r.eye,o,U);if(R.radius=k,R.intersectRay(h,F)){const e=m(F,F,r.eye);f=n(e)*x}}const _=.99*Math.min(h.near,f);_<M.Infinite.near&&_>z.near&&(z.near=t(z.near,_,w))}return z}computeFarDistance(e,t,i){const r=n(e),s=r-this._referenceEllipsoid.radius,a=this._computeVirtualAltitude(s,t);return this._computeFarDistance(r,a,t,i)}_computeFarDistance(e,t,i,r){const n=this._referenceEllipsoid.radius,s=n+Math.min(0,i),a=f(t),o=Math.sqrt(t*(t+2*s)),m=o+Math.max(Math.min(.2*o,.01*n),r);return a<.5?m:1.2*(e+n)}_computeVirtualAltitude(e,t){const i=Math.abs(e-t);return Math.max(i,Math.abs(e))}}function v(e,t,i,r){const n=b/i,s=e/t;return s>n?(r.far=e,r.near=s):(r.near=n,r.far=r.near*t),r}const E=7.983,g=16.994,j=2e4,I=100,b=2,w=.001,D=1e-4,F=c(),P=c(),z={near:0,far:0},R=new x,U=u();export{y as NearFarHeuristicGlobal,_ as createNearFarHeuristic,b as minNearDistanceInMeters};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as E}from"tslib";import _ from"../../../core/Accessor.js";import{property as S,subclass as T}from"../../../core/accessorSupport/decorators.js";let o=class extends _{constructor(){super(...arguments),this.SCENEVIEW_HITTEST_RETURN_INTERSECTOR=!1,this.DECONFLICTOR_SHOW_VISIBLE=!1,this.DECONFLICTOR_SHOW_INVISIBLE=!1,this.DECONFLICTOR_SHOW_GRID=!1,this.LABELS_SHOW_BORDER=!1,this.TEXT_SHOW_BASELINE=!1,this.TEXT_SHOW_BORDER=!1,this.OVERLAY_DRAW_DEBUG_TEXTURE=!1,this.OVERLAY_SHOW_CENTER=!1,this.SHOW_POI=!1,this.TESTS_DISABLE_OPTIMIZATIONS=!1,this.TESTS_DISABLE_FAST_UPDATES=!1,this.DRAW_MESH_GEOMETRY_NORMALS=!1,this.FEATURE_TILE_FETCH_SHOW_TILES=!1,this.FEATURE_TILE_TREE_SHOW_TILES=!1,this.TERRAIN_TILE_TREE_SHOW_TILES=!1,this.I3S_TREE_SHOW_TILES=!1,this.I3S_SHOW_MODIFICATIONS=!1,this.LOD_INSTANCE_RENDERER_DISABLE_UPDATES=!1,this.LOD_INSTANCE_RENDERER_COLORIZE_BY_LEVEL=!1,this.EDGES_SHOW_HIDDEN_TRANSPARENT_EDGES=!1,this.LINE_WIREFRAMES=!1,this.FLOW_GLOBAL_SCALE_THRESHOLD=null}};E([S()],o.prototype,"SCENEVIEW_HITTEST_RETURN_INTERSECTOR",void 0),E([S()],o.prototype,"DECONFLICTOR_SHOW_VISIBLE",void 0),E([S()],o.prototype,"DECONFLICTOR_SHOW_INVISIBLE",void 0),E([S()],o.prototype,"DECONFLICTOR_SHOW_GRID",void 0),E([S()],o.prototype,"LABELS_SHOW_BORDER",void 0),E([S()],o.prototype,"TEXT_SHOW_BASELINE",void 0),E([S()],o.prototype,"TEXT_SHOW_BORDER",void 0),E([S()],o.prototype,"OVERLAY_DRAW_DEBUG_TEXTURE",void 0),E([S()],o.prototype,"OVERLAY_SHOW_CENTER",void 0),E([S()],o.prototype,"SHOW_POI",void 0),E([S()],o.prototype,"TESTS_DISABLE_OPTIMIZATIONS",void 0),E([S()],o.prototype,"TESTS_DISABLE_FAST_UPDATES",void 0),E([S()],o.prototype,"DRAW_MESH_GEOMETRY_NORMALS",void 0),E([S()],o.prototype,"FEATURE_TILE_FETCH_SHOW_TILES",void 0),E([S()],o.prototype,"FEATURE_TILE_TREE_SHOW_TILES",void 0),E([S()],o.prototype,"TERRAIN_TILE_TREE_SHOW_TILES",void 0),E([S()],o.prototype,"I3S_TREE_SHOW_TILES",void 0),E([S()],o.prototype,"I3S_SHOW_MODIFICATIONS",void 0),E([S()],o.prototype,"LOD_INSTANCE_RENDERER_DISABLE_UPDATES",void 0),E([S()],o.prototype,"LOD_INSTANCE_RENDERER_COLORIZE_BY_LEVEL",void 0),E([S()],o.prototype,"EDGES_SHOW_HIDDEN_TRANSPARENT_EDGES",void 0),E([S()],o.prototype,"LINE_WIREFRAMES",void 0),E([S()],o.prototype,"FLOW_GLOBAL_SCALE_THRESHOLD",void 0),o=E([T("esri.views.3d.support.debugFlags")],o);const t=new o;export{t as debugFlags};
|
|
5
|
+
import{__decorate as E}from"tslib";import _ from"../../../core/Accessor.js";import{property as S,subclass as T}from"../../../core/accessorSupport/decorators.js";let o=class extends _{constructor(){super(...arguments),this.SCENEVIEW_HITTEST_RETURN_INTERSECTOR=!1,this.DECONFLICTOR_SHOW_VISIBLE=!1,this.DECONFLICTOR_SHOW_INVISIBLE=!1,this.DECONFLICTOR_SHOW_GRID=!1,this.LABELS_SHOW_BORDER=!1,this.TEXT_SHOW_BASELINE=!1,this.TEXT_SHOW_BORDER=!1,this.OVERLAY_DRAW_DEBUG_TEXTURE=!1,this.OVERLAY_SHOW_CENTER=!1,this.SHOW_POI=!1,this.OCCLUSION_QUERY_DEBUG_PIXEL=!1,this.TESTS_DISABLE_OPTIMIZATIONS=!1,this.TESTS_DISABLE_FAST_UPDATES=!1,this.DRAW_MESH_GEOMETRY_NORMALS=!1,this.FEATURE_TILE_FETCH_SHOW_TILES=!1,this.FEATURE_TILE_TREE_SHOW_TILES=!1,this.TERRAIN_TILE_TREE_SHOW_TILES=!1,this.I3S_TREE_SHOW_TILES=!1,this.I3S_SHOW_MODIFICATIONS=!1,this.LOD_INSTANCE_RENDERER_DISABLE_UPDATES=!1,this.LOD_INSTANCE_RENDERER_COLORIZE_BY_LEVEL=!1,this.EDGES_SHOW_HIDDEN_TRANSPARENT_EDGES=!1,this.LINE_WIREFRAMES=!1,this.FLOW_GLOBAL_SCALE_THRESHOLD=null}};E([S()],o.prototype,"SCENEVIEW_HITTEST_RETURN_INTERSECTOR",void 0),E([S()],o.prototype,"DECONFLICTOR_SHOW_VISIBLE",void 0),E([S()],o.prototype,"DECONFLICTOR_SHOW_INVISIBLE",void 0),E([S()],o.prototype,"DECONFLICTOR_SHOW_GRID",void 0),E([S()],o.prototype,"LABELS_SHOW_BORDER",void 0),E([S()],o.prototype,"TEXT_SHOW_BASELINE",void 0),E([S()],o.prototype,"TEXT_SHOW_BORDER",void 0),E([S()],o.prototype,"OVERLAY_DRAW_DEBUG_TEXTURE",void 0),E([S()],o.prototype,"OVERLAY_SHOW_CENTER",void 0),E([S()],o.prototype,"SHOW_POI",void 0),E([S()],o.prototype,"OCCLUSION_QUERY_DEBUG_PIXEL",void 0),E([S()],o.prototype,"TESTS_DISABLE_OPTIMIZATIONS",void 0),E([S()],o.prototype,"TESTS_DISABLE_FAST_UPDATES",void 0),E([S()],o.prototype,"DRAW_MESH_GEOMETRY_NORMALS",void 0),E([S()],o.prototype,"FEATURE_TILE_FETCH_SHOW_TILES",void 0),E([S()],o.prototype,"FEATURE_TILE_TREE_SHOW_TILES",void 0),E([S()],o.prototype,"TERRAIN_TILE_TREE_SHOW_TILES",void 0),E([S()],o.prototype,"I3S_TREE_SHOW_TILES",void 0),E([S()],o.prototype,"I3S_SHOW_MODIFICATIONS",void 0),E([S()],o.prototype,"LOD_INSTANCE_RENDERER_DISABLE_UPDATES",void 0),E([S()],o.prototype,"LOD_INSTANCE_RENDERER_COLORIZE_BY_LEVEL",void 0),E([S()],o.prototype,"EDGES_SHOW_HIDDEN_TRANSPARENT_EDGES",void 0),E([S()],o.prototype,"LINE_WIREFRAMES",void 0),E([S()],o.prototype,"FLOW_GLOBAL_SCALE_THRESHOLD",void 0),o=E([T("esri.views.3d.support.debugFlags")],o);const t=new o;export{t as debugFlags};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import t from"../../../Color.js";import has from"../../../core/has.js";import{disposeMaybe as i}from"../../../core/maybe.js";import{MemCachePool as r}from"../../../core/MemCachePool.js";import s from"../../../core/ObjectPool.js";import{watch as n,sync as a}from"../../../core/reactiveUtils.js";import{property as o,subclass as l}from"../../../core/accessorSupport/decorators.js";import{e as c,h as d,g as h}from"../../../chunks/vec32.js";import{ZEROS as u,create as _,fromValues as g}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as f,ZEROS as p}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{create as m,set as y}from"../../../geometry/support/aaBoundingBox.js";import{BufferViewVec3f as b}from"../../../geometry/support/buffer/BufferView.js";import{overlayRenderOccludedFlag as T}from"./OverlayRenderer.js";import{PatchRenderData as x}from"./PatchRenderData.js";import{TerrainAttributesCache as v}from"./TerrainAttributesCache.js";import{enableTerrainInternalChecks as R}from"./terrainUtils.js";import{TileRenderer as P}from"./TileRenderer.js";import{IteratorPreorder as O,sortTiles as w,compareTiles as D}from"./tileUtils.js";import{getOverlayContentForOutputTerrain as S}from"../webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js";import{SyncRenderPlugin as B,ConsumesDepth as E,ConsumesNone as j}from"../webgl-engine/effects/RenderPlugin.js";import{Vertices as F}from"../webgl-engine/lib/Attribute.js";import{IntersectorResult as q}from"../webgl-engine/lib/IntersectorResult.js";import{intersectAabbInvDirBefore as C,MeshIntersectionOptions as A,intersectTriangles as G}from"../webgl-engine/lib/RayIntersections.js";import{TriangleIntersectionData as M}from"../webgl-engine/lib/TriangleIntersectionData.js";import{terrainId as k,getVerticalOffsetTerrain as U}from"../webgl-engine/lib/verticalOffsetUtils.js";import{DrawParameters as N}from"../webgl-engine/materials/DrawParameters.js";import{T as I}from"../../../chunks/Terrain.glsl.js";import{TerrainTechnique as L}from"../webgl-engine/shaders/TerrainTechnique.js";import{TerrainTechniqueConfiguration as V}from"../webgl-engine/shaders/TerrainTechniqueConfiguration.js";import{PrimitiveType as z}from"../../webgl/enums.js";const H=7,W=10,Q=200,Z=m();let J=class extends B{get visibleTiles(){return Array.from(this._visiblePatchesByOrigin.values()).flat()}get _isGlobal(){return 1===this._stage.viewingMode}get _techniques(){return this._context.techniques}get _rctx(){return this._context.renderContext.rctx}constructor(e,t,i,n,a){super({}),this._overlayRenderer=e,this._stage=t,this._allTiles=i,this._compressionTracker=n,this.type=7,this.isGround=!0,this._passParameters=new I,this._drawParameters=new N,this._renderDataPool=new s(()=>new x),this._visiblePatchesByOrigin=new Map,this._allPatchesByOrigin=new Map,this._patchesByOriginDirty=!0,this._patchSortingDirty=!0,this._tileIterator=new O,this._castShadows=!1,this._inViewshed=!1,this._cutFillEnabled=!1,this._tileRenderer=null,this._stencilEnabledLayerExtents=new Array,this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0,this.renderOccludedFlags=1,this._oitGround=!!has("enable-feature:oit-ground"),this.produces=new Map([[1,()=>1===this._desiredSlot],[6,()=>6===this._desiredSlot],[7,()=>7===this._desiredSlot],[10,()=>this._produces()&&this.renderOccludedFlags===T]]),this._tileSize=256,this._configuration=new V(1===t.viewingMode),this._tileTextureCache=new r((e,t)=>a.newCache(e,t),"TileTexture"),this.tileGeometryCache=new v(a)}normalizeCtorArgs(){return{}}initialize(){this._stage.addRenderPlugin(this),this.addHandles(n(()=>this._overlayRenderer.renderOccludedFlags,e=>{this.renderOccludedFlags=e,this.setNeedsRender()},a))}destroy(){this._stage.removeRenderPlugin(this),this._tileTextureCache.destroy(),this.tileGeometryCache.destroy(),this._allTiles.prune(),this._tileRenderer=null}_produces(){return this.visible&&!!this._rootTiles&&!this.renderingDisabled}consumes(){return this._overlayRenderer.hasWater?E:j}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.setNeedsRender())}get transparency(){return this._configuration.transparencyMode}get renderPatchBorders(){return this._configuration.tileBorders}set renderPatchBorders(e){this._configuration.tileBorders!==e&&(this._configuration.tileBorders=e,this.setNeedsRender(),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.setNeedsRender())}set textureFadingEnabled(e){this._configuration.textureFadingEnabled!==e&&(this._configuration.textureFadingEnabled=e,this.setNeedsRender())}set pbrMode(e){this._configuration.pbrMode!==e&&(this._configuration.pbrMode=e,this.setNeedsRender())}setRootTiles(e){this._rootTiles=e,this.setDirty()}setStencilEnabledLayerExtents(e){this._stencilEnabledLayerExtents=e,this._setSortingDirty()}set tileSize(e){this._tileSize=e,null!=this._tileRenderer&&(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)))}loadTile(e){this._ensureRenderData(e),this.updateTileGeometryState(e),this.reuseTextureFromParent(e)||this.updateTileTexture(e,32)}reuseTextureFromParent(e){const t=e.parent;if(!t)return!1;const i=f(1&e.lij[2]?.5:0,1&e.lij[1]?0:.5,.5,.5);return t.renderData?.reuseTexture(e.renderData,i)??!1}updateTileTexture(e,t){null!=this._tileRenderer&&(this._tileRenderer.updateTileTexture(e,32===t?0:2),this.setNeedsRender(),e.resetPendingUpdate(t))}updateTileGeometryState(e){for(const i of e.layerInfo[0])i.pendingUpdates&=-9;e.resetPendingUpdate(8);const t=e.renderData.updateGeometryState();return t&&this.setDirty(),t}updateGeometryIfNeeded(e){e.loaded&&e.renderData.updateGeometryIfNeeded(this._rctx)}unloadTile(e){const t=e.renderData;t&&(t.releaseGeometry(),this._renderDataPool.release(t),t.clear(),e.renderData=null,e.setMemoryDirty(),this.setDirty())}_getLocalOriginOfTile(e){const t=W-H,i=Math.max(0,Math.floor((e.level-t)/H)*H);if(this._isGlobal&&0===i)return u;for(;e.parent&&e.level>i;)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.setNeedsRender())}setDirty(e=1){this._patchesByOriginDirty=!0,this._context.requestRender(e)}_setSortingDirty(e=1){this._patchSortingDirty=!0,this._context.requestRender(e)}setNeedsRender(e=1){this._context.requestRender(e)}initializeRenderContext(e){this._context=e,this._tileRenderer=new P(this._rctx,this._tileSize,this._techniques,this._tileTextureCache,this._compressionTracker),this.updateTileBackground()}uninitializeRenderContext(){this._tileRenderer=i(this._tileRenderer)}intersect(e,t,i,r){if(!this._rootTiles||e.options.selectOpaqueTerrainOnly&&e.options.selectionMode&&0!==this.transparency)return;const s=K,n=X;c(s,r,i),d(n,1/s[0],1/s[1],1/s[2]);const a=e.results.min,o=e.results.max,l=e.results.ground,u=0===e.options.store,_=!!e.results.ground.target,g=U(e.verticalOffset),f=e.tolerance;let p,m=u&&null!=a.distance?a.distance:1/0;const T=e.options,x=T.normalRequired||!T.backfacesTerrain,v=new A(f,!1,x),R=d=>{const _=d.renderData;if(!_?.vao)return;const R=_.geometry;y(Z,R.boundingBox);const P=_.localOrigin;null!=g&&(g.localOrigin=P,g.applyToAabb(Z));const O=Z;if(Y[0]=i[0]-P[0],Y[1]=i[1]-P[1],Y[2]=i[2]-P[2],!C(O,Y,n,f,m))return;const w=(e,t,i)=>{e.set(this.type,d,t,i),m=u&&null!=a.distance?a.distance:1/0},D=(n,c,d)=>{if((!x||null!=d)&&n>=0&&(T.backfacesTerrain||h(d,s)<0)&&(T.invisibleTerrain||!T.selectionMode||null==t||t(i,r,n))){if((null==l.distance||n<l.distance)&&w(l,n,d),T.isFiltered)return;2===T.store&&(null==p?(p=new q(e.ray),w(p,n,d),e.results.all.push(p)):n<p.distance&&w(p,n,d)),(null==a.distance||n<a.distance)&&w(a,n,d),0!==T.store&&(null==o.distance||n>o.distance)&&w(o,n,d)}},S=$;c(S,r,P);const{indices:B,indexCount:E}=R,j=R.vertexAttributes,A=j.getField("position",b),k=new F(A.typedBuffer,3,j.stride/4),U=E/3;if(!g&&U>Q){const e=d.renderData;e.intersectionData??=new M(B,U,k),e.intersectionData.intersectRay(Y,S,v,D)}else G(Y,S,0,U,B,k,g,v,D)},P=this._rootTiles;if(null!=P){(()=>{const t=this._tileIterator;t.reset(P);const r=e.options.invisibleTerrain;for(let e=t.next();e;e=t.next())!(e.visible||r&&e.intersectsClippingArea)||null==g&&!e.intersectsRay(i,s,f,m)||_&&this._useStencilForTile(e)?t.skipSubtree():R(e)})()}}processScaleRangeQueries(e,t){if(!t.done&&e)for(this._updatePatchGroups();e.updating&&!t.done;){e.prepare();for(const t of this._visiblePatchesByOrigin.values())for(const i of t)null!=i.renderData?.textureReference&&e.queriesForTile(i);e.process(),t.madeProgress()}}get _desiredSlot(){if(!this._produces())return null;switch(this.transparency){case 0:return 1;case 1:case 2:return this._oitGround?7:6;case 3:case 4:return null}}acquireTechniques(e){const{shadowMap:t,viewshedEnabled:i,cutFillEnabled:r,slot:s,oitPass:n,hasEmission:a}=e.bind,o=!!has("enable-feature:terrain-shadows")&&t.enabled;if(o!==this._castShadows&&(this._castShadows=o,this._patchesByOriginDirty=!0),this._inViewshed!==i&&(this._inViewshed=i,this._patchesByOriginDirty=!0),this._cutFillEnabled!==r&&(this._cutFillEnabled=r,this._patchesByOriginDirty=!0),3===this.transparency)return null;if(10===s){if(0===(e.renderOccludedMask&T))return null}else if(s!==this._desiredSlot)return null;const l=this._configuration;switch(l.screenSpaceReflections=l.cloudReflections=l.receiveShadows=l.receiveAmbientOcclusion=l.renderOccluded=l.hasHighlightMixTexture=l.hasEmission=!1,l.overlayMode=this._overlayRenderer.mode,l.oitPass=0,e.output){case 0:{const{ssr:i,clouds:r,ssao:o}=e.bind;l.screenSpaceReflections=null!=i.lastFrameColor,l.cloudReflections=null!=r.data;const c=10===s;return l.receiveShadows=t.ready&&!c,l.renderOccluded=c,l.receiveAmbientOcclusion=!c&&null!=o,l.oitPass=n,l.hasEmission=a,this._acquireTechnique(e.output)}case 3:case 5:return this._castShadows?this._acquireTechnique(3):null;case 6:return this._inViewshed?this._acquireTechnique(6):null;case 7:return this._cutFillEnabled?this._acquireTechnique(7):null;case 1:case 2:return this._acquireTechnique(e.output);case 9:return this._acquireTechnique(9);case 8:return l.hasHighlightMixTexture=null!=e.bind.highlightMixTexture,this._overlayRenderer.hasHighlights?this._acquireTechnique(8):null}return null}render(e,t){switch(this._updatePatchGroups(),t.useStencil=!1,this._passParameters.overlayContent=S(e.output,e.bind),e.output){case 0:return this._renderMaterialPass(e,t);case 1:case 2:case 9:return this._renderAuxiliaryPass(e,t,this._visiblePatchesByOrigin);case 8:{const i=e.bind.highlight?.name;i&&this._overlayRenderer.hasHighlights&&this._overlayRenderer.renders(2)&&this._overlayRenderer.hasHighlight(i)&&this._renderAuxiliaryPass(e,t,this._visiblePatchesByOrigin);break}case 3:case 5:case 6:case 7:return this._renderAuxiliaryPass(e,t,this._allPatchesByOrigin)}}updateTileBackground(e){if(null==this._tileRenderer)return;const i=this._tileRenderer;let r;if(null!=e){const i=t.toUnitRGBA(e);r=g(i[0]||0,i[1]||0,i[2]||0)}i.setBackground(r),this._allTiles.forAll(e=>i.updateTileTexture(e,0)),this._configuration.tileBlendInput=i.backgroundIsGrid?2:null!=i.backgroundColor?1:0,this.setNeedsRender()}_updatePatchGroups(){if(this._patchesByOriginDirty&&(this._rebuildPatchGroups(),this._patchesByOriginDirty=!1,this._patchSortingDirty=!0),this._patchSortingDirty){const e=Array.from(this._visiblePatchesByOrigin.values()),t=this._stencilEnabledLayerExtents;for(const i of e)w(i,t);e.sort((e,t)=>D(e[0],t[0])),this._visiblePatchesByOrigin=new Map(e.map(e=>[e[0].renderData.localOrigin,e])),this.notifyChange("visibleTiles"),this._patchSortingDirty=!1}}_rebuildPatchGroups(){const e=this._rootTiles;if(null!=e){e[0]?.surface.checkAllTilesWaterproofness(),this._visiblePatchesByOrigin.clear(),this._allPatchesByOrigin.clear();for(const t of e)this._rebuildPatchGroupsForRootTile(t)}}_rebuildPatchGroupsForRootTile(e){const t=this._tileIterator;for(t.resetOne(e);!t.done;){const e=t.next(),i=e.renderData;if(!i){this._numTilesCulled++;continue}const r=i.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 s=this._visiblePatchesByOrigin.get(r);s||(s=[],this._visiblePatchesByOrigin.set(r,s)),s.push(e),t.skipSubtree()}}_useStencilForTile(e){for(const t of this._stencilEnabledLayerExtents)if(e.intersectsExtent(t))return!0;return!1}_renderAuxiliaryPass(e,t,i){const{rctx:r,bind:s}=e;r.bindTechnique(t,s,this._passParameters);const n=this._stencilEnabledLayerExtents.length>0;i.forEach(i=>{this._drawParameters.origin=i[0].renderData.localOrigin,t.program.bindDraw(s,this._passParameters,this._drawParameters);for(let r=0;r<i.length;r++)this._renderPatch(e,t,i[r],z.TRIANGLES,n,null===this._passParameters.overlayContent)}),r.bindVAO(null)}_renderMaterialPass(e,t){const{rctx:i,bind:r}=e,s=i.bindTechnique(t,r,this._passParameters);this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0;const n=10===r.slot;n&&(s.bindTexture("tex",i.emptyTexture),s.setUniform3fv("textureOpacities",u),s.setUniform4fv("texOffsetAndScale",p));const a=null!=this._tileRenderer?.backgroundColor?this._tileRenderer.backgroundColor:u;1===this._configuration.tileBlendInput&&s.setUniform3fv("backgroundColor",a);const o=this._stencilEnabledLayerExtents.length>0,l=this.wireframe?z.LINES:z.TRIANGLES;7===r.slot&&i.setFrontFace(r.camera.aboveGround?2305:2304),this._configuration.textureFadingEnabled&&s.bindTexture("texNext",i.emptyTexture);const c=this._visiblePatchesByOrigin;for(const d of c.values()){const i=d[0].renderData.localOrigin;this._drawParameters.origin=i,t.program.bindDraw(r,this._passParameters,this._drawParameters),this._numOriginsRendered++;for(const r of d){const i=r.renderData,a=i.textureReference;if(null!=a){if(!n){s.setUniform4fv("texOffsetAndScale",a.offsetAndScale),s.bindTexture("tex",a.texture.texture);const e=i.textureFadeFactor,t=e<1?i.nextTextureReference:null;this._configuration.textureFadingEnabled&&t&&e<1?(s.setUniform1f("fadeFactor",e),s.setUniform4fv("nextTexOffsetAndScale",t.offsetAndScale),s.setUniform3fv("nextTexOpacities",t.opacities),s.bindTexture("texNext",t.texture.texture)):s.setUniform1f("fadeFactor",1),i.textureIsFading&&this.setNeedsRender(2),s.setUniform3fv("textureOpacities",a.opacities)}this._renderPatch(e,t,r,l,o),r.renderOrder=this._numTilesRendered,this._numTilesRendered++}}}i.bindVAO(null)}_renderPatch(e,t,i,r,s,n=!1){const a=i.renderData,o=a.vao,l=o?.indexBuffer;if(!o||null==l)return void(R&&console.error("Rendered tile with no indices: ",i.lij," : ",a));const c=t.program;n||this._overlayRenderer.isEmpty||this._bindOverlayPatchData(c,a.overlay);const{rctx:d,bind:h}=e;s&&(t.useStencil=this._useStencilForTile(i),d.setPipelineState(t.getPipeline(h)));const u=a.geometry.indexCount;d.bindVAO(o),c.assertCompatibleVertexAttributeLocations(o),d.drawElements(r,u,l.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(L,this._configuration)}get test(){}hasHighlight(e){return this._overlayRenderer.hasHighlight(e)}};e([o({readOnly:!0})],J.prototype,"visibleTiles",null),e([o({readOnly:!0})],J.prototype,"_isGlobal",null),e([o()],J.prototype,"renderOccludedFlags",void 0),e([o({value:!1})],J.prototype,"renderingDisabled",null),e([o({value:!0})],J.prototype,"visible",null),e([o()],J.prototype,"renderPatchBorders",null),e([o()],J.prototype,"wireframe",null),J=e([l("esri.views.3d.terrain.TerrainRenderer")],J);const K=_(),X=_(),Y=_(),$=_();export{J as TerrainRenderer};
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../../Color.js";import has from"../../../core/has.js";import{disposeMaybe as i}from"../../../core/maybe.js";import{MemCachePool as r}from"../../../core/MemCachePool.js";import s from"../../../core/ObjectPool.js";import{watch as n,sync as a}from"../../../core/reactiveUtils.js";import{property as l,subclass as o}from"../../../core/accessorSupport/decorators.js";import{e as c,h as d,g as h}from"../../../chunks/vec32.js";import{ZEROS as u,create as _,fromValues as g}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as f,ZEROS as p}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{create as m,set as y}from"../../../geometry/support/aaBoundingBox.js";import{BufferViewVec3f as b}from"../../../geometry/support/buffer/BufferView.js";import{overlayRenderOccludedFlag as T}from"./OverlayRenderer.js";import{PatchRenderData as x}from"./PatchRenderData.js";import{TerrainAttributesCache as R}from"./TerrainAttributesCache.js";import{enableTerrainInternalChecks as v}from"./terrainUtils.js";import{TileRenderer as P}from"./TileRenderer.js";import{IteratorPreorder as O,sortTiles as w,compareTiles as D}from"./tileUtils.js";import{getOverlayContentForOutputTerrain as S}from"../webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js";import{SyncRenderPlugin as B,ConsumesDepth as E,ConsumesNone as j}from"../webgl-engine/effects/RenderPlugin.js";import{Vertices as q}from"../webgl-engine/lib/Attribute.js";import{IntersectorResult as C}from"../webgl-engine/lib/IntersectorResult.js";import{intersectAabbInvDirBefore as F,MeshIntersectionOptions as A,intersectTriangles as M}from"../webgl-engine/lib/RayIntersections.js";import{TriangleIntersectionData as G}from"../webgl-engine/lib/TriangleIntersectionData.js";import{terrainId as k,getVerticalOffsetTerrain as U}from"../webgl-engine/lib/verticalOffsetUtils.js";import{DrawParameters as N}from"../webgl-engine/materials/DrawParameters.js";import{T as I}from"../../../chunks/Terrain.glsl.js";import{TerrainTechnique as L}from"../webgl-engine/shaders/TerrainTechnique.js";import{TerrainTechniqueConfiguration as V}from"../webgl-engine/shaders/TerrainTechniqueConfiguration.js";import{PrimitiveType as z}from"../../webgl/enums.js";const H=7,W=10,Q=200,Z=m();let J=class extends B{get visibleTiles(){return Array.from(this._visiblePatchesByOrigin.values()).flat()}get _isGlobal(){return 1===this._stage.viewingMode}get _techniques(){return this._context.techniques}get _rctx(){return this._context.renderContext.rctx}constructor(e,t,i,n,a){super({}),this._overlayRenderer=e,this._stage=t,this._allTiles=i,this._compressionTracker=n,this.type=7,this.isGround=!0,this._passParameters=new I,this._drawParameters=new N,this._renderDataPool=new s(()=>new x),this._visiblePatchesByOrigin=new Map,this._allPatchesByOrigin=new Map,this._patchesByOriginDirty=!0,this._patchSortingDirty=!0,this._tileIterator=new O,this._castShadows=!1,this._inViewshed=!1,this._cutFillEnabled=!1,this._tileRenderer=null,this._stencilEnabledLayerExtents=new Array,this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0,this.renderOccludedFlags=1,this._oitGround=!!has("enable-feature:oit-ground"),this.produces=new Map([[1,()=>1===this._desiredSlot],[6,()=>6===this._desiredSlot],[7,()=>7===this._desiredSlot],[10,()=>this._produces()&&this.renderOccludedFlags===T]]),this._tileSize=256,this._configuration=new V(1===t.viewingMode),this._tileTextureCache=new r((e,t)=>a.newCache(e,t),"TileTexture"),this.tileGeometryCache=new R(a)}normalizeCtorArgs(){return{}}initialize(){this._stage.addRenderPlugin(this),this.addHandles(n(()=>this._overlayRenderer.renderOccludedFlags,e=>{this.renderOccludedFlags=e,this.setNeedsRender()},a))}destroy(){this._stage.removeRenderPlugin(this),this._tileTextureCache.destroy(),this.tileGeometryCache.destroy(),this._allTiles.prune(),this._tileRenderer=null}_produces(){return this.visible&&!!this._rootTiles&&!this.renderingDisabled}consumes(){return this._overlayRenderer.hasWater?E:j}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.setNeedsRender())}get transparency(){return this._configuration.transparencyMode}get renderPatchBorders(){return this._configuration.tileBorders}set renderPatchBorders(e){this._configuration.tileBorders!==e&&(this._configuration.tileBorders=e,this.setNeedsRender(),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.setNeedsRender())}set textureFadingEnabled(e){this._configuration.textureFadingEnabled!==e&&(this._configuration.textureFadingEnabled=e,this.setNeedsRender())}set pbrMode(e){this._configuration.pbrMode!==e&&(this._configuration.pbrMode=e,this.setNeedsRender())}setRootTiles(e){this._rootTiles=e,this.setDirty()}setStencilEnabledLayerExtents(e){this._stencilEnabledLayerExtents=e,this._setSortingDirty()}set tileSize(e){this._tileSize=e,null!=this._tileRenderer&&(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)))}loadTile(e){this._ensureRenderData(e),this.updateTileGeometryState(e),this.reuseTextureFromParent(e)||this.updateTileTexture(e,32)}reuseTextureFromParent(e){const t=e.parent;if(!t)return!1;const i=f(1&e.lij[2]?.5:0,1&e.lij[1]?0:.5,.5,.5);return t.renderData?.reuseTexture(e.renderData,i)??!1}updateTileTexture(e,t){null!=this._tileRenderer&&(this._tileRenderer.updateTileTexture(e,32===t?0:2),this.setNeedsRender(),e.resetPendingUpdate(t))}updateTileGeometryState(e){for(const i of e.layerInfo[0])i.pendingUpdates&=-9;e.resetPendingUpdate(8);const t=e.renderData.updateGeometryState();return t&&this.setDirty(),t}updateGeometryIfNeeded(e){e.loaded&&e.renderData.updateGeometryIfNeeded(this._rctx)}unloadTile(e){const t=e.renderData;t&&(t.releaseGeometry(),this._renderDataPool.release(t),t.clear(),e.renderData=null,e.setMemoryDirty(),this.setDirty())}_getLocalOriginOfTile(e){const t=W-H,i=Math.max(0,Math.floor((e.level-t)/H)*H);if(this._isGlobal&&0===i)return u;for(;e.parent&&e.level>i;)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.setNeedsRender())}setDirty(e=1){this._patchesByOriginDirty=!0,this._context.requestRender(e)}_setSortingDirty(e=1){this._patchSortingDirty=!0,this._context.requestRender(e)}setNeedsRender(e=1){this._context.requestRender(e)}initializeRenderContext(e){this._context=e,this._tileRenderer=new P(this._rctx,this._tileSize,this._techniques,this._tileTextureCache,this._compressionTracker),this.updateTileBackground()}uninitializeRenderContext(){this._tileRenderer=i(this._tileRenderer)}intersect(e,t,i,r){if(!this._rootTiles||e.options.selectOpaqueTerrainOnly&&e.options.selectionMode&&0!==this.transparency)return;const s=K,n=X;c(s,r,i),d(n,1/s[0],1/s[1],1/s[2]);const a=e.results.min,l=e.results.max,o=e.results.ground,u=0===e.options.store,_=!!e.results.ground.target,g=U(e.verticalOffset),f=e.tolerance;let p,m=u&&null!=a.distance?a.distance:1/0;const T=e.options,x=T.normalRequired||!T.backfacesTerrain,R=new A(f,!1,x),v=d=>{const _=d.renderData;if(!_?.vao)return;const v=_.geometry;y(Z,v.boundingBox);const P=_.localOrigin;null!=g&&(g.localOrigin=P,g.applyToAabb(Z));const O=Z;if(Y[0]=i[0]-P[0],Y[1]=i[1]-P[1],Y[2]=i[2]-P[2],!F(O,Y,n,f,m))return;const w=(e,t,i)=>{e.set(this.type,d,t,i),m=u&&null!=a.distance?a.distance:1/0},D=(n,c,d)=>{if((!x||null!=d)&&n>=0&&(T.backfacesTerrain||h(d,s)<0)&&(T.invisibleTerrain||!T.selectionMode||null==t||t(i,r,n))){if((null==o.distance||n<o.distance)&&w(o,n,d),T.isFiltered)return;2===T.store&&(null==p?(p=new C(e.ray),w(p,n,d),e.results.all.push(p)):n<p.distance&&w(p,n,d)),(null==a.distance||n<a.distance)&&w(a,n,d),0!==T.store&&(null==l.distance||n>l.distance)&&w(l,n,d)}},S=$;c(S,r,P);const{indices:B,indexCount:E}=v,j=v.vertexAttributes,A=j.getField("position",b),k=new q(A.typedBuffer,3,j.stride/4),U=E/3;if(!g&&U>Q){const e=d.renderData;e.intersectionData??=new G(B,U,k),e.intersectionData.intersectRay(Y,S,R,D)}else M(Y,S,0,U,B,k,g,R,D)},P=this._rootTiles;if(null!=P){(()=>{const t=this._tileIterator;t.reset(P);const r=e.options.invisibleTerrain;for(let e=t.next();e;e=t.next())!(e.visible||r&&e.intersectsClippingArea)||null==g&&!e.intersectsRay(i,s,f,m)||_&&this._useStencilForTile(e)?t.skipSubtree():v(e)})()}}processScaleRangeQueries(e,t){if(!t.done&&e)for(this._updatePatchGroups();e.updating&&!t.done;){e.prepare();for(const t of this._visiblePatchesByOrigin.values())for(const i of t)null!=i.renderData?.textureReference&&e.queriesForTile(i);e.process(),t.madeProgress()}}get _desiredSlot(){if(!this._produces())return null;switch(this.transparency){case 0:return 1;case 1:case 2:return this._oitGround?7:6;case 3:case 4:return null}}acquireTechniques(e){const{shadowMap:t,viewshedEnabled:i,cutFillEnabled:r,slot:s,oitPass:n,hasEmission:a}=e.bind,l=!!has("enable-feature:terrain-shadows")&&t.enabled;if(l!==this._castShadows&&(this._castShadows=l,this._patchesByOriginDirty=!0),this._inViewshed!==i&&(this._inViewshed=i,this._patchesByOriginDirty=!0),this._cutFillEnabled!==r&&(this._cutFillEnabled=r,this._patchesByOriginDirty=!0),3===this.transparency)return null;if(10===s){if(0===(e.renderOccludedMask&T))return null}else if(s!==this._desiredSlot)return null;const o=this._configuration;switch(o.screenSpaceReflections=o.cloudReflections=o.receiveShadows=o.receiveAmbientOcclusion=o.renderOccluded=o.hasHighlightMixTexture=o.hasEmission=!1,o.overlayMode=this._overlayRenderer.mode,o.oitPass=0,e.output){case 0:{const{ssr:i,clouds:r,ssao:l}=e.bind;o.screenSpaceReflections=null!=i.lastFrameColor,o.cloudReflections=null!=r.data;const c=10===s;return o.receiveShadows=t.ready&&!c,o.renderOccluded=c,o.receiveAmbientOcclusion=!c&&null!=l,o.oitPass=n,o.hasEmission=a,this._acquireTechnique(e.output)}case 3:case 5:return this._castShadows?this._acquireTechnique(3):null;case 6:return this._inViewshed?this._acquireTechnique(6):null;case 7:return this._cutFillEnabled?this._acquireTechnique(7):null;case 1:case 2:return this._acquireTechnique(e.output);case 9:return this._acquireTechnique(9);case 8:return o.hasHighlightMixTexture=null!=e.bind.highlightMixTexture,this._overlayRenderer.hasHighlights?this._acquireTechnique(8):null}return null}render(e,t){switch(this._updatePatchGroups(),t.useStencil=!1,this._passParameters.overlayContent=S(e.output,e.bind),e.output){case 0:return this._renderMaterialPass(e,t);case 1:case 2:case 9:return this._renderAuxiliaryPass(e,t,this._visiblePatchesByOrigin);case 8:{const i=e.bind.highlight?.name;i&&this._overlayRenderer.hasHighlights&&this._overlayRenderer.renders(2)&&this._overlayRenderer.hasHighlight(i)&&this._renderAuxiliaryPass(e,t,this._visiblePatchesByOrigin);break}case 3:case 5:case 6:case 7:return this._renderAuxiliaryPass(e,t,this._allPatchesByOrigin)}}updateTileBackground(e){if(null==this._tileRenderer)return;const i=this._tileRenderer;let r;if(null!=e){const i=t.toUnitRGBA(e);r=g(i[0]||0,i[1]||0,i[2]||0)}i.setBackground(r),this._allTiles.forAll(e=>i.updateTileTexture(e,0)),this._configuration.tileBlendInput=i.backgroundIsGrid?2:null!=i.backgroundColor?1:0,this.setNeedsRender()}_updatePatchGroups(){if(this._patchesByOriginDirty&&(this._rebuildPatchGroups(),this._patchesByOriginDirty=!1,this._patchSortingDirty=!0),this._patchSortingDirty){const e=Array.from(this._visiblePatchesByOrigin.values()),t=this._stencilEnabledLayerExtents;for(const i of e)w(i,t);e.sort((e,t)=>D(e[0],t[0])),this._visiblePatchesByOrigin=new Map(e.map(e=>[e[0].renderData.localOrigin,e])),this.notifyChange("visibleTiles"),this._patchSortingDirty=!1}}_rebuildPatchGroups(){const e=this._rootTiles;if(null!=e){e[0]?.surface.checkAllTilesWaterproofness(),this._visiblePatchesByOrigin.clear(),this._allPatchesByOrigin.clear();for(const t of e)this._rebuildPatchGroupsForRootTile(t)}}_rebuildPatchGroupsForRootTile(e){const t=this._tileIterator;for(t.resetOne(e);!t.done;){const e=t.next(),i=e.renderData;if(!i){this._numTilesCulled++;continue}const r=i.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 s=this._visiblePatchesByOrigin.get(r);s||(s=[],this._visiblePatchesByOrigin.set(r,s)),s.push(e),t.skipSubtree()}}_useStencilForTile(e){for(const t of this._stencilEnabledLayerExtents)if(e.intersectsExtent(t))return!0;return!1}_renderAuxiliaryPass(e,t,i){const{rctx:r,bind:s}=e;r.bindTechnique(t,s,this._passParameters);const n=this._stencilEnabledLayerExtents.length>0;i.forEach(i=>{this._drawParameters.origin=i[0].renderData.localOrigin,t.program.bindDraw(s,this._passParameters,this._drawParameters);for(let r=0;r<i.length;r++)this._renderPatch(e,t,i[r],z.TRIANGLES,n,null===this._passParameters.overlayContent)}),r.bindVAO(null)}_renderMaterialPass(e,t){const{rctx:i,bind:r}=e,s=i.bindTechnique(t,r,this._passParameters);this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0;const n=10===r.slot;n&&(s.bindTexture("tex",i.emptyTexture),s.setUniform3fv("textureOpacities",u),s.setUniform4fv("texOffsetAndScale",p));const a=null!=this._tileRenderer?.backgroundColor?this._tileRenderer.backgroundColor:u;1===this._configuration.tileBlendInput&&s.setUniform3fv("backgroundColor",a);const l=this._stencilEnabledLayerExtents.length>0,o=this.wireframe?z.LINES:z.TRIANGLES;this._configuration.textureFadingEnabled&&s.bindTexture("texNext",i.emptyTexture);const c=this._visiblePatchesByOrigin;for(const d of c.values()){const i=d[0].renderData.localOrigin;this._drawParameters.origin=i,t.program.bindDraw(r,this._passParameters,this._drawParameters),this._numOriginsRendered++;for(const r of d){const i=r.renderData,a=i.textureReference;if(null!=a){if(!n){s.setUniform4fv("texOffsetAndScale",a.offsetAndScale),s.bindTexture("tex",a.texture.texture);const e=i.textureFadeFactor,t=e<1?i.nextTextureReference:null;this._configuration.textureFadingEnabled&&t&&e<1?(s.setUniform1f("fadeFactor",e),s.setUniform4fv("nextTexOffsetAndScale",t.offsetAndScale),s.setUniform3fv("nextTexOpacities",t.opacities),s.bindTexture("texNext",t.texture.texture)):s.setUniform1f("fadeFactor",1),i.textureIsFading&&this.setNeedsRender(2),s.setUniform3fv("textureOpacities",a.opacities)}this._renderPatch(e,t,r,o,l),r.renderOrder=this._numTilesRendered,this._numTilesRendered++}}}i.bindVAO(null)}_renderPatch(e,t,i,r,s,n=!1){const a=i.renderData,l=a.vao,o=l?.indexBuffer;if(!l||null==o)return void(v&&console.error("Rendered tile with no indices: ",i.lij," : ",a));const c=t.program;n||this._overlayRenderer.isEmpty||this._bindOverlayPatchData(c,a.overlay);const{rctx:d,bind:h}=e;s&&(t.useStencil=this._useStencilForTile(i),d.setPipelineState(t.getPipeline(h)));const u=a.geometry.indexCount;d.bindVAO(l),c.assertCompatibleVertexAttributeLocations(l),d.drawElements(r,u,o.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(L,this._configuration)}get test(){}hasHighlight(e){return this._overlayRenderer.hasHighlight(e)}};e([l({readOnly:!0})],J.prototype,"visibleTiles",null),e([l({readOnly:!0})],J.prototype,"_isGlobal",null),e([l()],J.prototype,"renderOccludedFlags",void 0),e([l({value:!1})],J.prototype,"renderingDisabled",null),e([l({value:!0})],J.prototype,"visible",null),e([l()],J.prototype,"renderPatchBorders",null),e([l()],J.prototype,"wireframe",null),J=e([o("esri.views.3d.terrain.TerrainRenderer")],J);const K=_(),X=_(),Y=_(),$=_();export{J as TerrainRenderer};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as t}from"tslib";import{disposeMaybe as e,destroyMaybe as i}from"../../../../core/maybe.js";import{property as r,subclass as
|
|
5
|
+
import{__decorate as t}from"tslib";import"../../../../core/has.js";import{disposeMaybe as e,destroyMaybe as i}from"../../../../core/maybe.js";import{property as r,subclass as o}from"../../../../core/accessorSupport/decorators.js";import{multiply as s,fromTranslation as n}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as h}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{h as u,a}from"../../../../chunks/vec32.js";import{create as p}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{RenderCategory as f}from"../../webgl.js";import{debugFlags as c}from"../../support/debugFlags.js";import{glLayout as _}from"../../support/buffer/glUtil.js";import{newLayout as d}from"../../support/buffer/InterleavedLayout.js";import l from"../../webgl/RenderNode.js";import{Pos2Locations as m}from"./DefaultVertexBufferLayouts.js";import{VertexArrayObject as g}from"./VertexArrayObject.js";import{TaskPriority as x}from"../../../support/Scheduler.js";import{Yield as v}from"../../../support/Yield.js";import{DataType as b,PixelType as w}from"../../../webgl/enums.js";import{makePipelineState as y,defaultColorWrite as P}from"../../../webgl/renderState.js";import{Sync as T}from"../../../webgl/Sync.js";import{Texture as j}from"../../../webgl/Texture.js";import{TextureDescriptor as B}from"../../../webgl/TextureDescriptor.js";import{fromLayout as C}from"../../../webgl/VertexAttributeLocations.js";import{VertexBuffer as E}from"../../../webgl/VertexBuffer.js";let F=class extends l{constructor(t){super(t),this.category=f.COMPOSITE,this._debugVao=null,this._debugVaoLength=0,this.readyToRun=!1,this.done=!0,this._start=!1,this._origin=p(),this._textureWidth=256,this._uploadBuffer=new Float32Array(3*this._textureWidth),this._counter=0,this._width=0,this._height=0,this._pixelBufferSize=0,this._pipeline=y({colorWrite:P}),this._format=0}initialize(){const t=this.view.resourceController.scheduler.registerTask(x.GRAPHICS_CORE,this);this.addHandles(t),this.produces="disabled",this.consumes.required=[this.category],this.formatOverride&&(this._format=this.formatOverride)}destroy(){this._program=e(this._program),this._debugProgram=e(this._debugProgram),this._debugVao=e(this._debugVao);const t=this.gl;this._sync=i(this._sync),this._pixelBuffer&&(t.deleteBuffer(this._pixelBuffer),this._pixelBuffer=null,this._pixelBufferSize=0),this._texture=e(this._texture)}precompile(){this._ensureProgram(this.renderingContext)}render(t){const e=t.find(({name:t})=>t===this.category),i=this.renderingContext,r=this.gl,o=e.getTexture(r.DEPTH_STENCIL_ATTACHMENT),s=this.view.stage?.renderer.fboCache;if(!o||!s||this._sync||!this._start)return e;this._start=!1,this.produces=c.OCCLUSION_QUERY_DEBUG_PIXEL?this.category:"disabled";const n=s.acquire(this._width,this._height,"hud visibility",9);i.bindFramebuffer(n.fbo),i.setPipelineState(this._pipeline);const h=this._ensureProgram(i);return i.useProgram(h),L(h,this.camera,this._origin),i.bindTexture(o,0),h.setUniform1i("depthTex",0),i.bindTexture(this._texture,1),h.setUniform1i("positionTex",1),h.setUniform1i("count",this._counter),i.screen.draw(),this._pixelBuffer||(this._pixelBuffer=r.createBuffer()),0===this._format&&(this._format=6403===r.getParameter(r.IMPLEMENTATION_COLOR_READ_FORMAT)&&r.getParameter(r.IMPLEMENTATION_COLOR_READ_TYPE)===b.FLOAT?6403:6408),this._pixelBufferSize=this._width*this._height*(6403===this._format?4:16),r.bindBuffer(r.PIXEL_PACK_BUFFER,this._pixelBuffer),r.bufferData(r.PIXEL_PACK_BUFFER,this._pixelBufferSize,r.STREAM_READ),r.readPixels(0,0,this._width,this._height,this._format,b.FLOAT,0),this._sync=new T(r),n.release(),setTimeout(()=>this.readyToRun=!0,0),e}runTask(){if(!this._sync)return void(this.readyToRun=!1);try{if(!this._sync.poll())return v}catch(e){return this.readyToRun=!1,void(this._sync=i(this._sync))}this.readyToRun=!1,this._sync=i(this._sync);const t=this.gl;t.bindBuffer(t.PIXEL_PACK_BUFFER,this._pixelBuffer),this._cpuBuffer=new Float32Array(this._width*this._height*(6403===this._format?1:4)),t.getBufferSubData(t.PIXEL_PACK_BUFFER,0,this._cpuBuffer),t.bindBuffer(t.PIXEL_PACK_BUFFER,null),this.done=!0}init(t,e){const i=this._textureWidth;if(this._width=i,this._height=Math.ceil(t/i),this._counter=0,this._texture?.dispose(),0===this._height)return;const r=new B(this._width,this._height);r.pixelFormat=6407,r.dataType=w.FLOAT,r.samplingMode=9728,this._texture=new j(this.renderingContext,r),this.done=!1,u(this._origin,Math.fround(e[0]),Math.fround(e[1]),Math.fround(e[2]))}addPosition(t){const e=this._width;if(this._counter>=e*this._height)return-1;const i=this._counter%e;return a(M,t,this._origin),this._uploadBuffer[3*i+0]=M[0],this._uploadBuffer[3*i+1]=M[1],this._uploadBuffer[3*i+2]=M[2],i===e-1&&this._flush(),this._counter++}start(){if(0===this._width||0===this._height)return;const t=this._width;this._counter%t>0&&this._flush(),this.produces=this.category,this._start=!0,this.requestRender(1)}getOcclusion(t){return this._cpuBuffer?.[6403===this._format?t:4*t]??-1}get usedMemory(){return(this._texture?.usedMemory??0)+this._pixelBufferSize+4*(this._uploadBuffer?.length??0)+4*(this._cpuBuffer?.length??0)}_flush(){const t=this._width,e=Math.floor(this._counter/t);this._texture?.updateData(0,0,e,t,1,this._uploadBuffer)}_ensureProgram(t){return this._program??=t.programCache.acquire(D,O,m),this._program}_ensureDebugProgram(t){return this._debugProgram??=t.programCache.acquire(A,R,V),this._debugProgram}_ensureDebugVao(t,i){if(!this._debugVao||this._debugVaoLength<i){const r=new Float32Array(i);for(let t=0;t<i;t++)r[t]=t;this._debugVao=e(this._debugVao),this._debugVao=new g(t,new E(t,S,r))}return this._debugVao}};t([r()],F.prototype,"category",void 0),t([r()],F.prototype,"formatOverride",void 0),t([r()],F.prototype,"readyToRun",void 0),t([r()],F.prototype,"done",void 0),F=t([o("esri.views.3d.webgl-engine.lib.GPUPointOcclusionQuery")],F);const A="#version 300 es\nprecision highp float;\nprecision highp int;\n\nin highp float componentIndex;\n\nuniform highp mat4 proj;\nuniform highp mat4 view;\n\nuniform highp sampler2D positionTex;\n\nvoid main() {\n int width = textureSize(positionTex, 0).x;\n int u = int(componentIndex) % width;\n int v = int(componentIndex) / width;\n\n vec4 posWorld = vec4(texelFetch(positionTex, ivec2(u, v), 0).rgb, 1.0);\n vec4 posView = view * posWorld;\n vec4 projected = proj * posView;\n\n gl_Position = projected;\n gl_PointSize = 1.0;\n}",R="#version 300 es\nout highp vec4 fragColor;\nuniform lowp vec4 color;\nvoid main() {\n fragColor = color;\n}\n",D="#version 300 es\nprecision highp float;\nin vec2 position;\n\nvoid main() {\n gl_Position = vec4(position, 0.0, 1.0);\n}",O="#version 300 es\nprecision highp float;\nout highp vec4 fragColor;\n\nuniform highp mat4 proj;\nuniform highp mat4 view;\n\nuniform highp int count;\n\nuniform highp sampler2D depthTex;\nuniform highp sampler2D positionTex;\n\nfloat linearizeDepth(float depth) {\n float depthNdc = depth * 2.0 - 1.0;\n float c1 = proj[3][2];\n float c2 = proj[2][2];\n return -c1 / (depthNdc + c2 + 1e-7);\n}\n\nvoid main() {\n int u = int(floor(gl_FragCoord.x));\n int v = int(floor(gl_FragCoord.y));\n if (u + v * textureSize(positionTex, 0).x >= count) {\n fragColor = vec4(-1);\n return;\n }\n vec4 posWorld = vec4(texelFetch(positionTex, ivec2(u, v), 0).rgb, 1.0);\n vec4 posView = view * posWorld;\n vec4 projected = proj * posView;\n\n vec3 clipPos = projected.xyz / projected.w;\n\n if (clipPos.x < -1.0 || clipPos.x > 1.0 || clipPos.y < -1.0 || clipPos.y > 1.0) {\n fragColor = vec4(-1);\n return;\n }\n\n vec3 uvDepth = 0.5 * clipPos + vec3(0.5);\n\n float depth = texture(depthTex, uvDepth.xy).r;\n\n if (uvDepth.z <= depth) {\n fragColor = vec4(0);\n return;\n }\n\n fragColor = vec4(linearizeDepth(depth) - linearizeDepth(uvDepth.z));\n}\n";function L(t,e,i){s(I,e.viewMatrix,n(I,i)),t.setUniformMatrix4fv("view",I),t.setUniformMatrix4fv("proj",e.projectionMatrix)}const M=p(),I=h(),S=_(d().f32("componentIndex")),V=C(S);export{F as GPUPointOcclusionQuery};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import{subclass as r}from"../../../../core/accessorSupport/decorators.js";import{layout as i}from"../../terrain/TerrainAttributes.js";import{isColor as t}from"../core/shaderLibrary/ShaderOutput.js";import{ReloadableShader as s}from"../core/shaderTechnique/ReloadableShader.js";import{ShaderTechnique as n,depthOnlyOutputBuffersOr as l}from"../core/shaderTechnique/ShaderTechnique.js";import{depthWrite as o,depthTest as a,blending as c,drawBuffers as p}from"../lib/OrderIndependentTransparency.js";import{renderWhenBitIsNotSet as u}from"../lib/StencilUtils.js";import{a as d}from"../../../../chunks/Terrain.glsl.js";import{makePipelineState as h,defaultColorWrite as m,defaultDepthWrite as f,premultipliedAlpha as T
|
|
5
|
+
import{__decorate as e}from"tslib";import{subclass as r}from"../../../../core/accessorSupport/decorators.js";import{layout as i}from"../../terrain/TerrainAttributes.js";import{isColor as t}from"../core/shaderLibrary/ShaderOutput.js";import{ReloadableShader as s}from"../core/shaderTechnique/ReloadableShader.js";import{ShaderTechnique as n,depthOnlyOutputBuffersOr as l}from"../core/shaderTechnique/ShaderTechnique.js";import{depthWrite as o,depthTest as a,blending as c,drawBuffers as p}from"../lib/OrderIndependentTransparency.js";import{renderWhenBitIsNotSet as u}from"../lib/StencilUtils.js";import{a as d}from"../../../../chunks/Terrain.glsl.js";import{makePipelineState as h,defaultColorWrite as m,defaultDepthWrite as f,premultipliedAlpha as T}from"../../../webgl/renderState.js";let b=class extends n{constructor(e,r){super(e,r,i.locations),this.shader=new s(d,()=>import("./Terrain.glsl.js")),this.useStencil=!1}initializePipeline(e){return this._stencilPipelineState=this._createPipeline(e,!0),this._createPipeline(e,!1)}_createPipeline(e,r){const{renderOccluded:i,output:s,oitPass:n,hasEmission:d}=e;return h(0===n?{blending:i?T:null,depthTest:i?null:{func:513},depthWrite:i?null:f,colorWrite:m,stencilTest:r?u(1):null,drawBuffers:l(s)}:{blending:t(s)?c(n,i):null,depthTest:a(n,i?519:513),depthWrite:i?null:o(e),drawBuffers:l(s,p(n,d)),colorWrite:m,stencilTest:r?u(1):null})}getPipeline(e){return this.useStencil?this._stencilPipelineState:super.getPipeline(e)}};b=e([r("esri.views.3d.webgl-engine.shaders.TerrainTechnique")],b);export{b as TerrainTechnique};
|