@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 3.76 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{copy as t,set as e,length as s,normalize as i,dot as r,scale as o,add as n}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{h as l,i as h}from"../../../../chunks/vec32.js";import{create as c}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as p}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{newFloatArray as m}from"../../../../geometry/support/FloatArray.js";import{newHalfFloatArray as u}from"../../../../geometry/support/HalfFloatArray.js";import{getZeroIndexArray as f}from"../../../../geometry/support/Indices.js";import{Attribute as d,Vertices as A}from"./Attribute.js";import{decompressNormal as b,compressNormal as g}from"./Normals.js";import{intersectTriangles as v}from"./RayIntersections.js";import{VertexAttribute as I}from"./VertexAttribute.js";class x{constructor(t){this.builder=t}onPathChanged(t){this.builder.onPathChanged()}}class T extends x{constructor(t){super(t),this.color=p(255,255,255,255),this._size=a(),this.positions=m(3*this.builder.numVerticesTotal),this.normals=new Int16Array(2*this.builder.numVerticesTotal)}bakeVertexColors(t){this.color[0]=255*t[0],this.color[1]=255*t[1],this.color[2]=255*t[2],this.color[3]=255*(t.length>3?t[3]:1)}bake(a){t(this._size,a);const{numVerticesTotal:c,pathVertexData:p,positions:m,profileRightAxes:u,profileUpAxes:f,profileVertexAndNormals:d,profileAuxData:A}=this.builder;for(let t=0;t<c;++t){let c=p[t];c*=3;const v=w;let I=0,x=0;const T=b(C,u,t),O=b(V,f,t),j=4*t,y=e(R,d[j]*a[0],d[j+1]*a[1]),U=3*t;if(1===A[U+2])l(v,O,T),I=A[U]*a[0],x=A[U+1];else{const t=E,a=P;e(t,A[U],A[U+1]);const l=s(t);i(t,t);const c=r(y,t);if(Math.abs(c)>l){e(a,-t[1],t[0]);const s=r(y,a);o(t,t,l*Math.sign(c)),o(a,a,s),n(y,t,a)}h(v,0,0,0)}const F=T[0]*y[0]+O[0]*y[1],N=T[1]*y[0]+O[1]*y[1],_=T[2]*y[0]+O[2]*y[1];this.positions[U]=m[c]+F+v[0]*I,this.positions[U+1]=m[c+1]+N+v[1]*I,this.positions[U+2]=m[c+2]+_+v[2]*I;const z=d[j+2],D=d[j+3];g(this.normals,t,T[0]*z+O[0]*D+v[0]*x,T[1]*z+O[1]*D+v[1]*x,T[2]*z+O[2]*D+v[2]*x)}}createGeometryData(){const t=this.builder.vertexIndices;return[[I.POSITION,new d(this.positions,t,3,!0)],[I.NORMALCOMPRESSED,new d(this.normals,t,2,!0)],[I.COLOR,new d(this.color,f(t.length),4,!0)]]}onPathChanged(t){super.onPathChanged(t),this.bake(this.size)}intersect(t,e,s,i){const r=this.builder.vertexIndices,o=new A(this.positions,3),n=r.length/3;v(t,e,0,n,r,o,void 0,s,((t,e,s)=>i(t,s,e)))}get size(){return this._size}}class O extends x{constructor(t,e,s,i){super(t),this.sizeAttributeValue=e,this.colorAttributeValue=s,this.opacityAttributeValue=i,this.baked=new T(t),this._vvSize=m(this.builder.path.vertices.length).fill(e),this._vvColor=u(this.builder.path.vertices.length).fill(s),this._vvOpacity=u(this.builder.path.vertices.length).fill(i)}createGeometryData(){const t=this.builder,{pathVertexIndices:e,vertexIndices:s}=t;return[[I.POSITION,new d(t.positions,e,3,!0)],[I.PROFILEVERTEXANDNORMAL,new d(t.profileVertexAndNormals,s,4,!0)],[I.PROFILEAUXDATA,new d(t.profileAuxData,s,3,!0)],[I.PROFILERIGHT,new d(t.profileRightAxes,s,2,!0)],[I.PROFILEUP,new d(t.profileUpAxes,s,2,!0)],[I.SIZEFEATUREATTRIBUTE,new d(this._vvSize,e,1,!0)],[I.COLORFEATUREATTRIBUTE,new d(this._vvColor,e,1,!0)],[I.OPACITYFEATUREATTRIBUTE,new d(this._vvOpacity,e,1,!0)]]}onPathChanged(t){super.onPathChanged(t);const e=t.getMutableAttribute(I.POSITION);e&&(e.data=this.builder.positions)}}const R=a(),E=a(),P=a(),w=c(),C=c(),V=c();export{O as FastUpdatePathGeometry,x as PathGeometryData,T as StaticPathGeometry};