UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

6 lines (5 loc) 4.11 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.33/esri/copyright.txt for details. */ import{pt2px as t}from"../../../../../../../core/screenUtils.js";import{GeometryCursor as e}from"../../../../../../../geometry/GeometryCursor.js";import{LineCapStyle as i,LineJoinStyle as s}from"../../../../../../../symbols/cim/enums.js";import"../../../definitions.js";import{LineTessellation as r}from"../../../TurboLine.js";import{clipLinesMarshall as n,triangulate as o}from"../../../mesh/templates/templateUtils.js";import{AAnimatedMeshWriter as a}from"./AnimatedMeshWriter.js";import{lineLength as h,noTiming as m,zoomRange as l,segmentDirection as u,normal as c,accumulatedDistance as d,sizing as p,animationPointerAndBaseSizeAndReferenceSize as f,tlbr as x,offset as _,pos as g,bitset as P,id as v,noLineLength as L}from"./attributes.js";import{createComputedAnimatedMeshParams as y}from"./ComputedAnimatedParams.js";import{processLineCapInput as W,processLineJoinInput as b}from"../fill/meshWriterUtils.js";import{LineTessellationParams as w}from"../line/LineMeshWriter.js";class C extends a{_write(t,i,s){const r=s??e.fromFeatureSetReaderCIM(i);if(!r)return;const n=this.evaluatedMeshParams.sprite,{textureBinding:o}=n;t.recordStart(this.instanceId,this.attributeLayout,o);const a=i.getDisplayId();this._writePoly(t,a,r.asOptimized()),t.recordEnd()}}class j extends C{constructor(){super(...arguments),this.vertexSpec={createComputedParams:y,attributes:{id:v,bitset:P,pos:g,offset:_.fill,tlbr:x,animationPointerAndBaseSizeAndReferenceSize:f,sizing:p},optionalAttributes:{zoomRange:l,value1Position2Value2:m,lineLength:L}}}_writePoly(t,e,i){const s=[];if(!o(s,i))return;const r=t.vertexCount();i.forEachVertex(((i,s)=>{this._writeVertex(t,e,i,s)})),t.indexEnsureSize(s.length);for(const n of s)t.indexWrite(r+n)}}class z{constructor(){this.id=0,this.bitset=0,this.indexCount=0,this.vertexCount=0,this.vertexFrom=0,this.vertexBounds=0,this.pathLength=0}}const S=65535;class T extends C{constructor(){super(...arguments),this.vertexSpec={createComputedParams:y,attributes:{id:v,bitset:P,pos:g,offset:_.line,tlbr:x,animationPointerAndBaseSizeAndReferenceSize:f,sizing:p,accumulatedDistance:d,normal:c,segmentDirection:u},optionalAttributes:{zoomRange:l,value1Position2Value2:m,lineLength:h}},this._tessParams=new w,this._currentWrite=new z,this._tessellationOptions={halfWidth:0,pixelCoordRatio:1,offset:0,wrapDistance:S,textured:!1},this._lineLength=0,this._lineTessellator=new r(((t,e,i,s,r,n,o,a,h,m,l)=>this._writeTesselatedVertex(t,e,i,s,r,n,o,a,h,m,l,this._lineLength)),this._writeTriangle.bind(this),!1)}_writePoly(r,o,a){const h=64,m=!1,l=n(e.fromOptimized(a,"esriGeometryPolyline"),h);if(null==l)return;const{_currentWrite:u,_tessellationOptions:c}=this,{baseSize:d,capType:p,joinType:f,miterLimit:x}=this.evaluatedMeshParams,_=t(.5*d);c.halfWidth=_,c.capType=W(p||i.Round),c.joinType=b(f||s.Round),c.miterLimit=x||2,u.out=r,u.id=o,u.vertexCount=0,u.indexCount=0,u.vertexFrom=r.vertexCount(),u.vertexBounds=1;for(const{line:t,start:e,pathLength:i}of l){c.initialDistance=e%S,u.pathLength=i,this._lineLength=0;for(let e=1;e<t.length;e++){const i=t[e].x-t[e-1].x,s=t[e].y-t[e-1].y;this._lineLength+=Math.sqrt(i*i+s*s)}this._lineTessellator.tessellate(t,c,m)}}_writeTesselatedVertex(t,e,i,s,r,n,o,a,h,m,l,u){const{out:c,id:d,vertexBounds:p,pathLength:f}=this._currentWrite;return this.hasEffects&&c.recordBounds(t,e,p,p),this._tessParams.extrusionOffsetX=o,this._tessParams.extrusionOffsetY=a,this._tessParams.normalX=h,this._tessParams.normalY=m,this._tessParams.directionX=r,this._tessParams.directionY=n,this._tessParams.distance=l,this._tessParams.pathLength=f,this._tessParams.lineLength=u,this._writeVertex(c,d,t,e,this._tessParams),this._currentWrite.vertexFrom+this._currentWrite.vertexCount++}_writeTriangle(t,e,i){const{out:s}=this._currentWrite;s.indexEnsureSize(3),s.indexWrite(t),s.indexWrite(e),s.indexWrite(i),this._currentWrite.indexCount+=3}}export{C as AAnimatedPolyMeshWriter,j as AnimatedFillMeshWriter,T as AnimatedLineMeshWriter};