@arcgis/core 5.1.0-next.45 → 5.1.0-next.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{288bd32831e94e81653e.js → 08d76c600926d7642a8b.js} +1 -1
- package/assets/esri/core/workers/chunks/{54db91c0a3bd1946e026.js → 0d59f5cd3fdd7d6fd693.js} +1 -1
- package/assets/esri/core/workers/chunks/{288082ae7b19837a3d38.js → 20e715e3aeb1c3265901.js} +1 -1
- package/assets/esri/core/workers/chunks/{0155e5679ded9de5c327.js → 3a7c02616d942c81257d.js} +1 -1
- package/assets/esri/core/workers/chunks/3e9700445518b8f9ae1b.js +1 -0
- package/assets/esri/core/workers/chunks/{375eac59c9f88c7572db.js → 4b3545965b11a54184d4.js} +2 -2
- package/assets/esri/core/workers/chunks/{d3d024b3d2bb8fbbf760.js → 569e4479707bc6881d97.js} +1 -1
- package/assets/esri/core/workers/chunks/{8cafdd4addd366795600.js → 6c49ac7888679b9f7823.js} +1 -1
- package/assets/esri/core/workers/chunks/{ca88a364ef911526102e.js → 7b48c102a44606291f82.js} +1 -1
- package/assets/esri/core/workers/chunks/{e5927f9d0e757ec4c22a.js → a422cfe1e2afe0722acd.js} +1 -1
- package/assets/esri/core/workers/chunks/{f6e3954ddbb5993d56df.js → b45fdc04d399d2849d63.js} +1 -1
- package/assets/esri/core/workers/chunks/{dbafe96ce37bb82d0584.js → b49b608c0d58a9b55fa2.js} +1 -1
- package/assets/esri/core/workers/chunks/b744b950999b92393e37.js +1 -0
- package/assets/esri/core/workers/chunks/{1a3f874700f86b750390.js → ce0a6bc9df30af778ac9.js} +2 -2
- package/assets/esri/core/workers/chunks/{b86cb84c03b76e824213.js → f9fe89ced41b49608667.js} +1 -1
- package/assets/esri/core/workers/chunks/{bf4d2f42d31861ea1046.js → ff75fb0fce51ac12e656.js} +1 -1
- package/chunks/GaussianSplat.glsl.js +2 -2
- package/chunks/HUDMaterial.glsl.js +1 -1
- package/chunks/LineCallout.glsl.js +1 -1
- package/chunks/PointRenderer.glsl.js +1 -1
- package/chunks/Terrain.glsl.js +4 -4
- package/config.js +1 -1
- package/kernel.js +1 -1
- package/layers/IntegratedMesh3DTilesLayer.d.ts +2 -1
- package/layers/IntegratedMesh3DTilesLayer.js +1 -1
- package/layers/knowledgeGraph/dataModelVisualizationUtils.js +1 -1
- package/layers/support/schemaValidator.js +1 -1
- package/libs/ajv/ajv.bundle-wrapper.js +2 -0
- package/package.json +3 -3
- package/renderers/visualVariables/SizeVariable.js +1 -1
- package/rest/locator/locationToAddress.js +1 -1
- package/rest/support/LocationToAddressParameters.d.ts +62 -2
- package/rest/support/types.d.ts +6 -0
- package/support/revision.js +1 -1
- package/views/2d/analysis/AreaMeasurement/AreaMeasurementTool.js +1 -1
- package/views/2d/engine/vectorTiles/Placement.js +1 -1
- package/views/3d/layers/GaussianSplatLayerView3D.js +1 -1
- package/views/3d/terrain/OverlayRenderer.js +1 -1
- package/views/3d/terrain/TerrainRenderer.js +1 -1
- package/views/3d/terrain/TileCompositor.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/Slice.glsl.js +3 -3
- package/views/3d/webgl-engine/effects/debug/RenderNodeVisualizerNode.js +1 -1
- package/views/3d/webgl-engine/effects/highlight/ShadowHighlight.js +1 -1
- package/views/3d/webgl-engine/lib/BindParameters.js +1 -1
- package/views/3d/webgl-engine/lib/GaussianSplatRenderNode.js +1 -1
- package/views/3d/webgl-engine/lib/RenderContext.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/ShadowAccumulator.js +1 -1
- package/views/3d/webgl-engine/shaders/GaussianSplat.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/GaussianSplatTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/shaders/OutputColorHighlightOLID.glsl.js +1 -1
- package/views/webgl/InstanceCounter.js +1 -1
- package/webscene/support/schemaValidator.js +1 -1
- package/widgets/Editor/workflowUtils.js +1 -1
- package/widgets/Sketch/SketchViewModel.js +1 -1
- package/assets/esri/core/workers/chunks/385f1bb9164b2d488b2d.js +0 -1
- package/assets/esri/core/workers/chunks/73d7337ac9efdbad14a4.js +0 -1
- package/chunks/ajv.bundle.js +0 -2
- /package/assets/esri/core/workers/chunks/{375eac59c9f88c7572db.js.LICENSE.txt → 4b3545965b11a54184d4.js.LICENSE.txt} +0 -0
|
@@ -2,11 +2,12 @@ import type Point from "../../geometry/Point.js";
|
|
|
2
2
|
import type SpatialReference from "../../geometry/SpatialReference.js";
|
|
3
3
|
import type { JSONSupport } from "../../core/JSONSupport.js";
|
|
4
4
|
import type { LocationType } from "../types.js";
|
|
5
|
+
import type { GeocodeFeatureType, GeocodePreferredLabel } from "./types.js";
|
|
5
6
|
import type { PointProperties } from "../../geometry/Point.js";
|
|
6
7
|
import type { SpatialReferenceProperties } from "../../geometry/SpatialReference.js";
|
|
7
8
|
|
|
8
9
|
/** @since 5.0 */
|
|
9
|
-
export interface LocationToAddressParametersProperties extends Partial<Pick<LocationToAddressParameters, "locationType">> {
|
|
10
|
+
export interface LocationToAddressParametersProperties extends Partial<Pick<LocationToAddressParameters, "apiKey" | "featureTypes" | "language" | "locationType" | "preferredLabelValues" | "returnInputLocation">> {
|
|
10
11
|
/**
|
|
11
12
|
* The point at which to search for the closest address. The location
|
|
12
13
|
* should be in the same spatial reference as that of the geocode service.
|
|
@@ -26,9 +27,44 @@ export interface LocationToAddressParametersProperties extends Partial<Pick<Loca
|
|
|
26
27
|
outSpatialReference?: SpatialReferenceProperties | null;
|
|
27
28
|
}
|
|
28
29
|
|
|
29
|
-
/**
|
|
30
|
+
/**
|
|
31
|
+
* Input parameters for [locationToAddress()](https://developers.arcgis.com/javascript/latest/references/core/rest/locator/#locationToAddress).
|
|
32
|
+
*
|
|
33
|
+
* @since 5.0
|
|
34
|
+
* @module esri/rest/support/LocationToAddressParameters
|
|
35
|
+
* @see module:esri/rest/locator
|
|
36
|
+
*/
|
|
30
37
|
export default class LocationToAddressParameters extends JSONSupport {
|
|
31
38
|
constructor(properties?: LocationToAddressParametersProperties);
|
|
39
|
+
/**
|
|
40
|
+
* An authorization string used to access a resource or service.
|
|
41
|
+
* [API keys](https://developers.arcgis.com/documentation/security-and-authentication/api-key-authentication/) are generated and managed in the portal.
|
|
42
|
+
* An API key is tied explicitly to an ArcGIS account; it is also used to monitor service usage.
|
|
43
|
+
* Setting a fine-grained API key on a specific class overrides the [global API key](esri-config.html#apiKey).
|
|
44
|
+
*
|
|
45
|
+
* @since 5.1
|
|
46
|
+
* @see [API keys](https://developers.arcgis.com/documentation/security-and-authentication/api-key-authentication/)
|
|
47
|
+
* @see [Display a map tutorial - get an access token](https://developers.arcgis.com/javascript/latest/display-a-map/#get-an-access-token)
|
|
48
|
+
* @see [ArcGIS REST APIs | reverseGeocode | token](https://developers.arcgis.com/rest/geocode/reverse-geocode/#token)
|
|
49
|
+
*/
|
|
50
|
+
accessor apiKey: string | null | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* The property limits the possible match types returned by the reverseGeocode operation.
|
|
53
|
+
*
|
|
54
|
+
* @since 5.1
|
|
55
|
+
* @see [ArcGIS REST APIs | reverseGeocode | featureTypes](https://developers.arcgis.com/rest/geocode/reverse-geocode/#featuretypes)
|
|
56
|
+
*/
|
|
57
|
+
accessor featureTypes: GeocodeFeatureType[] | null | undefined;
|
|
58
|
+
/**
|
|
59
|
+
* This property sets the language in which reverse-geocoded addresses are returned. Addresses in many countries are
|
|
60
|
+
* available in more than one language; in these cases, this property can be used to specify which language should be
|
|
61
|
+
* used for addresses returned by the reverseGeocode operation.
|
|
62
|
+
*
|
|
63
|
+
* @since 5.1
|
|
64
|
+
* @see [ArcGIS REST APIs | reverseGeocode | langCode](https://developers.arcgis.com/rest/geocode/reverse-geocode/#langcode)
|
|
65
|
+
* @see [ArcGIS REST APIs | reverseGeocode | Supported language codes](https://developers.arcgis.com/rest/geocode/geocode-coverage/#supported-language-codes)
|
|
66
|
+
*/
|
|
67
|
+
accessor language: string | null | undefined;
|
|
32
68
|
/**
|
|
33
69
|
* The point at which to search for the closest address. The location
|
|
34
70
|
* should be in the same spatial reference as that of the geocode service.
|
|
@@ -57,4 +93,28 @@ export default class LocationToAddressParameters extends JSONSupport {
|
|
|
57
93
|
*/
|
|
58
94
|
get outSpatialReference(): SpatialReference | null;
|
|
59
95
|
set outSpatialReference(value: SpatialReferenceProperties | null);
|
|
96
|
+
/**
|
|
97
|
+
* Defines how city names are resolved when ambiguity exists.
|
|
98
|
+
*
|
|
99
|
+
* Possible Value | Description
|
|
100
|
+
* ------------------------|------------------------
|
|
101
|
+
* local-city | Include the primary local city name in geocoding response output fields. This is the name of the city that the address is within, and may be different than the postal city.
|
|
102
|
+
* postal-city | Include the primary postal city value in geocoding response output fields. This is the primary name assigned to the postal code of the address.
|
|
103
|
+
*
|
|
104
|
+
* @since 5.1
|
|
105
|
+
* @see [ArcGIS REST APIs | reverseGeocode | preferredLabelValues](https://developers.arcgis.com/rest/geocode/reverse-geocode/#preferredlabelvalues)
|
|
106
|
+
*/
|
|
107
|
+
preferredLabelValues?: GeocodePreferredLabel | null;
|
|
108
|
+
/**
|
|
109
|
+
* Specifies what the type of the location returned.
|
|
110
|
+
*
|
|
111
|
+
* Possible Value | Description
|
|
112
|
+
* ------------------------|------------------------
|
|
113
|
+
* false | The response will include the reverse geocoded location. This is the default.
|
|
114
|
+
* true | The response will include the input location.
|
|
115
|
+
*
|
|
116
|
+
* @since 5.1
|
|
117
|
+
* @see [ArcGIS REST APIs | reverseGeocode | returnInputLocation](https://developers.arcgis.com/rest/geocode/reverse-geocode/#returninputlocation)
|
|
118
|
+
*/
|
|
119
|
+
accessor returnInputLocation: boolean | null | undefined;
|
|
60
120
|
}
|
package/rest/support/types.d.ts
CHANGED
|
@@ -129,6 +129,12 @@ export type JobStatus = "job-cancelled" | "job-cancelling" | "job-deleted" | "jo
|
|
|
129
129
|
/** @since 5.0 */
|
|
130
130
|
export type NetworkDate = Date | "now";
|
|
131
131
|
|
|
132
|
+
/** @since 5.1 */
|
|
133
|
+
export type GeocodeFeatureType = "distance-marker" | "locality" | "poi" | "point-address" | "postal" | "street-address" | "street-intersection" | "street-name" | "sub-address";
|
|
134
|
+
|
|
135
|
+
/** @since 5.1 */
|
|
136
|
+
export type GeocodePreferredLabel = "local-city" | "postal-city";
|
|
137
|
+
|
|
132
138
|
/** @since 5.0 */
|
|
133
139
|
export type PrintReportTemplate = "attribute-list-letter-ansi-a-landscape" | "attribute-list-letter-ansi-a-portrait" | "attribute-list-with-group-letter-ansi-a-landscape" | "attribute-list-with-group-letter-ansi-a-portrait" | "page-per-feature-letter-ansi-a-landscape" | "page-per-feature-letter-ansi-a-portrait";
|
|
134
140
|
|
package/support/revision.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
const
|
|
2
|
+
const c="20260319",f="4d1cac45dc930071b24203195aef607c7cf99c5f";export{c as buildDate,f as commitHash};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{multiplyOpacity as i}from"../../../../core/colorUtils.js";import{makeHandle as s}from"../../../../core/handleUtils.js";import{isAborted as a,ignoreAbortErrors as r}from"../../../../core/promiseUtils.js";import{watch as o,initial as n}from"../../../../core/reactiveUtils.js";import{property as l,subclass as h}from"../../../../core/accessorSupport/decorators.js";import{UpdatingHandles as
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{multiplyOpacity as i}from"../../../../core/colorUtils.js";import{makeHandle as s}from"../../../../core/handleUtils.js";import{isAborted as a,ignoreAbortErrors as r}from"../../../../core/promiseUtils.js";import{watch as o,initial as n}from"../../../../core/reactiveUtils.js";import{property as l,subclass as h}from"../../../../core/accessorSupport/decorators.js";import{UpdatingHandles as c}from"../../../../core/support/UpdatingHandles.js";import p from"../../../../symbols/SimpleFillSymbol.js";import m from"../../../../symbols/SimpleLineSymbol.js";import{ExclusiveOperationManager as d}from"../../../analysis/ExclusiveOperationManager.js";import u from"../../../../widgets/Sketch/SketchViewModel.js";function y(e){return"polygon"===e?.type}let w=class extends t{constructor(e){super(e),this._invisibleAreaSymbol=new p({color:null,outline:null}),this._operationManager=new d,this._updatingHandles=new c}initialize(){this._sketchViewModel=new u({defaultCreateOptions:{mode:"click"},defaultUpdateOptions:{enableMoveAllGraphics:!1,enableRotation:!1,enableScaling:!1,enableZ:!1,highlightOptions:{enabled:!1},multipleSelectionEnabled:!1,reshapeOptions:{edgeOperation:"none",shapeOperation:"none"},toggleToolOnClick:!1,tool:"reshape"},updateOnGraphicClick:!1,view:this.view}),this.addHandles([o(()=>({interactive:this.measurementViewData.interactive,visible:this.measurementViewData.visible}),({interactive:e,visible:t})=>{t&&e&&this._analysis.geometry?"place"!==this._operationManager.currentOperationType&&this.reshape():this._operationManager.stop()}),o(()=>this.measurementViewData.analysis.geometry,e=>{e||(this._operationManager.stop(),this._sketchViewModel?.cancel(),this.measurementViewData.sketchGraphicsLayer?.removeAll())}),o(()=>this.measurementViewData.snappingOptions,e=>{this._sketchViewModel&&(this._sketchViewModel.snappingOptions=e)},n),o(()=>this.view.effectiveTheme.accentColor,e=>{this._areaSymbol=new p({color:i(e,.3),outline:new m({color:e,width:2})})},n)])}destroy(){this._areaSymbol?.destroy(),this._invisibleAreaSymbol.destroy(),this._operationManager.destroy(),this._sketchViewModel?.destroy(),this._updatingHandles.destroy()}get state(){if(!this.measurementViewData.visible||!this._operationManager.currentOperationType)return"idle";switch(this._operationManager.currentOperationType){case"place":return"placing";case"reshape":return"reshaping"}}get updating(){return!this._sketchViewModel||this._sketchViewModel.updating||this._updatingHandles.updating}async place(e){return this._operationManager.start("place",async t=>{if(!this._sketchViewModel||!this.measurementViewData.sketchGraphicsLayer)return;const i=this._analysis.clone(),o=e=>{const i="state"in e?e.state:"active",s="graphic"in e?e.graphic:e.graphics?.at(0);switch(i){case"start":case"active":{const e=s?.geometry;"polygon"===e?.type&&(this._analysis.geometry=e);break}case"cancel":case"complete":t.stop(),this.reshape()}},n=this._sketchViewModel.on(["create","undo","redo"],o);t.handles.push(n,s(()=>{n.remove(),this._sketchViewModel?.cancel(),this.measurementViewData.sketchGraphicsLayer?.removeAll();const s=this._analysis;return s.valid?a(e)||i.equals(s)?t.reject():void t.resolve({}):(s.clear(),t.reject())})),this._sketchViewModel.polygonSymbol=this._invisibleAreaSymbol,this._sketchViewModel.layer=this.measurementViewData.sketchGraphicsLayer,this._updatingHandles.consumePromise(r(this._sketchViewModel.create("polygon")))},e)}async reshape(e){return this._operationManager.start("reshape",async t=>{if(!this._sketchViewModel)return;const i=()=>this._areaSymbol&&this._sketchViewModel&&this.measurementViewData.manipulatorGraphic&&this.measurementViewData.manipulatorGraphicsLayer?(this._sketchViewModel.polygonSymbol=this._areaSymbol,this._sketchViewModel.layer=this.measurementViewData.manipulatorGraphicsLayer,this._updatingHandles.addPromise(r(this._sketchViewModel.update(this.measurementViewData.manipulatorGraphic,{tool:"reshape"})))):Promise.resolve(),o=this._sketchViewModel.on("update",e=>{const s=e.graphics[0]?.geometry;this._analysis.geometry=y(s)?s:null,"complete"===e.state&&(this.measurementViewData.interactive?i():t.stop())});t.handles.push(o,s(()=>{if(o.remove(),this._sketchViewModel?.cancel(),a(e))return t.reject();t.resolve()})),await i()},e)}get _analysis(){return this.measurementViewData.analysis}};e([l()],w.prototype,"_sketchViewModel",void 0),e([l()],w.prototype,"measurementViewData",void 0),e([l()],w.prototype,"state",null),e([l()],w.prototype,"updating",null),e([l()],w.prototype,"view",void 0),w=e([h("esri.views.2d.analysis.AreaMeasurement.AreaMeasurementTool")],w);export{w as AreaMeasurementTool};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{Point as e}from"../../../../geometry/support/TileClipper.js";import{tilePixelRatio as t}from"./constants.js";import{cDegToRad as i,cPi as n,cInfinity as s,positiveMod as
|
|
2
|
+
import{Point as e}from"../../../../geometry/support/TileClipper.js";import{tilePixelRatio as t}from"./constants.js";import{cDegToRad as i,cPi as n,cInfinity as s,positiveMod as o,radToByte as a,c2pi as h}from"./GeometryUtils.js";import{TextShaping as l,sdfGlyphSize as r,sdfGlyphBaseline as c}from"./TextShaping.js";import{sdfBufferServer as g}from"../webgl/definitions.js";const m=.5,x=2;class d{constructor(e,t,i=0,n=-1,s=m){this.x=e,this.y=t,this.angle=i,this.segment=n,this.minzoom=s}}class p{constructor(e,t,i,n,o,a=m,h=s){this.anchor=e,this.labelAngle=t,this.glyphAngle=i,this.page=n,this.alternateVerticalGlyph=o,this.minzoom=a,this.maxzoom=h}}class w{constructor(e,t,i,n,s,o,a,h,l,r,c,g){this.tl=e,this.tr=t,this.bl=i,this.br=n,this.mosaicRect=s,this.labelAngle=o,this.minAngle=a,this.maxAngle=h,this.anchor=l,this.minzoom=r,this.maxzoom=c,this.page=g}}class y{constructor(e){this.shapes=e}}class f{getIconPlacement(t,s,o){const a=new e(t.x,t.y),h=0===o.rotationAlignment,l=o.keepUpright;let r=o.rotate*i;h&&(r+=t.angle);const c=new y([]);return c.iconColliders=[],this._addIconPlacement(c,a,s,o,r),h&&l&&this._addIconPlacement(c,a,s,o,r+n),c}_addIconPlacement(t,i,n,o,a){const h=n.rasterizationScale,l=n.width/h,r=n.height/h,c=o.offset;let g=c[0],x=c[1];switch(o.anchor){case 0:g-=l/2,x-=r/2;break;case 1:x-=r/2;break;case 2:g-=l,x-=r/2;break;case 3:g-=l/2;break;case 4:g-=l/2,x-=r;break;case 5:break;case 7:x-=r;break;case 6:g-=l;break;case 8:g-=l,x-=r}const d=n.rect,p=2/h,y=g-p,f=x-p,b=y+d.width/h,u=f+d.height/h,I=new e(y,f),T=new e(b,u),k=new e(y,u),P=new e(b,f);if(0!==a){const e=Math.cos(a),t=Math.sin(a);I.rotate(e,t),T.rotate(e,t),k.rotate(e,t),P.rotate(e,t)}const N=new w(I,P,k,T,d,a,0,256,i,m,s,0);t.shapes.push(N);{const e=o.size,n=o.padding,h={xTile:i.x,yTile:i.y,dxPixels:g*e-n,dyPixels:x*e-n,hard:!o.optional,partIndex:0,width:l*e+2*n,height:r*e+2*n,angle:a,minLod:m,maxLod:s};t.iconColliders.push(h)}}getTextPlacement(o,a,h,d){const f=new e(o.x,o.y),{keepUpright:b,rotate:u,rotationAlignment:I,size:T}=d,k=u*i,P=0===I,N=b,z=d.padding;let A=m;const _=!P?0:o.angle,G=o.segment>=0&&P,M=[],E=[],L=g,V=!G;let v=Number.POSITIVE_INFINITY,j=Number.NEGATIVE_INFINITY,C=v,F=j;const S=(G||P)&&N,Y=T/r;let q=!1;for(const e of a)if(e.vertical){q=!0;break}let U,O=0,B=0;if(!G&&q){const e=l.getTextBox(a,d.lineHeight*r);switch(d.anchor){case 1:O=e.height/2,B=-e.width/2;break;case 2:O=-e.height/2,B=e.width/2;break;case 3:O=e.height/2,B=e.width/2;break;case 4:O=-e.height/2,B=-e.width/2;break;case 5:O=e.height;break;case 7:B=-e.width;break;case 6:B=e.width;break;case 8:O=-e.height}}O+=d.offset[0]*r,B+=d.offset[1]*r;for(const i of a){const a=i.glyphMosaicItem;if(!a||a.rect.isEmpty)continue;const l=a.rect,r=a.metrics,g=a.page;if(M&&V){if(void 0!==U&&U!==i.y){let e,t,i,n;q?(e=-F+O,t=v+B,i=F-C,n=j-v):(e=v+O,t=C+B,i=j-v,n=F-C);const a={xTile:o.x,yTile:o.y,dxPixels:e*Y-z,dyPixels:t*Y-z,hard:!d.optional,partIndex:1,width:i*Y+2*z,height:n*Y+2*z,angle:k,minLod:m,maxLod:s};M.push(a),v=Number.POSITIVE_INFINITY,j=Number.NEGATIVE_INFINITY,C=v,F=j}U=i.y}const y=[];if(G){const e=.5*a.metrics.width,n=(i.x+r.left-L+e)*Y*t;if(A=this._placeGlyph(o,A,n,h,o.segment,1,i.vertical,g,y),N&&(A=this._placeGlyph(o,A,n,h,o.segment,-1,i.vertical,g,y)),A>=x)break}else y.push(new p(f,_,_,g,!1)),P&&N&&y.push(new p(f,_+n,_+n,g,!1));const b=i.x+r.left,u=i.y-c-r.top,I=b+r.width,T=u+r.height;let H,R,D,J,K,Q,W,X;if(!G&&q)if(i.vertical){const t=(b+I)/2-r.height/2,i=(u+T)/2+r.width/2;H=new e(-i-L+O,t-L+B),R=new e(H.x+l.width,H.y+l.height),D=new e(H.x,R.y),J=new e(R.x,H.y)}else H=new e(-u+L+O,b-L+B),R=new e(H.x-l.height,H.y+l.width),D=new e(R.x,H.y),J=new e(H.x,R.y);else H=new e(b-L+O,u-L+B),R=new e(H.x+l.width,H.y+l.height),D=new e(H.x,R.y),J=new e(R.x,H.y);for(const t of y){let n,s,a,h;if(t.alternateVerticalGlyph){if(!K){const t=(u+T)/2+B;K=new e((b+I)/2+O-r.height/2-L,t+r.width/2+L),Q=new e(K.x+l.height,K.y-l.width),W=new e(Q.x,K.y),X=new e(K.x,Q.y)}n=K,s=W,a=X,h=Q}else n=H,s=D,a=J,h=R;const c=u,g=T,m=t.glyphAngle+k;if(0!==m){const e=Math.cos(m),t=Math.sin(m);n=n.clone(),s=s?.clone(),a=a?.clone(),h=h?.clone(),n.rotate(e,t),h?.rotate(e,t),s?.rotate(e,t),a?.rotate(e,t)}let p=0,y=256;if(G&&q?i.vertical?t.alternateVerticalGlyph?(p=32,y=96):(p=224,y=32):(p=224,y=96):(p=192,y=64),E.push(new w(n,a,s,h,l,t.labelAngle,p,y,t.anchor,t.minzoom,t.maxzoom,t.page)),M&&(!S||this._legible(t.labelAngle)))if(V)b<v&&(v=b),c<C&&(C=c),I>j&&(j=I),g>F&&(F=g);else if(t.minzoom<x){const e={xTile:o.x,yTile:o.y,dxPixels:(b+O)*Y-z,dyPixels:(c+O)*Y-z,hard:!d.optional,partIndex:1,width:(I-b)*Y+2*z,height:(g-c)*Y+2*z,angle:m,minLod:t.minzoom,maxLod:t.maxzoom};M.push(e)}}}if(A>=x)return null;if(M&&V){let e,t,i,n;q?(e=-F+O,t=v+B,i=F-C,n=j-v):(e=v+O,t=C+B,i=j-v,n=F-C);const a={xTile:o.x,yTile:o.y,dxPixels:e*Y-z,dyPixels:t*Y-z,hard:!d.optional,partIndex:1,width:i*Y+2*z,height:n*Y+2*z,angle:k,minLod:m,maxLod:s};M.push(a)}const H=new y(E);return M&&M.length>0&&(H.textColliders=M),H}_legible(e){const t=a(e);return t<65||t>=193}_placeGlyph(t,i,a,l,r,c,g,m,x){let d=c;const w=d<0?o(t.angle+n,h):t.angle;let y=0;a<0&&(d*=-1,a*=-1,y=n),d>0&&++r;let f=new e(t.x,t.y),b=l[r],u=s;if(l.length<=r)return u;for(;;){const e=b.x-f.x,t=b.y-f.y,n=Math.sqrt(e*e+t*t),s=Math.max(a/n,i),c=e/n,I=t/n,T=o(Math.atan2(I,c)+y,h);if(x.push(new p(f,w,T,m,!1,s,u)),g&&x.push(new p(f,w,T,m,!0,s,u)),s<=i)return s;f=b.clone();do{if(r+=d,l.length<=r||r<0)return s;b=l[r]}while(f.isEqual(b));let k=b.x-f.x,P=b.y-f.y;const N=Math.sqrt(k*k+P*P);k*=n/N,P*=n/N,f.x-=k,f.y-=P,u=s}}}export{d as Anchor,w as PlacedSymbol,y as Placement,f as PlacementEngine};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import"../../../core/has.js";import t from"../../../core/Logger.js";import{removeMaybe as i}from"../../../core/maybe.js";import{watch as s,syncAndInitial as r}from"../../../core/reactiveUtils.js";import{unitFromRESTJSON as a,convertUnit as n}from"../../../core/units.js";import{property as o,subclass as l}from"../../../core/accessorSupport/decorators.js";import{fromValues as h}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{getReferenceEllipsoid as u}from"../../../geometry/ellipsoidUtils.js";import d from"../../../geometry/HeightModelInfo.js";import{create as m}from"../../../geometry/support/aaBoundingBox.js";import{isCompatible as p}from"../../../geometry/support/heightModelInfoUtils.js";import{isPlateCarree as c,isWebMercator as f,equals as g,isGeographic as y}from"../../../geometry/support/spatialReferenceUtils.js";import _ from"../../../geometry/support/WKIDUnitConversion.js";import{getHeightModelInfoFromVCS as w}from"../../../layers/support/tiles3DUtils.js";import{getElevationOffsetInMeters as v}from"../../../support/elevationInfoUtils.js";import{getMetersPerUnit as b}from"../../../symbols/support/unitConversionUtils.js";import{GaussianSplatLayerViewPerformanceInfo as x}from"./GaussianSplatLayerViewPerformanceInfo.js";import{LayerView3D as S}from"./LayerView3D.js";import{addLayerViewToWasm as C,getLyr3DWasm as M,removeLayerViewFromWasm as H}from"./Lyr3DWasm.js";import{LayerElevationProvider as j}from"./i3s/LayerElevationProvider.js";import{ElevationRange as E}from"../support/ElevationRange.js";import{projectToBoundingBox as P}from"../support/extentUtils.js";import{Obb as U}from"../support/orientedBoundingBox.js";import{splatPageSizeInU32 as A,elementsPerSplatPage as G,packedGaussianSizeInU32 as V,splatPageSizeInU32WithoutHeader as R,gaussiansPerSplatPage as I,splatAtlasTextureWidth as O}from"../support/gaussianSplatting/GaussianSplatAtlasPages.js";import{GaussianSplatDataStore as T}from"../support/gaussianSplatting/GaussianSplatDataStore.js";import{GaussianSplatFadeHelper as L}from"../support/gaussianSplatting/GaussianSplatFadeHelper.js";import{GaussianSplatIntersectionHandler as B}from"../support/gaussianSplatting/GaussianSplatIntersectionHandler.js";import{GaussianTile as F}from"../support/gaussianSplatting/GaussianTile.js";import{GaussianSplatRenderNode as k}from"../webgl-engine/lib/GaussianSplatRenderNode.js";import D from"../../layers/LayerView.js";import{spatialReferenceIncompatibleError as z,isInEffectiveScaleRange as q}from"../../support/layerViewUtils.js";import{TaskPriority as N}from"../../support/Scheduler.js";const W=()=>t.getLogger("esri.views.3d.layers.GaussianSplatLayerView3D");let $=class extends(S(D)){constructor(e){super(e),this.type="gaussian-splat-3d",this.ignoresMemoryFactor=!1,this._tileHandles=new Map,this._pageBuffer=new Uint32Array(A),this._tmpObbsWithChangedVisibility=new Array,this._wasmLayerId=-1,this._metersPerVCSUnit=1,this._usedMemory=0,this._cacheMemory=0,this._useEsriCrs=!1,this.fullExtentInLocalViewSpatialReference=null,this._suspendedHandle=null,this._conversionBuffer=new ArrayBuffer(4),this._u32View=new Uint32Array(this._conversionBuffer),this._f32View=new Float32Array(this._conversionBuffer);const t=e.view.resourceController;this._memCache=t.memoryController.newCache(`GaussianSplat-${this.uid}`,e=>this._deleteTile(e)),this._frameTask=t.scheduler.registerTask(N.GAUSSIAN_SPLAT_TEXTURE_ATLAS)}get _clippingBox(){if(!this.view?.clippingArea)return null;const e=m();return P(this.view.clippingArea,e,this.view.renderSpatialReference)?e:null}get clippingBox(){return this._renderNode?.clippingBox??null}initialize(){if(!this._canProjectWithoutEngine())throw z("layer",this.layer.spatialReference.wkid,this.view.renderSpatialReference?.wkid);const e=C(this).then(e=>{this._wasmLayerId=e,this._renderNode=new k({view:this.view,layerView:this}),this.data=new T(this._renderNode),this.fadeHelper=new L(this),this._intersectionHandler=new B(this),this.view.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler),this._elevationProvider=new j({view:this.view,layerElevationSource:this,intersectionHandler:this._intersectionHandler}),this.view.elevationProvider.register(2,this._elevationProvider),this.addHandles([s(()=>this.layer.elevationInfo,e=>this._elevationInfoChanged(e))]),this._suspendedHandle=s(()=>this.suspended,e=>this._wasm?.setEnabled(this,!e),r),this.addHandles([s(()=>this._clippingBox,e=>this._renderNode.clippingBox=e,r)]),this.setMaximumGaussianCount(this.view.qualitySettings.gaussianSplat.maximumNumberOfGaussians)});this.addHandles([s(()=>this.view.qualitySettings.fadeDuration,e=>{this.fadeHelper.onFadeDurationChanged(e),this.data.fadingTexture.updateTexture(this.data.textureAtlas.pageAllocator.pageCount)}),s(()=>this.view.qualitySettings.gaussianSplat.maximumNumberOfGaussians,e=>this.setMaximumGaussianCount(e*this.view.quality)),s(()=>this.view.quality,e=>this.setMaximumGaussianCount(this.view.qualitySettings.gaussianSplat.maximumNumberOfGaussians*e))]),this.addResolvingPromise(e)}get wasmLayerId(){return this._wasmLayerId}get metersPerVCSUnit(){return this._metersPerVCSUnit}get tileHandles(){return this._tileHandles}get _wasm(){return M(this.view)}get usedMemory(){return this._usedMemory}get cachedMemory(){return this._cacheMemory}get unloadedMemory(){return 0}get useEsriCrs(){return this._useEsriCrs}get elevationProvider(){return this._elevationProvider}get elevationOffset(){return v(this.layer.elevationInfo)}get elevationRange(){const e=this.fullExtent;return e?.zmin&&e?.zmax?new E(e.zmin,e.zmax):null}getElevationRange(e){return this._intersectionHandler.getElevationRange(e)}get fullExtent(){return this.layer.fullExtent}get visibleAtCurrentScale(){return q(this.layer.effectiveScaleRange,this.view.scale)}isUpdating(){const e=this._wasm;return!(this._wasmLayerId<0||null==e)&&(e.isUpdating(this._wasmLayerId)||this.data.updating||this.fadeHelper.updating)}updatingFlagChanged(){this.notifyChange("updating")}async createRenderable(e){const t=e.meshData;if(null==t.data)throw new Error("meshData.data undefined");if(t.desc=JSON.parse(t.desc),null==t.desc)throw new Error("meshData.desc undefined");const i=t.desc.prims[0],s=i.vertexCount,r=i.atrbs[0].view,a=i.atrbs[0].view.byteCount,n=i.atrbs[0].view.byteOffset;let o=null;if("U32"!==r.type)return W().warnOnce("unexpected meshData.data format"),{memUsageBytes:0,numGaussians:0};o=new Uint32Array(t.data.buffer,n,a/4);const l=this.extractHeader(o),d=Math.ceil(s/I),m=new Uint32Array(s),p=new Array;let c=!1,f=0;const g=async e=>{for(;f<d&&!e.done&&!c;f++){let t=this.data.textureAtlas.requestPage();if(null===t&&(this._freeInvisibleTiles(),t=this.data.textureAtlas.requestPage()),null!==t){p.push(t);const i=s-f*I,r=Math.min(i,I),a=f*I;for(let e=0;e<r;e++)m[e+a]=e+G*t;const n=f*R;this._pageBuffer.set(o.subarray(n,n+r*V)),this._pageBuffer.set(l.packedHeader,R);const h=t*G,u=h%O,d=Math.floor(h/O);this.data.textureAtlas.update(u,d,this._pageBuffer),e.madeProgress()}else c=!0}f<d&&!c&&await this._frameTask.schedule(g)};if(await this._frameTask.schedule(g),c)return W().warnOnce("ran out of gaussian splat memory"),{memUsageBytes:0,numGaussians:0};const y=new Float32Array(3*s),_=new Float32Array(s),w=2.048,v=l.tileOrigin.x*w,b=l.tileOrigin.y*w,x=l.tileOrigin.z*w,S=l.invPosScale;let C=null;if(t.desc.obb){const e=t.desc.obb.quaternion;C=new U(t.desc.obb.center,t.desc.obb.halfSize,h(...e))}C||(W().warnOnce("encountered tile without a bounding box"),C=new U);const M=C.centerX,H=C.centerY,j=C.centerZ,P=new E,A=this.view.state.isGlobal,T=A?u(this.view.spatialReference).radius:0;let L=0,B=0,k=0;const D=async e=>{for(;k<s&&!e.done;k++){const t=k*V,{rawX:i,rawY:s,rawZ:r}=this._extractGaussianPosition(o,t),a=this._extractGaussianSphericalScale(o,t),n=i*S+v,l=s*S+b,h=r*S+x;y[L]=n-M,y[L+1]=l-H,y[L+2]=h-j;const u=A?Math.sqrt(n*n+l*l+h*h)-T:h;P.expandElevationRangeValues(u,u),_[k]=a*a,B=Math.max(B,a),L+=3,e.madeProgress()}k<s&&await this._frameTask.schedule(D)};await this._frameTask.schedule(D);const{fullExtent:z}=this.layer;z?.hasZ&&z.zmax&&z.zmin&&(P.minElevation=Math.max(P.minElevation,z.zmin),P.maxElevation=Math.min(P.maxElevation,z.zmax));const q=new F(e.handle,C,m,p,y,_,B,P);return this._memCache.put(`${q.handle}`,q),this._tileHandles.set(e.handle,q),this._cacheMemory+=q.usedMemory,{memUsageBytes:q.usedMemory,numGaussians:s}}_extractGaussianPosition(e,t){const i=e[t+1];return{rawX:16383&i,rawY:i>>>14&16383,rawZ:i>>>28&15|(1023&e[t+2])<<4}}_extractGaussianSphericalScale(e,t){const i=e[t+2],s=i>>>10&255,r=i>>>18&255,a=i>>>26&63|(3&e[t+3])<<6,n=Math.exp(s/16-10),o=Math.exp(r/16-10),l=Math.exp(a/16-10);return Math.max(n,o,l)}freeRenderable(e){const t=this._tileHandles.get(e);t&&(t.isVisible&&!this.fadeHelper.isTileFadingOut(t)?this._usedMemory-=t.usedMemory:this._cacheMemory-=t.usedMemory,t.pageIds.forEach(e=>this.data.textureAtlas.freePage(e)),this.freeObject(t),this._tileHandles.delete(e)),this.updateGaussians()}freeObject(e){this._memCache.pop(`${e.handle}`)}setRenderableVisibility(e,t,i){const s=this._tmpObbsWithChangedVisibility;s.length=0;for(let r=0;r<i;r++){if(!t[r])continue;const i=e[r],a=this._tileHandles.get(i);a&&(a.isVisible&&!this.fadeHelper.isTileFadingOut(a)||(a.isVisible=!0,s.push(a.obb),this.fadeHelper.isTileFadingOut(a)||this._popTileFromCache(a),this.fadeHelper.fadeTile(a,0)))}for(let r=0;r<i;r++){if(t[r])continue;const i=e[r],a=this._tileHandles.get(i);a&&a.isVisible&&(s.push(a.obb),this.fadeHelper.fadeTile(a,1))}s.length>0&&this._elevationProvider&&this._elevationProvider.notifyObjectsChanged(s),this.updateGaussians()}_popTileFromCache(e){this._usedMemory+=e.usedMemory,this._cacheMemory-=e.usedMemory,this._memCache.pop(`${e.handle}`)}moveTileToCache(e){this._usedMemory-=e.usedMemory,this._cacheMemory+=e.usedMemory,this._memCache.put(`${e.handle}`,e)}destroy(){H(this),this._suspendedHandle&&(this._suspendedHandle=i(this._suspendedHandle)),this._intersectionHandler&&(this.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler=null),this._elevationProvider&&this.view.elevationProvider&&(this._elevationProvider.notifyObjectsChangedFunctional(e=>{for(const t of this._tileHandles.values())e(t.obb)}),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this._frameTask.remove(),this._renderNode.destroy(),this.data.destroy(),this._memCache.destroy()}_canProjectWithoutEngine(){if(1===this.view.state.viewingMode)return!0;if(c(this.view.renderSpatialReference)||f(this.view.renderSpatialReference))return!0;if(this.layer.esriCrsSpatialReference&&g(this.layer.esriCrsSpatialReference,this.view.renderSpatialReference)){if(115700===this.layer.esriCrsSpatialReference.vcsWkid)return!1;let e=w(this.layer.esriCrsSpatialReference);if(!e){const t=this.layer.esriCrsSpatialReference;let i="meters";!y(t)&&t.wkid&&-1!==t.wkid&&(i=a(_.units[_[t.wkid]])),i&&(e=new d({heightModel:"gravity-related-height",heightUnit:i}))}const t=this.view.heightModelInfo;return this._useEsriCrs=0===p(e,t,!1),this._useEsriCrs&&(e&&(this._metersPerVCSUnit=n(1,"meters",e.heightUnit)),this.fullExtentInLocalViewSpatialReference=this.layer.esriCrsFullExtent),this._useEsriCrs}return!1}_elevationInfoChanged(e){if(e?.offset)if(this._useEsriCrs){const t=b(e?.unit)/this._metersPerVCSUnit,i=e?.offset??0;this._wasm?.setLayerOffset(this,i*t)}else this._wasm?.setLayerOffset(this,v(e));else this._wasm?.setLayerOffset(this,0)}updateGaussians(){const e=new Array;for(const t of this._tileHandles.values())t.isVisible&&e.push(t);this.data.updateGaussianVisibility(e),this.notifyChange("updating")}setMaximumGaussianCount(e){this._wasm?.setMaximumGaussianSplatCount(e)}_freeInvisibleTiles(){for(const e of this._tileHandles.values())e.isVisible||this._deleteTile(e)}extractHeader(e){const t=e.length-4,i=this.reinterpretU32AsFloat(e[t]),s=this.reinterpretU32AsFloat(e[t+1]),r=this.reinterpretU32AsFloat(e[t+2]),a=1/(1<<(255&e[t+3]));return{packedHeader:e.subarray(t,t+4),tileOrigin:{x:i,y:s,z:r},invPosScale:a}}_deleteTile(e){this._wasm?.onRenderableEvicted(this,e.handle,e.usedMemory),this.freeRenderable(e.handle)}reinterpretU32AsFloat(e){return this._u32View[0]=e,this._f32View[0]}get performanceInfo(){let e=0,t=0;return this._tileHandles.forEach(i=>{i.isVisible?e++:t++}),new x(this.usedMemory,e,t,this.cachedMemory)}get test(){}};e([o()],$.prototype,"layer",void 0),e([o({readOnly:!0})],$.prototype,"_clippingBox",null),e([o()],$.prototype,"elevationOffset",null),e([o({readOnly:!0})],$.prototype,"visibleAtCurrentScale",null),e([o()],$.prototype,"fullExtentInLocalViewSpatialReference",void 0),$=e([l("esri.views.3d.layers.GaussianSplatLayerView3D")],$);const X=$;export{X as default};
|
|
2
|
+
import{__decorate as e}from"tslib";import"../../../core/has.js";import t from"../../../core/Logger.js";import{removeMaybe as i}from"../../../core/maybe.js";import{watch as s,initial as r}from"../../../core/reactiveUtils.js";import{unitFromRESTJSON as a,convertUnit as n}from"../../../core/units.js";import{property as o,subclass as l}from"../../../core/accessorSupport/decorators.js";import{fromValues as h}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{getReferenceEllipsoid as d}from"../../../geometry/ellipsoidUtils.js";import u from"../../../geometry/HeightModelInfo.js";import{create as m}from"../../../geometry/support/aaBoundingBox.js";import{isCompatible as p}from"../../../geometry/support/heightModelInfoUtils.js";import{isPlateCarree as c,isWebMercator as f,equals as g,isGeographic as y}from"../../../geometry/support/spatialReferenceUtils.js";import _ from"../../../geometry/support/WKIDUnitConversion.js";import{getHeightModelInfoFromVCS as w}from"../../../layers/support/tiles3DUtils.js";import{getElevationOffsetInMeters as v}from"../../../support/elevationInfoUtils.js";import{getMetersPerUnit as b}from"../../../symbols/support/unitConversionUtils.js";import{GaussianSplatLayerViewPerformanceInfo as x}from"./GaussianSplatLayerViewPerformanceInfo.js";import{LayerView3D as S}from"./LayerView3D.js";import{addLayerViewToWasm as C,getLyr3DWasm as H,removeLayerViewFromWasm as M}from"./Lyr3DWasm.js";import{LayerElevationProvider as E}from"./i3s/LayerElevationProvider.js";import{ElevationRange as P}from"../support/ElevationRange.js";import{projectToBoundingBox as j}from"../support/extentUtils.js";import{Obb as U}from"../support/orientedBoundingBox.js";import{splatPageSizeInU32 as A,elementsPerSplatPage as G,packedGaussianSizeInU32 as V,splatPageSizeInU32WithoutHeader as R,gaussiansPerSplatPage as I,splatAtlasTextureWidth as O}from"../support/gaussianSplatting/GaussianSplatAtlasPages.js";import{GaussianSplatDataStore as T}from"../support/gaussianSplatting/GaussianSplatDataStore.js";import{GaussianSplatFadeHelper as L}from"../support/gaussianSplatting/GaussianSplatFadeHelper.js";import{GaussianSplatIntersectionHandler as B}from"../support/gaussianSplatting/GaussianSplatIntersectionHandler.js";import{GaussianTile as F}from"../support/gaussianSplatting/GaussianTile.js";import{GaussianSplatRenderNode as k}from"../webgl-engine/lib/GaussianSplatRenderNode.js";import D from"../../layers/LayerView.js";import{spatialReferenceIncompatibleError as N,isInEffectiveScaleRange as z}from"../../support/layerViewUtils.js";import{TaskPriority as q}from"../../support/Scheduler.js";const W=()=>t.getLogger("esri.views.3d.layers.GaussianSplatLayerView3D");let $=class extends(S(D)){constructor(e){super(e),this.type="gaussian-splat-3d",this.ignoresMemoryFactor=!1,this._tileHandles=new Map,this._pageBuffer=new Uint32Array(A),this._tmpObbsWithChangedVisibility=new Array,this._wasmLayerId=-1,this._metersPerVCSUnit=1,this._usedMemory=0,this._cacheMemory=0,this._useEsriCrs=!1,this.fullExtentInLocalViewSpatialReference=null,this._suspendedHandle=null,this._conversionBuffer=new ArrayBuffer(4),this._u32View=new Uint32Array(this._conversionBuffer),this._f32View=new Float32Array(this._conversionBuffer);const t=e.view.resourceController;this._memCache=t.memoryController.newCache(`GaussianSplat-${this.uid}`,e=>this._deleteTile(e)),this._frameTask=t.scheduler.registerTask(q.GAUSSIAN_SPLAT_TEXTURE_ATLAS)}get _clippingBox(){if(!this.view?.clippingArea)return null;const e=m();return j(this.view.clippingArea,e,this.view.renderSpatialReference)?e:null}get clippingBox(){return this._renderNode?.clippingBox??null}initialize(){if(!this._canProjectWithoutEngine())throw N("layer",this.layer.spatialReference.wkid,this.view.renderSpatialReference?.wkid);const e=C(this).then(e=>{this._wasmLayerId=e,this._renderNode=new k({view:this.view,layerView:this}),this.data=new T(this._renderNode),this.fadeHelper=new L(this),this._intersectionHandler=new B(this),this.view.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler),this._elevationProvider=new E({view:this.view,layerElevationSource:this,intersectionHandler:this._intersectionHandler}),this.view.elevationProvider.register(2,this._elevationProvider),this.addHandles([s(()=>this.layer.elevationInfo,e=>this._elevationInfoChanged(e)),s(()=>this.slicePlaneEnabled,e=>this._slicePlaneEnabledChanged(e),r)]),this._suspendedHandle=s(()=>this.suspended,e=>this._wasm?.setEnabled(this,!e),r),this.addHandles([s(()=>this._clippingBox,e=>this._renderNode.clippingBox=e,r)]),this.setMaximumGaussianCount(this.view.qualitySettings.gaussianSplat.maximumNumberOfGaussians)});this.addHandles([s(()=>this.view.qualitySettings.fadeDuration,e=>{this.fadeHelper.onFadeDurationChanged(e),this.data.fadingTexture.updateTexture(this.data.textureAtlas.pageAllocator.pageCount)}),s(()=>this.view.qualitySettings.gaussianSplat.maximumNumberOfGaussians,e=>this.setMaximumGaussianCount(e*this.view.quality)),s(()=>this.view.quality,e=>this.setMaximumGaussianCount(this.view.qualitySettings.gaussianSplat.maximumNumberOfGaussians*e))]),this.addResolvingPromise(e)}get wasmLayerId(){return this._wasmLayerId}get metersPerVCSUnit(){return this._metersPerVCSUnit}get tileHandles(){return this._tileHandles}get _wasm(){return H(this.view)}get usedMemory(){return this._usedMemory}get cachedMemory(){return this._cacheMemory}get unloadedMemory(){return 0}get useEsriCrs(){return this._useEsriCrs}get elevationProvider(){return this._elevationProvider}get elevationOffset(){return v(this.layer.elevationInfo)}get elevationRange(){const e=this.fullExtent;return e?.zmin&&e?.zmax?new P(e.zmin,e.zmax):null}getElevationRange(e){return this._intersectionHandler.getElevationRange(e)}get fullExtent(){return this.layer.fullExtent}get visibleAtCurrentScale(){return z(this.layer.effectiveScaleRange,this.view.scale)}isUpdating(){const e=this._wasm;return!(this._wasmLayerId<0||null==e)&&(e.isUpdating(this._wasmLayerId)||this.data.updating||this.fadeHelper.updating)}updatingFlagChanged(){this.notifyChange("updating")}async createRenderable(e){const t=e.meshData;if(null==t.data)throw new Error("meshData.data undefined");if(t.desc=JSON.parse(t.desc),null==t.desc)throw new Error("meshData.desc undefined");const i=t.desc.prims[0],s=i.vertexCount,r=i.atrbs[0].view,a=i.atrbs[0].view.byteCount,n=i.atrbs[0].view.byteOffset;let o=null;if("U32"!==r.type)return W().warnOnce("unexpected meshData.data format"),{memUsageBytes:0,numGaussians:0};o=new Uint32Array(t.data.buffer,n,a/4);const l=this.extractHeader(o),u=Math.ceil(s/I),m=new Uint32Array(s),p=new Array;let c=!1,f=0;const g=async e=>{for(;f<u&&!e.done&&!c;f++){let t=this.data.textureAtlas.requestPage();if(null===t&&(this._freeInvisibleTiles(),t=this.data.textureAtlas.requestPage()),null!==t){p.push(t);const i=s-f*I,r=Math.min(i,I),a=f*I;for(let e=0;e<r;e++)m[e+a]=e+G*t;const n=f*R;this._pageBuffer.set(o.subarray(n,n+r*V)),this._pageBuffer.set(l.packedHeader,R);const h=t*G,d=h%O,u=Math.floor(h/O);this.data.textureAtlas.update(d,u,this._pageBuffer),e.madeProgress()}else c=!0}f<u&&!c&&await this._frameTask.schedule(g)};if(await this._frameTask.schedule(g),c)return W().warnOnce("ran out of gaussian splat memory"),{memUsageBytes:0,numGaussians:0};const y=new Float32Array(3*s),_=new Float32Array(s),w=2.048,v=l.tileOrigin.x*w,b=l.tileOrigin.y*w,x=l.tileOrigin.z*w,S=l.invPosScale;let C=null;if(t.desc.obb){const e=t.desc.obb.quaternion;C=new U(t.desc.obb.center,t.desc.obb.halfSize,h(...e))}C||(W().warnOnce("encountered tile without a bounding box"),C=new U);const H=C.centerX,M=C.centerY,E=C.centerZ,j=new P,A=this.view.state.isGlobal,T=A?d(this.view.spatialReference).radius:0;let L=0,B=0,k=0;const D=async e=>{for(;k<s&&!e.done;k++){const t=k*V,{rawX:i,rawY:s,rawZ:r}=this._extractGaussianPosition(o,t),a=this._extractGaussianSphericalScale(o,t),n=i*S+v,l=s*S+b,h=r*S+x;y[L]=n-H,y[L+1]=l-M,y[L+2]=h-E;const d=A?Math.sqrt(n*n+l*l+h*h)-T:h;j.expandElevationRangeValues(d,d),_[k]=a*a,B=Math.max(B,a),L+=3,e.madeProgress()}k<s&&await this._frameTask.schedule(D)};await this._frameTask.schedule(D);const{fullExtent:N}=this.layer;N?.hasZ&&N.zmax&&N.zmin&&(j.minElevation=Math.max(j.minElevation,N.zmin),j.maxElevation=Math.min(j.maxElevation,N.zmax));const z=new F(e.handle,C,m,p,y,_,B,j);return this._memCache.put(`${z.handle}`,z),this._tileHandles.set(e.handle,z),this._cacheMemory+=z.usedMemory,{memUsageBytes:z.usedMemory,numGaussians:s}}_extractGaussianPosition(e,t){const i=e[t+1];return{rawX:16383&i,rawY:i>>>14&16383,rawZ:i>>>28&15|(1023&e[t+2])<<4}}_extractGaussianSphericalScale(e,t){const i=e[t+2],s=i>>>10&255,r=i>>>18&255,a=i>>>26&63|(3&e[t+3])<<6,n=Math.exp(s/16-10),o=Math.exp(r/16-10),l=Math.exp(a/16-10);return Math.max(n,o,l)}freeRenderable(e){const t=this._tileHandles.get(e);t&&(t.isVisible&&!this.fadeHelper.isTileFadingOut(t)?this._usedMemory-=t.usedMemory:this._cacheMemory-=t.usedMemory,t.pageIds.forEach(e=>this.data.textureAtlas.freePage(e)),this.freeObject(t),this._tileHandles.delete(e)),this.updateGaussians()}freeObject(e){this._memCache.pop(`${e.handle}`)}setRenderableVisibility(e,t,i){const s=this._tmpObbsWithChangedVisibility;s.length=0;for(let r=0;r<i;r++){if(!t[r])continue;const i=e[r],a=this._tileHandles.get(i);a&&(a.isVisible&&!this.fadeHelper.isTileFadingOut(a)||(a.isVisible=!0,s.push(a.obb),this.fadeHelper.isTileFadingOut(a)||this._popTileFromCache(a),this.fadeHelper.fadeTile(a,0)))}for(let r=0;r<i;r++){if(t[r])continue;const i=e[r],a=this._tileHandles.get(i);a&&a.isVisible&&(s.push(a.obb),this.fadeHelper.fadeTile(a,1))}s.length>0&&this._elevationProvider&&this._elevationProvider.notifyObjectsChanged(s),this.updateGaussians()}_popTileFromCache(e){this._usedMemory+=e.usedMemory,this._cacheMemory-=e.usedMemory,this._memCache.pop(`${e.handle}`)}moveTileToCache(e){this._usedMemory-=e.usedMemory,this._cacheMemory+=e.usedMemory,this._memCache.put(`${e.handle}`,e)}destroy(){M(this),this._suspendedHandle&&(this._suspendedHandle=i(this._suspendedHandle)),this._intersectionHandler&&(this.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler=null),this._elevationProvider&&this.view.elevationProvider&&(this._elevationProvider.notifyObjectsChangedFunctional(e=>{for(const t of this._tileHandles.values())e(t.obb)}),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this._frameTask.remove(),this._renderNode.destroy(),this.data.destroy(),this._memCache.destroy()}_canProjectWithoutEngine(){if(1===this.view.state.viewingMode)return!0;if(c(this.view.renderSpatialReference)||f(this.view.renderSpatialReference))return!0;if(this.layer.esriCrsSpatialReference&&g(this.layer.esriCrsSpatialReference,this.view.renderSpatialReference)){if(115700===this.layer.esriCrsSpatialReference.vcsWkid)return!1;let e=w(this.layer.esriCrsSpatialReference);if(!e){const t=this.layer.esriCrsSpatialReference;let i="meters";!y(t)&&t.wkid&&-1!==t.wkid&&(i=a(_.units[_[t.wkid]])),i&&(e=new u({heightModel:"gravity-related-height",heightUnit:i}))}const t=this.view.heightModelInfo;return this._useEsriCrs=0===p(e,t,!1),this._useEsriCrs&&(e&&(this._metersPerVCSUnit=n(1,"meters",e.heightUnit)),this.fullExtentInLocalViewSpatialReference=this.layer.esriCrsFullExtent),this._useEsriCrs}return!1}_elevationInfoChanged(e){if(e?.offset)if(this._useEsriCrs){const t=b(e?.unit)/this._metersPerVCSUnit,i=e?.offset??0;this._wasm?.setLayerOffset(this,i*t)}else this._wasm?.setLayerOffset(this,v(e));else this._wasm?.setLayerOffset(this,0)}_slicePlaneEnabledChanged(e){this._renderNode&&(this._renderNode.slicePlaneEnabled=e),this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e)}updateGaussians(){const e=new Array;for(const t of this._tileHandles.values())t.isVisible&&e.push(t);this.data.updateGaussianVisibility(e),this.notifyChange("updating")}setMaximumGaussianCount(e){this._wasm?.setMaximumGaussianSplatCount(e)}_freeInvisibleTiles(){for(const e of this._tileHandles.values())e.isVisible||this._deleteTile(e)}extractHeader(e){const t=e.length-4,i=this.reinterpretU32AsFloat(e[t]),s=this.reinterpretU32AsFloat(e[t+1]),r=this.reinterpretU32AsFloat(e[t+2]),a=1/(1<<(255&e[t+3]));return{packedHeader:e.subarray(t,t+4),tileOrigin:{x:i,y:s,z:r},invPosScale:a}}_deleteTile(e){this._wasm?.onRenderableEvicted(this,e.handle,e.usedMemory),this.freeRenderable(e.handle)}reinterpretU32AsFloat(e){return this._u32View[0]=e,this._f32View[0]}get performanceInfo(){let e=0,t=0;return this._tileHandles.forEach(i=>{i.isVisible?e++:t++}),new x(this.usedMemory,e,t,this.cachedMemory)}get test(){}};e([o()],$.prototype,"layer",void 0),e([o({readOnly:!0})],$.prototype,"_clippingBox",null),e([o()],$.prototype,"elevationOffset",null),e([o({readOnly:!0})],$.prototype,"visibleAtCurrentScale",null),e([o()],$.prototype,"fullExtentInLocalViewSpatialReference",void 0),$=e([l("esri.views.3d.layers.GaussianSplatLayerView3D")],$);const X=$;export{X as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{unique as r}from"../../../core/arrayUtils.js";import{EventEmitter as t}from"../../../core/Evented.js";import"../../../core/has.js";import{someMap as s,everyMap as i}from"../../../core/MapUtils.js";import{disposeMaybe as n}from"../../../core/maybe.js";import a from"../../../core/PooledArray.js";import{watch as o,syncAndInitial as h,on as d,initial as l}from"../../../core/reactiveUtils.js";import{someSet as c}from"../../../core/SetUtils.js";import{property as u,subclass as p}from"../../../core/accessorSupport/decorators.js";import{ortho as _,fromTranslation as g}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{set as m}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{ones as y}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{debugFlags as f}from"../support/debugFlags.js";import{Overlay as R}from"./Overlay.js";import{OverlayRenderTargets as v}from"./OverlayRenderTargets.js";import x from"../webgl/RenderCamera.js";import{SyncRenderPlugin as T}from"../webgl-engine/effects/RenderPlugin.js";import{trackHighlightOptions as w,renderHighlightBuffer as b}from"../webgl-engine/effects/highlight/Highlight.js";import{GLMaterialRepository as S}from"../webgl-engine/lib/GLMaterialRepository.js";import{GridLocalOriginFactory as O}from"../webgl-engine/lib/GridLocalOriginFactory.js";import{RenderContext as D,defaultRenderOccludedMask as C}from"../webgl-engine/lib/RenderContext.js";import{ShadowMap as P}from"../webgl-engine/lib/ShadowMap.js";import{T as j}from"../../../chunks/Texture.glsl.js";import{TextureTechnique as E}from"../webgl-engine/lib/TextureTechnique.js";import{TextureTechniqueConfiguration as M}from"../webgl-engine/lib/TextureTechniqueConfiguration.js";import{AmbientLight as F}from"../webgl-engine/lighting/Lightsources.js";import{O as W}from"../../../chunks/OverlayCompositing.glsl.js";import{OverlayCompositingTechnique as q}from"../webgl-engine/shaders/OverlayCompositingTechnique.js";import{TaskPriority as V,noBudget as A}from"../../support/Scheduler.js";import G from"../../webgl/Texture.js";import{TextureDescriptor as k}from"../../webgl/TextureDescriptor.js";let I=class extends T{constructor(e){super(e),this._overlays=null,this._renderTargets=null,this._overlayParameters=new W,this.hasHighlights=!1,this.renderOccludedFlags=1,this._hasWater=!1,this._renderers=new Map,this._sortedDrapeSourceRenderersDirty=!1,this._sortedRenderers=new a,this._passParameters=new j,this._screenToWorldRatio=1,this._localOriginFactory=null,this.unloadedMemory=0,this.ignoresMemoryFactor=!1,this._camera=new x,this.events=new t,this.longitudeCyclical=null,this.produces=new Map([[19,e=>10!==e||this.hasHighlights],[20,()=>this._hasWater]]),this._hasTargetWithoutRasterImage=!1,this._hasDrapedFeatureSource=!1,this._hasDrapedRasterSource=!1,this._hasDrapedFlowSource=!1}initialize(){const e=this._view,r=e.stage,t=r.renderer.fboCache,{waterTextures:s,techniques:i}=r.renderView;this._renderContext=new D(this._rctx,new P(t,e.state.viewingMode),i),this.addHandles([o(()=>s.updating,()=>this.events.emit("content-changed"),h),o(()=>this._spatialReference,e=>this._localOriginFactory=new O(e),h),d(()=>e.allLayerViews,"after-changes",()=>this._sortedDrapeSourceRenderersDirty=!0),o(()=>w(e.state.highlights),()=>this._sortedDrapeSourceRenderersDirty=!0,l),o(()=>e.state.highlights,r=>{this._bindParameters.highlights=r,this._bindParameters.highlightOrderMap=e.state.highlightOrderMap},l),e.resourceController.scheduler.registerTask(V.OVERLAY_RENDERER,this)]);const n=this._camera;n.near=1,n.far=1e4,n.relativeElevation=null,this._bindParameters.slot=19,this._bindParameters.camera=n,this._bindParameters.updateLighting(new F(y()),0,0,0)}destroy(){this._renderers.forEach(e=>e.destroy()),this._renderers.clear(),this._passParameters.texture=n(this._passParameters.texture),this.disposeOverlays(),this._renderContext=null,this._sortedRenderers.prune()}get _bindParameters(){return this._renderContext.bind}get _rctx(){return this._stage.renderView.renderingContext}get _view(){return this.parent.view}get _stage(){return this.parent.view.stage}get _spatialReference(){return this.parent.spatialReference}get _techniques(){return this._stage.renderView.techniques}get rctx(){return this._rctx}get materials(){return this._pluginContext.materials}get screenToWorldRatio(){return this._screenToWorldRatio}get localOriginFactory(){return this._localOriginFactory}set time(e){this._renderContext.time=e}get pluginContext(){return this._pluginContext}initializeRenderContext(e){const r=new S(this._view.stage.renderView.textures,this._techniques,()=>{this._onMaterialOrContentChanged(),this.events.emit("content-changed"),this.notifyChange("updating"),this.notifyChange("isEmpty")},()=>this.events.emit("content-changed"));this._pluginContext={...e,materials:r},this._techniques.precompile(q)}uninitializeRenderContext(){}acquireTechniques(){return[]}render(){}get updating(){return this._sortedDrapeSourceRenderersDirty||s(this._renderers,e=>e.updating||e.canCompact)}get hasOverlays(){return null!=this._overlays&&null!=this._renderTargets}getMaterialRenderer(e){for(const r of this._renderers.values()){const t=r.getMaterialRenderer(e);if(t)return t}return null}get layers(){return this._sortedDrapeSourceRenderersDirty&&this._updateSortedDrapeSourceRenderers(),r(this._sortedRenderers.map(e=>e.drapeSource.layer).filter(e=>!!e))}registerDrapeSource(e,r){const t=this._renderers.get(e);null!=t&&t.destroy(),this._renderers.set(e,r),this._sortedDrapeSourceRenderersDirty=!0,"fullOpacity"in e&&this.addHandles(o(()=>e.fullOpacity,()=>this.events.emit("content-changed")),e)}removeDrapeSourceRenderer(e){if(null==e)return;const r=this._renderers.get(e);null!=r&&(this._sortedDrapeSourceRenderersDirty=!0,this._renderers.delete(e),this.removeHandles(e),r.destroy())}computeValidity(){return this._renderTargets?.computeValidity()??0}releaseRenderTargets(e){this._renderTargets?.dispose(e)}get overlays(){return this._overlays??[]}ensureDrapeTargets(e){this._hasTargetWithoutRasterImage=!!this._overlays&&c(e,e=>1===e.drapeTargetType)}ensureDrapeSources(e){this._overlays?(this._hasDrapedFeatureSource=c(e,e=>1===e.drapeSourceType),this._hasDrapedRasterSource=c(e,e=>0===e.drapeSourceType),this._hasDrapedFlowSource=c(e,e=>2===e.drapeSourceType)):this._hasDrapedFeatureSource=this._hasDrapedRasterSource=this._hasDrapedFlowSource=!1}get _needsColorWithoutRasterImage(){return this._hasDrapedRasterSource&&this._hasDrapedFeatureSource&&this._hasTargetWithoutRasterImage}ensureOverlays(e,r,t=this._bindParameters.overlayStretch){null==this._overlays&&(this._renderTargets=new v(this._stage.renderer.fboCache),this._overlays=[new R,new R]),this.ensureDrapeTargets(e),this.ensureDrapeSources(r),this._bindParameters.overlayStretch=t}disposeOverlays(){this._overlays=null,this._renderTargets?.dispose(1),this._renderTargets=null,this.events.emit("textures-disposed")}_useOverlayColorInsteadOfColorNoRasterImage(e){return 1===e&&!this._needsColorWithoutRasterImage&&this._hasDrapedFeatureSource}getTexture(e){const r=this._useOverlayColorInsteadOfColorNoRasterImage(e);return this._renderTargets?.getTexture(r?0:e)}get readyToRun(){return this.updating}runTask(e){this._processDrapeSources(e,()=>!0)}_onMaterialOrContentChanged(){this.renderOccludedFlags=s(this._renderers,e=>e.hasOccluders)?L:1}_processDrapeSources(e,r){let t=!1;for(const[s,i]of this._renderers){if(e.done)break;(s.destroyed||r(s))&&(i.commitChanges()&&(t=!0,e.madeProgress()))}this._sortedDrapeSourceRenderersDirty&&(this._sortedDrapeSourceRenderersDirty=!1,t=!0,this._updateSortedDrapeSourceRenderers(),e.madeProgress()),this.compact(e),t&&(null!=this._overlays&&0===this._renderers.size&&this.disposeOverlays(),this.notifyChange("updating"),this.notifyChange("isEmpty"),this._onMaterialOrContentChanged(),this.hasHighlights=s(this._renderers,e=>e.hasHighlights),this.events.emit("content-changed"))}compact(e){let r=!1;for(const t of this._renderers.values()){if(e.done)break;r=t.compact(e)||r}return r&&this.notifyChange("updating"),r}hasHighlight(e){return s(this._renderers,r=>r.hasHighlight(e))}processSyncDrapeSources(){this._processDrapeSources(A,e=>1===e.updatePolicy)}get isEmpty(){return!f.OVERLAY_DRAW_DEBUG_TEXTURE&&i(this._renderers,e=>e.isEmpty)}get hasWater(){const e=s(this._renderers,({hasWater:e})=>e);return e!==this._hasWater&&(this._hasWater=e,this.events.emit("has-water")),this._hasWater}renders(e){if(f.OVERLAY_DRAW_DEBUG_TEXTURE&&4!==e&&2!==e)return!0;if(!this._overlays)return!1;const r=this._overlays[0];for(const i of this._overlays)i.setupGeometryViews(this.longitudeCyclical);if(!r.hasSomeSizedView())return!1;const t=this._setOutput(this._renderTargets?.targets.find(r=>r.content===e)?.output??0);++this._techniques.precompiling;const s=this._sortedRenderers.some(({renderer:e})=>e.precompile(this._renderContext));return--this._techniques.precompiling,this._setOutput(t),s}_setOutput(e){const r=this._bindParameters.output;return this._bindParameters.output=e,this._bindParameters.slot=4===e?20:19,r}get mode(){return this.isEmpty?0:this.hasWater&&this.renders(3)?2:this._renderTargets?.getTexture(0)?1:0}updateAnimation(e){let r=!1;return this._renderers.forEach(t=>r=t.updateAnimation(e)||r),r&&this.parent.requestRender(0),r}updateDrapeSourceOrder(){this._sortedDrapeSourceRenderersDirty=!0}precompileShaders(e){if(!this._overlays||!this._renderTargets)return!1;const r=this._bindParameters;r.alignPixelEnabled=e.alignPixelEnabled,++this._techniques.precompiling;for(const t of this._renderTargets.targets){if(1===t.content&&!this._needsColorWithoutRasterImage)continue;const{output:e}=t;this._setOutput(e),10===e&&(r.highlightMixTexture=r.highlights.length>1?this._rctx.emptyTexture:null);const s=this._renderContext.renderOccludedMask;4===t.content&&(this._renderContext.renderOccludedMask=L),this._sortedRenderers.forAll(({drapeSource:e,renderer:r})=>{1===t.content&&0===e.drapeSourceType||4===t.content&&r.hasOnlyOccluders||r.precompile(this._renderContext)}),this._renderContext.renderOccludedMask=s,r.highlightMixTexture=null}return--this._techniques.precompiling,!0}drawOverlays(e,r){if(!this._overlays||!this._renderTargets)return;for(const s of this._overlays)s.setupGeometryViews(this.longitudeCyclical);this._bindParameters.alignPixelEnabled=e.alignPixelEnabled;const t=this.allSourcesOccluders;for(const s of this._renderTargets.targets){if(!(0===s.content&&this._hasDrapedFlowSource)&&!s.handleRenderRequest(r)||1===s.content&&!this._needsColorWithoutRasterImage||4===s.content&&t)continue;const e=this._drawTarget(0,s),i=this._drawTarget(1,s);(e||i)&&s.fbo.generateMipMap()}}_drawTarget(e,r){const t=this._overlays[e],s=t.canvasGeometries;if(0===s.numViews)return!1;const i=this._view.state.contentPixelRatio;this._screenToWorldRatio=i*t.mapUnitsPerPixel/this._bindParameters.overlayStretch;const{output:n,content:a}=r;if(this.isEmpty||4===n&&!this.hasWater||!t.hasSomeSizedView())return!1;const{_rctx:o,_camera:h,_renderContext:d,_bindParameters:l}=this;if(h.pixelRatio=t.pixelRatio*i,this._setOutput(n),l.screenToWorldRatio=this._screenToWorldRatio,l.screenToPCSRatio=this._screenToWorldRatio*this.parent.worldToPCSRatio,4===a&&(d.renderOccludedMask=L),!this.renders(a))return d.renderOccludedMask=C,!1;const{resolution:c}=t,u=0===e,p=u?0:c;o.setViewport(p,0,c,c),this._bindTargetFBO(r),u&&(10===n?o.gl.clearBufferuiv(o.gl.COLOR,0,[0,0,0,0]):(o.setClearColor(0,0,0,0),o.clear(16384)));if(f.OVERLAY_DRAW_DEBUG_TEXTURE&&4!==a&&2!==a){this._techniques.precompile(E,z);const r=this._techniques.get(E,z);for(let i=0;i<s.numViews;i++)this._setViewParameters(s.extents[i],t),this._ensureDebugPatternResources(t.resolution,B[e]),o.bindTechnique(r,l,this._passParameters),o.screen.draw()}if(10===n){const{fboCache:t}=this._stage.renderer,s=this._resolution;this._bindTargetFBO(r),b(o,t,s,s,l,()=>this._renderAllGeometry(e,r),p)}else this._renderAllGeometry(e,r);return o.bindFramebuffer(null),d.renderOccludedMask=C,!0}get allSourcesOccluders(){return i(this._renderers,e=>e.hasOnlyOccluders)}_renderAllGeometry(e,r){const t=this._overlays[e],s=t.canvasGeometries;this._sortedRenderers.forAll(({drapeSource:i,renderer:n})=>{if(1===r.content&&0===i.drapeSourceType)return;const{fullOpacity:a}=i,o=null!=a&&a<1&&0===r.output&&this._bindTemporaryFBO();for(let e=0;e<s.numViews;e++)this._setViewParameters(s.extents[e],t),n.render(this._renderContext);if(o){this._bindTargetFBO(r),this._overlayParameters.texture=o.getTexture(),this._overlayParameters.opacity=a,this._overlayParameters.overlayIndex=e;const t=this._techniques.get(q);this._rctx.bindTechnique(t,this._bindParameters,this._overlayParameters),this._rctx.screen.draw(),o.release()}})}_bindTargetFBO(e){const r=this._resolution,t=2*r;e.fbo.ensureFramebuffer(t,r),e.fbo.bind(this._rctx)}_bindTemporaryFBO(){const e=this._resolution,r=2*e,t=this._stage.renderer.fboCache,s=t.acquire(r,e,"overlay tmp");return t.rctx.bindFramebuffer(s.fbo),t.rctx.clear(16384),s}get _resolution(){return this._overlays?.[0].resolution??0}notifyContentChanged(){this.events.emit("content-changed")}intersect(e,r,t,s){this._sortedDrapeSourceRenderersDirty&&this._updateSortedDrapeSourceRenderers();let i=0;for(const{renderer:n}of this._sortedRenderers)i=n.intersect?.(e,r,t,s,i)??i}_updateSortedDrapeSourceRenderers(){if(this._sortedRenderers.clear(),0===this._renderers.size)return;const e=this._view.map.allLayers.map(e=>e.uid),r=e.length;this._renderers.forEach((t,s)=>{const i=e.indexOf(s.layer?.uid),n=i>=0,a=s.renderGroup??(n?0:1),o=s.drapeSourcePriorityOffset??0,h=r*a+(n?i:0)+o;this._sortedRenderers.push(new U(s,t,h))}),this._sortedRenderers.sort((e,r)=>e.index-r.index)}_setViewParameters(e,r){const t=this._camera;t.viewport=[0,0,r.resolution,r.resolution],_(t.projectionMatrix,0,e[2]-e[0],0,e[3]-e[1],t.near,t.far),g(t.viewMatrix,[-e[0],-e[1],0])}_ensureDebugPatternResources(e,r){if(m(this._passParameters.color,r[0],r[1],r[2]),this._passParameters.texture)return;const t=new Uint8Array(e*e*4);let s=0;for(let n=0;n<e;n++)for(let r=0;r<e;r++){const i=Math.floor(r/10),a=Math.floor(n/10);i<2||a<2||10*i>e-20||10*a>e-20?(t[s++]=255,t[s++]=255,t[s++]=255,t[s++]=255):(t[s++]=255,t[s++]=255,t[s++]=255,t[s++]=1&i&&1&a?1&r^1&n?0:255:1&i^1&a?0:128)}const i=new k(e);i.samplingMode=9728,this._passParameters.texture=new G(this._rctx,i,t)}get test(){}};e([u()],I.prototype,"hasHighlights",void 0),e([u()],I.prototype,"renderOccludedFlags",void 0),e([u()],I.prototype,"_sortedDrapeSourceRenderersDirty",void 0),e([u({constructOnly:!0})],I.prototype,"parent",void 0),e([u({readOnly:!0})],I.prototype,"_techniques",null),e([u({type:Boolean,readOnly:!0})],I.prototype,"updating",null),e([u()],I.prototype,"isEmpty",null),I=e([p("esri.views.3d.terrain.OverlayRenderer")],I);class U{constructor(e,r,t){this.drapeSource=e,this.renderer=r,this.index=t}}const B=[[1,.5,.5],[.5,.5,1]],H=-2,L=4,z=new M;z.hasAlpha=!0;export{I as OverlayRenderer,H as drapedZ,L as overlayRenderOccludedFlag};
|
|
2
|
+
import{__decorate as e}from"tslib";import{unique as r}from"../../../core/arrayUtils.js";import{EventEmitter as t}from"../../../core/Evented.js";import"../../../core/has.js";import{someMap as s,everyMap as i}from"../../../core/MapUtils.js";import{disposeMaybe as n}from"../../../core/maybe.js";import a from"../../../core/PooledArray.js";import{watch as o,syncAndInitial as h,on as d,initial as l}from"../../../core/reactiveUtils.js";import{someSet as c}from"../../../core/SetUtils.js";import{property as u,subclass as p}from"../../../core/accessorSupport/decorators.js";import{ortho as _,fromTranslation as g}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{set as m}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{ones as y}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{debugFlags as f}from"../support/debugFlags.js";import{Overlay as R}from"./Overlay.js";import{OverlayRenderTargets as v}from"./OverlayRenderTargets.js";import w from"../webgl/RenderCamera.js";import{SyncRenderPlugin as x}from"../webgl-engine/effects/RenderPlugin.js";import{trackHighlightOptions as T,renderHighlightBuffer as b}from"../webgl-engine/effects/highlight/Highlight.js";import{GLMaterialRepository as S}from"../webgl-engine/lib/GLMaterialRepository.js";import{GridLocalOriginFactory as O}from"../webgl-engine/lib/GridLocalOriginFactory.js";import{RenderContext as D,defaultRenderOccludedMask as C}from"../webgl-engine/lib/RenderContext.js";import{ShadowMap as P}from"../webgl-engine/lib/ShadowMap.js";import{T as j}from"../../../chunks/Texture.glsl.js";import{TextureTechnique as E}from"../webgl-engine/lib/TextureTechnique.js";import{TextureTechniqueConfiguration as M}from"../webgl-engine/lib/TextureTechniqueConfiguration.js";import{AmbientLight as F}from"../webgl-engine/lighting/Lightsources.js";import{O as W}from"../../../chunks/OverlayCompositing.glsl.js";import{OverlayCompositingTechnique as V}from"../webgl-engine/shaders/OverlayCompositingTechnique.js";import{TaskPriority as q,noBudget as A}from"../../support/Scheduler.js";import G from"../../webgl/Texture.js";import{TextureDescriptor as k}from"../../webgl/TextureDescriptor.js";let I=class extends x{constructor(e){super(e),this._overlays=null,this._renderTargets=null,this._overlayParameters=new W,this.hasHighlights=!1,this.renderOccludedFlags=1,this._hasWater=!1,this._renderers=new Map,this._sortedDrapeSourceRenderersDirty=!1,this._sortedRenderers=new a,this._passParameters=new j,this._screenToWorldRatio=1,this._localOriginFactory=null,this.unloadedMemory=0,this.ignoresMemoryFactor=!1,this._camera=new w,this.events=new t,this.longitudeCyclical=null,this.produces=new Map([[19,e=>10!==e||this.hasHighlights],[20,()=>this._hasWater]]),this._hasTargetWithoutRasterImage=!1,this._hasDrapedFeatureSource=!1,this._hasDrapedRasterSource=!1,this._hasDrapedFlowSource=!1;const{state:r,stage:s}=e.parent.view,i=s.renderer.fboCache,n=s.renderView.renderingContext,o=s.renderView.techniques;this._renderContext=new D(n,new P(i,r.viewingMode),o)}initialize(){const e=this._view,r=e.stage.renderView.waterTextures;this.addHandles([o(()=>r.updating,()=>this.events.emit("content-changed"),h),o(()=>this._spatialReference,e=>this._localOriginFactory=new O(e),h),d(()=>e.allLayerViews,"after-changes",()=>this._sortedDrapeSourceRenderersDirty=!0),o(()=>T(e.state.highlights),()=>this._sortedDrapeSourceRenderersDirty=!0,l),o(()=>e.state.highlights,r=>{this._bindParameters.highlights=r,this._bindParameters.highlightOrderMap=e.state.highlightOrderMap},l),e.resourceController.scheduler.registerTask(q.OVERLAY_RENDERER,this)]);const t=this._camera;t.near=1,t.far=1e4,t.relativeElevation=null,this._bindParameters.slot=19,this._bindParameters.camera=t,this._bindParameters.updateLighting(new F(y()),0,0,0)}destroy(){this._renderers.forEach(e=>e.destroy()),this._renderers.clear(),this._passParameters.texture=n(this._passParameters.texture),this.disposeOverlays(),this._renderContext.destroy(),this._sortedRenderers.prune()}get _bindParameters(){return this._renderContext.bind}get _rctx(){return this._stage.renderView.renderingContext}get _view(){return this.parent.view}get _stage(){return this.parent.view.stage}get _spatialReference(){return this.parent.spatialReference}get _techniques(){return this._stage.renderView.techniques}get rctx(){return this._rctx}get materials(){return this._pluginContext.materials}get screenToWorldRatio(){return this._screenToWorldRatio}get localOriginFactory(){return this._localOriginFactory}set time(e){this._renderContext.time=e}get pluginContext(){return this._pluginContext}initializeRenderContext(e){const r=new S(this._view.stage.renderView.textures,this._techniques,()=>{this._onMaterialOrContentChanged(),this.events.emit("content-changed"),this.notifyChange("updating"),this.notifyChange("isEmpty")},()=>this.events.emit("content-changed"));this._pluginContext={...e,materials:r},this._techniques.precompile(V)}uninitializeRenderContext(){}acquireTechniques(){return[]}render(){}get updating(){return this._sortedDrapeSourceRenderersDirty||s(this._renderers,e=>e.updating||e.canCompact)}get hasOverlays(){return null!=this._overlays&&null!=this._renderTargets}getMaterialRenderer(e){for(const r of this._renderers.values()){const t=r.getMaterialRenderer(e);if(t)return t}return null}get layers(){return this._sortedDrapeSourceRenderersDirty&&this._updateSortedDrapeSourceRenderers(),r(this._sortedRenderers.map(e=>e.drapeSource.layer).filter(e=>!!e))}registerDrapeSource(e,r){const t=this._renderers.get(e);null!=t&&t.destroy(),this._renderers.set(e,r),this._sortedDrapeSourceRenderersDirty=!0,"fullOpacity"in e&&this.addHandles(o(()=>e.fullOpacity,()=>this.events.emit("content-changed")),e)}removeDrapeSourceRenderer(e){if(null==e)return;const r=this._renderers.get(e);null!=r&&(this._sortedDrapeSourceRenderersDirty=!0,this._renderers.delete(e),this.removeHandles(e),r.destroy())}computeValidity(){return this._renderTargets?.computeValidity()??0}releaseRenderTargets(e){this._renderTargets?.dispose(e)}get overlays(){return this._overlays??[]}ensureDrapeTargets(e){this._hasTargetWithoutRasterImage=!!this._overlays&&c(e,e=>1===e.drapeTargetType)}ensureDrapeSources(e){this._overlays?(this._hasDrapedFeatureSource=c(e,e=>1===e.drapeSourceType),this._hasDrapedRasterSource=c(e,e=>0===e.drapeSourceType),this._hasDrapedFlowSource=c(e,e=>2===e.drapeSourceType)):this._hasDrapedFeatureSource=this._hasDrapedRasterSource=this._hasDrapedFlowSource=!1}get _needsColorWithoutRasterImage(){return this._hasDrapedRasterSource&&this._hasDrapedFeatureSource&&this._hasTargetWithoutRasterImage}ensureOverlays(e,r,t=this._bindParameters.overlayStretch){null==this._overlays&&(this._renderTargets=new v(this._stage.renderer.fboCache),this._overlays=[new R,new R]),this.ensureDrapeTargets(e),this.ensureDrapeSources(r),this._bindParameters.overlayStretch=t}disposeOverlays(){this._overlays=null,this._renderTargets?.dispose(1),this._renderTargets=null,this.events.emit("textures-disposed")}_useOverlayColorInsteadOfColorNoRasterImage(e){return 1===e&&!this._needsColorWithoutRasterImage&&this._hasDrapedFeatureSource}getTexture(e){const r=this._useOverlayColorInsteadOfColorNoRasterImage(e);return this._renderTargets?.getTexture(r?0:e)}get readyToRun(){return this.updating}runTask(e){this._processDrapeSources(e,()=>!0)}_onMaterialOrContentChanged(){this.renderOccludedFlags=s(this._renderers,e=>e.hasOccluders)?L:1}_processDrapeSources(e,r){let t=!1;for(const[s,i]of this._renderers){if(e.done)break;(s.destroyed||r(s))&&(i.commitChanges()&&(t=!0,e.madeProgress()))}this._sortedDrapeSourceRenderersDirty&&(this._sortedDrapeSourceRenderersDirty=!1,t=!0,this._updateSortedDrapeSourceRenderers(),e.madeProgress()),this.compact(e),t&&(null!=this._overlays&&0===this._renderers.size&&this.disposeOverlays(),this.notifyChange("updating"),this.notifyChange("isEmpty"),this._onMaterialOrContentChanged(),this.hasHighlights=s(this._renderers,e=>e.hasHighlights),this.events.emit("content-changed"))}compact(e){let r=!1;for(const t of this._renderers.values()){if(e.done)break;r=t.compact(e)||r}return r&&this.notifyChange("updating"),r}hasHighlight(e){return s(this._renderers,r=>r.hasHighlight(e))}processSyncDrapeSources(){this._processDrapeSources(A,e=>1===e.updatePolicy)}get isEmpty(){return!f.OVERLAY_DRAW_DEBUG_TEXTURE&&i(this._renderers,e=>e.isEmpty)}get hasWater(){const e=s(this._renderers,({hasWater:e})=>e);return e!==this._hasWater&&(this._hasWater=e,this.events.emit("has-water")),this._hasWater}renders(e){if(f.OVERLAY_DRAW_DEBUG_TEXTURE&&4!==e&&2!==e)return!0;if(!this._overlays)return!1;const r=this._overlays[0];for(const i of this._overlays)i.setupGeometryViews(this.longitudeCyclical);if(!r.hasSomeSizedView())return!1;const t=this._setOutput(this._renderTargets?.targets.find(r=>r.content===e)?.output??0);++this._techniques.precompiling;const s=this._sortedRenderers.some(({renderer:e})=>e.precompile(this._renderContext));return--this._techniques.precompiling,this._setOutput(t),s}_setOutput(e){const r=this._bindParameters.output;return this._bindParameters.output=e,this._bindParameters.slot=4===e?20:19,r}get mode(){return this.isEmpty?0:this.hasWater&&this.renders(3)?2:this._renderTargets?.getTexture(0)?1:0}updateAnimation(e){let r=!1;return this._renderers.forEach(t=>r=t.updateAnimation(e)||r),r&&this.parent.requestRender(0),r}updateDrapeSourceOrder(){this._sortedDrapeSourceRenderersDirty=!0}precompileShaders(e){if(!this._overlays||!this._renderTargets)return!1;const r=this._bindParameters;r.alignPixelEnabled=e.alignPixelEnabled,++this._techniques.precompiling;for(const t of this._renderTargets.targets){if(1===t.content&&!this._needsColorWithoutRasterImage)continue;const{output:e}=t;this._setOutput(e),10===e&&(r.highlightMixTexture=r.highlights.length>1?this._rctx.emptyTexture:null);const s=this._renderContext.renderOccludedMask;4===t.content&&(this._renderContext.renderOccludedMask=L),this._sortedRenderers.forAll(({drapeSource:e,renderer:r})=>{1===t.content&&0===e.drapeSourceType||4===t.content&&r.hasOnlyOccluders||r.precompile(this._renderContext)}),this._renderContext.renderOccludedMask=s,r.highlightMixTexture=null}return--this._techniques.precompiling,!0}drawOverlays(e,r){if(!this._overlays||!this._renderTargets)return;for(const s of this._overlays)s.setupGeometryViews(this.longitudeCyclical);this._bindParameters.alignPixelEnabled=e.alignPixelEnabled;const t=this.allSourcesOccluders;for(const s of this._renderTargets.targets){if(!(0===s.content&&this._hasDrapedFlowSource)&&!s.handleRenderRequest(r)||1===s.content&&!this._needsColorWithoutRasterImage||4===s.content&&t)continue;const e=this._drawTarget(0,s),i=this._drawTarget(1,s);(e||i)&&s.fbo.generateMipMap()}}_drawTarget(e,r){const t=this._overlays[e],s=t.canvasGeometries;if(0===s.numViews)return!1;const i=this._view.state.contentPixelRatio;this._screenToWorldRatio=i*t.mapUnitsPerPixel/this._bindParameters.overlayStretch;const{output:n,content:a}=r;if(this.isEmpty||4===n&&!this.hasWater||!t.hasSomeSizedView())return!1;const{_rctx:o,_camera:h,_renderContext:d,_bindParameters:l}=this;if(h.pixelRatio=t.pixelRatio*i,this._setOutput(n),l.screenToWorldRatio=this._screenToWorldRatio,l.screenToPCSRatio=this._screenToWorldRatio*this.parent.worldToPCSRatio,4===a&&(d.renderOccludedMask=L),!this.renders(a))return d.renderOccludedMask=C,!1;const{resolution:c}=t,u=0===e,p=u?0:c;o.setViewport(p,0,c,c),this._bindTargetFBO(r),u&&(10===n?o.gl.clearBufferuiv(o.gl.COLOR,0,[0,0,0,0]):(o.setClearColor(0,0,0,0),o.clear(16384)));if(f.OVERLAY_DRAW_DEBUG_TEXTURE&&4!==a&&2!==a){this._techniques.precompile(E,z);const r=this._techniques.get(E,z);for(let i=0;i<s.numViews;i++)this._setViewParameters(s.extents[i],t),this._ensureDebugPatternResources(t.resolution,B[e]),o.bindTechnique(r,l,this._passParameters),o.screen.draw()}if(10===n){const{fboCache:t}=this._stage.renderer,s=this._resolution;this._bindTargetFBO(r),b(o,t,s,s,l,()=>this._renderAllGeometry(e,r),p)}else this._renderAllGeometry(e,r);return o.bindFramebuffer(null),d.renderOccludedMask=C,!0}get allSourcesOccluders(){return i(this._renderers,e=>e.hasOnlyOccluders)}_renderAllGeometry(e,r){const t=this._overlays[e],s=t.canvasGeometries;this._sortedRenderers.forAll(({drapeSource:i,renderer:n})=>{if(1===r.content&&0===i.drapeSourceType)return;const{fullOpacity:a}=i,o=null!=a&&a<1&&0===r.output&&this._bindTemporaryFBO();for(let e=0;e<s.numViews;e++)this._setViewParameters(s.extents[e],t),n.render(this._renderContext);if(o){this._bindTargetFBO(r),this._overlayParameters.texture=o.getTexture(),this._overlayParameters.opacity=a,this._overlayParameters.overlayIndex=e;const t=this._techniques.get(V);this._rctx.bindTechnique(t,this._bindParameters,this._overlayParameters),this._rctx.screen.draw(),o.release()}})}_bindTargetFBO(e){const r=this._resolution,t=2*r;e.fbo.ensureFramebuffer(t,r),e.fbo.bind(this._rctx)}_bindTemporaryFBO(){const e=this._resolution,r=2*e,t=this._stage.renderer.fboCache,s=t.acquire(r,e,"overlay tmp");return t.rctx.bindFramebuffer(s.fbo),t.rctx.clear(16384),s}get _resolution(){return this._overlays?.[0].resolution??0}notifyContentChanged(){this.events.emit("content-changed")}intersect(e,r,t,s){this._sortedDrapeSourceRenderersDirty&&this._updateSortedDrapeSourceRenderers();let i=0;for(const{renderer:n}of this._sortedRenderers)i=n.intersect?.(e,r,t,s,i)??i}_updateSortedDrapeSourceRenderers(){if(this._sortedRenderers.clear(),0===this._renderers.size)return;const e=this._view.map.allLayers.map(e=>e.uid),r=e.length;this._renderers.forEach((t,s)=>{const i=e.indexOf(s.layer?.uid),n=i>=0,a=s.renderGroup??(n?0:1),o=s.drapeSourcePriorityOffset??0,h=r*a+(n?i:0)+o;this._sortedRenderers.push(new U(s,t,h))}),this._sortedRenderers.sort((e,r)=>e.index-r.index)}_setViewParameters(e,r){const t=this._camera;t.viewport=[0,0,r.resolution,r.resolution],_(t.projectionMatrix,0,e[2]-e[0],0,e[3]-e[1],t.near,t.far),g(t.viewMatrix,[-e[0],-e[1],0])}_ensureDebugPatternResources(e,r){if(m(this._passParameters.color,r[0],r[1],r[2]),this._passParameters.texture)return;const t=new Uint8Array(e*e*4);let s=0;for(let n=0;n<e;n++)for(let r=0;r<e;r++){const i=Math.floor(r/10),a=Math.floor(n/10);i<2||a<2||10*i>e-20||10*a>e-20?(t[s++]=255,t[s++]=255,t[s++]=255,t[s++]=255):(t[s++]=255,t[s++]=255,t[s++]=255,t[s++]=1&i&&1&a?1&r^1&n?0:255:1&i^1&a?0:128)}const i=new k(e);i.samplingMode=9728,this._passParameters.texture=new G(this._rctx,i,t)}get test(){}};e([u()],I.prototype,"hasHighlights",void 0),e([u()],I.prototype,"renderOccludedFlags",void 0),e([u()],I.prototype,"_sortedDrapeSourceRenderersDirty",void 0),e([u({constructOnly:!0})],I.prototype,"parent",void 0),e([u({readOnly:!0})],I.prototype,"_techniques",null),e([u({type:Boolean,readOnly:!0})],I.prototype,"updating",null),e([u()],I.prototype,"isEmpty",null),I=e([p("esri.views.3d.terrain.OverlayRenderer")],I);class U{constructor(e,r,t){this.drapeSource=e,this.renderer=r,this.index=t}}const B=[[1,.5,.5],[.5,.5,1]],H=-2,L=4,z=new M;z.hasAlpha=!0;export{I as OverlayRenderer,H as drapedZ,L as overlayRenderOccludedFlag};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import has from"../../../core/has.js";import{disposeMaybe as t}from"../../../core/maybe.js";import{MemCachePool as i}from"../../../core/MemCachePool.js";import r from"../../../core/ObjectPool.js";import{watch as s,sync as n}from"../../../core/reactiveUtils.js";import{property as a,subclass as l}from"../../../core/accessorSupport/decorators.js";import{subtract as o,set as c,dot as d}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{ZEROS as h,fromValues as u,create as _}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as g,ZEROS as f}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{create as p,set as m}from"../../../geometry/support/aaBoundingBox.js";import{BufferViewVec3f as y}from"../../../geometry/support/buffer/BufferView.js";import{overlayRenderOccludedFlag as b}from"./OverlayRenderer.js";import{PatchRenderData as x}from"./PatchRenderData.js";import{TerrainAttributesCache as T}from"./TerrainAttributesCache.js";import{enableTerrainInternalChecks as R}from"./terrainUtils.js";import{TileRenderer as v}from"./TileRenderer.js";import{IteratorPreorder as P,fallsWithinLayerView 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}from"../webgl-engine/effects/RenderPlugin.js";import{Vertices as E}from"../webgl-engine/lib/Attribute.js";import{IntersectorResult as F}from"../webgl-engine/lib/IntersectorResult.js";import{intersectAabbInvDirBefore as j,MeshIntersectionOptions as q,intersectTriangles as C}from"../webgl-engine/lib/RayIntersections.js";import{TriangleIntersectionData as A}from"../webgl-engine/lib/TriangleIntersectionData.js";import{terrainId as M,getVerticalOffsetTerrain as G}from"../webgl-engine/lib/verticalOffsetUtils.js";import{DrawParameters as U}from"../webgl-engine/materials/DrawParameters.js";import{T as k}from"../../../chunks/Terrain.glsl.js";import{TerrainTechnique as I}from"../webgl-engine/shaders/TerrainTechnique.js";import{TerrainTechniqueConfiguration as N}from"../webgl-engine/shaders/TerrainTechniqueConfiguration.js";import{PrimitiveType as L}from"../../webgl/enums.js";const V=7,z=10,H=200,Q=p();let W=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}get renderOccludedFlags(){return this._overlayRenderer.renderOccludedFlags}constructor(e,t,s,n,a){super({}),this._overlayRenderer=e,this._stage=t,this._allTiles=s,this._compressionTracker=n,this.type=7,this.isGround=!0,this._passParameters=new k,this._drawParameters=new U,this._renderDataPool=new r(()=>new x),this._visiblePatchesByOrigin=new Map,this._allPatchesByOrigin=new Map,this._patchesByOriginDirty=!0,this._patchSortingDirty=!0,this._tileIterator=new P,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.produces=new Map([[1,()=>1===this._desiredSlot],[6,()=>6===this._desiredSlot],[7,()=>7===this._desiredSlot],[10,()=>this._produces()&&this.renderOccludedFlags===b]]),this._tileSize=256,this._configuration=new N(1===t.viewingMode),this._tileTextureCache=new i((e,t)=>a.newCache(e,t),"TileTexture"),this.tileGeometryCache=new T(a)}normalizeCtorArgs(){return{}}initialize(){this._stage.addRenderPlugin(this),this.addHandles(s(()=>this._overlayRenderer.renderOccludedFlags,()=>this.setNeedsRender(),n))}destroy(){this._stage.removeRenderPlugin(this),this._tileTextureCache.destroy(),this.tileGeometryCache.destroy(),this._allTiles.prune(),this._tileRenderer=null}get _oitEnabled(){return this._stage.renderer.oitEnabled}_produces(){return this.visible&&!!this._rootTiles&&!this.renderingDisabled}set renderingDisabled(e){this._set("renderingDisabled",!!e),this.setDirty()}set visible(e){this._set("visible",!!e),this.setDirty()}updateHeading(e){this._tileRenderer?.updateHeading(e)}set transparency(e){this._configuration.transparencyMode!==e&&(this._configuration.transparencyMode=e,this.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 M}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{parent:t}=e;if(!this._canReuseTextureFromParent(t,e))return!1;const i=g(1&e.lij[2]?.5:0,1&e.lij[1]?0:.5,.5,.5);return t.renderData?.reuseTexture(e.renderData,i)??!1}_canReuseTextureFromParent(e,t){if(!e)return!1;const{layerInfo:i,surface:r}=t;for(let s=0;s<i[1].length;s++){const i=r.layerViewByIndex(s,1);if(O(e,i)!==O(t,i))return!1}return!0}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=z-V,i=Math.max(0,Math.floor((e.level-t)/V)*V);if(this._isGlobal&&0===i)return h;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 v(this._rctx,this._tileSize,this._techniques,this._tileTextureCache,this._compressionTracker),this.updateTileBackground()}uninitializeRenderContext(){this._tileRenderer=t(this._tileRenderer)}intersect(e,t,i,r){if(!this._rootTiles||e.options.selectOpaqueTerrainOnly&&e.options.selectionMode&&0!==this.transparency)return;const s=Z,n=J;o(s,r,i),c(n,1/s[0],1/s[1],1/s[2]);const a=e.results.min,l=e.results.max,h=e.results.ground,u=0===e.options.store,_=!!e.results.ground.target,g=G(e.verticalOffset),f=e.tolerance;let p,b=u&&null!=a.distance?a.distance:1/0;const x=e.options,T=x.normalRequired||!x.backfacesTerrain,R=new q(f,!1,T),v=c=>{const _=c.renderData;if(!_?.vao)return;const v=_.geometry;m(Q,v.boundingBox);const P=_.localOrigin;null!=g&&(g.localOrigin=P,g.applyToAabb(Q));const O=Q;if(K[0]=i[0]-P[0],K[1]=i[1]-P[1],K[2]=i[2]-P[2],!j(O,K,n,f,b))return;const w=(e,t,i)=>{e.set(this.type,c,t,i),b=u&&null!=a.distance?a.distance:1/0},D=(n,o,c)=>{if((!T||null!=c)&&n>=0&&(x.backfacesTerrain||d(c,s)<0)&&(x.invisibleTerrain||!x.selectionMode||null==t||t(i,r,n))){if((null==h.distance||n<h.distance)&&w(h,n,c),x.isFiltered)return;2===x.store&&(null==p?(p=new F(e.ray),w(p,n,c),e.results.all.push(p)):n<p.distance&&w(p,n,c)),(null==a.distance||n<a.distance)&&w(a,n,c),0!==x.store&&(null==l.distance||n>l.distance)&&w(l,n,c)}},S=X;o(S,r,P);const{indices:B,indexCount:q}=v,M=v.vertexAttributes,G=M.getField("position",y),U=new E(G.typedBuffer,3,M.stride/4),k=q/3;if(!g&&k>H){const e=c.renderData;e.intersectionData??=new A(B,k,U),e.intersectionData.intersectRay(K,S,R,D)}else C(K,S,0,k,B,U,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,b)||_&&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._oitEnabled?7:6;case 3:case 4:return null}}acquireTechniques(e){const{shadowMap:t,viewshedEnabled:i,cutFillEnabled:r,slot:s,hasEmission:n}=e.bind,a=!!has("enable-feature:terrain-shadows")&&t.enabled;if(a!==this._castShadows&&(this._castShadows=a,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&b))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,e.output){case 0:case 1:case 2:{const{ssr:i,clouds:r,ssao:a}=e.bind;l.screenSpaceReflections=null!=i.lastFrameColor,l.cloudReflections=null!=r.data;const o=10===s;return l.receiveShadows=t.ready&&!o,l.renderOccluded=o,l.receiveAmbientOcclusion=!o&&null!=a,l.hasEmission=n,this._acquireTechnique(e.output)}case 5:case 7:return this._castShadows?this._acquireTechnique(5):null;case 8:return this._inViewshed?this._acquireTechnique(8):null;case 9:return this._cutFillEnabled?this._acquireTechnique(9):null;case 3:case 4:return this._acquireTechnique(e.output);case 11:return this._acquireTechnique(11);case 10:return l.hasHighlightMixTexture=null!=e.bind.highlightMixTexture,this._overlayRenderer.hasHighlights?this._acquireTechnique(10):null}return null}render(e,t){switch(this._updatePatchGroups(),t.useStencil=!1,this._passParameters.overlayContent=S(e.output,e.bind),e.output){case 0:case 1:case 2:return this._renderMaterialPass(e,t);case 3:case 4:case 11:return this._renderAuxiliaryPass(e,t,this._visiblePatchesByOrigin);case 10:{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 5:case 7:case 8:case 9:return this._renderAuxiliaryPass(e,t,this._allPatchesByOrigin)}}updateTileBackground(e){if(null==this._tileRenderer)return;const t=this._tileRenderer;let i;if(null!=e){const t=e.toUnitRGBA();i=u(t[0]||0,t[1]||0,t[2]||0)}t.setBackground(i),this._allTiles.forAll(e=>t.updateTileTexture(e,0)),this._configuration.tileBlendInput=t.backgroundIsGrid?2:null!=t.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],L.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",h),s.setUniform4fv("texOffsetAndScale",f));const a=null!=this._tileRenderer?.backgroundColor?this._tileRenderer.backgroundColor:h;1===this._configuration.tileBlendInput&&s.setUniform3fv("backgroundColor",a);const l=this._stencilEnabledLayerExtents.length>0,o=this.wireframe?L.LINES:L.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(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(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(I,this._configuration)}get test(){}hasHighlight(e){return this._overlayRenderer.hasHighlight(e)}};e([a({readOnly:!0})],W.prototype,"visibleTiles",null),e([a({readOnly:!0})],W.prototype,"_isGlobal",null),e([a()],W.prototype,"renderOccludedFlags",null),e([a({value:!1})],W.prototype,"renderingDisabled",null),e([a({value:!0})],W.prototype,"visible",null),e([a()],W.prototype,"renderPatchBorders",null),e([a()],W.prototype,"wireframe",null),W=e([l("esri.views.3d.terrain.TerrainRenderer")],W);const Z=_(),J=_(),K=_(),X=_();export{W as TerrainRenderer};
|
|
2
|
+
import{__decorate as e}from"tslib";import has from"../../../core/has.js";import{disposeMaybe as t}from"../../../core/maybe.js";import{MemCachePool as i}from"../../../core/MemCachePool.js";import r from"../../../core/ObjectPool.js";import{watch as s,sync as n}from"../../../core/reactiveUtils.js";import{property as a,subclass as l}from"../../../core/accessorSupport/decorators.js";import{subtract as o,set as c,dot as d}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{ZEROS as h,fromValues as u,create as _}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as g,ZEROS as f}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{create as p,set as m}from"../../../geometry/support/aaBoundingBox.js";import{BufferViewVec3f as y}from"../../../geometry/support/buffer/BufferView.js";import{overlayRenderOccludedFlag as b}from"./OverlayRenderer.js";import{PatchRenderData as x}from"./PatchRenderData.js";import{TerrainAttributesCache as T}from"./TerrainAttributesCache.js";import{enableTerrainInternalChecks as R}from"./terrainUtils.js";import{TileRenderer as v}from"./TileRenderer.js";import{IteratorPreorder as O,fallsWithinLayerView as P,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}from"../webgl-engine/effects/RenderPlugin.js";import{Vertices as E}from"../webgl-engine/lib/Attribute.js";import{IntersectorResult as F}from"../webgl-engine/lib/IntersectorResult.js";import{intersectAabbInvDirBefore as j,MeshIntersectionOptions as q,intersectTriangles as C}from"../webgl-engine/lib/RayIntersections.js";import{TriangleIntersectionData as A}from"../webgl-engine/lib/TriangleIntersectionData.js";import{terrainId as M,getVerticalOffsetTerrain as G}from"../webgl-engine/lib/verticalOffsetUtils.js";import{DrawParameters as U}from"../webgl-engine/materials/DrawParameters.js";import{T as k}from"../../../chunks/Terrain.glsl.js";import{TerrainTechnique as I}from"../webgl-engine/shaders/TerrainTechnique.js";import{TerrainTechniqueConfiguration as N}from"../webgl-engine/shaders/TerrainTechniqueConfiguration.js";import{PrimitiveType as L}from"../../webgl/enums.js";const V=7,z=10,H=200,Q=p();let W=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}get renderOccludedFlags(){return this._overlayRenderer.renderOccludedFlags}constructor(e,t,s,n,a){super({}),this._overlayRenderer=e,this._stage=t,this._allTiles=s,this._compressionTracker=n,this.type=7,this.isGround=!0,this._passParameters=new k,this._drawParameters=new U,this._renderDataPool=new r(()=>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.produces=new Map([[1,()=>1===this._desiredSlot],[6,()=>6===this._desiredSlot],[7,()=>7===this._desiredSlot],[10,()=>this._produces()&&this.renderOccludedFlags===b]]),this._tileSize=256,this._configuration=new N(1===t.viewingMode),this._tileTextureCache=new i((e,t)=>a.newCache(e,t),"TileTexture"),this.tileGeometryCache=new T(a)}normalizeCtorArgs(){return{}}initialize(){this._stage.addRenderPlugin(this),this.addHandles(s(()=>this._overlayRenderer.renderOccludedFlags,()=>this.setNeedsRender(),n))}destroy(){this._stage.removeRenderPlugin(this),this._tileTextureCache.destroy(),this.tileGeometryCache.destroy(),this._allTiles.prune(),this._tileRenderer=null}get _oitEnabled(){return this._stage.renderer.oitEnabled}_produces(){return this.visible&&!!this._rootTiles&&!this.renderingDisabled}set renderingDisabled(e){this._set("renderingDisabled",!!e),this.setDirty()}set visible(e){this._set("visible",!!e),this.setDirty()}updateHeading(e){this._tileRenderer?.updateHeading(e)}set transparency(e){this._configuration.transparencyMode!==e&&(this._configuration.transparencyMode=e,this.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 M}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{parent:t}=e;if(!this._canReuseTextureFromParent(t,e))return!1;const i=g(1&e.lij[2]?.5:0,1&e.lij[1]?0:.5,.5,.5);return t.renderData?.reuseTexture(e.renderData,i)??!1}_canReuseTextureFromParent(e,t){if(!e)return!1;const{layerInfo:i,surface:r}=t;for(let s=0;s<i[1].length;s++){const i=r.layerViewByIndex(s,1);if(P(e,i)!==P(t,i))return!1}return!0}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=z-V,i=Math.max(0,Math.floor((e.level-t)/V)*V);if(this._isGlobal&&0===i)return h;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 v(this._rctx,this._tileSize,this._techniques,this._tileTextureCache,this._compressionTracker),this.updateTileBackground()}uninitializeRenderContext(){this._tileRenderer=t(this._tileRenderer)}intersect(e,t,i,r){if(!this._rootTiles||e.options.selectOpaqueTerrainOnly&&e.options.selectionMode&&0!==this.transparency)return;const s=Z,n=J;o(s,r,i),c(n,1/s[0],1/s[1],1/s[2]);const a=e.results.min,l=e.results.max,h=e.results.ground,u=0===e.options.store,_=!!e.results.ground.target,g=G(e.verticalOffset),f=e.tolerance;let p,b=u&&null!=a.distance?a.distance:1/0;const x=e.options,T=x.normalRequired||!x.backfacesTerrain,R=new q(f,!1,T),v=c=>{const _=c.renderData;if(!_?.vao)return;const v=_.geometry;m(Q,v.boundingBox);const O=_.localOrigin;null!=g&&(g.localOrigin=O,g.applyToAabb(Q));const P=Q;if(K[0]=i[0]-O[0],K[1]=i[1]-O[1],K[2]=i[2]-O[2],!j(P,K,n,f,b))return;const w=(e,t,i)=>{e.set(this.type,c,t,i),b=u&&null!=a.distance?a.distance:1/0},D=(n,o,c)=>{if((!T||null!=c)&&n>=0&&(x.backfacesTerrain||d(c,s)<0)&&(x.invisibleTerrain||!x.selectionMode||null==t||t(i,r,n))){if((null==h.distance||n<h.distance)&&w(h,n,c),x.isFiltered)return;2===x.store&&(null==p?(p=new F(e.ray),w(p,n,c),e.results.all.push(p)):n<p.distance&&w(p,n,c)),(null==a.distance||n<a.distance)&&w(a,n,c),0!==x.store&&(null==l.distance||n>l.distance)&&w(l,n,c)}},S=X;o(S,r,O);const{indices:B,indexCount:q}=v,M=v.vertexAttributes,G=M.getField("position",y),U=new E(G.typedBuffer,3,M.stride/4),k=q/3;if(!g&&k>H){const e=c.renderData;e.intersectionData??=new A(B,k,U),e.intersectionData.intersectRay(K,S,R,D)}else C(K,S,0,k,B,U,g,R,D)},O=this._rootTiles;if(null!=O){(()=>{const t=this._tileIterator;t.reset(O);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,b)||_&&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._oitEnabled?7:6;case 3:case 4:return null}}acquireTechniques(e){const{shadowMap:t,viewshedEnabled:i,cutFillEnabled:r,slot:s,hasEmission:n,hasFloatOit: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&b))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.hasFloatOit=a,e.output){case 0:case 1:case 2:{const{ssr:i,clouds:r,ssao:a}=e.bind;o.screenSpaceReflections=null!=i.lastFrameColor,o.cloudReflections=null!=r.data;const l=10===s;return o.receiveShadows=t.ready&&!l,o.renderOccluded=l,o.receiveAmbientOcclusion=!l&&null!=a,o.hasEmission=n,this._acquireTechnique(e.output)}case 5:case 7:return this._castShadows?this._acquireTechnique(5):null;case 8:return this._inViewshed?this._acquireTechnique(8):null;case 9:return this._cutFillEnabled?this._acquireTechnique(9):null;case 3:case 4:return this._acquireTechnique(e.output);case 11:return this._acquireTechnique(11);case 10:return o.hasHighlightMixTexture=null!=e.bind.highlightMixTexture,this._overlayRenderer.hasHighlights?this._acquireTechnique(10):null}return null}render(e,t){switch(this._updatePatchGroups(),t.useStencil=!1,this._passParameters.overlayContent=S(e.output,e.bind),e.output){case 0:case 1:case 2:return this._renderMaterialPass(e,t);case 3:case 4:case 11:return this._renderAuxiliaryPass(e,t,this._visiblePatchesByOrigin);case 10:{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 5:case 7:case 8:case 9:return this._renderAuxiliaryPass(e,t,this._allPatchesByOrigin)}}updateTileBackground(e){if(null==this._tileRenderer)return;const t=this._tileRenderer;let i;if(null!=e){const t=e.toUnitRGBA();i=u(t[0]||0,t[1]||0,t[2]||0)}t.setBackground(i),this._allTiles.forAll(e=>t.updateTileTexture(e,0)),this._configuration.tileBlendInput=t.backgroundIsGrid?2:null!=t.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],L.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",h),s.setUniform4fv("texOffsetAndScale",f));const a=null!=this._tileRenderer?.backgroundColor?this._tileRenderer.backgroundColor:h;1===this._configuration.tileBlendInput&&s.setUniform3fv("backgroundColor",a);const l=this._stencilEnabledLayerExtents.length>0,o=this.wireframe?L.LINES:L.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(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(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(I,this._configuration)}get test(){}hasHighlight(e){return this._overlayRenderer.hasHighlight(e)}};e([a({readOnly:!0})],W.prototype,"visibleTiles",null),e([a({readOnly:!0})],W.prototype,"_isGlobal",null),e([a()],W.prototype,"renderOccludedFlags",null),e([a({value:!1})],W.prototype,"renderingDisabled",null),e([a({value:!0})],W.prototype,"visible",null),e([a()],W.prototype,"renderPatchBorders",null),e([a()],W.prototype,"wireframe",null),W=e([l("esri.views.3d.terrain.TerrainRenderer")],W);const Z=_(),J=_(),K=_(),X=_();export{W as TerrainRenderer};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import e from"../../../core/Logger.js";import{disposeMaybe as t}from"../../../core/maybe.js";import{ZEROS as r}from"../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{VectorTileRendererHelper3D as i}from"../../2d/engine/vectorTiles/VectorTileRendererHelper3D.js";import{BlendLayersTechnique as s}from"./BlendLayersTechnique.js";import{BlendLayersTechniqueConfiguration as o}from"./BlendLayersTechniqueConfiguration.js";import{RasterColorizerTechnique as n}from"./RasterColorizerTechnique.js";import{RasterColorizerTechniqueConfiguration as a}from"./RasterColorizerTechniqueConfiguration.js";import{MultiSizeFramebuffer as h}from"./support/MultiSizeFramebuffer.js";import{BindParameters as c}from"../webgl-engine/lib/BindParameters.js";import{createQuadVAO as l}from"../webgl-engine/lib/glUtil3D.js";import{PrimitiveType as u}from"../../webgl/enums.js";import d from"../../webgl/Texture.js";const _=()=>e.getLogger("esri.views.3d.terrain");class f{constructor(e,t){this._rctx=e,this._techniques=t,this._fbos=[],this._vectorTileHelper=new i,this._blendConfiguration=new o,this._current=0,this._lastUsedIds=new Array,this._lastCreatedBufferId=0,this._onHoldIds=new Array,this._vao=l(this._rctx,1),this._bindParameters=new c(e,null)}dispose(){this._fbos.forEach(t),this._fbos=null,this._vtFBO=t(this._vtFBO),this._vao=t(this._vao),this._vectorTileHelper=t(this._vectorTileHelper)}updateHeading(e){this._vectorTileHelper?.updateHeading(e)}_acquireBlendTechnique(e,t,r,i=!1,o=0){return this._blendConfiguration.output=t,this._blendConfiguration.blendMode=e,this._blendConfiguration.applyBaseOpacity=r,this._blendConfiguration.premultipliedAlphaSource=i,this._blendConfiguration.background=o,this._techniques.precompile(s,this._blendConfiguration),this._techniques.get(s,this._blendConfiguration)}drawBackground(e,t){const r=this._acquireBlendTechnique(0,t?2:3,!1,!1,1),i=this._rctx.bindTechnique(r,this._bindParameters,e);this._render(i)}_render(e){this._rctx.bindVAO(this._vao),e.assertCompatibleVertexAttributeLocations(this._vao),this._rctx.drawArrays(u.TRIANGLE_STRIP,0,this._vao.vertexCount("geometry"))}drawGroup(e,t,r,i,s=!0){1===t&&(e.fboTexture=this._fbos[this.getLastOnHoldId()].get(r).colorTexture,null==e.fboTexture&&(e.fboTexture=this._rctx.emptyTexture)),e.texture=this.currentFBO(r).colorTexture,this.closeGroup(r);const o=e.baseOpacity<1,n=this._acquireBlendTechnique(i,t,o,s),a=this._rctx.bindTechnique(n,this._bindParameters,e);this._render(a)}drawImageData(e,t,r,i,s=!1){if(null==e.texture)return;const o=e.baseOpacity<1;e.fboTexture=4===t||0===i&&!o&&!s?null:this.switch(r).colorTexture,e.fboTexture??=this._rctx.emptyTexture;const n=this._acquireBlendTechnique(i,t,o,s),a=this._rctx.bindTechnique(n,this._bindParameters,e);this._render(a)}drawRasterData(e,t,r,i,s){const o=s.sourceLayerInfo.data;if(!o.source)return;if(s.tile.surface.layerViewByIndex(s.layerIndex,1).ensureSymbolizerParameters(o),!o.bind(this._rctx))return;const n=e.baseOpacity<1;e.fboTexture=0!==i||n?this.switch(r).colorTexture:null;const a=this._acquireRasterTechnique(o,t,i,n);if(!a)return;o.opacity=e.opacity;const h=o.getUniforms(this._rctx);h.scale=s.scale,h.offset=s.offset,h.backgroundColor=e.backgroundColor,h.fboTexture=e.fboTexture,h.baseOpacity=e.baseOpacity;const c=this._rctx.bindTechnique(a,this._bindParameters,h);this._render(c)}_acquireRasterTechnique(e,t,r,i){if(!this._rctx.capabilities.colorBufferFloat)return null;const s=e.symbolizerParameters,o=["stretch","lut","hillshade"].indexOf(s.type);return this._rasterConfiguration??=new a,this._rasterConfiguration.output=t,this._rasterConfiguration.blendMode=r,this._rasterConfiguration.applyBaseOpacity=i,this._rasterConfiguration.colorizerType=o,this._rasterConfiguration.applyColormap=!!s.colormap,this._rasterConfiguration.requireBilinearWithNN=e.isBilinearWithStretchColorRamp,this._rasterConfiguration.stretchType=e.hasStretchTypeNone()?0:1,this._techniques.precompile(n,this._rasterConfiguration),this._techniques.get(n,this._rasterConfiguration)}drawVectorData(e,t,i,s,o,n,a,c){const l=this._rctx,u=o.sourceLayerInfo.data,d=o.tile.surface.layerViewByIndex(o.layerIndex,1),f=e.baseOpacity<1,p=f||e.opacity<1||0!==s||1!==t,b=p,g=this._acquireBlendTechnique(s,t,f,b);l.setPipelineState(g.getPipeline(this._bindParameters));let m=null,x=null;p?(x=this.currentFBO(i),null==this._vtFBO&&(this._vtFBO=new h(this._rctx)),m=this._vtFBO.get(i),l.bindFramebuffer(m),this._clearCurrentFBO()):c&&l.clear(256);try{this._vectorTileHelper.renderBackground(l,o.sourceLod,d.painter,d.layer.styleRepository,d.schemaHelper,Math.round(1/o.scale),o.offset,a,n,d.contentZoom),u&&this._vectorTileHelper.renderContent(l,o.sourceLod,u,o.vtlNeighborInfos,d.painter,d.layer.styleRepository,d.schemaHelper,Math.round(1/o.scale),o.offset,a,n,d.contentZoom)}catch(T){_().warnOnce("A render call containing vector tiles did not resolve correctly.",T)}return!m||(l.bindFramebuffer(x),e.texture=m.colorTexture,e.offset=r,e.scale=1,this.drawImageData(e,t,i,s,b),c)}copyFBOToTexture(e){const t=this._rctx,r=t.bindTexture(e.texture,d.TEXTURE_UNIT_FOR_UPDATES),i=e.descriptor;t.gl.copyTexImage2D(3553,0,i.pixelFormat,0,0,i.width,i.height,0),e.generateMipmap(),t.bindTexture(r,d.TEXTURE_UNIT_FOR_UPDATES)}_clearCurrentFBO(){this._rctx.setStencilWriteMask(255),this._rctx.setClearColor(0,0,0,0),this._rctx.setClearDepth(1),this._rctx.setClearStencil(0),this._rctx.clear(17664)}_initFBO(e,t,r){this._rctx.bindFramebuffer(e),r&&(this._rctx.setViewport(0,0,t,t),this._clearCurrentFBO())}ensureBuffer(e){this._lastUsedIds.length=0,this._lastUsedIds.push(1),this._lastCreatedBufferId=1,this._onHoldIds.length=0,this.bind(e)}bind(e,t=0,r=!0){if(this._current=t,t>=this._fbos.length)for(let i=this._fbos.length;i<=t;i++)this._fbos.push(new h(this._rctx));this._initFBO(this._fbos[t].get(e),e,r)}_bindNextFreeBuffer(e){this._lastUsedIds.length>0?this.bind(e,this._lastUsedIds.pop()):(this._lastCreatedBufferId++,this.bind(e,this._lastCreatedBufferId))}openGroup(e){this._onHoldIds.push(this._current),this._bindNextFreeBuffer(e)}switch(e){const t=this.currentFBO(e),r=this._current;return this._bindNextFreeBuffer(e),this._lastUsedIds.push(r),t}getLastOnHoldId(){return this._onHoldIds[this._onHoldIds.length-1]}closeGroup(e){const t=this._current;this._bindNextFreeBuffer(e),this._lastUsedIds.push(t),this._lastUsedIds.push(this._onHoldIds.pop())}unbind(){this._rctx.bindFramebuffer(null)}currentFBO(e){return this._fbos[this._current].get(e)}}export{f as TileCompositor};
|
|
2
|
+
import e from"../../../core/Logger.js";import{disposeMaybe as t}from"../../../core/maybe.js";import{ZEROS as r}from"../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{VectorTileRendererHelper3D as i}from"../../2d/engine/vectorTiles/VectorTileRendererHelper3D.js";import{BlendLayersTechnique as s}from"./BlendLayersTechnique.js";import{BlendLayersTechniqueConfiguration as o}from"./BlendLayersTechniqueConfiguration.js";import{RasterColorizerTechnique as n}from"./RasterColorizerTechnique.js";import{RasterColorizerTechniqueConfiguration as a}from"./RasterColorizerTechniqueConfiguration.js";import{MultiSizeFramebuffer as h}from"./support/MultiSizeFramebuffer.js";import{BindParameters as c}from"../webgl-engine/lib/BindParameters.js";import{createQuadVAO as l}from"../webgl-engine/lib/glUtil3D.js";import{PrimitiveType as u}from"../../webgl/enums.js";import d from"../../webgl/Texture.js";const _=()=>e.getLogger("esri.views.3d.terrain");class f{constructor(e,t){this._rctx=e,this._techniques=t,this._fbos=[],this._vectorTileHelper=new i,this._blendConfiguration=new o,this._current=0,this._lastUsedIds=new Array,this._lastCreatedBufferId=0,this._onHoldIds=new Array,this._vao=l(this._rctx,1),this._bindParameters=new c(e,null)}dispose(){this._bindParameters.destroy(),this._fbos.forEach(t),this._fbos=null,this._vtFBO=t(this._vtFBO),this._vao=t(this._vao),this._vectorTileHelper=t(this._vectorTileHelper)}updateHeading(e){this._vectorTileHelper?.updateHeading(e)}_acquireBlendTechnique(e,t,r,i=!1,o=0){return this._blendConfiguration.output=t,this._blendConfiguration.blendMode=e,this._blendConfiguration.applyBaseOpacity=r,this._blendConfiguration.premultipliedAlphaSource=i,this._blendConfiguration.background=o,this._techniques.precompile(s,this._blendConfiguration),this._techniques.get(s,this._blendConfiguration)}drawBackground(e,t){const r=this._acquireBlendTechnique(0,t?2:3,!1,!1,1),i=this._rctx.bindTechnique(r,this._bindParameters,e);this._render(i)}_render(e){this._rctx.bindVAO(this._vao),e.assertCompatibleVertexAttributeLocations(this._vao),this._rctx.drawArrays(u.TRIANGLE_STRIP,0,this._vao.vertexCount("geometry"))}drawGroup(e,t,r,i,s=!0){1===t&&(e.fboTexture=this._fbos[this.getLastOnHoldId()].get(r).colorTexture,null==e.fboTexture&&(e.fboTexture=this._rctx.emptyTexture)),e.texture=this.currentFBO(r).colorTexture,this.closeGroup(r);const o=e.baseOpacity<1,n=this._acquireBlendTechnique(i,t,o,s),a=this._rctx.bindTechnique(n,this._bindParameters,e);this._render(a)}drawImageData(e,t,r,i,s=!1){if(null==e.texture)return;const o=e.baseOpacity<1;e.fboTexture=4===t||0===i&&!o&&!s?null:this.switch(r).colorTexture,e.fboTexture??=this._rctx.emptyTexture;const n=this._acquireBlendTechnique(i,t,o,s),a=this._rctx.bindTechnique(n,this._bindParameters,e);this._render(a)}drawRasterData(e,t,r,i,s){const o=s.sourceLayerInfo.data;if(!o.source)return;if(s.tile.surface.layerViewByIndex(s.layerIndex,1).ensureSymbolizerParameters(o),!o.bind(this._rctx))return;const n=e.baseOpacity<1;e.fboTexture=0!==i||n?this.switch(r).colorTexture:null;const a=this._acquireRasterTechnique(o,t,i,n);if(!a)return;o.opacity=e.opacity;const h=o.getUniforms(this._rctx);h.scale=s.scale,h.offset=s.offset,h.backgroundColor=e.backgroundColor,h.fboTexture=e.fboTexture,h.baseOpacity=e.baseOpacity;const c=this._rctx.bindTechnique(a,this._bindParameters,h);this._render(c)}_acquireRasterTechnique(e,t,r,i){if(!this._rctx.capabilities.colorBufferFloat)return null;const s=e.symbolizerParameters,o=["stretch","lut","hillshade"].indexOf(s.type);return this._rasterConfiguration??=new a,this._rasterConfiguration.output=t,this._rasterConfiguration.blendMode=r,this._rasterConfiguration.applyBaseOpacity=i,this._rasterConfiguration.colorizerType=o,this._rasterConfiguration.applyColormap=!!s.colormap,this._rasterConfiguration.requireBilinearWithNN=e.isBilinearWithStretchColorRamp,this._rasterConfiguration.stretchType=e.hasStretchTypeNone()?0:1,this._techniques.precompile(n,this._rasterConfiguration),this._techniques.get(n,this._rasterConfiguration)}drawVectorData(e,t,i,s,o,n,a,c){const l=this._rctx,u=o.sourceLayerInfo.data,d=o.tile.surface.layerViewByIndex(o.layerIndex,1),f=e.baseOpacity<1,p=f||e.opacity<1||0!==s||1!==t,b=p,g=this._acquireBlendTechnique(s,t,f,b);l.setPipelineState(g.getPipeline(this._bindParameters));let m=null,x=null;p?(x=this.currentFBO(i),null==this._vtFBO&&(this._vtFBO=new h(this._rctx)),m=this._vtFBO.get(i),l.bindFramebuffer(m),this._clearCurrentFBO()):c&&l.clear(256);try{this._vectorTileHelper.renderBackground(l,o.sourceLod,d.painter,d.layer.styleRepository,d.schemaHelper,Math.round(1/o.scale),o.offset,a,n,d.contentZoom),u&&this._vectorTileHelper.renderContent(l,o.sourceLod,u,o.vtlNeighborInfos,d.painter,d.layer.styleRepository,d.schemaHelper,Math.round(1/o.scale),o.offset,a,n,d.contentZoom)}catch(T){_().warnOnce("A render call containing vector tiles did not resolve correctly.",T)}return!m||(l.bindFramebuffer(x),e.texture=m.colorTexture,e.offset=r,e.scale=1,this.drawImageData(e,t,i,s,b),c)}copyFBOToTexture(e){const t=this._rctx,r=t.bindTexture(e.texture,d.TEXTURE_UNIT_FOR_UPDATES),i=e.descriptor;t.gl.copyTexImage2D(3553,0,i.pixelFormat,0,0,i.width,i.height,0),e.generateMipmap(),t.bindTexture(r,d.TEXTURE_UNIT_FOR_UPDATES)}_clearCurrentFBO(){this._rctx.setStencilWriteMask(255),this._rctx.setClearColor(0,0,0,0),this._rctx.setClearDepth(1),this._rctx.setClearStencil(0),this._rctx.clear(17664)}_initFBO(e,t,r){this._rctx.bindFramebuffer(e),r&&(this._rctx.setViewport(0,0,t,t),this._clearCurrentFBO())}ensureBuffer(e){this._lastUsedIds.length=0,this._lastUsedIds.push(1),this._lastCreatedBufferId=1,this._onHoldIds.length=0,this.bind(e)}bind(e,t=0,r=!0){if(this._current=t,t>=this._fbos.length)for(let i=this._fbos.length;i<=t;i++)this._fbos.push(new h(this._rctx));this._initFBO(this._fbos[t].get(e),e,r)}_bindNextFreeBuffer(e){this._lastUsedIds.length>0?this.bind(e,this._lastUsedIds.pop()):(this._lastCreatedBufferId++,this.bind(e,this._lastCreatedBufferId))}openGroup(e){this._onHoldIds.push(this._current),this._bindNextFreeBuffer(e)}switch(e){const t=this.currentFBO(e),r=this._current;return this._bindNextFreeBuffer(e),this._lastUsedIds.push(r),t}getLastOnHoldId(){return this._onHoldIds[this._onHoldIds.length-1]}closeGroup(e){const t=this._current;this._bindNextFreeBuffer(e),this._lastUsedIds.push(t),this._lastUsedIds.push(this._onHoldIds.pop())}unbind(){this._rctx.bindFramebuffer(null)}currentFBO(e){return this._fbos[this._current].get(e)}}export{f as TileCompositor};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{translate as s}from"../../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as i}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{
|
|
2
|
+
import{__decorate as e}from"tslib";import{translate as s}from"../../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as i}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{transformMat4 as a,add as o,subtract as l,set as n}from"../../../../../core/libs/gl-matrix-2/math/vec3.js";import{ZEROS as c,create as t}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{InstancedDoubleConfiguration as r}from"./attributes/InstancedDoubleConfiguration.js";import{Float3DrawUniform as f}from"../shaderModules/Float3DrawUniform.js";import{Float3PassUniform as d}from"../shaderModules/Float3PassUniform.js";import{glsl as u}from"../shaderModules/glsl.js";import{parameter as p}from"../shaderTechnique/ShaderTechniqueConfiguration.js";import{NoParameters as m}from"../../../../webgl/NoParameters.js";class P extends r{constructor(){super(...arguments),this.hasSlicePlane=!1,this.hasSliceTranslatedView=!1}}e([p()],P.prototype,"hasSlicePlane",void 0);class b extends m{constructor(e=null){super(),this.slicePlaneLocalOrigin=e}}function v(e,s){y(e,s,...F(s))}function h(e,s){y(e,s,...j(s))}function S(e,s){g(e,s,...j(s))}function w(e,s){g(e,s,...F(s))}const B=u`struct SliceFactors {
|
|
3
3
|
float front;
|
|
4
4
|
float side0;
|
|
5
5
|
float side1;
|
|
@@ -34,5 +34,5 @@ return dot(slicePlaneBasis1, slicePlaneBasis1) != 0.0;
|
|
|
34
34
|
}
|
|
35
35
|
bool rejectBySlice(vec3 pos) {
|
|
36
36
|
return sliceEnabled() && sliceByFactors(calculateSliceFactors(pos));
|
|
37
|
-
}`;function
|
|
38
|
-
vec4 applySlice(vec4 color, vec3 pos) { return color; }`)}function
|
|
37
|
+
}`;function g(e,s,...i){s.hasSlicePlane?(e.uniforms.add(...i),e.code.add(B)):e.code.add("bool rejectBySlice(vec3 pos) { return false; }")}function y(e,s,...i){e.constants.add("groundSliceOpacity","float",.2),g(e,s,...i),s.hasSlicePlane?e.code.add("\n void discardBySlice(vec3 pos) {\n if (rejectBySlice(pos)) {\n discard;\n }\n }\n\n vec4 applySliceOutline(vec4 color, vec3 pos) {\n SliceFactors factors = calculateSliceFactors(pos);\n\n factors.front /= 2.0 * fwidth(factors.front);\n factors.side0 /= 2.0 * fwidth(factors.side0);\n factors.side1 /= 2.0 * fwidth(factors.side1);\n factors.side2 /= 2.0 * fwidth(factors.side2);\n factors.side3 /= 2.0 * fwidth(factors.side3);\n\n // return after calling fwidth, to avoid aliasing caused by discontinuities in the input to fwidth\n if (sliceByFactors(factors)) {\n return color;\n }\n\n float outlineFactor = (1.0 - step(0.5, factors.front))\n * (1.0 - step(0.5, factors.side0))\n * (1.0 - step(0.5, factors.side1))\n * (1.0 - step(0.5, factors.side2))\n * (1.0 - step(0.5, factors.side3));\n\n return mix(color, vec4(vec3(0.0), color.a), outlineFactor * 0.3);\n }\n\n vec4 applySlice(vec4 color, vec3 pos) {\n return sliceEnabled() ? applySliceOutline(color, pos) : color;\n }\n "):e.code.add(u`void discardBySlice(vec3 pos) { }
|
|
38
|
+
vec4 applySlice(vec4 color, vec3 pos) { return color; }`)}function F(e){return[new d("slicePlaneOrigin",(s,i)=>L(e,s,i)),new d("slicePlaneBasis1",(s,i)=>M(e,s,i,i.slicePlane?.basis1)),new d("slicePlaneBasis2",(s,i)=>M(e,s,i,i.slicePlane?.basis2))]}function j(e){return[new f("slicePlaneOrigin",(s,i)=>L(e,s,i)),new f("slicePlaneBasis1",(s,i)=>M(e,s,i,i.slicePlane?.basis1)),new f("slicePlaneBasis2",(s,i)=>M(e,s,i,i.slicePlane?.basis2))]}function x(e,s,i){return e.instancedDoublePrecision?n(T,i.camera.viewInverseTransposeMatrix[3],i.camera.viewInverseTransposeMatrix[7],i.camera.viewInverseTransposeMatrix[11]):s.slicePlaneLocalOrigin}function D(e,s){return null!=e?l(I,s.origin,e):s.origin}function O(e,i,a){return e.hasSliceTranslatedView?null!=i?s(E,a.camera.viewMatrix,i):a.camera.viewMatrix:null}function L(e,s,i){if(null==i.slicePlane)return c;const o=x(e,s,i),l=D(o,i.slicePlane),n=O(e,o,i);return null!=n?a(I,l,n):l}function M(e,s,i,n){if(null==n||null==i.slicePlane)return c;const t=x(e,s,i),r=D(t,i.slicePlane),f=O(e,t,i);return null!=f?(o(N,n,r),a(I,r,f),a(N,N,f),l(N,N,I)):n}const T=t(),I=t(),N=t(),E=i();export{S as RejectBySliceDraw,w as RejectBySlicePass,P as SliceConfiguration,h as SliceDraw,v as SlicePass,b as SlicePlaneParameters};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{releaseMaybe as
|
|
2
|
+
import{__decorate as e}from"tslib";import{releaseMaybe as t}from"../../../../../core/maybe.js";import{property as r,subclass as o}from"../../../../../core/accessorSupport/decorators.js";import{ZEROS as n}from"../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{RenderNodeOutput as i}from"../../../webgl.js";import s from"../../../webgl/RenderNode.js";import{If as a,glsl as c}from"../../core/shaderModules/glsl.js";import{Pos2Locations as l}from"../../lib/DefaultVertexBufferLayouts.js";import{oitReductionFactor as u}from"../../shaders/oitResolution.glsl.js";import{checkWebGLError as h}from"../../../../webgl/checkWebGLError.js";import{ColorAttachment0 as p,SizedPixelFormat as d,DataType as f}from"../../../../webgl/enums.js";let m=class extends s{constructor(e){super(e),this.destroyedCB=null,this.produces=i.FINAL,this.consumes={required:[i.FINAL]},this.clearColor=n,this._focusedFBOType=7,this._programs=new Map}destroy(){this._programs.clear(),this.destroyedCB()}render(e){const t=e.find(({name:e})=>e===i.FINAL);if(!this._focusedTexture)return t;const r=this.renderingContext;r.bindFramebuffer(t.fbo),r.setClearColor(0,0,0,0),r.clear(16384);const o=this._focusedTexture.attachment,n=[v(o)],s=this._ensureProgram(r,!1,n);return r.useProgram(s),r.bindTexture(o,0),s.setUniform1i("colorTex0",0),s.setUniform1i("inputType",this._focusedFBOType),3===this._focusedFBOType&&s.setUniform2fv("nearFar",this.camera.nearFar),r.screen.draw(),t}getDownscaledFBO(e,t,r,o,n){t&&(o=e.width,n=e.height);const i="linear depth"===r||r.includes("shadow"),s="overlay highlight"===r||"highlights"===r||"highlight mix"===r,a="highlight coverage"===r,c=e.colorTexture?.descriptor,l=c?.internalFormat,u=[],d=new Array,f=new Array;e.colorAttachments.forEach((t,r)=>{const o=e.getColorTexture(t);if(o){const e=v(o);u.push(e);const{descriptor:t}=o;"float"!==e||t.hasMipmap||t.isImmutable||(o.generateMipmap(),d[r]=!0)}if(r>0){const r=e.getColorTexture(t)?.descriptor.internalFormat;return void f.push(F(r))}f.push(i?0:s?1:a?2:F(l))});const m=this.renderingContext,{depthStencilTexture:g}=e,x=this._ensureProgram(m,null!=g,u),T=this.fboCache.acquire(o,n,"fbo visualizer");m.useProgram(x),m.bindFramebuffer(T.fbo);const b=[];e.colorAttachments.forEach((t,r)=>{const o=`colorTex${r.toFixed()}`;m.bindTexture(e.getColorTexture(t),r),x.setUniform1i(o,r),r>0&&T.acquireColor(p+r,5,"fbo visualizer"),b.push(t)});const C=g?.descriptor.linearFilterDepth??!1;if(g){const t=e.colorAttachments.length;g.setShadowFiltering(!1),m.bindTexture(g,t),x.setUniform1i("depthTex",t);const r=p+t;r>p&&T.acquireColor(r,5,"fbo visualizer"),b.push(r)}m.gl.drawBuffers(b),h(m.gl);const R=m.getViewport();return m.setViewport(0,0,o,n),m.setClearColor(0,0,0,0),m.clear(16384),m.setBlendingEnabled(!0),m.setBlendFunction(1,771),x.setUniform1iv("inputTypes",f.length>0?f:[7]),x.setUniform2fv("nearFar",this.camera.nearFar),m.screen.draw(),h(m.gl),m.bindFramebuffer(null),m.setViewport(R.x,R.y,R.width,R.height),t&&(this._focusedTexture?.release(),this._focusedTexture=T.getAttachment(p),this._focusedTexture?.retain(),this._focusedFBOType=f[0]),e.colorAttachments.forEach((t,r)=>{if(d[r]){const r=e.getColorTexture(t);r?.clearMipmap()}}),g&&g.setShadowFiltering(C),T}clearFocusedFBO(){this._focusedTexture=t(this._focusedTexture)}getPreviewContent(e,t,r,o){const n=this.renderingContext,i=o.includes("\ndepth"),s=this.fboCache.acquire(e,t,"fbo visualizer");n.bindFramebuffer(s?.fbo);const a=n.getViewport();n.setViewport(0,0,e,t),n.setClearColor(this.clearColor[0],this.clearColor[1],this.clearColor[2],this.clearColor[3]),n.clear(16384),n.setBlendingEnabled(!0),n.setBlendFunction(1,771);const c=r.attachment,l=this._ensureProgram(n,!1,[v(c)]);n.useProgram(l),n.bindTexture(c,0),l.setUniform1i("colorTex0",0),l.setUniform1iv("inputTypes",[i||c.descriptor.internalFormat!==d.RGBA16F?7:5]),n.screen.draw();const u=new ImageData(new Uint8ClampedArray(e*t*4),e,t);return n.gl.readPixels(0,0,e,t,6408,f.UNSIGNED_BYTE,new Uint8Array(u.data.buffer)),h(n.gl),n.bindFramebuffer(null),n.setViewport(a.x,a.y,a.width,a.height),s?.release(),u}_ensureProgram(e,t,r){const o=x({hasDepthAttachment:t,colorSamplerTypes:r}),n=this._programs.get(o);if(n)return n;const i="#version 300 es\n in vec2 position;\n out vec2 uv;\n\n void main() {\n gl_Position = vec4(position, 0.0, 1.0);\n uv = position * 0.5 + vec2(0.5);\n }",s=e=>{let t="";for(let r=0;r<e.length;++r){const o=e[r];t+=`layout(location = ${c.int(r)}) out vec4 fragColor${c.int(r)};\n uniform ${g(o)} colorTex${c.int(r)};`}return t},h=e=>e.reduce((e,t,r)=>e+`{\n int inputType = inputTypes[${r}];\n if (inputType == ${3..toFixed()}) {\n fragColor${r} = vec4(vec3(texture(colorTex${r}, uv).r), 1.0);\n } else if (inputType == ${4..toFixed()}) {\n fragColor${r} = vec4(texture(colorTex${r}, uv).rg, 0.0, 1.0);\n } else if (inputType == ${(0).toFixed()}) {\n float depth = 1.0 - ((-linearDepthFromTexture(colorTex${r}, uv) - nearFar[0]) / (nearFar[1] - nearFar[0]));\n fragColor${r} = vec4(vec3(depth), depth >= 0.999 ? 0.0 : 1.0);\n } else if (inputType == ${5..toFixed()}) {\n // Divide F16 by oitOutputScale to get similar previews as in the OIT8 pipeline\n fragColor${r} = vec4(texture(colorTex${r}, uv).rgb, 1.0) / ${u.toFixed(1)};\n } else if (inputType == ${1..toFixed()}) {\n fragColor${r} = vec4(texture(colorTex${r}, uv)) * 255.0;\n fragColor${r} = vec4(fragColor${r}.rgb / fragColor${r}.a, fragColor${r}.a);\n } else if(inputType == ${2..toFixed()}) {\n vec2 texDim = vec2(textureSize(colorTex${r}, 0));\n ivec2 iuv = ivec2(uv*texDim);\n uvec2 hh = uvec2(texelFetch(colorTex${r},iuv,0).rg);\n fragColor${r} = vec4(\n ((hh & uvec2(0x55u)) != uvec2(0u)) ? 1.0 : 0.0,\n ((hh & uvec2(0xaau)) != uvec2(0u)) ? 1.0 : 0.0,\n 0.0,\n 1.0);\n } else {\n fragColor${r} = vec4(texture(colorTex${r}, uv));\n }\n }`,""),p=r.length,d=`#version 300 es\n precision highp float;\n precision highp usampler2D;\n\n in vec2 uv;\n ${s(r)}\n ${a(t,`layout(location = ${c.int(p)}) out vec4 fragDepth;\n uniform sampler2D depthTex;`)}\n\n uniform int inputTypes[${r.length||1}];\n uniform vec2 nearFar;\n\n // Factors to convert rgba back to float\n const vec4 RGBA_2_FLOAT_FACTORS = vec4(\n 255.0 / (256.0),\n 255.0 / (256.0 * 256.0),\n 255.0 / (256.0 * 256.0 * 256.0),\n 255.0 / (256.0 * 256.0 * 256.0 * 256.0)\n );\n\n\n float rgbaToFloat(vec4 rgba) {\n // Convert components from 0->1 back to 0->255 and then add the components together with their corresponding\n // fixed point factors, i.e. (256^1, 256^2, 256^3, 256^4)\n return dot(rgba, RGBA_2_FLOAT_FACTORS);\n }\n\n float linearDepthFromFloat(float depth) {\n depth = pow(depth, 0.2);\n return -(depth * (nearFar[1] - nearFar[0]) + nearFar[0]);\n }\n\n float linearDepthFromRGBA(vec4 depth) {\n return linearDepthFromFloat(rgbaToFloat(depth));\n }\n\n ${"float"===r[0]?"float linearDepthFromTexture(sampler2D depthTex, vec2 uv) {\n ivec2 iuv = ivec2(uv * vec2(textureSize(depthTex, 0)));\n return linearDepthFromRGBA(texelFetch(depthTex, iuv, 0));\n }":"float linearDepthFromTexture(usampler2D depthTex, vec2 uv) {\n ivec2 iuv = ivec2(uv * vec2(textureSize(depthTex, 0)));\n return linearDepthFromRGBA(vec4(texelFetch(depthTex, iuv, 0)) * 255.0);\n }"}\n\n void main() {\n ${h(r)}\n ${a(t,"float depth = 1.0 - pow(texture(depthTex, uv).r, 10.0);\n fragDepth = vec4(vec3(depth), depth < 0.000001 ? 0.0 : 1.0);")}\n }`,f=e.programCache.get(i,d,l);return this._programs.set(o,f),f}};function g(e){switch(e){case"float":return"sampler2D";case"uint":return"usampler2D";case"int":return"isampler2D"}}function v(e){if(!e)return"float";const{internalFormat:t}=e.descriptor;switch(t){case d.R8I:case d.R16I:case d.R32I:case d.RG8I:case d.RG16I:case d.RG32I:case d.RGB8I:case d.RGB16I:case d.RGB32I:case d.RGBA8I:case d.RGBA16I:case d.RGBA32I:return"int";case d.R8UI:case d.R16UI:case d.R32UI:case d.RG8UI:case d.RG16UI:case d.RG32UI:case d.RGB8UI:case d.RGB16UI:case d.RGB32UI:case d.RGBA8UI:case d.RGBA16UI:case d.RGBA32UI:return"uint";default:return"float"}}function x(e){const{hasDepthAttachment:t,colorSamplerTypes:r}=e;return`${t?"Depth":""}${r.reduceRight((e,t)=>e+`|C${t}`,"")}`}function F(e){switch(e){case d.R16F:case d.R32F:case d.R8:return 3;case d.RG8:return 4;case d.RGBA16F:return 5;case d.RG8UI:return 6;default:return 7}}e([r()],m.prototype,"destroyedCB",void 0),e([r()],m.prototype,"produces",void 0),e([r()],m.prototype,"consumes",void 0),e([r()],m.prototype,"clearColor",void 0),m=e([o("esri.views.3d.webgl-engine.effects.debug.RenderNodeVisualizerNode")],m);export{m as RenderNodeVisualizerNode};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{smoothstep as t,clamp as i}from"../../../../../core/mathUtils.js";import{watch as s,syncAndInitial as r}from"../../../../../core/reactiveUtils.js";import{property as a,subclass as
|
|
2
|
+
import{__decorate as e}from"tslib";import{smoothstep as t,clamp as i}from"../../../../../core/mathUtils.js";import{watch as s,syncAndInitial as r}from"../../../../../core/reactiveUtils.js";import{property as a,subclass as o}from"../../../../../core/accessorSupport/decorators.js";import{normalize as h,set as c,dot as n}from"../../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as d}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{RenderNodeOutput as p}from"../../../webgl.js";import m from"../../../webgl/RenderNode.js";import{ShadowHighlightPassParameters as l,ShadowHighlightTechnique as u}from"./ShadowHighlightTechnique.js";import{defaultShadowOpacity as g,defaultShadowDifference as f,defaultShadowColor as _}from"../../../../support/HighlightDefaults.js";const w=1/512,O=4e4,y=5e4;let P=class extends m{constructor(e){super(e),this.produces=p.COMPOSITE,this.consumes={required:[p.COMPOSITE,"highlights"]},this._passParameters=new l,this._maxOpacity=1,this._shadowDifference=.2}initialize(){this.addHandles([s(()=>this.view.defaultHighlight?.shadowOpacity,e=>{this._passParameters.shadowOpacity=e??g,this._updateOccludedShadowOpacity(),this._ensureMaxOpacity()},r),s(()=>this.view.defaultHighlight?.shadowDifference,e=>{this._shadowDifference=e??f,this._updateOccludedShadowOpacity(),this._ensureMaxOpacity()},r),s(()=>this.view.defaultHighlight?.shadowColor,e=>{this._passParameters.shadowColor=(e??_).toUnitRGBA(),this._ensureMaxOpacity()},r)])}_updateOccludedShadowOpacity(){this._passParameters.occludedShadowOpacity=this._passParameters.shadowOpacity*(1-this._shadowDifference)}_ensureMaxOpacity(){const e=Math.max(this._passParameters.shadowOpacity,this._passParameters.occludedShadowOpacity);this._maxOpacity=e*this._passParameters.shadowColor[3],this.requestRender(1)}precompile(){this._ensureIfVisible()&&this.techniques.precompile(u)}render(e){const t=e.find(({name:e})=>e===p.COMPOSITE),i=this.bindParameters;if(!this._ensureIfVisible())return t;const s=this.techniques.getCompiled(u);if(!s)return this.requestRender(1),t;this._passParameters.highlightTexture=e.find(({name:e})=>"highlights"===e)?.getTexture(),this._passParameters.origin=i.camera.center;const r=this.renderingContext;return r.bindFramebuffer(t.fbo),r.bindTechnique(s,i,this._passParameters),r.screen.draw(),t}_ensureIfVisible(){const e=this.bindParameters;if(!e.shadowHighlightsVisible||!e.depth)return!1;const{camera:s,lighting:r}=e;this._passParameters.opacityElevation=1-t(O,y,s.relativeElevation);const a=1===this.viewingMode?h(b,s.center):c(b,0,0,1),o=n(a,r.mainLight.direction);return this._passParameters.dayNightTerminator=t(0,1,i(30*o,0,1)),this._maxOpacity*this._passParameters.opacityElevation*this._passParameters.dayNightTerminator>=w}};e([a()],P.prototype,"produces",void 0),e([a()],P.prototype,"consumes",void 0),e([a({constructOnly:!0})],P.prototype,"viewingMode",void 0),P=e([o("esri.views.3d.webgl-engine.effects.highlight.ShadowHighlight")],P);const b=d();export{P as ShadowHighlight};
|