@arcgis/core 4.32.0-next.20241220 → 4.32.0-next.20241222

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.
Files changed (70) hide show
  1. package/WebLinkChart.js +1 -1
  2. package/assets/esri/core/workers/RemoteClient.js +1 -1
  3. package/assets/esri/core/workers/chunks/127c82cdb229434883b6.js +1 -0
  4. package/assets/esri/core/workers/chunks/16530347bd78dc6c2fcd.js +1 -0
  5. package/assets/esri/core/workers/chunks/{5119811063bfc97fb725.js → 1a713cc601c6fcd97d2f.js} +1 -1
  6. package/assets/esri/core/workers/chunks/{48f6eb3b63fec1d3312d.js → 2d908c115ea18e813b95.js} +1 -1
  7. package/assets/esri/core/workers/chunks/{11052103efe3d53a784e.js → 31d9f0a37a5d0a1c450b.js} +1 -1
  8. package/assets/esri/core/workers/chunks/{e7c3199813070ff30a3d.js → 3bb94da29dac3367ecc6.js} +1 -1
  9. package/assets/esri/core/workers/chunks/3ed7c8138231de3a3b96.js +1 -0
  10. package/assets/esri/core/workers/chunks/{9cc9bac6e02ab241e852.js → 4746b7afa90ea3641e60.js} +1 -1
  11. package/assets/esri/core/workers/chunks/{ce33d2b5f22a5c566661.js → 4b5dbdcad438cb2dd4bf.js} +1 -1
  12. package/assets/esri/core/workers/chunks/{ee1ddf56549bb169509c.js → 6332da54159d72a6ce66.js} +1 -1
  13. package/assets/esri/core/workers/chunks/648d7d8fa19a2e772c89.js +1 -0
  14. package/assets/esri/core/workers/chunks/66b411119b8ffb99b9dc.js +1 -0
  15. package/assets/esri/core/workers/chunks/88c68881cbdf4e911832.js +1 -0
  16. package/assets/esri/core/workers/chunks/8e60de347b209a753c73.js +1 -0
  17. package/assets/esri/core/workers/chunks/{770d233254419b741616.js → 9ad7d095e614e7e8d7f5.js} +1 -1
  18. package/assets/esri/core/workers/chunks/9dd167db3f2e68b71cea.js +1 -0
  19. package/assets/esri/core/workers/chunks/{b15894bff153e0793ef4.js → 9f495ad57cdbfa90c5b8.js} +1 -1
  20. package/assets/esri/core/workers/chunks/{d7b76bc7bff34abc2253.js → a0b3d70a1b0360084593.js} +1 -1
  21. package/assets/esri/core/workers/chunks/{95af4dee29eb196b8ada.js → a90611cdc86190799560.js} +1 -1
  22. package/assets/esri/core/workers/chunks/{e213f4a1c95a33f80cdc.js → aedff36d3fec86abb9fb.js} +1 -1
  23. package/assets/esri/core/workers/chunks/{194013d377e7dd00845f.js → b611f46835edcd6eefcc.js} +1 -1
  24. package/assets/esri/core/workers/chunks/c1c216b0aebe86311fae.js +1 -0
  25. package/assets/esri/core/workers/chunks/{f2b195d04414417682d4.js → cbf57abb537e86c1dd7f.js} +1 -1
  26. package/assets/esri/core/workers/chunks/f9af0473878d960a02f2.js +1 -0
  27. package/assets/esri/core/workers/chunks/fa1c68f2ffcdff7986b6.js +1 -0
  28. package/assets/esri/core/workers/chunks/{0f1a7aeec18db5323365.js → fdd8a5eb07466541f1f9.js} +1 -1
  29. package/form/elements/GroupElement.js +1 -1
  30. package/form/elements/UtilityNetworkAssociationsElement.d.ts +4 -0
  31. package/form/elements/{UtilityNetworkAssociationElement.js → UtilityNetworkAssociationsElement.js} +1 -1
  32. package/form/elements.js +1 -1
  33. package/form/support/formUtils.js +1 -1
  34. package/interfaces.d.ts +178 -67
  35. package/layers/LinkChartLayer.js +1 -1
  36. package/layers/knowledgeGraph/supportUtils.js +1 -1
  37. package/layers/support/VideoElement.js +1 -1
  38. package/linkChart/OrganicLayoutSettings.js +1 -1
  39. package/package.json +1 -1
  40. package/portal/schemas/definitions.js +1 -1
  41. package/rest/knowledgeGraphService.js +1 -1
  42. package/rest/support/fileFormat.js +1 -1
  43. package/support/revision.js +1 -1
  44. package/views/3d/terrain/TileTexture.js +1 -1
  45. package/views/3d/webgl-engine/collections/Component/RenderSubmitSystem.js +1 -1
  46. package/views/3d/webgl-engine/core/renderPasses/RenderPassManager.js +1 -1
  47. package/views/3d/webgl-engine/lib/TextureCompressionWorker.js +1 -1
  48. package/views/3d/webgl-engine/lib/depthRangeUtils.js +1 -1
  49. package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
  50. package/views/support/TextureCompressionHelper.js +1 -1
  51. package/views/webgl/Texture.js +1 -1
  52. package/webscene/Slide.js +1 -1
  53. package/webscene/SlideLegend.d.ts +4 -0
  54. package/webscene/SlideLegend.js +5 -0
  55. package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
  56. package/widgets/FeatureForm.js +1 -1
  57. package/widgets/Print/PrintViewModel.js +1 -1
  58. package/widgets/Print/TemplateOptions.js +1 -1
  59. package/widgets/Print.js +1 -1
  60. package/assets/esri/core/workers/chunks/0e9bd990a8d0691fb9c8.js +0 -1
  61. package/assets/esri/core/workers/chunks/27933d6ffeebb5c13ab7.js +0 -1
  62. package/assets/esri/core/workers/chunks/2c084c0c324e3af56424.js +0 -1
  63. package/assets/esri/core/workers/chunks/48266c87363e7dcaefb3.js +0 -1
  64. package/assets/esri/core/workers/chunks/668679baf519ada9ae28.js +0 -1
  65. package/assets/esri/core/workers/chunks/737f381f2cfeddb96d15.js +0 -1
  66. package/assets/esri/core/workers/chunks/a68068b3151a14c4a0ad.js +0 -1
  67. package/assets/esri/core/workers/chunks/ad99308fb9678cdce917.js +0 -1
  68. package/assets/esri/core/workers/chunks/cc427e8f1b17744b6ea4.js +0 -1
  69. package/assets/esri/core/workers/chunks/dd4bd96dfb7f9921b774.js +0 -1
  70. package/assets/esri/core/workers/chunks/e1a03231e24293e66418.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import"../geometry.js";import{id as e}from"../kernel.js";import t from"../request.js";import r from"../core/Error.js";import a from"../core/Logger.js";import n from"./knowledgeGraph/GraphQueryResult.js";import o from"./knowledgeGraph/GraphQueryResultHeader.js";import i from"./knowledgeGraph/GraphQueryStreamingResult.js";import d from"./knowledgeGraph/KnowledgeGraph.js";import s from"./knowledgeGraph/ServiceDefinition.js";import{encodeClientDataAtKeysRequest as l}from"./knowledgeGraph/wasmInterface/clientDataToWasmEncodedFactories.js";import{getWasmInterface as c}from"./knowledgeGraph/wasmInterface/knowledgeWasmAccess.js";import{setInputQuantizationParametersOnEncoder as p,setOutputQuantizationParametersOnEncoder as u,setProvenanceBehaviorOnEncoder as h,bindParamArrayToWasm as w,geometryToWasm as f,bindParamObjectToWasm as g}from"./knowledgeGraph/wasmInterface/queryToWasmEncodedFactories.js";import{inputQuantizationParametersToWasmFormat as y,namedObjectToWasm as m}from"./knowledgeGraph/wasmInterface/updateToWasmEncodedFactories.js";import{wasmClientDataFetchResponseToClientData as _,wasmClientDataAllKeysResponseToClientDataKeys as k}from"./knowledgeGraph/wasmInterface/wasmToClientDataFactories.js";import{wasmToDataModel as b}from"./knowledgeGraph/wasmInterface/wasmToDataModelFactories.js";import{wasmToGraphQueryResponseHeader as v,decodedWasmObjToQueryResponseObj as x}from"./knowledgeGraph/wasmInterface/wasmToQueryResponseObjFactories.js";import{decoderToApplyEditsResponse as A}from"./knowledgeGraph/wasmInterface/wasmToUpdateResponseFactories.js";import{checkWasmError as G}from"./knowledgeGraph/wasmInterface/wasmUtils.js";import S from"../geometry/SpatialReference.js";import T from"../geometry/Geometry.js";const D=new Map,E=()=>new Map(D.entries()),C={fetchKnowledgeGraph:async e=>{const t=new d({url:e}),r=[];return r.push(W(t)),r.push(L(t)),await Promise.all(r),t},refreshDataModel:async e=>{e.dataModel=await ee(e)},refreshServiceDefinition:async e=>{const r=(await t(e.url,{query:{f:"json"}})).data;return r.capabilities=r?.capabilities?.split(","),r.supportedQueryFormats=r?.supportedQueryFormats?.split(","),e.serviceDefinition=new s(r),e.serviceDefinition},executeQueryStreaming:async(e,t,a)=>{const n="include",o=`${e.url}/graph/query`;await U(e);const d=await O(o,a);if(!e.serviceDefinition?.supportsProvenance&&t.provenanceBehavior===n)throw new r("knowledge-graph:provenance-not-supported","The Knowledge Graph Service definition indicated that provenance is not supported");d.data.body=await $(t,e);const s=await I(d.data.url,d.data);if(e.dataModel){const t=await Z(s,e.dataModel);return new i({resultRowsStream:t.readableStream,resultHeader:t.resultHeader})}throw new r("knowledge-graph:undefined-data-model","The KnowledgeGraph supplied did not have a data model")},executeApplyEdits:async(e,t,a)=>{if(e.serviceDefinition?.dataEditingNotSupported)throw new r("knowledge-graph:data-editing-not-supported","The Knowledge Graph Service definition indicated that data editing is not supported");const n=`${e.url}/graph/applyEdits`;await U(e);const o=await O(n,a);o.data.body=await B(t,e);return V(await I(o.data.url,o.data))},executeQuery:async(e,a,o)=>{const i=`${e.url}/graph/query`,d=await t(i,{responseType:"array-buffer",query:{f:"pbf",openCypherQuery:a.openCypherQuery,...o?.query},signal:o?.signal,timeout:o?.timeout}),s=d.getHeader?.("content-type"),l=d.data;if(s?.includes("application/x-protobuf")){const t=new((await c()).GraphQueryDecoder);if(t.deleteLater(),e.dataModel){const r=X({wasmQueryDecoder:t,newArrayBufferToParse:l,dataModel:e.dataModel});return new n({resultRows:r.resultRows,resultHeader:r.resultHeader})}throw new r("knowledge-graph:undefined-data-model","The KnowledgeGraph supplied did not have a data model")}throw new r("knowledge-graph:unexpected-server-response","server returned an unexpected response",{responseType:s,data:d.data})},executeSearch:async(e,a,o)=>{const i=a.typeCategoryFilter,d=`${e.url}/graph/search`,s=await t(d,{responseType:"array-buffer",query:{f:"pbf",searchQuery:`"${a.searchQuery}"`,typeCategoryFilter:i,...o?.query},signal:o?.signal,timeout:o?.timeout}),l=s.getHeader?.("content-type"),p=s.data;if(l?.includes("application/x-protobuf")){const t=new((await c()).GraphQueryDecoder);if(t.deleteLater(),e.dataModel){const r=X({wasmQueryDecoder:t,newArrayBufferToParse:p,dataModel:e.dataModel});return new n({resultRows:r.resultRows,resultHeader:r.resultHeader})}throw new r("knowledge-graph:undefined-data-model","The KnowledgeGraph supplied did not have a data model")}throw new r("knowledge-graph:unexpected-server-response","server returned an unexpected response",{responseType:l,data:s.data})},executeSearchStreaming:async(e,t,a)=>{const n=`${e.url}/graph/search`;await U(e);const o=await O(n,a);o.data.body=await N(t);const d=await I(o.data.url,o.data);if(e.dataModel){const t=await Z(d,e.dataModel);return new i({resultRowsStream:t.readableStream,resultHeader:t.resultHeader})}throw new r("knowledge-graph:undefined-data-model","The KnowledgeGraph supplied did not have a data model")},fetchClientDataAtKeys:async(e,t,a={ignoreCache:!1})=>{if(!t.length)return new Map;let n=D.get(e.url||"");n||(n=new Map,D.set(e.url||"",n));const o=new Map(n.entries()),i=`${e.url}/clientData/fetch`;t=Array.from(new Set(t));const d=await c(),s=l(t,n,d,a.ignoreCache),p=await O(i,a.requestOptions);p.data.body=s;const u=await I(p.data.url,p.data),h=u.headers.get("content-type");if(h?.includes("application/x-protobuf")){const e=new d.ClientDataFetchResponseDecoder;e.deleteLater();const t=await u.arrayBuffer();return e.decode(new Uint8Array(t)),e.has_error()&&G(e.error,"knowledge-graph:fetchClientDataAtKeys-decoding-error","An error occurred while decoding the client data keys response"),_(e,n,o,a.ignoreCache)}throw new r("knowledge-graph:unexpected-server-response","server returned an unexpected response when fetching client data",{responseType:h,data:u})},fetchAllClientDataKeys:async(e,a)=>{const n=`${e.url}/clientData`,o=await t(n,{responseType:"array-buffer",query:{f:"pbf"},signal:a?.signal,timeout:a?.timeout}),i=o.getHeader?.("content-type"),d=o.data;if(i?.includes("application/x-protobuf")){const e=new((await c()).ClientDataKeysResponseDecoder);return e.deleteLater(),e.decode(new Uint8Array(d)),e.has_error()&&G(e.error,"knowledge-graph:fetchAllClientDataKeys-decoding-error","An error occurred while decoding the client data keys response"),k(e)}throw new r("knowledge-graph:unexpected-server-response","server returned an unexpected response",{responseType:i,data:o.data})},clearClientDataCache:()=>D.clear(),_fetchWrapper:async(e,t)=>fetch(e,t)};async function M(e,t,r){return C.executeApplyEdits(e,t,r)}async function Q(e,t,r){return C.executeQuery(e,t,r)}async function R(e,t,r){return C.executeQueryStreaming(e,t,r)}async function q(e,t,r){return C.executeSearch(e,t,r)}async function j(e,t,r){return C.executeSearchStreaming(e,t,r)}function P(e,t){return C.fetchAllClientDataKeys(e,t)}function F(e,t,r){return C.fetchClientDataAtKeys(e,t,r)}async function H(e){return C.fetchKnowledgeGraph(e)}async function W(e){return C.refreshDataModel(e)}async function L(e){return C.refreshServiceDefinition(e)}function K(){return C.clearClientDataCache()}async function I(e,t){return C._fetchWrapper(e,t)}async function U(t){const r=e?.findCredential(t.url);r||(t.dataModel?await ee(t):await W(t))}function z(e,t,r,a){null==t?r.set_param_key_value(e,""):"object"!=typeof t||t instanceof Date?r.set_param_key_value(e,t):t instanceof T?r.set_param_key_value(e,f(t,a)):Array.isArray(t)?r.set_param_key_value(e,w(t,a)):r.set_param_key_value(e,g(t,a))}async function B(e,t){if(t.dataModel||await W(t),!t.dataModel)throw new r("knowledge-graph:data-model-undefined","Encoding could not proceed because a data model was not provided and it could not be determined from the service");const a=await c(),n=!!e.options?.cascadeDelete,o=new a.GraphApplyEditsEncoder(a.SpatialReferenceUtil.WGS84(),e.options?.inputQuantizationParameters?y(e.options?.inputQuantizationParameters):a.InputQuantizationUtil.WGS84_lossless());o.deleteLater(),o.cascade_delete=n;try{let t;e.entityAdds?.forEach((e=>{t=o.add_entity(m(e,a)),G(t,"knowledge-graph:applyEdits-encoding-failed","Attempting to encode the applyEdits - an entity failed to be added to the encoder")})),e.relationshipAdds?.forEach((e=>{if(!e.originId||!e.destinationId)throw new r("knowledge-graph:relationship-origin-destination-missing","When adding a new relationship, you must provide both an origin and destination id on the appropriate class property");t=o.add_relationship(m(e,a)),G(t,"knowledge-graph:applyEdits-encoding-failed","Attempting to encode the applyEdits - a relationship failed to be added to the encoder")})),e.entityUpdates?.forEach((e=>{if(!e.id)throw new r("knowledge-graph:entity-id-missing","When updating an entity or relationship, you must specify the id on the class level property");t=o.update_entity(m(e,a)),G(t,"knowledge-graph:applyEdits-encoding-failed","Attempting to encode the applyEdits - an entity failed to be added to the encoder")})),e.relationshipUpdates?.forEach((e=>{if(!e.id)throw new r("knowledge-graph:relationship-id-missing","When updating an entity or relationship, you must specify the id on the class level property");t=o.update_relationship(m(e,a)),G(t,"knowledge-graph:applyEdits-encoding-failed","Attempting to encode the applyEdits - a relationship failed to be added to the encoder")})),e.entityDeletes?.forEach((e=>{if(!e.typeName)throw new r("knowledge-graph:no-type-name","You must indicate the entity/relationship named object type to apply edits - delete");const t=o.make_delete_helper(e.typeName,!0);t.deleteLater(),e.ids?.forEach((e=>{t.delete_by_id(e)}))})),e.relationshipDeletes?.forEach((e=>{if(!e.typeName)throw new r("knowledge-graph:no-type-name","You must indicate the entity/relationship named object type to apply edits - delete");const t=o.make_delete_helper(e.typeName,!1);e.ids?.forEach((e=>{t.delete_by_id(e)}))})),o.encode()}catch(d){throw new r("knowledge-graph:applyEdits-encoding-failed","Attempting to encode the applyEdits failed",{error:d})}const i=o.get_encoding_result();return G(i.error,"knowledge-graph:applyEdits-encoding-failed","Attempting to encode the applyEdits failed"),structuredClone(i.get_byte_buffer())}async function $(e,t){const a=await c(),n=new a.GraphQueryRequestEncoder;if(n.deleteLater(),e.outputSpatialReference?n.output_spatial_reference={wkid:e.outputSpatialReference.wkid,latestWkid:e.outputSpatialReference.latestWkid,vcsWkid:e.outputSpatialReference.vcsWkid,latestVcsWkid:e.outputSpatialReference.latestVcsWkid,wkt:e.outputSpatialReference.wkt??""}:n.output_spatial_reference=a.SpatialReferenceUtil.WGS84(),n.open_cypher_query=e.openCypherQuery,e.bindParameters)for(const[r,d]of Object.entries(e.bindParameters))z(r,d,n,a);if(e.bindGeometryQuantizationParameters)p(e.bindGeometryQuantizationParameters,n);else{if(t.dataModel||await W(t),4326!==t.dataModel?.spatialReference?.wkid)throw new r("knowledge-graph:SR-quantization-mismatch","If the DataModel indicates a coordinate system other than WGS84, inputQuantizationParameters must be provided to the query encoder");n.input_quantization_parameters=a.InputQuantizationUtil.WGS84_lossless()}e.outputQuantizationParameters&&u(e.outputQuantizationParameters,n,a),e.provenanceBehavior&&h(e.provenanceBehavior,n);try{n.encode()}catch(i){throw new r("knowledge-graph:query-encoding-failed","Attempting to encode the query failed",{error:i})}const o=n.get_encoding_result();if(0!==o.error.error_code)throw new r("knowledge-graph:query-encoding-failed","Attempting to encode the query failed",{errorCode:o.error.error_code,errorMessage:o.error.error_message});return structuredClone(o.get_byte_buffer())}async function N(e){const t=await c(),a=new t.GraphSearchRequestEncoder;if(a.deleteLater(),a.search_query=e.searchQuery,a.type_category_filter=t.esriNamedTypeCategory[e.typeCategoryFilter],!0===e.returnSearchContext&&(a.return_search_context=e.returnSearchContext),null!=e.start&&e.start>0&&(a.start_index=e.start),null!=e.num&&(a.max_num_results=e.num),null!=e.idsFilter&&Array.isArray(e.idsFilter)&&e.idsFilter.length>0)try{a.set_ids_filter(w(e.idsFilter,t))}catch(o){throw new r("knowledge-graph:ids-format-error","Attempting to set ids filter failed. This is usually caused by an incorrectly formatted UUID string",{error:o})}e.namedTypesFilter?.forEach((e=>{a.add_named_type_filter(e)}));try{a.encode()}catch(o){throw new r("knowledge-graph:search-encoding-failed","Attempting to encode the search failed",{error:o})}const n=a.get_encoding_result();if(0!==n.error.error_code)throw new r("knowledge-graph:search-encoding-failed","Attempting to get encoding result from the query failed",{errorCode:n.error.error_code,errorMessage:n.error.error_message});return structuredClone(n.get_byte_buffer())}async function O(e,r){return t(e,{responseType:"native-request-init",method:"post",query:{f:"pbf",...r?.query},body:"x",headers:{"Content-Type":"application/octet-stream"},signal:r?.signal,timeout:r?.timeout})}async function V(e){const t=e.headers.get("content-type");if(t?.includes("application/x-protobuf")){const t=await e.arrayBuffer(),r=new((await c()).GraphApplyEditsDecoder);return r.deleteLater(),r.decode(new Uint8Array(t)),A(r)}throw new r("knowledge-graph:unexpected-server-response","server returned an unexpected response",{responseType:t,data:e.text()})}let Y=50;function J(e){Y=e}function X({wasmQueryDecoder:e,newArrayBufferToParse:t,dataModel:a,decodedHeader:n,limitMaxProcessingTime:o=!1}){t&&e.push_buffer(new Uint8Array(t));const i=[];let d,s,l=0;const c=Date.now();let p=!0;for(;e.next_row();){d&&s||(d=n??v(e),s=d.outSpatialReference??new S({wkid:4326})),l||(l=e.get_header_keys().size());const t=new Array(l);for(let r=0;r<l;r++){const n=e.get_value(r);t[r]=x(n,a,s)}if(i.push(t),o&&Date.now()-c>Y){p=!1;break}}if(e.has_error())throw new r("knowledge-graph:stream-decoding-error","One or more result rows were not successfully decoded - inner row decoding",{errorCode:e.error.error_code,errorMessage:e.error.error_message});return{resultHeader:d,resultRows:i,parsedAllResultsFromBuffer:p}}async function Z(e,t){const n=e.headers.get("content-type");if(e.headers.get("content-length")&&a.getLogger("esri.rest.knowledgeGraph.knowledgeGraphService").warnOnce("Found `Content-Length` header when expecting a streaming HTTP response! Please investigate whether all intermediate HTTP proxies and/or load balancers are configured such that they don't forcefully buffer the entire response before returning it to the client. A valid HTTP streaming response should use Chunked Transfer Encoding and not have a Content Length defined."),n?.includes("application/x-protobuf")){const n=e.body?.getReader(),i=new((await c()).GraphQueryDecoder);let d,s,l;i.deleteLater();const p=new Promise(((e,t)=>{s=e,l=t}));let u=!1,h=null;const w=new ReadableStream({pull:async function e(c){if(!n){const e=new r("knowledge-graph:stream-decoding-error","Error reading from stream - reader is undefined");throw l(e),e}const{done:p,value:w}=h?{done:!1,value:null}:await n.read().catch((e=>{throw l(e),n.releaseLock(),e}));w&&(h=w);try{if(p){let e;if(i.has_error()?e=new r("knowledge-graph:stream-decoding-error","One or more result rows were not successfully decoded - query stream done",{errorCode:i.error.error_code,errorMessage:i.error.error_message}):u||s(new o),n.releaseLock(),e)throw c.error(e),l(e),e;return void c.close()}const{resultHeader:a,resultRows:f,parsedAllResultsFromBuffer:g}=X({wasmQueryDecoder:i,newArrayBufferToParse:w,dataModel:t,decodedHeader:d,limitMaxProcessingTime:!0});return g&&(h=null),!d&&a&&(d=a,s(a),u=!0),f.length>0?void c.enqueue(f):await e(c)}catch(f){throw a.getLogger("esri.rest.knowledgeGraph.knowledgeGraphService").error(f),l(f),n.releaseLock(),new r("knowledge-graph:unexpected-server-response","Error inside streaming data return parsing",{error:f})}}});return{readableStream:w,resultHeader:await p}}throw new r("knowledge-graph:unexpected-server-response","server returned an unexpected response",{responseType:n,data:e.text()})}async function ee(e){const a=`${e.url}/dataModel/queryDataModel`,n=await t(a,{responseType:"array-buffer",query:{f:"pbf"}}),o=n.getHeader?.("content-type"),i=n.data;if(o?.includes("application/x-protobuf")){const e=(await c()).decode_data_model_from_protocol_buffer(new Uint8Array(i));if(!e)throw new r("knowledge-graph:data-model-decode-failure","The server responded to the data model query, but the response failed to be decoded. This typically occurs when the Knowledge JS API (4.26 or later) is used with an unsupported backend (11.0 or earlier)");return b(e)}throw new r("knowledge-graph:unexpected-server-response","server returned an unexpected response",{responseType:o,data:n.data})}export{I as _fetchWrapper,E as _getClientDataCacheCopy,J as _setMaxQueryParsingDurationForTesting,K as clearClientDataCache,D as clientDataCache,M as executeApplyEdits,Q as executeQuery,R as executeQueryStreaming,q as executeSearch,j as executeSearchStreaming,P as fetchAllClientDataKeys,F as fetchClientDataAtKeys,H as fetchKnowledgeGraph,C as kgRestServices,W as refreshDataModel,L as refreshServiceDefinition};
5
+ import"../geometry.js";import{id as e}from"../kernel.js";import t from"../request.js";import r from"../core/Error.js";import a from"../core/Logger.js";import{isAbortError as n}from"../core/promiseUtils.js";import o from"./knowledgeGraph/GraphQueryResult.js";import i from"./knowledgeGraph/GraphQueryResultHeader.js";import d from"./knowledgeGraph/GraphQueryStreamingResult.js";import s from"./knowledgeGraph/KnowledgeGraph.js";import l from"./knowledgeGraph/ServiceDefinition.js";import{encodeClientDataAtKeysRequest as p}from"./knowledgeGraph/wasmInterface/clientDataToWasmEncodedFactories.js";import{getWasmInterface as c}from"./knowledgeGraph/wasmInterface/knowledgeWasmAccess.js";import{setInputQuantizationParametersOnEncoder as u,setOutputQuantizationParametersOnEncoder as h,setProvenanceBehaviorOnEncoder as w,bindParamArrayToWasm as f,geometryToWasm as g,bindParamObjectToWasm as y}from"./knowledgeGraph/wasmInterface/queryToWasmEncodedFactories.js";import{inputQuantizationParametersToWasmFormat as m,namedObjectToWasm as _}from"./knowledgeGraph/wasmInterface/updateToWasmEncodedFactories.js";import{wasmClientDataFetchResponseToClientData as k,wasmClientDataAllKeysResponseToClientDataKeys as b}from"./knowledgeGraph/wasmInterface/wasmToClientDataFactories.js";import{wasmToDataModel as v}from"./knowledgeGraph/wasmInterface/wasmToDataModelFactories.js";import{wasmToGraphQueryResponseHeader as x,decodedWasmObjToQueryResponseObj as A}from"./knowledgeGraph/wasmInterface/wasmToQueryResponseObjFactories.js";import{decoderToApplyEditsResponse as G}from"./knowledgeGraph/wasmInterface/wasmToUpdateResponseFactories.js";import{checkWasmError as S}from"./knowledgeGraph/wasmInterface/wasmUtils.js";import T from"../geometry/SpatialReference.js";import D from"../geometry/Geometry.js";const E=new Map,C=()=>new Map(E.entries()),M={fetchKnowledgeGraph:async e=>{const t=new s({url:e}),r=[];return r.push(L(t)),r.push(K(t)),await Promise.all(r),t},refreshDataModel:async e=>{e.dataModel=await te(e)},refreshServiceDefinition:async e=>{const r=(await t(e.url,{query:{f:"json"}})).data;return r.capabilities=r?.capabilities?.split(","),r.supportedQueryFormats=r?.supportedQueryFormats?.split(","),e.serviceDefinition=new l(r),e.serviceDefinition},executeQueryStreaming:async(e,t,a)=>{const n="include",o=`${e.url}/graph/query`;await z(e);const i=await V(o,a);if(!e.serviceDefinition?.supportsProvenance&&t.provenanceBehavior===n)throw new r("knowledge-graph:provenance-not-supported","The Knowledge Graph Service definition indicated that provenance is not supported");i.data.body=await N(t,e);const s=await U(i.data.url,i.data);if(e.dataModel){const t=await ee(s,e.dataModel);return new d({resultRowsStream:t.readableStream,resultHeader:t.resultHeader})}throw new r("knowledge-graph:undefined-data-model","The KnowledgeGraph supplied did not have a data model")},executeApplyEdits:async(e,t,a)=>{if(e.serviceDefinition?.dataEditingNotSupported)throw new r("knowledge-graph:data-editing-not-supported","The Knowledge Graph Service definition indicated that data editing is not supported");const n=`${e.url}/graph/applyEdits`;await z(e);const o=await V(n,a);o.data.body=await $(t,e);return Y(await U(o.data.url,o.data))},executeQuery:async(e,a,n)=>{const i=`${e.url}/graph/query`,d=await t(i,{responseType:"array-buffer",query:{f:"pbf",openCypherQuery:a.openCypherQuery,...n?.query},signal:n?.signal,timeout:n?.timeout}),s=d.getHeader?.("content-type"),l=d.data;if(s?.includes("application/x-protobuf")){const t=new((await c()).GraphQueryDecoder);if(t.deleteLater(),e.dataModel){const r=Z({wasmQueryDecoder:t,newArrayBufferToParse:l,dataModel:e.dataModel});return new o({resultRows:r.resultRows,resultHeader:r.resultHeader})}throw new r("knowledge-graph:undefined-data-model","The KnowledgeGraph supplied did not have a data model")}throw new r("knowledge-graph:unexpected-server-response","server returned an unexpected response",{responseType:s,data:d.data})},executeSearch:async(e,a,n)=>{const i=a.typeCategoryFilter,d=`${e.url}/graph/search`,s=await t(d,{responseType:"array-buffer",query:{f:"pbf",searchQuery:`"${a.searchQuery}"`,typeCategoryFilter:i,...n?.query},signal:n?.signal,timeout:n?.timeout}),l=s.getHeader?.("content-type"),p=s.data;if(l?.includes("application/x-protobuf")){const t=new((await c()).GraphQueryDecoder);if(t.deleteLater(),e.dataModel){const r=Z({wasmQueryDecoder:t,newArrayBufferToParse:p,dataModel:e.dataModel});return new o({resultRows:r.resultRows,resultHeader:r.resultHeader})}throw new r("knowledge-graph:undefined-data-model","The KnowledgeGraph supplied did not have a data model")}throw new r("knowledge-graph:unexpected-server-response","server returned an unexpected response",{responseType:l,data:s.data})},executeSearchStreaming:async(e,t,a)=>{const n=`${e.url}/graph/search`;await z(e);const o=await V(n,a);o.data.body=await O(t);const i=await U(o.data.url,o.data);if(e.dataModel){const t=await ee(i,e.dataModel);return new d({resultRowsStream:t.readableStream,resultHeader:t.resultHeader})}throw new r("knowledge-graph:undefined-data-model","The KnowledgeGraph supplied did not have a data model")},fetchClientDataAtKeys:async(e,t,a={ignoreCache:!1})=>{if(!t.length)return new Map;let n=E.get(e.url||"");n||(n=new Map,E.set(e.url||"",n));const o=new Map(n.entries()),i=`${e.url}/clientData/fetch`;t=Array.from(new Set(t));const d=await c(),s=p(t,n,d,a.ignoreCache),l=await V(i,a.requestOptions);l.data.body=s;const u=await U(l.data.url,l.data),h=u.headers.get("content-type");if(h?.includes("application/x-protobuf")){const e=new d.ClientDataFetchResponseDecoder;e.deleteLater();const t=await u.arrayBuffer();return e.decode(new Uint8Array(t)),e.has_error()&&S(e.error,"knowledge-graph:fetchClientDataAtKeys-decoding-error","An error occurred while decoding the client data keys response"),k(e,n,o,a.ignoreCache)}throw new r("knowledge-graph:unexpected-server-response","server returned an unexpected response when fetching client data",{responseType:h,data:u})},fetchAllClientDataKeys:async(e,a)=>{const n=`${e.url}/clientData`,o=await t(n,{responseType:"array-buffer",query:{f:"pbf"},signal:a?.signal,timeout:a?.timeout}),i=o.getHeader?.("content-type"),d=o.data;if(i?.includes("application/x-protobuf")){const e=new((await c()).ClientDataKeysResponseDecoder);return e.deleteLater(),e.decode(new Uint8Array(d)),e.has_error()&&S(e.error,"knowledge-graph:fetchAllClientDataKeys-decoding-error","An error occurred while decoding the client data keys response"),b(e)}throw new r("knowledge-graph:unexpected-server-response","server returned an unexpected response",{responseType:i,data:o.data})},clearClientDataCache:()=>E.clear(),_fetchWrapper:async(e,t)=>fetch(e,t)};async function Q(e,t,r){return M.executeApplyEdits(e,t,r)}async function R(e,t,r){return M.executeQuery(e,t,r)}async function q(e,t,r){return M.executeQueryStreaming(e,t,r)}async function j(e,t,r){return M.executeSearch(e,t,r)}async function P(e,t,r){return M.executeSearchStreaming(e,t,r)}function F(e,t){return M.fetchAllClientDataKeys(e,t)}function H(e,t,r){return M.fetchClientDataAtKeys(e,t,r)}async function W(e){return M.fetchKnowledgeGraph(e)}async function L(e){return M.refreshDataModel(e)}async function K(e){return M.refreshServiceDefinition(e)}function I(){return M.clearClientDataCache()}async function U(e,t){return M._fetchWrapper(e,t)}async function z(t){const r=e?.findCredential(t.url);r||(t.dataModel?await te(t):await L(t))}function B(e,t,r,a){null==t?r.set_param_key_value(e,""):"object"!=typeof t||t instanceof Date?r.set_param_key_value(e,t):t instanceof D?r.set_param_key_value(e,g(t,a)):Array.isArray(t)?r.set_param_key_value(e,f(t,a)):r.set_param_key_value(e,y(t,a))}async function $(e,t){if(t.dataModel||await L(t),!t.dataModel)throw new r("knowledge-graph:data-model-undefined","Encoding could not proceed because a data model was not provided and it could not be determined from the service");const a=await c(),n=!!e.options?.cascadeDelete,o=new a.GraphApplyEditsEncoder(a.SpatialReferenceUtil.WGS84(),e.options?.inputQuantizationParameters?m(e.options?.inputQuantizationParameters):a.InputQuantizationUtil.WGS84_lossless());o.deleteLater(),o.cascade_delete=n;try{let t;e.entityAdds?.forEach((e=>{t=o.add_entity(_(e,a)),S(t,"knowledge-graph:applyEdits-encoding-failed","Attempting to encode the applyEdits - an entity failed to be added to the encoder")})),e.relationshipAdds?.forEach((e=>{if(!e.originId||!e.destinationId)throw new r("knowledge-graph:relationship-origin-destination-missing","When adding a new relationship, you must provide both an origin and destination id on the appropriate class property");t=o.add_relationship(_(e,a)),S(t,"knowledge-graph:applyEdits-encoding-failed","Attempting to encode the applyEdits - a relationship failed to be added to the encoder")})),e.entityUpdates?.forEach((e=>{if(!e.id)throw new r("knowledge-graph:entity-id-missing","When updating an entity or relationship, you must specify the id on the class level property");t=o.update_entity(_(e,a)),S(t,"knowledge-graph:applyEdits-encoding-failed","Attempting to encode the applyEdits - an entity failed to be added to the encoder")})),e.relationshipUpdates?.forEach((e=>{if(!e.id)throw new r("knowledge-graph:relationship-id-missing","When updating an entity or relationship, you must specify the id on the class level property");t=o.update_relationship(_(e,a)),S(t,"knowledge-graph:applyEdits-encoding-failed","Attempting to encode the applyEdits - a relationship failed to be added to the encoder")})),e.entityDeletes?.forEach((e=>{if(!e.typeName)throw new r("knowledge-graph:no-type-name","You must indicate the entity/relationship named object type to apply edits - delete");const t=o.make_delete_helper(e.typeName,!0);t.deleteLater(),e.ids?.forEach((e=>{t.delete_by_id(e)}))})),e.relationshipDeletes?.forEach((e=>{if(!e.typeName)throw new r("knowledge-graph:no-type-name","You must indicate the entity/relationship named object type to apply edits - delete");const t=o.make_delete_helper(e.typeName,!1);e.ids?.forEach((e=>{t.delete_by_id(e)}))})),o.encode()}catch(d){throw new r("knowledge-graph:applyEdits-encoding-failed","Attempting to encode the applyEdits failed",{error:d})}const i=o.get_encoding_result();return S(i.error,"knowledge-graph:applyEdits-encoding-failed","Attempting to encode the applyEdits failed"),structuredClone(i.get_byte_buffer())}async function N(e,t){const a=await c(),n=new a.GraphQueryRequestEncoder;if(n.deleteLater(),e.outputSpatialReference?n.output_spatial_reference={wkid:e.outputSpatialReference.wkid,latestWkid:e.outputSpatialReference.latestWkid,vcsWkid:e.outputSpatialReference.vcsWkid,latestVcsWkid:e.outputSpatialReference.latestVcsWkid,wkt:e.outputSpatialReference.wkt??""}:n.output_spatial_reference=a.SpatialReferenceUtil.WGS84(),n.open_cypher_query=e.openCypherQuery,e.bindParameters)for(const[r,d]of Object.entries(e.bindParameters))B(r,d,n,a);if(e.bindGeometryQuantizationParameters)u(e.bindGeometryQuantizationParameters,n);else{if(t.dataModel||await L(t),4326!==t.dataModel?.spatialReference?.wkid)throw new r("knowledge-graph:SR-quantization-mismatch","If the DataModel indicates a coordinate system other than WGS84, inputQuantizationParameters must be provided to the query encoder");n.input_quantization_parameters=a.InputQuantizationUtil.WGS84_lossless()}e.outputQuantizationParameters&&h(e.outputQuantizationParameters,n,a),e.provenanceBehavior&&w(e.provenanceBehavior,n);try{n.encode()}catch(i){throw new r("knowledge-graph:query-encoding-failed","Attempting to encode the query failed",{error:i})}const o=n.get_encoding_result();if(0!==o.error.error_code)throw new r("knowledge-graph:query-encoding-failed","Attempting to encode the query failed",{errorCode:o.error.error_code,errorMessage:o.error.error_message});return structuredClone(o.get_byte_buffer())}async function O(e){const t=await c(),a=new t.GraphSearchRequestEncoder;if(a.deleteLater(),a.search_query=e.searchQuery,a.type_category_filter=t.esriNamedTypeCategory[e.typeCategoryFilter],!0===e.returnSearchContext&&(a.return_search_context=e.returnSearchContext),null!=e.start&&e.start>0&&(a.start_index=e.start),null!=e.num&&(a.max_num_results=e.num),null!=e.idsFilter&&Array.isArray(e.idsFilter)&&e.idsFilter.length>0)try{a.set_ids_filter(f(e.idsFilter,t))}catch(o){throw new r("knowledge-graph:ids-format-error","Attempting to set ids filter failed. This is usually caused by an incorrectly formatted UUID string",{error:o})}e.namedTypesFilter?.forEach((e=>{a.add_named_type_filter(e)}));try{a.encode()}catch(o){throw new r("knowledge-graph:search-encoding-failed","Attempting to encode the search failed",{error:o})}const n=a.get_encoding_result();if(0!==n.error.error_code)throw new r("knowledge-graph:search-encoding-failed","Attempting to get encoding result from the query failed",{errorCode:n.error.error_code,errorMessage:n.error.error_message});return structuredClone(n.get_byte_buffer())}async function V(e,r){return t(e,{responseType:"native-request-init",method:"post",query:{f:"pbf",...r?.query},body:"x",headers:{"Content-Type":"application/octet-stream"},signal:r?.signal,timeout:r?.timeout})}async function Y(e){const t=e.headers.get("content-type");if(t?.includes("application/x-protobuf")){const t=await e.arrayBuffer(),r=new((await c()).GraphApplyEditsDecoder);return r.deleteLater(),r.decode(new Uint8Array(t)),G(r)}throw new r("knowledge-graph:unexpected-server-response","server returned an unexpected response",{responseType:t,data:e.text()})}let J=50;function X(e){J=e}function Z({wasmQueryDecoder:e,newArrayBufferToParse:t,dataModel:a,decodedHeader:n,limitMaxProcessingTime:o=!1}){t&&e.push_buffer(new Uint8Array(t));const i=[];let d,s,l=0;const p=Date.now();let c=!0;for(;e.next_row();){d&&s||(d=n??x(e),s=d.outSpatialReference??new T({wkid:4326})),l||(l=e.get_header_keys().size());const t=new Array(l);for(let r=0;r<l;r++){const n=e.get_value(r);t[r]=A(n,a,s)}if(i.push(t),o&&Date.now()-p>J){c=!1;break}}if(e.has_error())throw new r("knowledge-graph:stream-decoding-error","One or more result rows were not successfully decoded - inner row decoding",{errorCode:e.error.error_code,errorMessage:e.error.error_message});return{resultHeader:d,resultRows:i,parsedAllResultsFromBuffer:c}}async function ee(e,t){const o=e.headers.get("content-type");if(e.headers.get("content-length")&&a.getLogger("esri.rest.knowledgeGraph.knowledgeGraphService").warnOnce("Found `Content-Length` header when expecting a streaming HTTP response! Please investigate whether all intermediate HTTP proxies and/or load balancers are configured such that they don't forcefully buffer the entire response before returning it to the client. A valid HTTP streaming response should use Chunked Transfer Encoding and not have a Content Length defined."),o?.includes("application/x-protobuf")){const o=e.body?.getReader(),d=new((await c()).GraphQueryDecoder);let s,l,p;d.deleteLater();const u=new Promise(((e,t)=>{l=e,p=t}));let h=!1,w=null;const f=new ReadableStream({pull:async function e(c){if(!o){const e=new r("knowledge-graph:stream-decoding-error","Error reading from stream - reader is undefined");throw p(e),e}const{done:u,value:f}=w?{done:!1,value:null}:await o.read().catch((e=>{throw p(e),o.releaseLock(),e}));f&&(w=f);try{if(u){let e;if(d.has_error()?e=new r("knowledge-graph:stream-decoding-error","One or more result rows were not successfully decoded - query stream done",{errorCode:d.error.error_code,errorMessage:d.error.error_message}):h||l(new i),o.releaseLock(),e)throw c.error(e),p(e),e;return void c.close()}const{resultHeader:a,resultRows:n,parsedAllResultsFromBuffer:g}=Z({wasmQueryDecoder:d,newArrayBufferToParse:f,dataModel:t,decodedHeader:s,limitMaxProcessingTime:!0});return g&&(w=null),!s&&a&&(s=a,l(a),h=!0),n.length>0?void c.enqueue(n):await e(c)}catch(g){throw a.getLogger("esri.rest.knowledgeGraph.knowledgeGraphService").error(g),p(g),o.releaseLock(),n(g)?g:new r("knowledge-graph:unexpected-server-response","Error inside streaming data return parsing",{error:g})}}});return{readableStream:f,resultHeader:await u}}throw new r("knowledge-graph:unexpected-server-response","server returned an unexpected response",{responseType:o,data:e.text()})}async function te(e){const a=`${e.url}/dataModel/queryDataModel`,n=await t(a,{responseType:"array-buffer",query:{f:"pbf"}}),o=n.getHeader?.("content-type"),i=n.data;if(o?.includes("application/x-protobuf")){const e=(await c()).decode_data_model_from_protocol_buffer(new Uint8Array(i));if(!e)throw new r("knowledge-graph:data-model-decode-failure","The server responded to the data model query, but the response failed to be decoded. This typically occurs when the Knowledge JS API (4.26 or later) is used with an unsupported backend (11.0 or earlier)");return v(e)}throw new r("knowledge-graph:unexpected-server-response","server returned an unexpected response",{responseType:o,data:n.data})}export{U as _fetchWrapper,C as _getClientDataCacheCopy,X as _setMaxQueryParsingDurationForTesting,I as clearClientDataCache,E as clientDataCache,Q as executeApplyEdits,R as executeQuery,q as executeQueryStreaming,j as executeSearch,P as executeSearchStreaming,F as fetchAllClientDataKeys,H as fetchClientDataAtKeys,W as fetchKnowledgeGraph,M as kgRestServices,L as refreshDataModel,K as refreshServiceDefinition};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{strict as p}from"../../core/jsonMap.js";const g=p()({AIX:"aix",EPS:"eps",GIF:"gif",JPG:"jpg",PDF:"pdf",PNG32:"png32",PNG8:"png8",SVG:"svg",SVGZ:"svgz",TIFF:"tiff"});export{g as formatJsonMap};
5
+ import{strict as n}from"../../core/jsonMap.js";const o=n()({AIX:"aix",EPS:"eps",GIF:"gif",JPG:"jpg",PDF:"pdf",PNG32:"png32",PNG8:"png8",SVG:"svg",SVGZ:"svgz",TIFF:"tiff"},{ignoreUnknown:!1});export{o as formatJsonMap};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- const c="20241220",b="71bcf4dd5c83009937c33220ba9765f643881234";export{c as buildDate,b as commitHash};
5
+ const e="20241222",b="364e0177afd8e82777b3cd60be03f5708e113306";export{e as buildDate,b as commitHash};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- class t{constructor(t,e){this._texture=t,this._cache=e,this.type="tile-texture",this._refCount=1}retain(){++this._refCount}release(){if(--this._refCount,0===this._refCount)if(this._cache){const t=`${this._texture.descriptor.width} ${this._texture.descriptor.pixelFormat}`;this._cache.put(t,this)}else this.dispose()}dispose(){this._texture.dispose()}get texture(){return this._texture}generateMipmap(){this._texture.generateMipmap()}get descriptor(){return this._texture.descriptor}get cachedMemory(){return this._texture.usedMemory}}export{t as default};
5
+ class t{constructor(t,e){this._texture=t,this._cache=e,this.type="tile-texture",this._refCount=1}retain(){++this._refCount}release(){if(--this._refCount,0===this._refCount)if(this._cache&&!this._texture.isCompressing){const t=`${this._texture.descriptor.width} ${this._texture.descriptor.pixelFormat}`;this._cache.put(t,this)}else this.dispose()}dispose(){this._texture.dispose()}get texture(){return this._texture}generateMipmap(){this._texture.generateMipmap()}get descriptor(){return this._texture.descriptor}get cachedMemory(){return this._texture.usedMemory}}export{t as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{computeDepthRange as s}from"./DepthRange.js";class e{constructor(s){this._objects=s}submit(s,e){this._objects.preSubmit(e),this._objects.visibleObjects.forAll((t=>t.renderable.material.submit(s,e,t)))}queryShadowCasterDepthRange(e){return this._objects.visibleObjects.length?s(e,this._objects.visibleObjects):null}get hasEmissions(){return this._objects.visibleObjects.some((s=>s.renderable.material.hasEmissions))}}export{e as RenderSubmitSystem};
5
+ import{computeDepthRange as s}from"./DepthRange.js";class e{constructor(s){this._objects=s}submit(s,e){this._objects.preSubmit(e),this._objects.visibleObjects.forAll((t=>t.renderable.material.submit(s,e,t)))}queryDepthRange(e){return this._objects.visibleObjects.length?s(e,this._objects.visibleObjects):null}get hasEmissions(){return this._objects.visibleObjects.some((s=>s.renderable.material.hasEmissions))}}export{e as RenderSubmitSystem};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{_ as s}from"../../../../../chunks/tslib.es6.js";import"../../../../../core/Logger.js";import"../../../../../core/has.js";import"../../../../../core/RandomLCG.js";import"../../../../../core/Error.js";import{subclass as e}from"../../../../../core/accessorSupport/decorators/subclass.js";import{fromMat4 as t,transpose as a,invert as r}from"../../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as i}from"../../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{copy as h}from"../../../../../core/libs/gl-matrix-2/math/mat4.js";import{i as o,c as n}from"../../../../../chunks/vec32.js";import{create as m}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{MaterialPassParameters as l,ShadowMapPassParameters as c,HighlightPassParameters as p,ViewshedShadowMapPassParameters as d,RenderPassIdentifier as u}from"./AllRenderPasses.js";import{RenderPass as _,RenderPassSorting as g}from"./RenderPass.js";import{ShaderOutput as w}from"../shaderLibrary/ShaderOutput.js";import{TwoVectorPosition as P}from"../util/TwoVectorPosition.js";import{SyncRenderPlugin as f}from"../../effects/RenderPlugin.js";import{DepthRange as R}from"../../lib/DepthRange.js";import{RenderSlot as S}from"../../lib/RenderSlot.js";let E=class extends f{constructor(){super({}),this._passes=null,this.produces=new Map([[S.OPAQUE_MATERIAL,s=>this._produces(s)],[S.TRANSPARENT_MATERIAL,s=>!!(this._passes&&this._passes.materialTransparent.count>0)&&this._produces(s)],[S.INTEGRATED_MESH,s=>this._produces(s)]]),this._materialPassParameters=new l,this._shadowPassParameters=new c,this._highlightPassParameters=new p,this._viewshedPassParameters=new d,this._systems=new Set}initializeRenderContext(s){this._context=s;const e=s.renderContext.rctx,t=s.techniques;this._passes={materialOpaque:new _(e,t),materialTransparent:new _(e,t,g.BackToFront),materialIntegratedMesh:new _(e,t),shadowMap:new _(e,t),highlight:new _(e,t),highlightIntegratedMesh:new _(e,t),highlightShadowMap:new _(e,t),viewshedShadowMap:new _(e,t),defaultShadowMap:new _(e,t)}}get rctx(){return this._context.renderContext.rctx}uninitializeRenderContext(){}dispose(){this._context=null,this._systems.clear()}register(s){this._systems.add(s)}_produces(s){return 0!==this._systems.size&&null!==this._passes&&(s===w.Highlight?this._passes.highlight.count>0||this._passes.highlightIntegratedMesh.count>0:s!==w.ShadowHighlight||this._passes.highlight.count>0)}prepareRender(s){if(0!==this._systems.size&&null!==this._passes){for(const s of Object.values(this._passes))s.prepareSubmit();this._systems.forEach((e=>e.submit(this._passes,s.bind)));for(const s of Object.values(this._passes))s.finishSubmit();this._context.techniques.frameUpdate()}}acquireTechniques(s){if(0===this._systems.size)return null;const e=s.output===w.Shadow||s.output===w.ShadowHighlight||s.output===w.ShadowExcludeHighlight?this._shadowPassParameters:s.output===w.ViewshedShadow?this._viewshedPassParameters:s.output===w.Highlight?this._highlightPassParameters:this._materialPassParameters,t=s.bind;return this._updateParameters(t.camera,e,t.slot===S.TRANSPARENT_MATERIAL),this._materialPassParameters.output=s.output,this._invoke(s,((e,t)=>e.acquire(t,s.bind)))}render(s,e){this._invoke(s,((t,a)=>t.dispatch(a,s.bind,e)))}_invoke(s,e){if(null===this._passes)return null;const t=s.output;switch(s.bind.slot){case S.OPAQUE_MATERIAL:switch(t){case w.Color:case w.ColorEmission:case w.Depth:case w.Normal:case w.ObjectAndLayerIdColor:return e(this._passes.materialOpaque,this._materialPassParameters);case w.Highlight:return e(this._passes.highlight,this._highlightPassParameters);case w.Shadow:return e(this._passes.shadowMap,this._shadowPassParameters);case w.ShadowHighlight:return e(this._passes.highlightShadowMap,this._shadowPassParameters);case w.ShadowExcludeHighlight:return e(this._passes.defaultShadowMap,this._shadowPassParameters);case w.ViewshedShadow:return e(this._passes.viewshedShadowMap,this._viewshedPassParameters)}break;case S.TRANSPARENT_MATERIAL:switch(t){case w.Color:case w.ColorEmission:case w.Depth:case w.Normal:case w.ObjectAndLayerIdColor:return e(this._passes.materialTransparent,this._materialPassParameters)}break;case S.INTEGRATED_MESH:switch(t){case w.Color:case w.ColorEmission:case w.Depth:case w.Normal:case w.ObjectAndLayerIdColor:return e(this._passes.materialIntegratedMesh,this._materialPassParameters);case w.Highlight:return e(this._passes.highlightIntegratedMesh,this._highlightPassParameters)}}return null}notifyDirty(){this._context.requestRender()}queryDepthRange(s){const e=new R;return this._systems.forEach((t=>e.union(t.queryShadowCasterDepthRange(s)))),e}get hasEmissions(){let s=!1;return this._systems.forEach((e=>s=e.hasEmissions||s)),s}_updateParameters(s,e,i){const m=s.viewInverseTransposeMatrix;o(b,m[3],m[7],m[11]),j.set(b),n(e.transformWorldFromViewTH,j.high),n(e.transformWorldFromViewTL,j.low),n(e.slicePlaneLocalOrigin,b),t(e.transformViewFromCameraRelativeRS,s.viewMatrix),h(e.transformProjFromView,s.projectionMatrix),e.identifier===u.Material&&(this._materialPassParameters.transparent=i,a(M,e.transformViewFromCameraRelativeRS),r(e.transformNormalViewFromGlobal,M))}};E=s([e("esri.views.3d.webgl-engine.core.renderPasses.RenderPassManager")],E);const b=m(),M=i(),j=new P;export{E as RenderPassManager};
5
+ import{_ as s}from"../../../../../chunks/tslib.es6.js";import"../../../../../core/Logger.js";import"../../../../../core/has.js";import"../../../../../core/RandomLCG.js";import"../../../../../core/Error.js";import{subclass as e}from"../../../../../core/accessorSupport/decorators/subclass.js";import{fromMat4 as t,transpose as a,invert as r}from"../../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as i}from"../../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{copy as h}from"../../../../../core/libs/gl-matrix-2/math/mat4.js";import{i as o,c as n}from"../../../../../chunks/vec32.js";import{create as m}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{MaterialPassParameters as l,ShadowMapPassParameters as c,HighlightPassParameters as p,ViewshedShadowMapPassParameters as d,RenderPassIdentifier as u}from"./AllRenderPasses.js";import{RenderPass as _,RenderPassSorting as g}from"./RenderPass.js";import{ShaderOutput as w}from"../shaderLibrary/ShaderOutput.js";import{TwoVectorPosition as P}from"../util/TwoVectorPosition.js";import{SyncRenderPlugin as f}from"../../effects/RenderPlugin.js";import{DepthRange as R}from"../../lib/DepthRange.js";import{RenderSlot as S}from"../../lib/RenderSlot.js";let E=class extends f{constructor(){super({}),this._passes=null,this.produces=new Map([[S.OPAQUE_MATERIAL,s=>this._produces(s)],[S.TRANSPARENT_MATERIAL,s=>!!(this._passes&&this._passes.materialTransparent.count>0)&&this._produces(s)],[S.INTEGRATED_MESH,s=>this._produces(s)]]),this._materialPassParameters=new l,this._shadowPassParameters=new c,this._highlightPassParameters=new p,this._viewshedPassParameters=new d,this._systems=new Set}initializeRenderContext(s){this._context=s;const e=s.renderContext.rctx,t=s.techniques;this._passes={materialOpaque:new _(e,t),materialTransparent:new _(e,t,g.BackToFront),materialIntegratedMesh:new _(e,t),shadowMap:new _(e,t),highlight:new _(e,t),highlightIntegratedMesh:new _(e,t),highlightShadowMap:new _(e,t),viewshedShadowMap:new _(e,t),defaultShadowMap:new _(e,t)}}get rctx(){return this._context.renderContext.rctx}uninitializeRenderContext(){}dispose(){this._context=null,this._systems.clear()}register(s){this._systems.add(s)}_produces(s){return 0!==this._systems.size&&null!==this._passes&&(s===w.Highlight?this._passes.highlight.count>0||this._passes.highlightIntegratedMesh.count>0:s!==w.ShadowHighlight||this._passes.highlight.count>0)}prepareRender(s){if(0!==this._systems.size&&null!==this._passes){for(const s of Object.values(this._passes))s.prepareSubmit();this._systems.forEach((e=>e.submit(this._passes,s.bind)));for(const s of Object.values(this._passes))s.finishSubmit();this._context.techniques.frameUpdate()}}acquireTechniques(s){if(0===this._systems.size)return null;const e=s.output===w.Shadow||s.output===w.ShadowHighlight||s.output===w.ShadowExcludeHighlight?this._shadowPassParameters:s.output===w.ViewshedShadow?this._viewshedPassParameters:s.output===w.Highlight?this._highlightPassParameters:this._materialPassParameters,t=s.bind;return this._updateParameters(t.camera,e,t.slot===S.TRANSPARENT_MATERIAL),this._materialPassParameters.output=s.output,this._invoke(s,((e,t)=>e.acquire(t,s.bind)))}render(s,e){this._invoke(s,((t,a)=>t.dispatch(a,s.bind,e)))}_invoke(s,e){if(null===this._passes)return null;const t=s.output;switch(s.bind.slot){case S.OPAQUE_MATERIAL:switch(t){case w.Color:case w.ColorEmission:case w.Depth:case w.Normal:case w.ObjectAndLayerIdColor:return e(this._passes.materialOpaque,this._materialPassParameters);case w.Highlight:return e(this._passes.highlight,this._highlightPassParameters);case w.Shadow:return e(this._passes.shadowMap,this._shadowPassParameters);case w.ShadowHighlight:return e(this._passes.highlightShadowMap,this._shadowPassParameters);case w.ShadowExcludeHighlight:return e(this._passes.defaultShadowMap,this._shadowPassParameters);case w.ViewshedShadow:return e(this._passes.viewshedShadowMap,this._viewshedPassParameters)}break;case S.TRANSPARENT_MATERIAL:switch(t){case w.Color:case w.ColorEmission:case w.Depth:case w.Normal:case w.ObjectAndLayerIdColor:return e(this._passes.materialTransparent,this._materialPassParameters)}break;case S.INTEGRATED_MESH:switch(t){case w.Color:case w.ColorEmission:case w.Depth:case w.Normal:case w.ObjectAndLayerIdColor:return e(this._passes.materialIntegratedMesh,this._materialPassParameters);case w.Highlight:return e(this._passes.highlightIntegratedMesh,this._highlightPassParameters)}}return null}notifyDirty(){this._context.requestRender()}queryDepthRange(s){const e=new R;return this._systems.forEach((t=>e.union(t.queryDepthRange(s)))),e}get hasEmissions(){let s=!1;return this._systems.forEach((e=>s=e.hasEmissions||s)),s}_updateParameters(s,e,i){const m=s.viewInverseTransposeMatrix;o(b,m[3],m[7],m[11]),j.set(b),n(e.transformWorldFromViewTH,j.high),n(e.transformWorldFromViewTL,j.low),n(e.slicePlaneLocalOrigin,b),t(e.transformViewFromCameraRelativeRS,s.viewMatrix),h(e.transformProjFromView,s.projectionMatrix),e.identifier===u.Material&&(this._materialPassParameters.transparent=i,a(M,e.transformViewFromCameraRelativeRS),r(e.transformNormalViewFromGlobal,M))}};E=s([e("esri.views.3d.webgl-engine.core.renderPasses.RenderPassManager")],E);const b=m(),M=i(),j=new P;export{E as RenderPassManager};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{getBasisEncoder as e}from"../../../../libs/basisu/BasisUEncoder.js";import{TextureFormat as t}from"../../../../libs/basisu/TextureFormat.js";import{CompressedTextureFormat as s,PixelFormat as n}from"../../../webgl/enums.js";let r=null,a=null;class l{constructor(e,t){this.internalFormat=e,this.compressedTexture=t}}async function i(e){await o();const t=await c(e.data,e.width,e.height,e.hasMipmap),s=t?await u(t,e.hasETC,e.hasS3TC):null;return{result:new l(s?.internalFormat??null,s?.compressedTexture??null)}}async function o(){return null==a&&(a=e(),r=await e()),a}async function c(e,t,s,n,a=255,l=0,i=!1,c=!1){null==r&&(r=await o());const u=new r.BasisEncoder;u.setUASTC(!1),u.setHDR(!1),u.setPerceptual(!c),u.setCheckForAlpha(!0),u.setForceAlpha(!1),u.setRenormalize(c),u.setMipGen(n),u.setMipSRGB(!c),u.setCreateKTX2File(!0),u.setKTX2UASTCSupercompression(!1),u.setKTX2SRGBTransferFunc(!c),u.setQualityLevel(a),u.setCompressionLevel(l);const T=new Uint8Array(25165824);u.setSliceSourceImage(0,new Uint8Array(e),t,s,i);const m=u.encode(T),p=new Uint8Array(T.buffer,0,m),C=new r.KTX2File(new Uint8Array(p));return C.isValid()?(u.delete(),p):(C.close(),C.delete(),u.delete(),null)}async function u(e,a,l){null==r&&(r=await o());const i=new r.KTX2File(new Uint8Array(e));i.startTranscoding();const[c,u]=a?i.getHasAlpha()?[t.ETC2_RGBA,s.COMPRESSED_RGBA8_ETC2_EAC]:[t.ETC1_RGB,s.COMPRESSED_RGB8_ETC2]:l?i.getHasAlpha()?[t.BC3_RGBA,s.COMPRESSED_RGBA_S3TC_DXT5_EXT]:[t.BC1_RGB,s.COMPRESSED_RGB_S3TC_DXT1_EXT]:[t.RGBA32,n.RGBA],T=i.getLevels(),m=[];for(let t=0;t<T;t++)m.push(new Uint8Array(i.getImageTranscodedSizeInBytes(t,0,0,c))),i.transcodeImage(m[t],t,0,0,c,0,-1,-1);return i.close(),i.delete(),{internalFormat:u,compressedTexture:{type:"compressed",levels:m}}}export{l as TextureCompressionWorkerOutput,i as compress,c as compressRGBADataToKTX2,u as createTextureDataKTX2,o as loadBasisEncoder};
5
+ import{getBasisEncoder as e}from"../../../../libs/basisu/BasisUEncoder.js";import{TextureFormat as t}from"../../../../libs/basisu/TextureFormat.js";import{CompressedTextureFormat as n,PixelFormat as s}from"../../../webgl/enums.js";let a=null,r=null;class i{constructor(e,t){this.internalFormat=e,this.compressedTexture=t}}async function l(e){await o();const t=T(e.data,e.flipped),n=await c(t,e.width,e.height,e.hasMipmap),s=n?await u(n,e.hasETC,e.hasS3TC):null;return{result:new i(s?.internalFormat??null,s?.compressedTexture??null)}}async function o(){return null==r&&(r=e(),a=await e()),r}async function c(e,t,n,s,r=255,i=0,l=!1,c=!1){null==a&&(a=await o());const u=new a.BasisEncoder;u.setUASTC(!1),u.setHDR(!1),u.setPerceptual(!c),u.setCheckForAlpha(!0),u.setForceAlpha(!1),u.setRenormalize(c),u.setMipGen(s),u.setMipSRGB(!c),u.setCreateKTX2File(!0),u.setKTX2UASTCSupercompression(!1),u.setKTX2SRGBTransferFunc(!c),u.setQualityLevel(r),u.setCompressionLevel(i);const T=new Uint8Array(25165824);u.setSliceSourceImage(0,new Uint8Array(e),t,n,l);const d=u.encode(T),m=new Uint8Array(T.buffer,0,d),p=new a.KTX2File(new Uint8Array(m));return p.isValid()?(u.delete(),m):(p.close(),p.delete(),u.delete(),null)}async function u(e,r,i){null==a&&(a=await o());const l=new a.KTX2File(new Uint8Array(e));l.startTranscoding();const[c,u]=r?l.getHasAlpha()?[t.ETC2_RGBA,n.COMPRESSED_RGBA8_ETC2_EAC]:[t.ETC1_RGB,n.COMPRESSED_RGB8_ETC2]:i?l.getHasAlpha()?[t.BC3_RGBA,n.COMPRESSED_RGBA_S3TC_DXT5_EXT]:[t.BC1_RGB,n.COMPRESSED_RGB_S3TC_DXT1_EXT]:[t.RGBA32,s.RGBA],T=l.getLevels(),d=[];for(let t=0;t<T;t++)d.push(new Uint8Array(l.getImageTranscodedSizeInBytes(t,0,0,c))),l.transcodeImage(d[t],t,0,0,c,0,-1,-1);return l.close(),l.delete(),{internalFormat:u,compressedTexture:{type:"compressed",levels:d}}}function T(e,t=!1){const n=new OffscreenCanvas(e.width,e.height),s=n.getContext("2d");t&&(s.translate(0,n.height),s.scale(1,-1)),s.drawImage(e,0,0);return s.getImageData(0,0,n.width,n.height).data}export{i as TextureCompressionWorkerOutput,l as compress,c as compressRGBADataToKTX2,u as createTextureDataKTX2,o as loadBasisEncoder};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../core/PooledArray.js";import{multiply as t}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as r}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{t as n}from"../../../../chunks/vec32.js";import{l as i}from"../../../../chunks/vec42.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{intersectsSphere as a}from"../../../../geometry/support/frustum.js";import{a as o,g as h,c as f}from"../../../../chunks/sphere.js";import{maxScale as c}from"../../support/mathUtils.js";import{DepthRange as l}from"./DepthRange.js";import u from"./Octree.js";import{assert as d}from"./Util.js";const _=1e4,m=100,g=500,p=500,b=.1;function R(e,t,r){let n=0;if(!t.some((e=>!!e.material&&(n+=e.numGeometries,n>=_))))return W.compute(e,t);const i=new l;return r.forAll((t=>i.union(w(e,t)))),i}function w(e,t){if(!t.visible)return;const r=new l,n=t.getSpatialQueryAccelerator();return n?C(r,e,n):j(r,e,t.objects),r}function C(e,t,r){const{eye:n,viewForward:i,frustum:s}=t,a=e=>e.visible,o=r.objectCount;if(o<g)y.set(t.near,Math.min(e.near,t.far)),r.forEachInDepthRange(n,i,u.DepthOrder.FRONT_TO_BACK,y,((r,n)=>{M(e,t,r),y.far=e.near,n.setRange(y)}),s,a),y.set(Math.max(e.far,t.near),t.far),r.forEachInDepthRange(n,i,u.DepthOrder.BACK_TO_FRONT,y,((r,n)=>{M(e,t,r),y.near=e.far,n.setRange(y)}),s,a);else{const n=Math.max(Math.min(o,p),Math.ceil(o*b)),h=r.findClosest(i,u.DepthOrder.FRONT_TO_BACK,s,a,n),f=r.findClosest(i,u.DepthOrder.BACK_TO_FRONT,s,a,n);h&&f&&(A(e,t,h.boundingVolumeWorldSpace.bounds),A(e,t,f.boundingVolumeWorldSpace.bounds))}}function j(e,t,r){S.clear(),r.forAll((e=>{e.visible&&0!==e.geometries.length&&S.add(e)})),S.empty||(S.sort(t),y.set(t.near,Math.min(e.near,t.far)),S.forEachInDepthRange(y,u.DepthOrder.FRONT_TO_BACK,((r,n)=>{n<e.near&&M(e,t,r)})),y.set(Math.max(e.far,t.near),t.far),S.forEachInDepthRange(y,u.DepthOrder.BACK_TO_FRONT,((t,r,n)=>{e.far=Math.max(e.far,n)})))}function M(e,r,n){if(!n.visible)return;if(!a(r.frustum,n.boundingVolumeWorldSpace.bounds))return;const i=n.transformation,s=N;n.geometries.forEach((n=>{t(s,i,n.transformation);const a=c(s);O(e,r,n.boundingInfo,s,a)}))}function O(e,t,r,i,s){if(null==r)return;n(o(P),r.center,i);const{eye:h,viewForward:f}=t,c=f[0]*(P[0]-h[0])+f[1]*(P[1]-h[1])+f[2]*(P[2]-h[2]);if(P[3]=r.radius*s,!(c-P[3]>e.near&&c+P[3]<e.far)&&a(t.frustum,P))if(r.radius>m&&r.getChildren())for(const n of r.getChildren())O(e,t,n,i,s);else E.unionDepthRangeWithAABB(e,t.viewProjectionMatrix,i,r.bbMin,r.bbMax)}function A(e,t,r){const n=t.eye,i=t.viewForward,s=(r[0]-n[0])*i[0]+(r[1]-n[1])*i[1]+(r[2]-n[2])*i[2];e.near=Math.min(e.near,s-r[3]),e.far=Math.max(e.far,s+r[3])}class v{constructor(){this._items=new e({allocator:e=>e||{object:null,distance:0,near:0,far:0},deallocator:e=>(e.object=null,e.distance=0,e.near=0,e.far=0,e)})}get length(){return this._items.length}get empty(){return 0===this._items.length}clear(){this._items.clear()}add(e){this._items.pushNew().object=e}sort(e){const t=e.eye,r=e.viewForward;this._items.forAll((e=>{const n=e.object.boundingVolumeWorldSpace.bounds,i=(n[0]-t[0])*r[0]+(n[1]-t[1])*r[1]+(n[2]-t[2])*r[2];e.distance=i,e.near=i-n[3],e.far=i+n[3]})),this._items.sort(((e,t)=>e.distance-t.distance))}forEachInDepthRange(e,t,r){if(t===u.DepthOrder.FRONT_TO_BACK)for(let n=0;n<this._items.length;++n){const t=this._items.data[n];t.far<e.near||t.near>e.far||r(t.object,t.near,t.far)}else for(let n=this._items.length-1;n>=0;--n){const t=this._items.data[n];t.far<e.near||t.near>e.far||r(t.object,t.near,t.far)}}}class B{constructor(){this._geometries=new Array,this._near=[],this._far=[],this._nearCandidates=[],this._farCandidates=[],this._looseRange=new l(0,0)}compute(e,t){this._reset();const{viewMatrix:r}=e;t.forAll((e=>{e.forEachGeometry((e=>{if(!e.visible||!e.castShadow)return;const t=e.boundingSphere,n=r[2]*t[0]+r[6]*t[1]+r[10]*t[2]+r[14],i=n-t[3],s=n+t[3];this._geometries.push(e),this._near.push(-s),this._far.push(-i)}))}));const n=new l;if(0===this._geometries.length)return n;for(let o=0;o<this._geometries.length;++o)this._near[o]>n.far&&(n.far=this._near[o]),this._near[o]>2&&this._far[o]<n.near&&(n.near=this._far[o]);const i=this._looseRange;i.near=Math.max(.5*n.near,2),i.far=2*n.far;let s=0,a=0;for(let o=0;o<this._geometries.length;++o)this._near[o]<n.near&&(this._near[o]>=i.near?n.near=this._near[o]:this._nearCandidates[s++]=o),this._far[o]>n.far&&(this._far[o]<=i.far?n.far=this._far[o]:this._farCandidates[a++]=o);if(0===this._nearCandidates.length&&0===this._farCandidates.length)return n;this._nearCandidates.sort(((e,t)=>this._near[e]<this._near[t]?-1:this._near[e]>this._near[t]?1:0)),this._farCandidates.sort(((e,t)=>this._far[e]<this._far[t]?1:this._far[e]>this._far[t]?-1:0));for(let o=0;o<this._nearCandidates.length;++o){const t=this._nearCandidates[o];if(this._near[t]<n.near){const r=this._geometries[t],i=r.boundingInfo;this._includeNearBoundingInfoRec(e,i,r.shaderTransformation,n)}}for(let o=0;o<this._farCandidates.length;++o){const t=this._farCandidates[o];if(this._far[t]>n.far){const r=this._geometries[t],i=r.boundingInfo;this._includeFarBoundingInfoRec(e,i,r.shaderTransformation,n)}}return this._reset(),n}_reset(){this._geometries.length=0,this._near.length=0,this._far.length=0,this._nearCandidates.length=0,this._farCandidates.length=0}_isOutsideSidePlanes(e,t){const r=o(e),n=h(e);return t[0][0]*r[0]+t[0][1]*r[1]+t[0][2]*r[2]+t[0][3]>n||t[1][0]*r[0]+t[1][1]*r[1]+t[1][2]*r[2]+t[1][3]>n||t[2][0]*r[0]+t[2][1]*r[1]+t[2][2]*r[2]+t[2][3]>n||t[3][0]*r[0]+t[3][1]*r[1]+t[3][2]*r[2]+t[3][3]>n}_includeNearBoundingInfoRec(e,t,r,i){if(null==t)return;const s=t.center;n(o(P),s,r),P[3]=t.radius*c(r);const{frustum:a}=e;if(this._isOutsideSidePlanes(P,a))return;const h=P[0],f=P[1],l=P[2],u=P[3],{viewMatrix:d}=e,_=d[2]*h+d[6]*f+d[10]*l+d[14],g=_+u;if(!(-(_-u)<2||-g>=i.near))if(-g>this._looseRange.near)i.near=-g;else{if(u>m){const n=t.getChildren();if(void 0!==n){for(const t of n)this._includeNearBoundingInfoRec(e,t,r,i);return}}E.unionDepthRangeWithAABB(i,e.viewProjectionMatrix,r,t.bbMin,t.bbMax)}}_includeFarBoundingInfoRec(e,t,r,i){if(null==t)return;const s=t.center;n(o(P),s,r),P[3]=t.radius*c(r);const{frustum:a}=e;if(this._isOutsideSidePlanes(P,a))return;const h=P[0],f=P[1],l=P[2],u=P[3],{viewMatrix:d}=e,_=d[2]*h+d[6]*f+d[10]*l+d[14]-u;if(!(-_<=i.far))if(-_<this._looseRange.far)i.far=-_;else{if(u>m){const n=t.getChildren();if(void 0!==n){for(const t of n)this._includeFarBoundingInfoRec(e,t,r,i);return}}E.unionDepthRangeWithAABB(i,e.viewProjectionMatrix,r,t.bbMin,t.bbMax)}}}class x{constructor(){this._modelViewProj=r(),this._clipPosition=[s(),s(),s(),s(),s(),s(),s(),s()]}unionDepthRangeWithAABB(e,r,n,i,s){const a=this._modelViewProj;t(a,r,n);let o=!1;for(let t=0;t<8;++t){const e=this._clipPosition[t],r=0===t||3===t||4===t||7===t?i[0]:s[0],n=0===t||1===t||4===t||5===t?i[1]:s[1],o=t<4?i[2]:s[2];e[0]=a[0]*r+a[4]*n+a[8]*o+a[12],e[1]=a[1]*r+a[5]*n+a[9]*o+a[13],e[2]=a[2]*r+a[6]*n+a[10]*o+a[14],e[3]=a[3]*r+a[7]*n+a[11]*o+a[15]}for(let t=0;t<12;++t){const r=D(this._clipPosition[I[t][0]],this._clipPosition[I[t][1]],this._clipPosition[I[t][2]]);let n=!0;for(let e=0;e<r.length;++e){if(r[e][3]>=2){n=!1;break}}if(!n){o=!0;for(let t=0;t<r.length;++t){const n=r[t][3];Number.isFinite(n)&&(e.near=Math.min(n,e.near),e.far=Math.max(n,e.far))}}}return o}}function D(e,t,r){let n=[e,t,r];for(let i=0;i<4;++i){const e=n;n=[];for(let t=0;t<e.length;++t){const r=e[t],s=e[(t+1)%e.length];T(s,i)?(T(r,i)||n.push(F(r,s,i)),n.push(s)):T(r,i)&&n.push(F(r,s,i))}}return n}function T(e,t){return 0===t?e[0]>=-e[3]:1===t?e[1]>=-e[3]:2===t?e[0]<=e[3]:3===t?e[1]<=e[3]:void d(!1)}function F(e,t,r){let n=0;return 0===r?n=(-e[3]-e[0])/(t[0]-e[0]+t[3]-e[3]):1===r?n=(-e[3]-e[1])/(t[1]-e[1]+t[3]-e[3]):2===r?n=(e[3]-e[0])/(t[0]-e[0]-t[3]+e[3]):3===r&&(n=(e[3]-e[1])/(t[1]-e[1]-t[3]+e[3])),i(s(),e,t,n)}const I=[[0,1,3],[2,3,1],[1,5,2],[6,2,5],[5,4,6],[7,6,4],[4,0,7],[3,7,0],[3,2,7],[6,7,2],[4,5,0],[1,0,5]],P=f(),N=r(),y=new l,S=new v,W=new B,E=new x;export{B as DepthRangeFromRenderGeometries,R as depthRangeFromScene};
5
+ import e from"../../../../core/PooledArray.js";import{multiply as t}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as r}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{t as n}from"../../../../chunks/vec32.js";import{l as i}from"../../../../chunks/vec42.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{intersectsSphere as a}from"../../../../geometry/support/frustum.js";import{a as o,g as h,c as f}from"../../../../chunks/sphere.js";import{maxScale as c}from"../../support/mathUtils.js";import{DepthRange as l}from"./DepthRange.js";import u from"./Octree.js";import{assert as d}from"./Util.js";var _;!function(e){e[e.SHADOW_CASTERS=0]="SHADOW_CASTERS",e[e.FULL_SCENE=1]="FULL_SCENE"}(_||(_={}));const m=1e4,g=100,p=500,b=500,C=.1;function R(e,t,r,n=_.SHADOW_CASTERS){let i=0;if(!t.some((e=>!!e.material&&(i+=e.numGeometries,i>=m))))return y.compute(e,t,n);const s=new l;return r.forAll((t=>s.union(A(e,t)))),s}function A(e,t){if(!t.visible)return;const r=new l,n=t.getSpatialQueryAccelerator();return n?O(r,e,n):w(r,e,t.objects),r}function O(e,t,r){const{eye:n,viewForward:i,frustum:s}=t,a=e=>e.visible,o=r.objectCount;if(o<p)P.set(t.near,Math.min(e.near,t.far)),r.forEachInDepthRange(n,i,u.DepthOrder.FRONT_TO_BACK,P,((r,n)=>{j(e,t,r),P.far=e.near,n.setRange(P)}),s,a),P.set(Math.max(e.far,t.near),t.far),r.forEachInDepthRange(n,i,u.DepthOrder.BACK_TO_FRONT,P,((r,n)=>{j(e,t,r),P.near=e.far,n.setRange(P)}),s,a);else{const n=Math.max(Math.min(o,b),Math.ceil(o*C)),h=r.findClosest(i,u.DepthOrder.FRONT_TO_BACK,s,a,n),f=r.findClosest(i,u.DepthOrder.BACK_TO_FRONT,s,a,n);h&&f&&(S(e,t,h.boundingVolumeWorldSpace.bounds),S(e,t,f.boundingVolumeWorldSpace.bounds))}}function w(e,t,r){W.clear(),r.forAll((e=>{e.visible&&0!==e.geometries.length&&W.add(e)})),W.empty||(W.sort(t),P.set(t.near,Math.min(e.near,t.far)),W.forEachInDepthRange(P,u.DepthOrder.FRONT_TO_BACK,((r,n)=>{n<e.near&&j(e,t,r)})),P.set(Math.max(e.far,t.near),t.far),W.forEachInDepthRange(P,u.DepthOrder.BACK_TO_FRONT,((t,r,n)=>{e.far=Math.max(e.far,n)})))}function j(e,r,n){if(!n.visible)return;if(!a(r.frustum,n.boundingVolumeWorldSpace.bounds))return;const i=n.transformation,s=N;n.geometries.forEach((n=>{t(s,i,n.transformation);const a=c(s);M(e,r,n.boundingInfo,s,a)}))}function M(e,t,r,i,s){if(null==r)return;n(o(I),r.center,i);const{eye:h,viewForward:f}=t,c=f[0]*(I[0]-h[0])+f[1]*(I[1]-h[1])+f[2]*(I[2]-h[2]);if(I[3]=r.radius*s,!(c-I[3]>e.near&&c+I[3]<e.far)&&a(t.frustum,I))if(r.radius>g&&r.getChildren())for(const n of r.getChildren())M(e,t,n,i,s);else K.unionDepthRangeWithAABB(e,t.viewProjectionMatrix,i,r.bbMin,r.bbMax)}function S(e,t,r){const n=t.eye,i=t.viewForward,s=(r[0]-n[0])*i[0]+(r[1]-n[1])*i[1]+(r[2]-n[2])*i[2];e.near=Math.min(e.near,s-r[3]),e.far=Math.max(e.far,s+r[3])}class v{constructor(){this._items=new e({allocator:e=>e||{object:null,distance:0,near:0,far:0},deallocator:e=>(e.object=null,e.distance=0,e.near=0,e.far=0,e)})}get length(){return this._items.length}get empty(){return 0===this._items.length}clear(){this._items.clear()}add(e){this._items.pushNew().object=e}sort(e){const t=e.eye,r=e.viewForward;this._items.forAll((e=>{const n=e.object.boundingVolumeWorldSpace.bounds,i=(n[0]-t[0])*r[0]+(n[1]-t[1])*r[1]+(n[2]-t[2])*r[2];e.distance=i,e.near=i-n[3],e.far=i+n[3]})),this._items.sort(((e,t)=>e.distance-t.distance))}forEachInDepthRange(e,t,r){if(t===u.DepthOrder.FRONT_TO_BACK)for(let n=0;n<this._items.length;++n){const t=this._items.data[n];t.far<e.near||t.near>e.far||r(t.object,t.near,t.far)}else for(let n=this._items.length-1;n>=0;--n){const t=this._items.data[n];t.far<e.near||t.near>e.far||r(t.object,t.near,t.far)}}}class B{constructor(){this._geometries=new Array,this._near=[],this._far=[],this._nearCandidates=[],this._farCandidates=[],this._looseRange=new l(0,0)}compute(e,t,r){this._reset();const{viewMatrix:n}=e;t.forAll((e=>{e.forEachGeometry((e=>{if(!e.visible||r===_.SHADOW_CASTERS&&!e.castShadow)return;const t=e.boundingSphere,i=n[2]*t[0]+n[6]*t[1]+n[10]*t[2]+n[14],s=i-t[3],a=i+t[3];this._geometries.push(e),this._near.push(-a),this._far.push(-s)}))}));const i=new l;if(0===this._geometries.length)return i;for(let h=0;h<this._geometries.length;++h)this._near[h]>i.far&&(i.far=this._near[h]),this._near[h]>2&&this._far[h]<i.near&&(i.near=this._far[h]);const s=this._looseRange;s.near=Math.max(.5*i.near,2),s.far=2*i.far;let a=0,o=0;for(let h=0;h<this._geometries.length;++h)this._near[h]<i.near&&(this._near[h]>=s.near?i.near=this._near[h]:this._nearCandidates[a++]=h),this._far[h]>i.far&&(this._far[h]<=s.far?i.far=this._far[h]:this._farCandidates[o++]=h);if(0===this._nearCandidates.length&&0===this._farCandidates.length)return i;this._nearCandidates.sort(((e,t)=>this._near[e]<this._near[t]?-1:this._near[e]>this._near[t]?1:0)),this._farCandidates.sort(((e,t)=>this._far[e]<this._far[t]?1:this._far[e]>this._far[t]?-1:0));for(let h=0;h<this._nearCandidates.length;++h){const t=this._nearCandidates[h];if(this._near[t]<i.near){const r=this._geometries[t],{boundingInfo:n,shaderTransformation:s}=r;this._includeNearBoundingInfoRec(e,n,s,i)}}for(let h=0;h<this._farCandidates.length;++h){const t=this._farCandidates[h];if(this._far[t]>i.far){const r=this._geometries[t],{boundingInfo:n,shaderTransformation:s}=r;this._includeFarBoundingInfoRec(e,n,s,i)}}return this._reset(),i}_reset(){this._geometries.length=0,this._near.length=0,this._far.length=0,this._nearCandidates.length=0,this._farCandidates.length=0}_isOutsideSidePlanes(e,t){const r=o(e),n=h(e);return t[0][0]*r[0]+t[0][1]*r[1]+t[0][2]*r[2]+t[0][3]>n||t[1][0]*r[0]+t[1][1]*r[1]+t[1][2]*r[2]+t[1][3]>n||t[2][0]*r[0]+t[2][1]*r[1]+t[2][2]*r[2]+t[2][3]>n||t[3][0]*r[0]+t[3][1]*r[1]+t[3][2]*r[2]+t[3][3]>n}_includeNearBoundingInfoRec(e,t,r,i){if(null==t)return;const s=t.center;n(o(I),s,r),I[3]=t.radius*c(r);const{frustum:a}=e;if(this._isOutsideSidePlanes(I,a))return;const h=I[0],f=I[1],l=I[2],u=I[3],{viewMatrix:d}=e,_=d[2]*h+d[6]*f+d[10]*l+d[14],m=_+u;if(!(-(_-u)<2||-m>=i.near))if(-m>this._looseRange.near)i.near=-m;else{if(u>g){const n=t.getChildren();if(void 0!==n){for(const t of n)this._includeNearBoundingInfoRec(e,t,r,i);return}}K.unionDepthRangeWithAABB(i,e.viewProjectionMatrix,r,t.bbMin,t.bbMax)}}_includeFarBoundingInfoRec(e,t,r,i){if(null==t)return;const s=t.center;n(o(I),s,r),I[3]=t.radius*c(r);const{frustum:a}=e;if(this._isOutsideSidePlanes(I,a))return;const h=I[0],f=I[1],l=I[2],u=I[3],{viewMatrix:d}=e,_=d[2]*h+d[6]*f+d[10]*l+d[14]-u;if(!(-_<=i.far))if(-_<this._looseRange.far)i.far=-_;else{if(u>g){const n=t.getChildren();if(void 0!==n){for(const t of n)this._includeFarBoundingInfoRec(e,t,r,i);return}}K.unionDepthRangeWithAABB(i,e.viewProjectionMatrix,r,t.bbMin,t.bbMax)}}}class D{constructor(){this._modelViewProj=r(),this._clipPosition=[s(),s(),s(),s(),s(),s(),s(),s()]}unionDepthRangeWithAABB(e,r,n,i,s){const a=this._modelViewProj;t(a,r,n);let o=!1;for(let t=0;t<8;++t){const e=this._clipPosition[t],r=0===t||3===t||4===t||7===t?i[0]:s[0],n=0===t||1===t||4===t||5===t?i[1]:s[1],o=t<4?i[2]:s[2];e[0]=a[0]*r+a[4]*n+a[8]*o+a[12],e[1]=a[1]*r+a[5]*n+a[9]*o+a[13],e[2]=a[2]*r+a[6]*n+a[10]*o+a[14],e[3]=a[3]*r+a[7]*n+a[11]*o+a[15]}for(let t=0;t<12;++t){const r=x(this._clipPosition[E[t][0]],this._clipPosition[E[t][1]],this._clipPosition[E[t][2]]);let n=!0;for(let e=0;e<r.length;++e){if(r[e][3]>=2){n=!1;break}}if(!n){o=!0;for(let t=0;t<r.length;++t){const n=r[t][3];Number.isFinite(n)&&(e.near=Math.min(n,e.near),e.far=Math.max(n,e.far))}}}return o}}function x(e,t,r){let n=[e,t,r];for(let i=0;i<4;++i){const e=n;n=[];for(let t=0;t<e.length;++t){const r=e[t],s=e[(t+1)%e.length];T(s,i)?(T(r,i)||n.push(F(r,s,i)),n.push(s)):T(r,i)&&n.push(F(r,s,i))}}return n}function T(e,t){return 0===t?e[0]>=-e[3]:1===t?e[1]>=-e[3]:2===t?e[0]<=e[3]:3===t?e[1]<=e[3]:void d(!1)}function F(e,t,r){let n=0;return 0===r?n=(-e[3]-e[0])/(t[0]-e[0]+t[3]-e[3]):1===r?n=(-e[3]-e[1])/(t[1]-e[1]+t[3]-e[3]):2===r?n=(e[3]-e[0])/(t[0]-e[0]-t[3]+e[3]):3===r&&(n=(e[3]-e[1])/(t[1]-e[1]-t[3]+e[3])),i(s(),e,t,n)}const E=[[0,1,3],[2,3,1],[1,5,2],[6,2,5],[5,4,6],[7,6,4],[4,0,7],[3,7,0],[3,2,7],[6,7,2],[4,5,0],[1,0,5]],I=f(),N=r(),P=new l,W=new v,y=new B,K=new D;export{B as DepthRangeFromRenderGeometries,_ as DepthRangeMode,R as depthRangeFromScene};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../../chunks/tslib.es6.js";import{isSome as t}from"../../../../../core/arrayUtils.js";import r from"../../../../../core/Error.js";import{someMap as n,getOrCreateMapValue as s}from"../../../../../core/MapUtils.js";import{destroyMaybe as a}from"../../../../../core/maybe.js";import{isAborted as i,throwIfAborted as o}from"../../../../../core/promiseUtils.js";import{property as l}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import{subclass as c}from"../../../../../core/accessorSupport/decorators/subclass.js";import{create as h}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{d,f as u,t as m}from"../../../../../chunks/vec32.js";import{create as f}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as p,fromValues as _}from"../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{debugFlags as g}from"../../../support/debugFlags.js";import{glLayout as I}from"../../../support/buffer/glUtil.js";import{newLayout as y}from"../../../support/buffer/InterleavedLayout.js";import v from"../../../webgl/RenderCamera.js";import{ShaderOutput as C}from"../../core/shaderLibrary/ShaderOutput.js";import{AsyncRenderPlugin as E}from"../../effects/RenderPlugin.js";import{Default3D as R}from"../DefaultVertexAttributeLocations.js";import{DepthRange as A}from"../DepthRange.js";import{IntersectorType as D}from"../IntersectorInterfaces.js";import b from"../Octree.js";import{RenderSlot as T}from"../RenderSlot.js";import{assert as L}from"../Util.js";import{VertexAttribute as S}from"../VertexAttribute.js";import{InstanceData as O,StateFlags as j}from"./InstanceData.js";import{InstanceOctree as M}from"./InstanceOctree.js";import{LevelSelector as x}from"./LevelSelector.js";import{LodLevel as N}from"./LodLevel.js";import{RenderInstanceData as w}from"./RenderInstanceData.js";import{colorMixModes as U}from"../../materials/internal/MaterialUtil.js";import{encodeDoubleVec3 as H}from"../../materials/renderers/utils.js";import{DefaultMaterialDrawParameters as F}from"../../shaders/DefaultMaterialTechnique.js";import{TaskPriority as V,noBudget as B}from"../../../../support/Scheduler.js";import{bindVertexBufferLayout as G,unbindVertexBufferLayout as q}from"../../../../webgl/Util.js";const P=e=>{const t=e.baseBoundingSphere.radius,r=e.levels.map((e=>e.minScreenSpaceRadius));return new x(t,r)};let z=class extends E{constructor(e,t){super(e),this.type=D.LOD,this.isGround=!1,this._levels=[],this._defaultRenderInstanceData=new Array,this._highlightRenderInstanceDataMap=new Map,this._instanceIndex=0,this._cycleStartIndex=0,this._slicePlane=!1,this._camera=new v,this._updateCyclesWithStaticCamera=-1,this._needFullCycle=!1,this.produces=new Map([[T.OPAQUE_MATERIAL,e=>this._produces(e)],[T.TRANSPARENT_MATERIAL,e=>!!this._hasTransparentLevels()&&this._produces(e)]]),this._instanceData=new O({shaderTransformation:e.shaderTransformation},e.optionalFields),this.addHandles(t.registerTask(V.LOD_RENDERER,this))}initialize(){this._instanceBufferLayout=K(this.optionalFields),this._glInstanceBufferLayout=I(this._instanceBufferLayout,1),this.addHandles([this._instanceData.events.on("instances-changed",(()=>this._requestUpdateCycle())),this._instanceData.events.on("instance-transform-changed",(({index:e})=>{this._requestUpdateCycle(),this.metadata.notifyGraphicGeometryChanged(e)})),this._instanceData.events.on("instance-visibility-changed",(({index:e})=>{this._requestUpdateCycle(!0),this.metadata.notifyGraphicVisibilityChanged(e)})),this._instanceData.events.on("instance-highlight-changed",(()=>this._requestUpdateCycle(!0)))])}get _allRenderInstanceData(){const e=[this._defaultRenderInstanceData];for(const t of this._highlightRenderInstanceDataMap)e.push(t[1]);return e}get _enableLevelSelection(){return this.symbol.levels.length>1}get levels(){return this._levels}get baseBoundingBox(){return this._levels[this._levels.length-1].boundingBox}get baseBoundingSphere(){return this._levels[this._levels.length-1].boundingSphere}get baseMaterial(){return this._levels[this._levels.length-1].components[0].material}get slicePlaneEnabled(){return this._slicePlane}set slicePlaneEnabled(e){this._slicePlane=e}get layerUid(){return this.metadata.layerUid}get instanceData(){return this._instanceData}get hasEmissions(){return this._levels.some((e=>e.components.some((e=>e.material.hasEmissions))))}get usedMemory(){return this._allRenderInstanceData.reduce(((e,t)=>t.reduce(((e,t)=>e+t.usedMemory),e)),this._levels.reduce(((e,t)=>e+t.components.reduce(((e,t)=>e+t.usedMemory),0)),0))}get renderStats(){const e=this._instanceData.size,t=[];return this._levels.forEach(((e,r)=>{const n=this._allRenderInstanceData[0][r].size+this._allRenderInstanceData[1][r].size,s=e.triangleCount;t.push({renderedInstances:n,renderedTriangles:n*s,trianglesPerInstance:s})})),{totalInstances:e,renderedInstances:t.reduce(((e,t)=>e+t.renderedInstances),0),renderedTriangles:t.reduce(((e,t)=>e+t.renderedTriangles),0),levels:t}}_createRenderInstanceDataArray(e=[]){const{rctx:t}=this._context.renderContext;return this.symbol.levels.map((r=>{e.push(new w(t,this._instanceBufferLayout))})),e}async initializeRenderContext(e,r){this._context=e,this._createRenderInstanceDataArray(this._defaultRenderInstanceData);const n=await Promise.allSettled(this.symbol.levels.map((t=>N.create(e,t,r)))),s=n.map((e=>"fulfilled"===e.status?e.value:null)).filter(t);if(i(r)||s.length!==n.length){s.forEach((e=>e.destroy())),o(r);for(const e of n)if("rejected"===e.status)throw e.reason}this._levels=s,this._levelSelector=P(this)}uninitializeRenderContext(){this._invalidateOctree(),this._levels.forEach((e=>e.destroy())),this._defaultRenderInstanceData.forEach((e=>e.destroy())),this._highlightRenderInstanceDataMap.forEach((e=>e.forEach((e=>e.destroy()))))}_hasTransparentLevels(){return this._levels.some((e=>e.components.some((e=>{const t=e.material.produces.get(T.TRANSPARENT_MATERIAL);return t?.(C.Color)}))))}hasHighlights(){return n(this._highlightRenderInstanceDataMap,(e=>e.some((e=>e.size>0))))}_produces(e){return e!==C.Highlight&&e!==C.ShadowHighlight||this.hasHighlights()}prepareRender(e){if(!g.LOD_INSTANCE_RENDERER_DISABLE_UPDATES){if(this._enableLevelSelection){const t=e.bind.contentCamera.equals(this._camera);this._camera.copyFrom(e.bind.contentCamera),t||this._requestUpdateCycle()}this._needFullCycle&&(this.runTask(B),this._needFullCycle=!1)}}acquireTechniques(e){if(!this.baseMaterial.visible||!this.baseMaterial.isVisibleForOutput(e.output))return null;const t=this._getInstanceDatas(e);if(!t)return null;const r=new Array,n=this.levels;return t.forEach((t=>n.forEach((({components:n},s)=>n.forEach((n=>r.push(this._beginComponent(e,t[s],n)))))))),r}render(e,t){const r=this._getInstanceDatas(e);if(!r||null==t)return;let n=0;e.rctx.bindVAO();const s=this.levels;r.forEach((r=>s.forEach((({components:s},a)=>s.forEach((s=>this._renderComponent(e,t[n++],r[a],s,a)))))))}_getInstanceDatas(e){const{output:t,bind:r}=e,n=t===C.Highlight,s=!n&&t!==C.ShadowHighlight,a=t!==C.ShadowExcludeHighlight;if(s)return a?this._allRenderInstanceData:[this._defaultRenderInstanceData];if(a){if(n){const e=r.highlight?.name;if(!e)return null;const t=this._highlightRenderInstanceDataMap.get(e);return t?[t]:null}return Array.from(this._highlightRenderInstanceDataMap.values())}return null}intersect(e,t,r,n){if(!this.baseMaterial.visible||null==this._octree)return;const s=f();d(s,n,r);const a=s=>{this._instanceData.getCombinedModelTransform(s,Q),e.transform.set(Q),m(Z,r,e.transform.inverse),m($,n,e.transform.inverse);const a=this._instanceData.getState(s),i=this._instanceData.getLodLevel(s),o=this._levels.length;L(!!(a&j.ACTIVE),"invalid instance state"),L(i>=0&&i<o,"invaid lod level"),this._levels[i].intersect(e,t,Z,$,s,this.metadata,o)};this.baseMaterial.parameters.verticalOffset?this._octree.forEach(a):this._octree.forEachAlongRay(r,s,a)}notifyShaderTransformationChanged(){this._invalidateOctree(),this._requestUpdateCycle()}get _octree(){if(null==this._octreeCached){const e=this._instanceData,t=e.view?.state;if(!t)return null;this._octreeCached=new M(e,this.baseBoundingSphere);for(let r=0;r<e.capacity;++r)t.get(r)&j.ACTIVE&&this._octreeCached.addInstance(r)}return this._octreeCached}_invalidateOctree(){this._octreeCached=a(this._octreeCached)}queryDepthRange(e){if(null==this._octree)return new A;const t=e.viewForward,r=this._octree.findClosest(t,b.DepthOrder.FRONT_TO_BACK,e.frustum),n=this._octree.findClosest(t,b.DepthOrder.BACK_TO_FRONT,e.frustum);if(null==r||null==n)return new A;const s=e.eye,a=this._instanceData.view;a.boundingSphere.getVec(r,J),d(J,J,s);const i=u(J,t)-J[3];a.boundingSphere.getVec(n,J),d(J,J,s);const o=u(J,t)+J[3];return new A(Math.max(e.near,i),Math.min(e.far,o))}_requestUpdateCycle(e=!1){this._updateCyclesWithStaticCamera=-1,this._cycleStartIndex=this._instanceIndex,e&&(this._needFullCycle=!0,this._context.requestRender())}_startUpdateCycle(){this._updateCyclesWithStaticCamera++,this._allRenderInstanceData.forEach((e=>e.forEach((e=>e.startUpdateCycle()))))}get running(){return this._instanceData.size>0&&this._updateCyclesWithStaticCamera<1}runTask(e){const{_enableLevelSelection:t,_camera:n,_levelSelector:a}=this;this._allRenderInstanceData.forEach((e=>e.forEach((e=>e.beginUpdate()))));const i=this._instanceData,o=i.view;let l=i.size;const c=i.capacity;let h=this._instanceIndex;const d=Math.ceil(c/500);for(let u=0;u<l&&!e.done;++u){h===this._cycleStartIndex&&this._startUpdateCycle();const u=o.state.get(h);let m=0;if(!(u&j.ALLOCATED)){h=h+1===c?0:h+1,l++;continue}const f=o.lodLevel.get(h);if(u&j.DEFAULT_ACTIVE&&this._defaultRenderInstanceData[f].freeTail(),u&j.HIGHLIGHT_ACTIVE){const e=i.geHighlightGroupPrev(h);if(e){const t=this._highlightRenderInstanceDataMap.get(e);if(!t)throw new r("Internal error in lodRenderer");t[f].freeTail()}}if(u&j.REMOVE)i.freeInstance(h);else if(u&j.VISIBLE){let e=0;if(t&&(o.modelOrigin.getVec(h,Y),e=a.selectLevel(Y,i.getCombinedMedianScaleFactor(h),n)),m=u&~(j.ACTIVE|j.TRANSFORM_CHANGED),e>=0)if(u&j.HIGHLIGHT){const t=i.getHighlightGroup(h);if(t){const n=()=>{const e=this._createRenderInstanceDataArray();return e.forEach((e=>e.beginUpdate())),e},a=s(this._highlightRenderInstanceDataMap,t,n);if(e>=a.length)throw new r(`LodRenderer internal error - missing lodLevel ${e}`);k(a[e],o,h)}m|=j.HIGHLIGHT_ACTIVE}else k(this._defaultRenderInstanceData[e],o,h),m|=j.DEFAULT_ACTIVE;o.state.set(h,m),o.lodLevel.set(h,e)}else m=u&~(j.ACTIVE|j.TRANSFORM_CHANGED),o.state.set(h,m);if(null!=this._octreeCached){const e=!!(u&j.ACTIVE),t=!!(m&j.ACTIVE);!e&&t?this._octreeCached.addInstance(h):e&&!t?this._octreeCached.removeInstance(h):e&&t&&u&j.TRANSFORM_CHANGED&&(this._octreeCached.removeInstance(h),this._octreeCached.addInstance(h))}h=h+1===c?0:h+1,h%d==0&&e.madeProgress()}this._instanceIndex=h,this._allRenderInstanceData.forEach((e=>e.forEach((e=>e.endUpdate())))),this._context.requestRender()}_beginComponent(e,t,r){if(0===t.size)return null;const n=r.glMaterials.load(e.rctx,e.bind.slot,e.output);return n?.beginSlot(e.bind)}_renderComponent(e,t,r,n,s){if(!t)return;const{bind:a,rctx:i}=e;i.runAppleAmdDriverHelper();const o=i.bindTechnique(t,a,n.material.parameters,ee);i.bindVAO(n.vao),t.ensureAttributeLocations(n.vao),g.LOD_INSTANCE_RENDERER_COLORIZE_BY_LEVEL&&e.output===C.Color&&(o.setUniform4fv("externalColor",X[Math.min(s,X.length-1)]),o.setUniform1i("colorMixMode",U.replace));const l=r.capacity,c=r.headIndex,h=r.tailIndex,d=r.firstIndex,u=this._glInstanceBufferLayout,m=(e,s)=>{G(i,R,r.buffer,u,e),i.drawArraysInstanced(t.primitiveType,0,n.vertexCount,s-e),q(i,R,r.buffer,u)};n.material.parameters.transparent&&null!=d?c>h?(L(d>=h&&d<=c,"invalid firstIndex"),m(d,c),m(h,d)):c<h&&(d<=c?(L(d>=0&&d<=c,"invalid firstIndex"),m(d,c),m(h,l),m(0,d)):(L(d>=h&&d<=l,"invalid firstIndex"),m(d,l),m(0,c),m(h,d))):c>h?m(h,c):c<h&&(m(0,c),m(h,l)),i.bindVAO(null)}};function k(e,t,r){const n=e.allocateHead();W(t,r,e.view,n)}function W(e,t,r,n){H(e.modelOrigin,t,r.modelOriginHi,r.modelOriginLo,n),r.model.copyFrom(n,e.model,t),r.modelNormal.copyFrom(n,e.modelNormal,t),e.color&&r.color&&r.color.copyFrom(n,e.color,t),e.objectAndLayerIdColor&&r.objectAndLayerIdColor&&r.objectAndLayerIdColor.copyFrom(n,e.objectAndLayerIdColor,t),e.featureAttribute&&r.featureAttribute&&r.featureAttribute.copyFrom(n,e.featureAttribute,t)}function K(e){let t=y().vec3f(S.INSTANCEMODELORIGINHI).vec3f(S.INSTANCEMODELORIGINLO).mat3f(S.INSTANCEMODEL).mat3f(S.INSTANCEMODELNORMAL);return null!=e&&e.includes("featureAttribute")&&(t=t.vec4f(S.INSTANCEFEATUREATTRIBUTE)),null!=e&&e.includes("color")&&(t=t.vec4u8(S.INSTANCECOLOR)),null!=e&&e.includes("objectAndLayerIdColor")&&(t=t.vec4u8(S.INSTANCEOBJECTANDLAYERIDCOLOR)),t}e([l({constructOnly:!0})],z.prototype,"symbol",void 0),e([l({constructOnly:!0})],z.prototype,"optionalFields",void 0),e([l({constructOnly:!0})],z.prototype,"metadata",void 0),e([l({constructOnly:!0})],z.prototype,"shaderTransformation",void 0),e([l()],z.prototype,"_instanceData",void 0),e([l()],z.prototype,"_cycleStartIndex",void 0),e([l({readOnly:!0})],z.prototype,"_enableLevelSelection",null),e([l()],z.prototype,"_updateCyclesWithStaticCamera",void 0),e([l({readOnly:!0})],z.prototype,"running",null),z=e([c("esri.views.3d.webgl-engine.lib.lodRendering.LodRenderer")],z);const Y=f(),J=p(),Q=h(),Z=f(),$=f(),X=[_(1,0,1,1),_(0,0,1,1),_(0,1,0,1),_(1,1,0,1),_(1,0,0,1)],ee=new F;export{z as LodRenderer};
5
+ import{_ as e}from"../../../../../chunks/tslib.es6.js";import{isSome as t}from"../../../../../core/arrayUtils.js";import r from"../../../../../core/Error.js";import{someMap as n,getOrCreateMapValue as s}from"../../../../../core/MapUtils.js";import{destroyMaybe as a}from"../../../../../core/maybe.js";import{isAborted as i,throwIfAborted as o}from"../../../../../core/promiseUtils.js";import{property as l}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import{subclass as c}from"../../../../../core/accessorSupport/decorators/subclass.js";import{create as h}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{d,f as u,t as m}from"../../../../../chunks/vec32.js";import{create as f}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as p,fromValues as _}from"../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{debugFlags as g}from"../../../support/debugFlags.js";import{glLayout as I}from"../../../support/buffer/glUtil.js";import{newLayout as y}from"../../../support/buffer/InterleavedLayout.js";import v from"../../../webgl/RenderCamera.js";import{ShaderOutput as C}from"../../core/shaderLibrary/ShaderOutput.js";import{AsyncRenderPlugin as E}from"../../effects/RenderPlugin.js";import{Default3D as R}from"../DefaultVertexAttributeLocations.js";import{DepthRange as A}from"../DepthRange.js";import{IntersectorType as D}from"../IntersectorInterfaces.js";import b from"../Octree.js";import{RenderSlot as T}from"../RenderSlot.js";import{assert as L}from"../Util.js";import{VertexAttribute as S}from"../VertexAttribute.js";import{InstanceData as O,StateFlags as j}from"./InstanceData.js";import{InstanceOctree as x}from"./InstanceOctree.js";import{LevelSelector as M}from"./LevelSelector.js";import{LodLevel as N}from"./LodLevel.js";import{RenderInstanceData as w}from"./RenderInstanceData.js";import{colorMixModes as U}from"../../materials/internal/MaterialUtil.js";import{encodeDoubleVec3 as H}from"../../materials/renderers/utils.js";import{DefaultMaterialDrawParameters as F}from"../../shaders/DefaultMaterialTechnique.js";import{TaskPriority as V,noBudget as B}from"../../../../support/Scheduler.js";import{bindVertexBufferLayout as G,unbindVertexBufferLayout as q}from"../../../../webgl/Util.js";const P=e=>{const t=e.baseBoundingSphere.radius,r=e.levels.map((e=>e.minScreenSpaceRadius));return new M(t,r)};let z=class extends E{constructor(e,t){super(e),this.type=D.LOD,this.isGround=!1,this._levels=[],this._defaultRenderInstanceData=new Array,this._highlightRenderInstanceDataMap=new Map,this._instanceIndex=0,this._cycleStartIndex=0,this._slicePlane=!1,this._camera=new v,this._updateCyclesWithStaticCamera=-1,this._needFullCycle=!1,this.produces=new Map([[T.OPAQUE_MATERIAL,e=>this._produces(e)],[T.TRANSPARENT_MATERIAL,e=>!!this._hasTransparentLevels()&&this._produces(e)]]),this._instanceData=new O({shaderTransformation:e.shaderTransformation},e.optionalFields),this.addHandles(t.registerTask(V.LOD_RENDERER,this))}initialize(){this._instanceBufferLayout=K(this.optionalFields),this._glInstanceBufferLayout=I(this._instanceBufferLayout,1),this.addHandles([this._instanceData.events.on("instances-changed",(()=>this._requestUpdateCycle())),this._instanceData.events.on("instance-transform-changed",(({index:e})=>{this._requestUpdateCycle(),this.metadata.notifyGraphicGeometryChanged(e)})),this._instanceData.events.on("instance-visibility-changed",(({index:e})=>{this._requestUpdateCycle(!0),this.metadata.notifyGraphicVisibilityChanged(e)})),this._instanceData.events.on("instance-highlight-changed",(()=>this._requestUpdateCycle(!0)))])}get _allRenderInstanceData(){const e=[this._defaultRenderInstanceData];for(const t of this._highlightRenderInstanceDataMap)e.push(t[1]);return e}get _enableLevelSelection(){return this.symbol.levels.length>1}get levels(){return this._levels}get baseBoundingBox(){return this._levels[this._levels.length-1].boundingBox}get baseBoundingSphere(){return this._levels[this._levels.length-1].boundingSphere}get baseMaterial(){return this._levels[this._levels.length-1].components[0].material}get slicePlaneEnabled(){return this._slicePlane}set slicePlaneEnabled(e){this._slicePlane=e}get layerUid(){return this.metadata.layerUid}get instanceData(){return this._instanceData}get hasEmissions(){return this._levels.some((e=>e.components.some((e=>e.material.hasEmissions))))}get usedMemory(){return this._allRenderInstanceData.reduce(((e,t)=>t.reduce(((e,t)=>e+t.usedMemory),e)),this._levels.reduce(((e,t)=>e+t.components.reduce(((e,t)=>e+t.usedMemory),0)),0))}get renderStats(){const e=this._instanceData.size,t=[];return this._levels.forEach(((e,r)=>{const n=this._allRenderInstanceData[0][r].size+this._allRenderInstanceData[1][r].size,s=e.triangleCount;t.push({renderedInstances:n,renderedTriangles:n*s,trianglesPerInstance:s})})),{totalInstances:e,renderedInstances:t.reduce(((e,t)=>e+t.renderedInstances),0),renderedTriangles:t.reduce(((e,t)=>e+t.renderedTriangles),0),levels:t}}_createRenderInstanceDataArray(e=[]){const{rctx:t}=this._context.renderContext;return this.symbol.levels.map((r=>{e.push(new w(t,this._instanceBufferLayout))})),e}async initializeRenderContext(e,r){this._context=e,this._createRenderInstanceDataArray(this._defaultRenderInstanceData);const n=await Promise.allSettled(this.symbol.levels.map((t=>N.create(e,t,r)))),s=n.map((e=>"fulfilled"===e.status?e.value:null)).filter(t);if(i(r)||s.length!==n.length){s.forEach((e=>e.destroy())),o(r);for(const e of n)if("rejected"===e.status)throw e.reason}this._levels=s,this._levelSelector=P(this)}uninitializeRenderContext(){this._invalidateOctree(),this._levels.forEach((e=>e.destroy())),this._defaultRenderInstanceData.forEach((e=>e.destroy())),this._highlightRenderInstanceDataMap.forEach((e=>e.forEach((e=>e.destroy()))))}_hasTransparentLevels(){return this._levels.some((e=>e.components.some((e=>{const t=e.material.produces.get(T.TRANSPARENT_MATERIAL);return t?.(C.Color)}))))}hasHighlights(){return n(this._highlightRenderInstanceDataMap,(e=>e.some((e=>e.size>0))))}_produces(e){return e!==C.Highlight&&e!==C.ShadowHighlight||this.hasHighlights()}prepareRender(e){if(!g.LOD_INSTANCE_RENDERER_DISABLE_UPDATES){if(this._enableLevelSelection){const t=e.bind.contentCamera.equals(this._camera);this._camera.copyFrom(e.bind.contentCamera),t||this._requestUpdateCycle()}this._needFullCycle&&(this.runTask(B),this._needFullCycle=!1)}}acquireTechniques(e){if(!this.baseMaterial.visible||!this.baseMaterial.isVisibleForOutput(e.output))return null;const t=this._getInstanceDatas(e);if(!t)return null;const r=new Array,n=this.levels;return t.forEach((t=>n.forEach((({components:n},s)=>n.forEach((n=>r.push(this._beginComponent(e,t[s],n)))))))),r}render(e,t){const r=this._getInstanceDatas(e);if(!r||null==t)return;let n=0;e.rctx.bindVAO();const s=this.levels;r.forEach((r=>s.forEach((({components:s},a)=>s.forEach((s=>this._renderComponent(e,t[n++],r[a],s,a)))))))}_getInstanceDatas(e){const{output:t,bind:r}=e,n=t===C.Highlight,s=!n&&t!==C.ShadowHighlight,a=t!==C.ShadowExcludeHighlight;if(s)return a?this._allRenderInstanceData:[this._defaultRenderInstanceData];if(a){if(n){const e=r.highlight?.name;if(!e)return null;const t=this._highlightRenderInstanceDataMap.get(e);return t?[t]:null}return Array.from(this._highlightRenderInstanceDataMap.values())}return null}intersect(e,t,r,n){if(!this.baseMaterial.visible||null==this._octree)return;const s=f();d(s,n,r);const a=s=>{this._instanceData.getCombinedModelTransform(s,Q),e.transform.set(Q),m(Z,r,e.transform.inverse),m($,n,e.transform.inverse);const a=this._instanceData.getState(s),i=this._instanceData.getLodLevel(s),o=this._levels.length;L(!!(a&j.ACTIVE),"invalid instance state"),L(i>=0&&i<o,"invaid lod level"),this._levels[i].intersect(e,t,Z,$,s,this.metadata,o)};this.baseMaterial.parameters.verticalOffset?this._octree.forEach(a):this._octree.forEachAlongRay(r,s,a)}notifyShaderTransformationChanged(){this._invalidateOctree(),this._requestUpdateCycle()}get _octree(){if(null==this._octreeCached){const e=this._instanceData,t=e.view?.state;if(!t)return null;this._octreeCached=new x(e,this.baseBoundingSphere);for(let r=0;r<e.capacity;++r)t.get(r)&j.ACTIVE&&this._octreeCached.addInstance(r)}return this._octreeCached}_invalidateOctree(){this._octreeCached=a(this._octreeCached)}queryDepthRange(e){if(null==this._octree)return new A;const t=e.viewForward,r=this._octree.findClosest(t,b.DepthOrder.FRONT_TO_BACK,e.frustum),n=this._octree.findClosest(t,b.DepthOrder.BACK_TO_FRONT,e.frustum);if(null==r||null==n)return new A;const s=e.eye,a=this._instanceData.view;a.boundingSphere.getVec(r,J),d(J,J,s);const i=u(J,t)-J[3];a.boundingSphere.getVec(n,J),d(J,J,s);const o=u(J,t)+J[3];return new A(i,o)}_requestUpdateCycle(e=!1){this._updateCyclesWithStaticCamera=-1,this._cycleStartIndex=this._instanceIndex,e&&(this._needFullCycle=!0,this._context.requestRender())}_startUpdateCycle(){this._updateCyclesWithStaticCamera++,this._allRenderInstanceData.forEach((e=>e.forEach((e=>e.startUpdateCycle()))))}get running(){return this._instanceData.size>0&&this._updateCyclesWithStaticCamera<1}runTask(e){const{_enableLevelSelection:t,_camera:n,_levelSelector:a}=this;this._allRenderInstanceData.forEach((e=>e.forEach((e=>e.beginUpdate()))));const i=this._instanceData,o=i.view;let l=i.size;const c=i.capacity;let h=this._instanceIndex;const d=Math.ceil(c/500);for(let u=0;u<l&&!e.done;++u){h===this._cycleStartIndex&&this._startUpdateCycle();const u=o.state.get(h);let m=0;if(!(u&j.ALLOCATED)){h=h+1===c?0:h+1,l++;continue}const f=o.lodLevel.get(h);if(u&j.DEFAULT_ACTIVE&&this._defaultRenderInstanceData[f].freeTail(),u&j.HIGHLIGHT_ACTIVE){const e=i.geHighlightGroupPrev(h);if(e){const t=this._highlightRenderInstanceDataMap.get(e);if(!t)throw new r("Internal error in lodRenderer");t[f].freeTail()}}if(u&j.REMOVE)i.freeInstance(h);else if(u&j.VISIBLE){let e=0;if(t&&(o.modelOrigin.getVec(h,Y),e=a.selectLevel(Y,i.getCombinedMedianScaleFactor(h),n)),m=u&~(j.ACTIVE|j.TRANSFORM_CHANGED),e>=0)if(u&j.HIGHLIGHT){const t=i.getHighlightGroup(h);if(t){const n=()=>{const e=this._createRenderInstanceDataArray();return e.forEach((e=>e.beginUpdate())),e},a=s(this._highlightRenderInstanceDataMap,t,n);if(e>=a.length)throw new r(`LodRenderer internal error - missing lodLevel ${e}`);k(a[e],o,h)}m|=j.HIGHLIGHT_ACTIVE}else k(this._defaultRenderInstanceData[e],o,h),m|=j.DEFAULT_ACTIVE;o.state.set(h,m),o.lodLevel.set(h,e)}else m=u&~(j.ACTIVE|j.TRANSFORM_CHANGED),o.state.set(h,m);if(null!=this._octreeCached){const e=!!(u&j.ACTIVE),t=!!(m&j.ACTIVE);!e&&t?this._octreeCached.addInstance(h):e&&!t?this._octreeCached.removeInstance(h):e&&t&&u&j.TRANSFORM_CHANGED&&(this._octreeCached.removeInstance(h),this._octreeCached.addInstance(h))}h=h+1===c?0:h+1,h%d==0&&e.madeProgress()}this._instanceIndex=h,this._allRenderInstanceData.forEach((e=>e.forEach((e=>e.endUpdate())))),this._context.requestRender()}_beginComponent(e,t,r){if(0===t.size)return null;const n=r.glMaterials.load(e.rctx,e.bind.slot,e.output);return n?.beginSlot(e.bind)}_renderComponent(e,t,r,n,s){if(!t)return;const{bind:a,rctx:i}=e;i.runAppleAmdDriverHelper();const o=i.bindTechnique(t,a,n.material.parameters,ee);i.bindVAO(n.vao),t.ensureAttributeLocations(n.vao),g.LOD_INSTANCE_RENDERER_COLORIZE_BY_LEVEL&&e.output===C.Color&&(o.setUniform4fv("externalColor",X[Math.min(s,X.length-1)]),o.setUniform1i("colorMixMode",U.replace));const l=r.capacity,c=r.headIndex,h=r.tailIndex,d=r.firstIndex,u=this._glInstanceBufferLayout,m=(e,s)=>{G(i,R,r.buffer,u,e),i.drawArraysInstanced(t.primitiveType,0,n.vertexCount,s-e),q(i,R,r.buffer,u)};n.material.parameters.transparent&&null!=d?c>h?(L(d>=h&&d<=c,"invalid firstIndex"),m(d,c),m(h,d)):c<h&&(d<=c?(L(d>=0&&d<=c,"invalid firstIndex"),m(d,c),m(h,l),m(0,d)):(L(d>=h&&d<=l,"invalid firstIndex"),m(d,l),m(0,c),m(h,d))):c>h?m(h,c):c<h&&(m(0,c),m(h,l)),i.bindVAO(null)}};function k(e,t,r){const n=e.allocateHead();W(t,r,e.view,n)}function W(e,t,r,n){H(e.modelOrigin,t,r.modelOriginHi,r.modelOriginLo,n),r.model.copyFrom(n,e.model,t),r.modelNormal.copyFrom(n,e.modelNormal,t),e.color&&r.color&&r.color.copyFrom(n,e.color,t),e.objectAndLayerIdColor&&r.objectAndLayerIdColor&&r.objectAndLayerIdColor.copyFrom(n,e.objectAndLayerIdColor,t),e.featureAttribute&&r.featureAttribute&&r.featureAttribute.copyFrom(n,e.featureAttribute,t)}function K(e){let t=y().vec3f(S.INSTANCEMODELORIGINHI).vec3f(S.INSTANCEMODELORIGINLO).mat3f(S.INSTANCEMODEL).mat3f(S.INSTANCEMODELNORMAL);return null!=e&&e.includes("featureAttribute")&&(t=t.vec4f(S.INSTANCEFEATUREATTRIBUTE)),null!=e&&e.includes("color")&&(t=t.vec4u8(S.INSTANCECOLOR)),null!=e&&e.includes("objectAndLayerIdColor")&&(t=t.vec4u8(S.INSTANCEOBJECTANDLAYERIDCOLOR)),t}e([l({constructOnly:!0})],z.prototype,"symbol",void 0),e([l({constructOnly:!0})],z.prototype,"optionalFields",void 0),e([l({constructOnly:!0})],z.prototype,"metadata",void 0),e([l({constructOnly:!0})],z.prototype,"shaderTransformation",void 0),e([l()],z.prototype,"_instanceData",void 0),e([l()],z.prototype,"_cycleStartIndex",void 0),e([l({readOnly:!0})],z.prototype,"_enableLevelSelection",null),e([l()],z.prototype,"_updateCyclesWithStaticCamera",void 0),e([l({readOnly:!0})],z.prototype,"running",null),z=e([c("esri.views.3d.webgl-engine.lib.lodRendering.LodRenderer")],z);const Y=f(),J=p(),Q=h(),Z=f(),$=f(),X=[_(1,0,1,1),_(0,0,1,1),_(0,1,0,1),_(1,1,0,1),_(1,0,0,1)],ee=new F;export{z as LodRenderer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../core/Logger.js";import{destroyMaybe as t}from"../../core/maybe.js";import{whenOnce as r}from"../../core/reactiveUtils.js";import{makeScheduleFunction as n}from"../3d/layers/support/makeScheduleFunction.js";import{TextureCompressionWorkerHandle as o}from"../3d/webgl-engine/lib/TextureCompressionWorkerHandle.js";let i=null;const s=new Set,a=()=>e.getLogger("esri/views/support/TextureCompressionHelper");function m(){return i}function c(e,t){return i??=new o(n(t)),s.has(e)?a().warn("Repeated texture compression worker initialization by the same view."):s.add(e),i}function u(e){i&&(s.delete(e)||a().warn("Unknown view attempted to destroy the texture compression worker."),s.size||(t(i),i=null))}function d(e,t=!1){const r=document.createElement("canvas"),n=r.getContext("2d");r.width=e.width,r.height=e.height,t&&(n.translate(0,r.height),n.scale(1,-1)),n.drawImage(e,0,0);return n.getImageData(0,0,r.width,r.height).data}async function l(e){const t=e.basemapTerrain.renderer.test.tileRenderer;return r((()=>!t?.texturesBeingCompressed))}function p(e){return e instanceof HTMLImageElement||e instanceof HTMLCanvasElement}export{u as destroyTextureCompressionWorker,m as getTextureCompressionWorker,c as initializeTextureCompressionWorker,p as isCompressionCandidate,d as prepareDataForCompression,l as waitForTerrainTextureCompression};
5
+ import e from"../../core/Logger.js";import{destroyMaybe as r}from"../../core/maybe.js";import{whenOnce as t}from"../../core/reactiveUtils.js";import{makeScheduleFunction as n}from"../3d/layers/support/makeScheduleFunction.js";import{TextureCompressionWorkerHandle as o}from"../3d/webgl-engine/lib/TextureCompressionWorkerHandle.js";let i=null;const s=new Set,a=()=>e.getLogger("esri/views/support/TextureCompressionHelper");function m(){return i}function u(e,r){return i??=new o(n(r)),s.has(e)?a().warn("Repeated texture compression worker initialization by the same view."):s.add(e),i}function p(e){i&&(s.delete(e)||a().warn("Unknown view attempted to destroy the texture compression worker."),s.size||(r(i),i=null))}async function c(e){const r=e.basemapTerrain.renderer.test.tileRenderer;return t((()=>!r?.texturesBeingCompressed))}function l(e){return e instanceof HTMLImageElement||e instanceof HTMLCanvasElement}export{p as destroyTextureCompressionWorker,m as getTextureCompressionWorker,u as initializeTextureCompressionWorker,l as isCompressionCandidate,c as waitForTerrainTextureCompression};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import t from"../../core/Error.js";import"../../core/has.js";import{signal as e}from"../../core/signal.js";import{getTextureCompressionWorker as i,isCompressionCandidate as r,prepareDataForCompression as s}from"../support/TextureCompressionHelper.js";import{checkWebGLError as o}from"./checkWebGLError.js";import{TextureType as a,ResourceType as n,CompressedTextureFormat as l,TextureSamplingMode as p,PixelFormat as h,PixelType as m,SizedPixelFormat as _}from"./enums.js";import{GLObjectType as d}from"./GLObjectType.js";import{estimateMemory as c}from"./TextureDescriptor.js";import{ValidatedTextureDescriptor as u}from"./ValidatedTextureDescriptor.js";const g=null;let T=class g{constructor(i,r=null,s=null){if(this.type=d.Texture,this._glName=null,this._samplingModeDirty=!1,this._wrapModeDirty=!1,this._wasImmutablyAllocated=!1,this._isCompressing=e(!1),"context"in i)this._descriptor=i,s=r;else{const e=u.validate(i,r);if(!e)throw new t("Texture descriptor invalid");this._descriptor=e}this._compressionWorkerAbortController=new AbortController,this._descriptor.target===a.TEXTURE_CUBE_MAP?this._setDataCubeMap(s):this.setData(s)}get glName(){return this._glName}get descriptor(){return this._descriptor}get usedMemory(){return c(this._descriptor)}get cachedMemory(){return this.usedMemory}get isDirty(){return this._samplingModeDirty||this._wrapModeDirty}get isCompressing(){return this._isCompressing.value}dispose(){this._compressionWorkerAbortController.abort(),this._glName&&this._descriptor.context.instanceCounter.decrement(n.Texture,this),this._descriptor.context.gl&&this._glName&&(this._descriptor.context.unbindTexture(this),this._descriptor.context.gl.deleteTexture(this._glName),this._glName=null)}release(){this.dispose()}resize(e,i){const r=this._descriptor;if(r.width!==e||r.height!==i){if(this._wasImmutablyAllocated)throw new t("Immutable textures can't be resized!");r.width=e,r.height=i,this._descriptor.target===a.TEXTURE_CUBE_MAP?this._setDataCubeMap(null):this.setData(null)}}enableCompression(t){this._descriptor.shouldCompress=t}_setDataCubeMap(t=null){for(let e=a.TEXTURE_CUBE_MAP_POSITIVE_X;e<=a.TEXTURE_CUBE_MAP_NEGATIVE_Z;e++)this._setData(t,e)}setData(t){return this.isCompressing&&(this._isCompressing.value=!1,this._compressionWorkerAbortController.abort()),!R(t)&&this._descriptor.internalFormat&&this._descriptor.internalFormat in l&&(this._descriptor.internalFormat=void 0),this._setData(t),i()&&!R(t)&&r(t)&&this._descriptor.shouldCompress&&this.compressOnWorker(t),this.isCompressing}compressOnWorker(t){const e=this._descriptor.context?.gl.getExtension("WEBGL_compressed_texture_etc"),r=this._descriptor.context?.gl.getExtension("WEBGL_compressed_texture_s3tc"),o=i(),a=s(t,this.descriptor.flipped);if(o&&(e||r)){this._isCompressing.value=!0;const i={data:a,width:t.width,height:t.height,hasMipmap:this._descriptor.hasMipmap,hasETC:!!e,hasS3TC:!!r,buffer:[new ArrayBuffer(0)]};o.invoke(i,this._compressionWorkerAbortController.signal).then((t=>{this._descriptor.internalFormat=t.internalFormat,this._setData(t.compressedTexture),this._isCompressing.value=!1})).catch((()=>{this._isCompressing.value=!1}))}}_setData(e,i){const r=this._descriptor.context?.gl;if(!r)return;o(r),this._glName||(this._glName=r.createTexture(),this._glName&&this._descriptor.context.instanceCounter.increment(n.Texture,this));const s=this._descriptor,a=i??s.target,l=b(a),p=this._descriptor.context.bindTexture(this,g.TEXTURE_UNIT_FOR_UPDATES);this._descriptor.context.setActiveTexture(g.TEXTURE_UNIT_FOR_UPDATES),E(s),this._configurePixelStorage(),o(r);const h=this._deriveInternalFormat();if(D(e)){let t="width"in e?e.width:e.codedWidth,i="height"in e?e.height:e.codedHeight;const n=1;e instanceof HTMLVideoElement&&(t=e.videoWidth,i=e.videoHeight),s.width&&s.height,l&&s.depth,s.isImmutable&&!this._wasImmutablyAllocated&&this._texStorage(a,h,s.hasMipmap,t,i,n),this._texImage(a,0,h,t,i,n,e),o(r),s.hasMipmap&&(this.generateMipmap(),o(r)),s.width||(s.width=t),s.height||(s.height=i),l&&!s.depth&&(s.depth=n)}else{const{width:i,height:n,depth:p}=s;if(null==i||null==n)throw new t("Width and height must be specified!");if(l&&null==p)throw new t("Depth must be specified!");if(s.isImmutable&&!this._wasImmutablyAllocated&&this._texStorage(a,h,s.hasMipmap,i,n,p),R(e)){const o=e.levels,l=N(a,i,n,p),m=Math.min(l,o.length)-1;r.texParameteri(s.target,this._descriptor.context.gl.TEXTURE_MAX_LEVEL,m);const _=h;if(!I(_))throw new t("Attempting to use compressed data with an uncompressed format!");this._forEachMipmapLevel(((t,e,i,r)=>{const s=o[Math.min(t,o.length-1)];this._compressedTexImage(a,t,_,e,i,r,s)}),m)}else this._texImage(a,0,h,i,n,p,e),o(r),s.hasMipmap&&this.generateMipmap()}x(r,this._descriptor),M(r,this._descriptor),A(this._descriptor.context,this._descriptor),o(r),this._descriptor.context.bindTexture(p,g.TEXTURE_UNIT_FOR_UPDATES)}updateData(e,i,r,s,o,a,n=0){a||console.error("An attempt to use uninitialized data!"),this._glName||console.error("An attempt to update uninitialized texture!");const l=this._descriptor,p=this._deriveInternalFormat(),{context:h,pixelFormat:m,dataType:_,target:d,isImmutable:c}=l;if(c&&!this._wasImmutablyAllocated)throw new t("Cannot update immutable texture before allocation!");const u=h.bindTexture(this,g.TEXTURE_UNIT_FOR_UPDATES,!0);(i<0||r<0||i+s>l.width||r+o>l.height)&&console.error("An attempt to update out of bounds of the texture!"),this._configurePixelStorage();const{gl:T}=h;n&&T.pixelStorei(T.UNPACK_SKIP_ROWS,n),D(a)?T.texSubImage2D(d,e,i,r,s,o,m,_,a):R(a)?T.compressedTexSubImage2D(d,e,i,r,s,o,p,a.levels[e]):T.texSubImage2D(d,e,i,r,s,o,m,_,a),n&&T.pixelStorei(T.UNPACK_SKIP_ROWS,0),h.bindTexture(u,g.TEXTURE_UNIT_FOR_UPDATES)}updateData3D(e,i,r,s,o,a,n,l){l||console.error("An attempt to use uninitialized data!"),this._glName||console.error("An attempt to update uninitialized texture!");const p=this._descriptor,h=this._deriveInternalFormat(),{context:m,pixelFormat:_,dataType:d,isImmutable:c,target:u}=p;if(c&&!this._wasImmutablyAllocated)throw new t("Cannot update immutable texture before allocation!");b(u)||console.warn("Attempting to set 3D texture data on a non-3D texture");const T=m.bindTexture(this,g.TEXTURE_UNIT_FOR_UPDATES);m.setActiveTexture(g.TEXTURE_UNIT_FOR_UPDATES),(i<0||r<0||s<0||i+o>p.width||r+a>p.height||s+n>p.depth)&&console.error("An attempt to update out of bounds of the texture!"),this._configurePixelStorage();const{gl:E}=m;if(R(l))l=l.levels[e],E.compressedTexSubImage3D(u,e,i,r,s,o,a,n,h,l);else{const t=l;E.texSubImage3D(u,e,i,r,s,o,a,n,_,d,t)}m.bindTexture(T,g.TEXTURE_UNIT_FOR_UPDATES)}generateMipmap(){const e=this._descriptor;if(!e.hasMipmap){if(this._wasImmutablyAllocated)throw new t("Cannot add mipmaps to immutable texture after allocation");e.hasMipmap=!0,this._samplingModeDirty=!0,E(e)}e.samplingMode===p.LINEAR?(this._samplingModeDirty=!0,e.samplingMode=p.LINEAR_MIPMAP_NEAREST):e.samplingMode===p.NEAREST&&(this._samplingModeDirty=!0,e.samplingMode=p.NEAREST_MIPMAP_NEAREST);const i=this._descriptor.context.bindTexture(this,g.TEXTURE_UNIT_FOR_UPDATES);this._descriptor.context.setActiveTexture(g.TEXTURE_UNIT_FOR_UPDATES),this._descriptor.context.gl.generateMipmap(e.target),this._descriptor.context.bindTexture(i,g.TEXTURE_UNIT_FOR_UPDATES)}clearMipmap(){const e=this._descriptor;if(e.hasMipmap){if(this._wasImmutablyAllocated)throw new t("Cannot delete mipmaps to immutable texture after allocation");e.hasMipmap=!1,this._samplingModeDirty=!0,E(e)}e.samplingMode===p.LINEAR_MIPMAP_NEAREST?(this._samplingModeDirty=!0,e.samplingMode=p.LINEAR):e.samplingMode===p.NEAREST_MIPMAP_NEAREST&&(this._samplingModeDirty=!0,e.samplingMode=p.NEAREST)}setSamplingMode(t){t!==this._descriptor.samplingMode&&(this._descriptor.samplingMode=t,this._samplingModeDirty=!0)}setWrapMode(t){t!==this._descriptor.wrapMode&&(this._descriptor.wrapMode=t,E(this._descriptor),this._wrapModeDirty=!0)}applyChanges(){const t=this._descriptor,e=t.context.gl;this._samplingModeDirty&&(x(e,t),this._samplingModeDirty=!1),this._wrapModeDirty&&(M(e,t),this._wrapModeDirty=!1)}_deriveInternalFormat(){if(null!=this._descriptor.internalFormat)return this._descriptor.internalFormat===h.DEPTH_STENCIL&&(this._descriptor.internalFormat=h.DEPTH24_STENCIL8),this._descriptor.internalFormat;switch(this._descriptor.dataType){case m.FLOAT:switch(this._descriptor.pixelFormat){case h.RGBA:return this._descriptor.internalFormat=_.RGBA32F;case h.RGB:return this._descriptor.internalFormat=_.RGB32F;default:throw new t("Unable to derive format")}case m.UNSIGNED_BYTE:switch(this._descriptor.pixelFormat){case h.RGBA:return this._descriptor.internalFormat=_.RGBA8;case h.RGB:return this._descriptor.internalFormat=_.RGB8}}return this._descriptor.internalFormat=this._descriptor.pixelFormat===h.DEPTH_STENCIL?h.DEPTH24_STENCIL8:this._descriptor.pixelFormat}_configurePixelStorage(){const t=this._descriptor.context.gl,{unpackAlignment:e,flipped:i,preMultiplyAlpha:r}=this._descriptor;t.pixelStorei(t.UNPACK_ALIGNMENT,e),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,i?1:0),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r?1:0)}_texStorage(e,i,r,s,o,a){const{gl:n}=this._descriptor.context;if(!f(i))throw new t("Immutable textures must have a sized internal format");if(!this._descriptor.isImmutable)return;const l=r?N(e,s,o,a):1;if(b(e)){if(null==a)throw new t("Missing depth dimension for 3D texture upload");n.texStorage3D(e,l,i,s,o,a)}else n.texStorage2D(e,l,i,s,o);this._wasImmutablyAllocated=!0}_texImage(e,i,r,s,o,a,n){const l=this._descriptor.context.gl,p=b(e),{isImmutable:h,pixelFormat:m,dataType:_}=this._descriptor;if(h){if(null!=n){const r=n;if(p){if(null==a)throw new t("Missing depth dimension for 3D texture upload");l.texSubImage3D(e,i,0,0,0,s,o,a,m,_,r)}else l.texSubImage2D(e,i,0,0,s,o,m,_,r)}}else{const h=n;if(p){if(null==a)throw new t("Missing depth dimension for 3D texture upload");l.texImage3D(e,i,r,s,o,a,0,m,_,h)}else l.texImage2D(e,i,r,s,o,0,m,_,h)}}_compressedTexImage(e,i,r,s,o,a,n){const l=this._descriptor.context.gl,p=b(e);if(this._descriptor.isImmutable){if(null!=n)if(p){if(null==a)throw new t("Missing depth dimension for 3D texture upload");l.compressedTexSubImage3D(e,i,0,0,0,s,o,a,r,n)}else l.compressedTexSubImage2D(e,i,0,0,s,o,r,n)}else if(p){if(null==a)throw new t("Missing depth dimension for 3D texture upload");l.compressedTexImage3D(e,i,r,s,o,a,0,n)}else l.compressedTexImage2D(e,i,r,s,o,0,n)}_forEachMipmapLevel(e,i=1/0){let{width:r,height:s,depth:o,hasMipmap:n,target:l}=this._descriptor;const p=l===a.TEXTURE_3D;if(null==r||null==s||p&&null==o)throw new t("Missing texture dimensions for mipmap calculation");for(let t=0;e(t,r,s,o),n&&(1!==r||1!==s||p&&1!==o)&&!(t>=i);++t)r=Math.max(1,r>>1),s=Math.max(1,s>>1),p&&(o=Math.max(1,o>>1))}};function E(t){(null!=t.width&&t.width<0||null!=t.height&&t.height<0||null!=t.depth&&t.depth<0)&&console.error("Negative dimension parameters are not allowed!")}function x(t,e){let i=e.samplingMode,r=e.samplingMode;i===p.LINEAR_MIPMAP_NEAREST||i===p.LINEAR_MIPMAP_LINEAR?(i=p.LINEAR,e.hasMipmap||(r=p.LINEAR)):i!==p.NEAREST_MIPMAP_NEAREST&&i!==p.NEAREST_MIPMAP_LINEAR||(i=p.NEAREST,e.hasMipmap||(r=p.NEAREST)),t.texParameteri(e.target,t.TEXTURE_MAG_FILTER,i),t.texParameteri(e.target,t.TEXTURE_MIN_FILTER,r)}function M(t,e){"number"==typeof e.wrapMode?(t.texParameteri(e.target,t.TEXTURE_WRAP_S,e.wrapMode),t.texParameteri(e.target,t.TEXTURE_WRAP_T,e.wrapMode)):(t.texParameteri(e.target,t.TEXTURE_WRAP_S,e.wrapMode.s),t.texParameteri(e.target,t.TEXTURE_WRAP_T,e.wrapMode.t))}function A(t,e){const i=t.capabilities.textureFilterAnisotropic;if(!i)return;t.gl.texParameterf(e.target,i.TEXTURE_MAX_ANISOTROPY,e.maxAnisotropy??1)}function f(t){return t in _}function I(t){return t in l}function R(t){return null!=t&&"type"in t&&"compressed"===t.type}function w(t){return null!=t&&"byteLength"in t}function D(t){return null!=t&&!R(t)&&!w(t)}function b(t){return t===a.TEXTURE_3D||t===a.TEXTURE_2D_ARRAY}function N(t,e,i,r=1){let s=Math.max(e,i);return t===a.TEXTURE_3D&&(s=Math.max(s,r)),Math.floor(Math.log2(s))+1}T.TEXTURE_UNIT_FOR_UPDATES=0;export{T as Texture,g as tracer};
5
+ import t from"../../core/Error.js";import"../../core/has.js";import{signal as e}from"../../core/signal.js";import{getTextureCompressionWorker as i,isCompressionCandidate as r}from"../support/TextureCompressionHelper.js";import{checkWebGLError as s}from"./checkWebGLError.js";import{TextureType as o,ResourceType as a,CompressedTextureFormat as n,TextureSamplingMode as l,PixelFormat as p,PixelType as h,SizedPixelFormat as m}from"./enums.js";import{GLObjectType as d}from"./GLObjectType.js";import{estimateMemory as _}from"./TextureDescriptor.js";import{ValidatedTextureDescriptor as c}from"./ValidatedTextureDescriptor.js";const u=null;let g=class u{constructor(i,r=null,s=null){if(this.type=d.Texture,this._glName=null,this._samplingModeDirty=!1,this._wrapModeDirty=!1,this._wasImmutablyAllocated=!1,this._isCompressing=e(!1),"context"in i)this._descriptor=i,s=r;else{const e=c.validate(i,r);if(!e)throw new t("Texture descriptor invalid");this._descriptor=e}this._descriptor.target===o.TEXTURE_CUBE_MAP?this._setDataCubeMap(s):this.setData(s)}get glName(){return this._glName}get descriptor(){return this._descriptor}get usedMemory(){return _(this._descriptor)}get cachedMemory(){return this.usedMemory}get isDirty(){return this._samplingModeDirty||this._wrapModeDirty}get isCompressing(){return this._isCompressing.value}set isCompressing(t){t?(this._compressionWorkerAbortController=new AbortController,this._isCompressing.value=!0):(this._compressionWorkerAbortController=null,this._isCompressing.value=!1)}dispose(){this._compressionWorkerAbortController?.abort(),this._glName&&this._descriptor.context.instanceCounter.decrement(a.Texture,this),this._descriptor.context.gl&&this._glName&&(this._descriptor.context.unbindTexture(this),this._descriptor.context.gl.deleteTexture(this._glName),this._glName=null)}release(){this.dispose()}resize(e,i){const r=this._descriptor;if(r.width!==e||r.height!==i){if(this._wasImmutablyAllocated)throw new t("Immutable textures can't be resized!");r.width=e,r.height=i,this._descriptor.target===o.TEXTURE_CUBE_MAP?this._setDataCubeMap(null):this.setData(null)}}enableCompression(t){this._descriptor.shouldCompress=t}_setDataCubeMap(t=null){for(let e=o.TEXTURE_CUBE_MAP_POSITIVE_X;e<=o.TEXTURE_CUBE_MAP_NEGATIVE_Z;e++)this._setData(t,e)}setData(t){return this.isCompressing&&(this._compressionWorkerAbortController.abort(),this.isCompressing=!1),!I(t)&&this._descriptor.internalFormat&&this._descriptor.internalFormat in n&&(this._descriptor.internalFormat=void 0),this._setData(t),i()&&!I(t)&&r(t)&&this._descriptor.shouldCompress&&(this.isCompressing=!0,this.compressOnWorker(t)),this.isCompressing}async compressOnWorker(t){const e=this._descriptor.context?.gl.getExtension("WEBGL_compressed_texture_etc"),r=this._descriptor.context?.gl.getExtension("WEBGL_compressed_texture_s3tc"),s=i(),o=await createImageBitmap(t);if(s&&(e||r)){const i={data:o,flipped:this.descriptor.flipped,width:t.width,height:t.height,hasMipmap:this._descriptor.hasMipmap,hasETC:!!e,hasS3TC:!!r,buffer:[new ArrayBuffer(0)]};s.invoke(i,this._compressionWorkerAbortController.signal).then((t=>{t&&this.glName&&(this._descriptor.internalFormat=t.internalFormat,this._setData(t.compressedTexture)),this.isCompressing=!1})).catch((()=>{this.isCompressing=!1}))}}_setData(e,i){const r=this._descriptor.context?.gl;if(!r)return;s(r),this._glName||(this._glName=r.createTexture(),this._glName&&this._descriptor.context.instanceCounter.increment(a.Texture,this));const o=this._descriptor,n=i??o.target,l=D(n),p=this._descriptor.context.bindTexture(this,u.TEXTURE_UNIT_FOR_UPDATES);this._descriptor.context.setActiveTexture(u.TEXTURE_UNIT_FOR_UPDATES),T(o),this._configurePixelStorage(),s(r);const h=this._deriveInternalFormat();if(w(e)){let t="width"in e?e.width:e.codedWidth,i="height"in e?e.height:e.codedHeight;const a=1;e instanceof HTMLVideoElement&&(t=e.videoWidth,i=e.videoHeight),o.width&&o.height,l&&o.depth,o.isImmutable&&!this._wasImmutablyAllocated&&this._texStorage(n,h,o.hasMipmap,t,i,a),this._texImage(n,0,h,t,i,a,e),s(r),o.hasMipmap&&(this.generateMipmap(),s(r)),o.width||(o.width=t),o.height||(o.height=i),l&&!o.depth&&(o.depth=a)}else{const{width:i,height:a,depth:p}=o;if(null==i||null==a)throw new t("Width and height must be specified!");if(l&&null==p)throw new t("Depth must be specified!");if(o.isImmutable&&!this._wasImmutablyAllocated&&this._texStorage(n,h,o.hasMipmap,i,a,p),I(e)){const s=e.levels,l=b(n,i,a,p),m=Math.min(l,s.length)-1;r.texParameteri(o.target,this._descriptor.context.gl.TEXTURE_MAX_LEVEL,m);const d=h;if(!f(d))throw new t("Attempting to use compressed data with an uncompressed format!");this._forEachMipmapLevel(((t,e,i,r)=>{const o=s[Math.min(t,s.length-1)];this._compressedTexImage(n,t,d,e,i,r,o)}),m)}else this._texImage(n,0,h,i,a,p,e),s(r),o.hasMipmap&&this.generateMipmap()}E(r,this._descriptor),x(r,this._descriptor),M(this._descriptor.context,this._descriptor),s(r),this._descriptor.context.bindTexture(p,u.TEXTURE_UNIT_FOR_UPDATES)}updateData(e,i,r,s,o,a,n=0){a||console.error("An attempt to use uninitialized data!"),this._glName||console.error("An attempt to update uninitialized texture!");const l=this._descriptor,p=this._deriveInternalFormat(),{context:h,pixelFormat:m,dataType:d,target:_,isImmutable:c}=l;if(c&&!this._wasImmutablyAllocated)throw new t("Cannot update immutable texture before allocation!");const g=h.bindTexture(this,u.TEXTURE_UNIT_FOR_UPDATES,!0);(i<0||r<0||i+s>l.width||r+o>l.height)&&console.error("An attempt to update out of bounds of the texture!"),this._configurePixelStorage();const{gl:T}=h;n&&T.pixelStorei(T.UNPACK_SKIP_ROWS,n),w(a)?T.texSubImage2D(_,e,i,r,s,o,m,d,a):I(a)?T.compressedTexSubImage2D(_,e,i,r,s,o,p,a.levels[e]):T.texSubImage2D(_,e,i,r,s,o,m,d,a),n&&T.pixelStorei(T.UNPACK_SKIP_ROWS,0),h.bindTexture(g,u.TEXTURE_UNIT_FOR_UPDATES)}updateData3D(e,i,r,s,o,a,n,l){l||console.error("An attempt to use uninitialized data!"),this._glName||console.error("An attempt to update uninitialized texture!");const p=this._descriptor,h=this._deriveInternalFormat(),{context:m,pixelFormat:d,dataType:_,isImmutable:c,target:g}=p;if(c&&!this._wasImmutablyAllocated)throw new t("Cannot update immutable texture before allocation!");D(g)||console.warn("Attempting to set 3D texture data on a non-3D texture");const T=m.bindTexture(this,u.TEXTURE_UNIT_FOR_UPDATES);m.setActiveTexture(u.TEXTURE_UNIT_FOR_UPDATES),(i<0||r<0||s<0||i+o>p.width||r+a>p.height||s+n>p.depth)&&console.error("An attempt to update out of bounds of the texture!"),this._configurePixelStorage();const{gl:E}=m;if(I(l))l=l.levels[e],E.compressedTexSubImage3D(g,e,i,r,s,o,a,n,h,l);else{const t=l;E.texSubImage3D(g,e,i,r,s,o,a,n,d,_,t)}m.bindTexture(T,u.TEXTURE_UNIT_FOR_UPDATES)}generateMipmap(){const e=this._descriptor;if(!e.hasMipmap){if(this._wasImmutablyAllocated)throw new t("Cannot add mipmaps to immutable texture after allocation");e.hasMipmap=!0,this._samplingModeDirty=!0,T(e)}e.samplingMode===l.LINEAR?(this._samplingModeDirty=!0,e.samplingMode=l.LINEAR_MIPMAP_NEAREST):e.samplingMode===l.NEAREST&&(this._samplingModeDirty=!0,e.samplingMode=l.NEAREST_MIPMAP_NEAREST);const i=this._descriptor.context.bindTexture(this,u.TEXTURE_UNIT_FOR_UPDATES);this._descriptor.context.setActiveTexture(u.TEXTURE_UNIT_FOR_UPDATES),this._descriptor.context.gl.generateMipmap(e.target),this._descriptor.context.bindTexture(i,u.TEXTURE_UNIT_FOR_UPDATES)}clearMipmap(){const e=this._descriptor;if(e.hasMipmap){if(this._wasImmutablyAllocated)throw new t("Cannot delete mipmaps to immutable texture after allocation");e.hasMipmap=!1,this._samplingModeDirty=!0,T(e)}e.samplingMode===l.LINEAR_MIPMAP_NEAREST?(this._samplingModeDirty=!0,e.samplingMode=l.LINEAR):e.samplingMode===l.NEAREST_MIPMAP_NEAREST&&(this._samplingModeDirty=!0,e.samplingMode=l.NEAREST)}setSamplingMode(t){t!==this._descriptor.samplingMode&&(this._descriptor.samplingMode=t,this._samplingModeDirty=!0)}setWrapMode(t){t!==this._descriptor.wrapMode&&(this._descriptor.wrapMode=t,T(this._descriptor),this._wrapModeDirty=!0)}applyChanges(){const t=this._descriptor,e=t.context.gl;this._samplingModeDirty&&(E(e,t),this._samplingModeDirty=!1),this._wrapModeDirty&&(x(e,t),this._wrapModeDirty=!1)}_deriveInternalFormat(){if(null!=this._descriptor.internalFormat)return this._descriptor.internalFormat===p.DEPTH_STENCIL&&(this._descriptor.internalFormat=p.DEPTH24_STENCIL8),this._descriptor.internalFormat;switch(this._descriptor.dataType){case h.FLOAT:switch(this._descriptor.pixelFormat){case p.RGBA:return this._descriptor.internalFormat=m.RGBA32F;case p.RGB:return this._descriptor.internalFormat=m.RGB32F;default:throw new t("Unable to derive format")}case h.UNSIGNED_BYTE:switch(this._descriptor.pixelFormat){case p.RGBA:return this._descriptor.internalFormat=m.RGBA8;case p.RGB:return this._descriptor.internalFormat=m.RGB8}}return this._descriptor.internalFormat=this._descriptor.pixelFormat===p.DEPTH_STENCIL?p.DEPTH24_STENCIL8:this._descriptor.pixelFormat}_configurePixelStorage(){const t=this._descriptor.context.gl,{unpackAlignment:e,flipped:i,preMultiplyAlpha:r}=this._descriptor;t.pixelStorei(t.UNPACK_ALIGNMENT,e),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,i?1:0),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r?1:0)}_texStorage(e,i,r,s,o,a){const{gl:n}=this._descriptor.context;if(!A(i))throw new t("Immutable textures must have a sized internal format");if(!this._descriptor.isImmutable)return;const l=r?b(e,s,o,a):1;if(D(e)){if(null==a)throw new t("Missing depth dimension for 3D texture upload");n.texStorage3D(e,l,i,s,o,a)}else n.texStorage2D(e,l,i,s,o);this._wasImmutablyAllocated=!0}_texImage(e,i,r,s,o,a,n){const l=this._descriptor.context.gl,p=D(e),{isImmutable:h,pixelFormat:m,dataType:d}=this._descriptor;if(h){if(null!=n){const r=n;if(p){if(null==a)throw new t("Missing depth dimension for 3D texture upload");l.texSubImage3D(e,i,0,0,0,s,o,a,m,d,r)}else l.texSubImage2D(e,i,0,0,s,o,m,d,r)}}else{const h=n;if(p){if(null==a)throw new t("Missing depth dimension for 3D texture upload");l.texImage3D(e,i,r,s,o,a,0,m,d,h)}else l.texImage2D(e,i,r,s,o,0,m,d,h)}}_compressedTexImage(e,i,r,s,o,a,n){const l=this._descriptor.context.gl,p=D(e);if(this._descriptor.isImmutable){if(null!=n)if(p){if(null==a)throw new t("Missing depth dimension for 3D texture upload");l.compressedTexSubImage3D(e,i,0,0,0,s,o,a,r,n)}else l.compressedTexSubImage2D(e,i,0,0,s,o,r,n)}else if(p){if(null==a)throw new t("Missing depth dimension for 3D texture upload");l.compressedTexImage3D(e,i,r,s,o,a,0,n)}else l.compressedTexImage2D(e,i,r,s,o,0,n)}_forEachMipmapLevel(e,i=1/0){let{width:r,height:s,depth:a,hasMipmap:n,target:l}=this._descriptor;const p=l===o.TEXTURE_3D;if(null==r||null==s||p&&null==a)throw new t("Missing texture dimensions for mipmap calculation");for(let t=0;e(t,r,s,a),n&&(1!==r||1!==s||p&&1!==a)&&!(t>=i);++t)r=Math.max(1,r>>1),s=Math.max(1,s>>1),p&&(a=Math.max(1,a>>1))}};function T(t){(null!=t.width&&t.width<0||null!=t.height&&t.height<0||null!=t.depth&&t.depth<0)&&console.error("Negative dimension parameters are not allowed!")}function E(t,e){let i=e.samplingMode,r=e.samplingMode;i===l.LINEAR_MIPMAP_NEAREST||i===l.LINEAR_MIPMAP_LINEAR?(i=l.LINEAR,e.hasMipmap||(r=l.LINEAR)):i!==l.NEAREST_MIPMAP_NEAREST&&i!==l.NEAREST_MIPMAP_LINEAR||(i=l.NEAREST,e.hasMipmap||(r=l.NEAREST)),t.texParameteri(e.target,t.TEXTURE_MAG_FILTER,i),t.texParameteri(e.target,t.TEXTURE_MIN_FILTER,r)}function x(t,e){"number"==typeof e.wrapMode?(t.texParameteri(e.target,t.TEXTURE_WRAP_S,e.wrapMode),t.texParameteri(e.target,t.TEXTURE_WRAP_T,e.wrapMode)):(t.texParameteri(e.target,t.TEXTURE_WRAP_S,e.wrapMode.s),t.texParameteri(e.target,t.TEXTURE_WRAP_T,e.wrapMode.t))}function M(t,e){const i=t.capabilities.textureFilterAnisotropic;if(!i)return;t.gl.texParameterf(e.target,i.TEXTURE_MAX_ANISOTROPY,e.maxAnisotropy??1)}function A(t){return t in m}function f(t){return t in n}function I(t){return null!=t&&"type"in t&&"compressed"===t.type}function R(t){return null!=t&&"byteLength"in t}function w(t){return null!=t&&!I(t)&&!R(t)}function D(t){return t===o.TEXTURE_3D||t===o.TEXTURE_2D_ARRAY}function b(t,e,i,r=1){let s=Math.max(e,i);return t===o.TEXTURE_3D&&(s=Math.max(s,r)),Math.floor(Math.log2(s))+1}g.TEXTURE_UNIT_FOR_UPDATES=0;export{g as Texture,u as tracer};
package/webscene/Slide.js CHANGED
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import t from"../Basemap.js";import i from"../Viewpoint.js";import{result as n}from"../core/asyncUtils.js";import r from"../core/Clonable.js";import o from"../core/Collection.js";import{referenceSetter as s}from"../core/collectionUtils.js";import a from"../core/JSONSupport.js";import l from"../core/Logger.js";import{moduloPositive as p}from"../core/mathUtils.js";import{destroyMaybe as m,removeMaybe as c}from"../core/maybe.js";import{onAbortOrThrow as h,createAbortError as d,isAbortError as u}from"../core/promiseUtils.js";import{whenOnce as y,when as g}from"../core/reactiveUtils.js";import{property as v}from"../core/accessorSupport/decorators/property.js";import{cast as b}from"../core/accessorSupport/decorators/cast.js";import"../core/RandomLCG.js";import"../core/has.js";import{subclass as w}from"../core/accessorSupport/decorators/subclass.js";import{ensureType as f}from"../core/accessorSupport/ensureType.js";import{s as T}from"../chunks/vec32.js";import{create as L}from"../core/libs/gl-matrix-2/factories/vec3f64.js";import C from"../layers/Layer.js";import{basemapEnsureType as j,clonePreservingTiledLayers as _}from"../support/basemapEnsureType.js";import{TaskPriority as E}from"../views/support/Scheduler.js";import{SlideThumbnail as S}from"../webdoc/support/SlideThumbnail.js";import{timeExtent as k}from"../webdoc/support/timeProperties.js";import V from"./SunLighting.js";import U from"./VirtualLighting.js";import x from"./support/Description.js";import{SlideEnvironment as I}from"./support/SlideEnvironment.js";import D from"./support/SlideGround.js";import{SlideVisibleLayer as R}from"./support/SlideVisibleLayer.js";import A from"./support/Title.js";let M=0;const P=o.ofType(R),q=["caption","cover","none"];let B=class extends(r.ClonableMixin(a)){constructor(e){super(e),this.id=Date.now().toString(16)+"-slide-"+M++,this.title=new A,this.description=new x,this.hidden=!1,this.thumbnail=new S,this.viewpoint=null,this.basemap=null,this.ground=null,this.layout="caption",this.environment=new I,this.timeExtent=null,this.visibleLayers=new P}destroy(){this.visibleLayers.removeAll(),this.basemap=null,this.thumbnail=m(this.thumbnail),this.description=null,this.title=null,this.thumbnail=null}castTitle(e){return"string"==typeof e?new A({text:e}):f(A,e)}castDescription(e){return"string"==typeof e?new x({text:e}):f(x,e)}castThumbnail(e){return"string"==typeof e?new S({url:e}):f(S,e)}castBasemap(e){return j(e)}set visibleLayers(e){this._set("visibleLayers",s(e,this._get("visibleLayers"),P))}castVisibleLayers(e){return e&&"function"==typeof e.map?e.map((e=>{if("string"==typeof e)return{id:e};if(e instanceof C){const t=G(e);return{id:e.id,sublayerIds:t}}return e.id?{id:e.id,sublayerIds:"sublayerIds"in e?e.sublayerIds:void 0}:(l.getLogger(this).warn('Invalid visible layer, expected { id }, Layer or "id"'),e)})):null}async _updateVisibleLayersFrom(e){const t=[];await Promise.allSettled(this._getLayers(e.map).map((i=>e.whenLayerView(i).then((e=>{if(e.visible){const n=G(i);t.push(new R({id:e.layer.id,sublayerIds:n}))}})))).toArray()),this.visibleLayers.removeAll(),this.visibleLayers.addMany(t)}updateFrom(e,t){const i={format:"png",quality:80,width:120,height:75,disableDecorations:!0,...t?.screenshot};return e.when((()=>(this.viewpoint=e.viewpoint.clone(),this.environment.lighting="virtual"===e.environment.lighting.type?U.prototype.clone.apply(e.environment.lighting):V.prototype.clone.apply(e.environment.lighting),this.environment.weather=e.environment.weather.clone(),this.basemap=e.map.basemap&&e.map.basemap.clone()||null,this.ground=e.map.ground?D.fromGround(e.map.ground):null,this.timeExtent=e.timeExtent?.clone()??null,this._updateVisibleLayersFrom(e)))).then((()=>e.takeScreenshot(i))).then((e=>(this.thumbnail=new S({url:e.dataUrl}),this)))}async applyTo(e,t){null!=this._applyToController&&this._applyToController.abort();let i=new AbortController;this._applyToController=i;const r=h(t,(()=>i?.abort())),o=()=>{this._applyToController===i&&(this._applyToController=null),i=null,r?.remove()};try{await y((()=>e.ready),i.signal)}catch(c){throw o(),c}if(i.signal.aborted)throw o(),d();const s=e.resourceController.scheduler.registerTask(E.SLIDE);let a=!1;const l={animate:!0,...t,signal:this._applyToController.signal},p=async()=>{await Promise.all([s.schedule((async()=>a=await this._setViewpointOfInterest(e,l))),s.schedule((()=>this._applyBasemap(e,l)),l.signal),s.schedule((()=>this._loadLayersWithSublayerVisibility(e)))]),await Promise.all([s.schedule((()=>this._applyLayerVisibility(e)),l.signal),s.schedule((()=>this._applyGround(e)),l.signal),s.schedule((()=>this._applyViewpoint(e,l)),l.signal),s.schedule((()=>e.timeExtent=this.timeExtent?.clone()??null),l.signal),s.schedule((()=>e.environment.weather=this.environment.weather.clone()))])},m=await n(e.addUpdatingPromise(p()));if(a&&(e.contentCamera=null),s.remove(),o(),!1===m.ok)throw m.error;return this}async _applyBasemap(e,t){if(this.basemap){try{await this.basemap.load(t)}catch(i){if(u(i))throw i}e.map.basemap=_(this.basemap,e.map.basemap)}}_applyGround(e){this.ground&&(e.map.ground=this.ground.cloneAndApplyTo(e.map.ground))}_getLayers(e){const t=new o;return this._collectLayers(e,t),this._collectLayers(e.ground,t),t}_collectLayers(e,t){e.layers.forEach((e=>{e.persistenceEnabled&&(t.add(e),"layers"in e&&this._collectLayers(e,t))}))}async _loadLayersWithSublayerVisibility(e){this.visibleLayers&&await Promise.allSettled(this._getLayers(e.map).items.map((e=>{const t=this.visibleLayers.find((t=>t.id===e.id))?.sublayerIds;return t?e.load():null})))}_applyLayerVisibility(e){if(!this.visibleLayers)return;this._getLayers(e.map).forEach((e=>{const t=this.visibleLayers.find((t=>t.id===e.id));e.visible=null!=t;const i=t?.sublayerIds,n=F(e);i&&n&&n.forEach((e=>e.visible=i.includes(e.id)))}))}async _setViewpointOfInterest(e,t){if(e.state.fixedContentCamera||!this.viewpoint||t?.ignoreViewpoint||!t?.useDestinationCamera)return!1;const{toCameraAsync:i}=await import("../views/3d/support/viewpointUtils.js"),n=await i(e,this.viewpoint);return e.contentCamera=n,null!=n}async _applyViewpoint(e,t){if(this._applyCachedCameraTrackingEnabled(e),this.viewpoint&&!t.ignoreViewpoint){const i=this.environment.lighting;if(t.animate&&"sun"===i.type&&i.date)return this._animateToLighting(e,t);t.animate&&(e.environment.applyLighting(i.clone()),await e.goTo(this.viewpoint,t)),e.viewpoint=this.viewpoint}e.environment.applyLighting(this.environment.lighting.clone())}async _animateToLighting(e,t){let i=null;"virtual"!==e.environment.lighting.type&&"virtual"!==this.environment.lighting.type&&("global"===e.viewingMode&&(i=this._animateLightingWithCamera(e,e.environment.lighting,this.environment.lighting)),e.environment.cachedCameraTrackingEnabled=e.environment.lighting.cameraTrackingEnabled,e.environment.lighting.cameraTrackingEnabled=!1),e.environment.lighting.directShadowsEnabled=this.environment.lighting.directShadowsEnabled,"virtual"===this.environment.lighting.type||"virtual"===e.environment.lighting.type?(e.environment.applyLighting(this.environment.lighting.clone()),"virtual"!==e.environment.lighting.type&&(e.environment.cachedCameraTrackingEnabled=e.environment.lighting.cameraTrackingEnabled,e.environment.lighting.cameraTrackingEnabled=!1)):null!=this.environment.lighting.displayUTCOffset&&(e.environment.lighting.displayUTCOffset=this.environment.lighting.displayUTCOffset);return e.goTo(this.viewpoint,t).then((()=>{this._applyCachedCameraTrackingEnabled(e),e.environment.applyLighting(this.environment.lighting.clone())})).catch((t=>{throw null==e.animation&&this._applyCachedCameraTrackingEnabled(e),t})).finally((()=>{c(i)}))}_applyCachedCameraTrackingEnabled(e){null!=e.environment.cachedCameraTrackingEnabled&&(e.environment.lighting.cameraTrackingEnabled=e.environment.cachedCameraTrackingEnabled,e.environment.cachedCameraTrackingEnabled=null)}_getTime(e){return[e.getTime(),3600*e.getUTCHours()+60*e.getUTCMinutes()+e.getUTCSeconds()]}_setTime(e,t,i){return e.setTime(t),e.setUTCHours(i/3600),e.setUTCMinutes(i%3600/60),e.setUTCSeconds(i%3600%60),e}_animateLightingWithCamera(e,t,i){const n=new Date(t.date.toString()),[r,o]=this._getTime(n),[s,a]=this._getTime(i.date),l=H(o,a),p=e.renderCoordsHelper,m=L();p.toRenderCoords(e.camera.position,m);const c=L(),h=L();null!=this.viewpoint.camera&&p.toRenderCoords(this.viewpoint.camera.position,c);const d=new Date;return g((()=>e.camera),(e=>{p.toRenderCoords(e.position,h);const i=T(m,h),n=T(c,h);let a=0;i+n!==0&&(a=i/(i+n));const u=r+(s-r)*a,y=J(o,l*a);t.date=this._setTime(d,u,y)}))}static createFrom(e,t){return(new this).updateFrom(e,t)}};e([v({type:String,json:{write:{isRequired:!0}}})],B.prototype,"id",void 0),e([v({type:A,json:{default:()=>new A({text:""}),write:{isRequired:!0}}})],B.prototype,"title",void 0),e([b("title")],B.prototype,"castTitle",null),e([v({type:x,json:{write:{overridePolicy:e=>({enabled:!(!e||!e.text)})}}})],B.prototype,"description",void 0),e([b("description")],B.prototype,"castDescription",null),e([v({type:Boolean,nonNullable:!0,json:{write:!0,default:!1}})],B.prototype,"hidden",void 0),e([v({type:S,json:{default:()=>new S({url:""}),write:{isRequired:!0}}})],B.prototype,"thumbnail",void 0),e([b("thumbnail")],B.prototype,"castThumbnail",null),e([v({type:i,nonNullable:!0,json:{write:{isRequired:!0}}})],B.prototype,"viewpoint",void 0),e([v({type:t,json:{read:{source:"baseMap"},write:{target:"baseMap"}}})],B.prototype,"basemap",void 0),e([b("basemap")],B.prototype,"castBasemap",null),e([v({type:D,json:{write:!0}})],B.prototype,"ground",void 0),e([v({type:q,json:{write:!0,default:"caption"},nonNullable:!0})],B.prototype,"layout",void 0),e([v({type:P,json:{write:{isRequired:!0}}})],B.prototype,"visibleLayers",null),e([b("visibleLayers")],B.prototype,"castVisibleLayers",null),e([v({type:I,json:{write:!0}})],B.prototype,"environment",void 0),e([v(k)],B.prototype,"timeExtent",void 0),B=e([w("esri.webscene.Slide")],B);const O=B;function F(e){if("building-scene"===e.type||"map-image"===e.type)return e.allSublayers.toArray()}function G(e){const t=F(e);if(t)return t.filter((e=>e.visible)).map((e=>e.id))}const N=86400,W=43200;function H(e,t){let i=t-e;return i>W&&(i-=N),i<-W&&(i+=N),i}function J(e,t){return p(e+t,N)}export{O as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import t from"../Basemap.js";import i from"../Viewpoint.js";import{result as n}from"../core/asyncUtils.js";import r from"../core/Clonable.js";import o from"../core/Collection.js";import{referenceSetter as s}from"../core/collectionUtils.js";import a from"../core/JSONSupport.js";import l from"../core/Logger.js";import{moduloPositive as p}from"../core/mathUtils.js";import{destroyMaybe as m,removeMaybe as c}from"../core/maybe.js";import{onAbortOrThrow as h,createAbortError as d,isAbortError as u}from"../core/promiseUtils.js";import{whenOnce as y,when as g}from"../core/reactiveUtils.js";import{property as v}from"../core/accessorSupport/decorators/property.js";import{cast as b}from"../core/accessorSupport/decorators/cast.js";import"../core/RandomLCG.js";import"../core/has.js";import{subclass as w}from"../core/accessorSupport/decorators/subclass.js";import{ensureType as f}from"../core/accessorSupport/ensureType.js";import{s as T}from"../chunks/vec32.js";import{create as L}from"../core/libs/gl-matrix-2/factories/vec3f64.js";import j from"../layers/Layer.js";import{basemapEnsureType as C,clonePreservingTiledLayers as _}from"../support/basemapEnsureType.js";import{TaskPriority as E}from"../views/support/Scheduler.js";import{SlideThumbnail as S}from"../webdoc/support/SlideThumbnail.js";import{timeExtent as k}from"../webdoc/support/timeProperties.js";import V from"./SlideLegend.js";import U from"./SunLighting.js";import x from"./VirtualLighting.js";import I from"./support/Description.js";import{SlideEnvironment as D}from"./support/SlideEnvironment.js";import R from"./support/SlideGround.js";import{SlideVisibleLayer as A}from"./support/SlideVisibleLayer.js";import M from"./support/Title.js";let P=0;const q=o.ofType(A),B=["caption","cover","none"];let O=class extends(r.ClonableMixin(a)){constructor(e){super(e),this.id=Date.now().toString(16)+"-slide-"+P++,this.title=new M,this.description=new I,this.hidden=!1,this.thumbnail=new S,this.viewpoint=null,this.basemap=null,this.ground=null,this.layout="caption",this.environment=new D,this.timeExtent=null,this.legend=null,this.visibleLayers=new q}destroy(){this.visibleLayers.removeAll(),this.basemap=null,this.thumbnail=m(this.thumbnail),this.description=null,this.title=null,this.thumbnail=null,this.legend=null}castTitle(e){return"string"==typeof e?new M({text:e}):f(M,e)}castDescription(e){return"string"==typeof e?new I({text:e}):f(I,e)}castThumbnail(e){return"string"==typeof e?new S({url:e}):f(S,e)}castBasemap(e){return C(e)}set visibleLayers(e){this._set("visibleLayers",s(e,this._get("visibleLayers"),q))}castVisibleLayers(e){return e&&"function"==typeof e.map?e.map((e=>{if("string"==typeof e)return{id:e};if(e instanceof j){const t=N(e);return{id:e.id,sublayerIds:t}}return e.id?{id:e.id,sublayerIds:"sublayerIds"in e?e.sublayerIds:void 0}:(l.getLogger(this).warn('Invalid visible layer, expected { id }, Layer or "id"'),e)})):null}async _updateVisibleLayersFrom(e){const t=[];await Promise.allSettled(this._getLayers(e.map).map((i=>e.whenLayerView(i).then((e=>{if(e.visible){const n=N(i);t.push(new A({id:e.layer.id,sublayerIds:n}))}})))).toArray()),this.visibleLayers.removeAll(),this.visibleLayers.addMany(t)}updateFrom(e,t){const i={format:"png",quality:80,width:120,height:75,disableDecorations:!0,...t?.screenshot};return e.when((()=>(this.viewpoint=e.viewpoint.clone(),this.environment.lighting="virtual"===e.environment.lighting.type?x.prototype.clone.apply(e.environment.lighting):U.prototype.clone.apply(e.environment.lighting),this.environment.weather=e.environment.weather.clone(),this.basemap=e.map.basemap&&e.map.basemap.clone()||null,this.ground=e.map.ground?R.fromGround(e.map.ground):null,this.timeExtent=e.timeExtent?.clone()??null,this._updateVisibleLayersFrom(e)))).then((()=>e.takeScreenshot(i))).then((e=>(this.thumbnail=new S({url:e.dataUrl}),this)))}async applyTo(e,t){null!=this._applyToController&&this._applyToController.abort();let i=new AbortController;this._applyToController=i;const r=h(t,(()=>i?.abort())),o=()=>{this._applyToController===i&&(this._applyToController=null),i=null,r?.remove()};try{await y((()=>e.ready),i.signal)}catch(c){throw o(),c}if(i.signal.aborted)throw o(),d();const s=e.resourceController.scheduler.registerTask(E.SLIDE);let a=!1;const l={animate:!0,...t,signal:this._applyToController.signal},p=async()=>{await Promise.all([s.schedule((async()=>a=await this._setViewpointOfInterest(e,l))),s.schedule((()=>this._applyBasemap(e,l)),l.signal),s.schedule((()=>this._loadLayersWithSublayerVisibility(e)))]),await Promise.all([s.schedule((()=>this._applyLayerVisibility(e)),l.signal),s.schedule((()=>this._applyGround(e)),l.signal),s.schedule((()=>this._applyViewpoint(e,l)),l.signal),s.schedule((()=>e.timeExtent=this.timeExtent?.clone()??null),l.signal),s.schedule((()=>e.environment.weather=this.environment.weather.clone()))])},m=await n(e.addUpdatingPromise(p()));if(a&&(e.contentCamera=null),s.remove(),o(),!1===m.ok)throw m.error;return this}async _applyBasemap(e,t){if(this.basemap){try{await this.basemap.load(t)}catch(i){if(u(i))throw i}e.map.basemap=_(this.basemap,e.map.basemap)}}_applyGround(e){this.ground&&(e.map.ground=this.ground.cloneAndApplyTo(e.map.ground))}_getLayers(e){const t=new o;return this._collectLayers(e,t),this._collectLayers(e.ground,t),t}_collectLayers(e,t){e.layers.forEach((e=>{e.persistenceEnabled&&(t.add(e),"layers"in e&&this._collectLayers(e,t))}))}async _loadLayersWithSublayerVisibility(e){this.visibleLayers&&await Promise.allSettled(this._getLayers(e.map).items.map((e=>{const t=this.visibleLayers.find((t=>t.id===e.id))?.sublayerIds;return t?e.load():null})))}_applyLayerVisibility(e){if(!this.visibleLayers)return;this._getLayers(e.map).forEach((e=>{const t=this.visibleLayers.find((t=>t.id===e.id));e.visible=null!=t;const i=t?.sublayerIds,n=G(e);i&&n&&n.forEach((e=>e.visible=i.includes(e.id)))}))}async _setViewpointOfInterest(e,t){if(e.state.fixedContentCamera||!this.viewpoint||t?.ignoreViewpoint||!t?.useDestinationCamera)return!1;const{toCameraAsync:i}=await import("../views/3d/support/viewpointUtils.js"),n=await i(e,this.viewpoint);return e.contentCamera=n,null!=n}async _applyViewpoint(e,t){if(this._applyCachedCameraTrackingEnabled(e),this.viewpoint&&!t.ignoreViewpoint){const i=this.environment.lighting;if(t.animate&&"sun"===i.type&&i.date)return this._animateToLighting(e,t);t.animate&&(e.environment.applyLighting(i.clone()),await e.goTo(this.viewpoint,t)),e.viewpoint=this.viewpoint}e.environment.applyLighting(this.environment.lighting.clone())}async _animateToLighting(e,t){let i=null;"virtual"!==e.environment.lighting.type&&"virtual"!==this.environment.lighting.type&&("global"===e.viewingMode&&(i=this._animateLightingWithCamera(e,e.environment.lighting,this.environment.lighting)),e.environment.cachedCameraTrackingEnabled=e.environment.lighting.cameraTrackingEnabled,e.environment.lighting.cameraTrackingEnabled=!1),e.environment.lighting.directShadowsEnabled=this.environment.lighting.directShadowsEnabled,"virtual"===this.environment.lighting.type||"virtual"===e.environment.lighting.type?(e.environment.applyLighting(this.environment.lighting.clone()),"virtual"!==e.environment.lighting.type&&(e.environment.cachedCameraTrackingEnabled=e.environment.lighting.cameraTrackingEnabled,e.environment.lighting.cameraTrackingEnabled=!1)):null!=this.environment.lighting.displayUTCOffset&&(e.environment.lighting.displayUTCOffset=this.environment.lighting.displayUTCOffset);return e.goTo(this.viewpoint,t).then((()=>{this._applyCachedCameraTrackingEnabled(e),e.environment.applyLighting(this.environment.lighting.clone())})).catch((t=>{throw null==e.animation&&this._applyCachedCameraTrackingEnabled(e),t})).finally((()=>{c(i)}))}_applyCachedCameraTrackingEnabled(e){null!=e.environment.cachedCameraTrackingEnabled&&(e.environment.lighting.cameraTrackingEnabled=e.environment.cachedCameraTrackingEnabled,e.environment.cachedCameraTrackingEnabled=null)}_getTime(e){return[e.getTime(),3600*e.getUTCHours()+60*e.getUTCMinutes()+e.getUTCSeconds()]}_setTime(e,t,i){return e.setTime(t),e.setUTCHours(i/3600),e.setUTCMinutes(i%3600/60),e.setUTCSeconds(i%3600%60),e}_animateLightingWithCamera(e,t,i){const n=new Date(t.date.toString()),[r,o]=this._getTime(n),[s,a]=this._getTime(i.date),l=J(o,a),p=e.renderCoordsHelper,m=L();p.toRenderCoords(e.camera.position,m);const c=L(),h=L();null!=this.viewpoint.camera&&p.toRenderCoords(this.viewpoint.camera.position,c);const d=new Date;return g((()=>e.camera),(e=>{p.toRenderCoords(e.position,h);const i=T(m,h),n=T(c,h);let a=0;i+n!==0&&(a=i/(i+n));const u=r+(s-r)*a,y=z(o,l*a);t.date=this._setTime(d,u,y)}))}static createFrom(e,t){return(new this).updateFrom(e,t)}};e([v({type:String,json:{write:{isRequired:!0}}})],O.prototype,"id",void 0),e([v({type:M,json:{default:()=>new M({text:""}),write:{isRequired:!0}}})],O.prototype,"title",void 0),e([b("title")],O.prototype,"castTitle",null),e([v({type:I,json:{write:{overridePolicy:e=>({enabled:!(!e||!e.text)})}}})],O.prototype,"description",void 0),e([b("description")],O.prototype,"castDescription",null),e([v({type:Boolean,nonNullable:!0,json:{write:!0,default:!1}})],O.prototype,"hidden",void 0),e([v({type:S,json:{default:()=>new S({url:""}),write:{isRequired:!0}}})],O.prototype,"thumbnail",void 0),e([b("thumbnail")],O.prototype,"castThumbnail",null),e([v({type:i,nonNullable:!0,json:{write:{isRequired:!0}}})],O.prototype,"viewpoint",void 0),e([v({type:t,json:{read:{source:"baseMap"},write:{target:"baseMap"}}})],O.prototype,"basemap",void 0),e([b("basemap")],O.prototype,"castBasemap",null),e([v({type:R,json:{write:!0}})],O.prototype,"ground",void 0),e([v({type:B,json:{write:!0,default:"caption"},nonNullable:!0})],O.prototype,"layout",void 0),e([v({type:q,json:{write:{isRequired:!0}}})],O.prototype,"visibleLayers",null),e([b("visibleLayers")],O.prototype,"castVisibleLayers",null),e([v({type:D,json:{write:!0}})],O.prototype,"environment",void 0),e([v(k)],O.prototype,"timeExtent",void 0),e([v({type:V,json:{write:!0}})],O.prototype,"legend",void 0),O=e([w("esri.webscene.Slide")],O);const F=O;function G(e){if("building-scene"===e.type||"map-image"===e.type)return e.allSublayers.toArray()}function N(e){const t=G(e);if(t)return t.filter((e=>e.visible)).map((e=>e.id))}const W=86400,H=43200;function J(e,t){let i=t-e;return i>H&&(i-=W),i<-H&&(i+=W),i}function z(e,t){return p(e+t,W)}export{F as default};
@@ -0,0 +1,4 @@
1
+ import "../interfaces";
2
+
3
+ import SlideLegend = __esri.SlideLegend;
4
+ export default SlideLegend;
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
+ */
5
+ import{_ as e}from"../chunks/tslib.es6.js";import s from"../core/JSONSupport.js";import{property as r}from"../core/accessorSupport/decorators/property.js";import{subclass as o}from"../core/accessorSupport/decorators/subclass.js";var t;let i=t=class extends s{constructor(e){super(e),this.visible=!1}clone(){return new t({visible:this.visible})}cloneConstructProperties(){return{visible:this.visible}}};e([r({type:Boolean,json:{default:!1,write:!0}})],i.prototype,"visible",void 0),i=t=e([o("esri.webscene.SlideLegend")],i);const c=i;export{c as default};