@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 3.3 kB
JavaScript
/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
*/
import{_ as e}from"../../../../../chunks/tslib.es6.js";import t from"../../../../../core/Accessor.js";import{property as r}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as o}from"../../../../../core/accessorSupport/decorators/subclass.js";import{create as s}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{WorkerHandle as n}from"../../../../../core/workers/WorkerHandle.js";import{f as i}from"../../../../../chunks/sphere.js";import{markAsTarget as a,fromVec3 as d}from"../../../sketch/normalizedPoint.js";import{EdgeSnappingCandidate as c}from"../../candidates/EdgeSnappingCandidate.js";import{VertexSnappingCandidate as p}from"../../candidates/VertexSnappingCandidate.js";let l=class extends t{constructor(e){super(e),this.availability=0,this._ids=new Set}destroy(){this._workerHandle.destroy(),this._workerHandle=null}initialize(){this._workerHandle=new h(this.schedule,{fetchAllEdgeLocations:(e,t)=>this._fetchAllEdgeLocations(e,t)})}async fetchCandidates(e,t){const r=e.coordinateHelper,{point:o}=e,s=u;this.renderCoordsHelper.toRenderCoords(o,r.spatialReference,s);const n=e.distance,a="number"==typeof n?n:n.distance,d=await this._workerHandle.invoke({bounds:i(s[0],s[1],s[2],a),returnEdge:e.returnEdge,returnVertex:"none"!==e.vertexMode},t);return d.candidates.sort(((e,t)=>e.distance-t.distance)),d.candidates.map((e=>this._convertCandidate(r,e)))}async add(e,t){this._ids.add(e.id),await this._workerHandle.invokeMethod("add",e,t)}async remove(e,t){this._ids.delete(e.id),await this._workerHandle.invokeMethod("remove",e,t)}_convertCandidate(e,t){switch(t.type){case"edge":return new c({objectId:t.objectId,targetPoint:a(this._convertRenderCoordinate(e,t.target)),edgeStart:this._convertRenderCoordinate(e,t.start),edgeEnd:this._convertRenderCoordinate(e,t.end),isDraped:!1});case"vertex":return new p({objectId:t.objectId,targetPoint:a(this._convertRenderCoordinate(e,t.target)),isDraped:!1})}}_convertRenderCoordinate({spatialReference:e},t){const r=s();return this.renderCoordsHelper.fromRenderCoords(t,r,e),d(r)}async _fetchAllEdgeLocations(e,t){const r=[],o=[];for(const{id:s,uid:n}of e.components)this._ids.has(s)&&r.push((async()=>{const e=await this.fetchEdgeLocations(s,t.signal),r=e.locations.buffer;return o.push(r),{id:s,uid:n,objectIds:e.objectIds,locations:r,origin:e.origin,type:e.type}})());return{result:{components:(await Promise.all(r)).filter((({id:e})=>this._ids.has(e)))},transferList:o}}};e([r({constructOnly:!0})],l.prototype,"renderCoordsHelper",void 0),e([r({constructOnly:!0})],l.prototype,"fetchEdgeLocations",void 0),e([r({constructOnly:!0})],l.prototype,"schedule",void 0),e([r({readOnly:!0})],l.prototype,"availability",void 0),l=e([o("esri.views.interactive.snapping.featureSources.sceneLayerSource.SceneLayerSnappingSourceWorkerHandle")],l);class h extends n{constructor(e,t){super("SceneLayerSnappingSourceWorker","fetchCandidates",{},e,{strategy:"dedicated",client:t})}}const u=s();export{l as SceneLayerSnappingSourceWorkerHandle};