createPolylineVolumeGeometry.js 5.5 KB

1234567891011121314151617181920212223242526
  1. /**
  2. * @license
  3. * Cesium - https://github.com/CesiumGS/cesium
  4. * Version 1.110.1
  5. *
  6. * Copyright 2011-2022 Cesium Contributors
  7. *
  8. * Licensed under the Apache License, Version 2.0 (the "License");
  9. * you may not use this file except in compliance with the License.
  10. * You may obtain a copy of the License at
  11. *
  12. * http://www.apache.org/licenses/LICENSE-2.0
  13. *
  14. * Unless required by applicable law or agreed to in writing, software
  15. * distributed under the License is distributed on an "AS IS" BASIS,
  16. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17. * See the License for the specific language governing permissions and
  18. * limitations under the License.
  19. *
  20. * Columbus View (Pat. Pend.)
  21. *
  22. * Portions licensed separately.
  23. * See https://github.com/CesiumGS/cesium/blob/main/LICENSE.md for full licensing details.
  24. */
  25. import{a as M}from"./chunk-UBTZOT6V.js";import{a as W}from"./chunk-54EUFFXI.js";import"./chunk-CAKU43HZ.js";import"./chunk-WNXNCTQK.js";import{a as x,b as j}from"./chunk-2TVWWMSA.js";import{a as I}from"./chunk-W6HUVIKD.js";import"./chunk-TGTYSVRM.js";import"./chunk-ML5MKDLJ.js";import{a as g}from"./chunk-FEU4H2YL.js";import"./chunk-BV3RKX5O.js";import"./chunk-XQLAWHTP.js";import{a as $,b as V}from"./chunk-P2SABSEB.js";import{a as Z}from"./chunk-FO3UCCVP.js";import"./chunk-GTKXIG42.js";import"./chunk-EVUMPJJC.js";import"./chunk-BXMC6F3B.js";import{a as X}from"./chunk-EUSUDYW7.js";import{a as Q}from"./chunk-XYZU5ZKW.js";import{b as Y,c as z,d as U}from"./chunk-ADEEKX5Q.js";import{d as K}from"./chunk-O5E7EBKP.js";import"./chunk-LEJDAZA7.js";import{d as C}from"./chunk-GMFQULD7.js";import{a as B}from"./chunk-IS523WNE.js";import{a as T,c as f}from"./chunk-4ZQSV4FU.js";import{a as J}from"./chunk-CLQ5X6HS.js";import"./chunk-6Y3U6IMI.js";import"./chunk-7DENS74L.js";import{a as k}from"./chunk-FOJGNIAW.js";import{a as D}from"./chunk-UGI536VH.js";import{e as _}from"./chunk-BQUQ5TPM.js";function oe(t,e,n,o){let l=new Q;o.position&&(l.position=new U({componentDatatype:B.DOUBLE,componentsPerAttribute:3,values:t}));let i=e.length,u=t.length/3,L=(u-i*2)/(i*2),E=V.triangulate(e),G=(L-1)*i*6+E.length*2,r=X.createTypedArray(u,G),m,s,d,b,A,q,F=i*2,p=0;for(m=0;m<L-1;m++){for(s=0;s<i-1;s++)d=s*2+m*i*2,q=d+F,b=d+1,A=b+F,r[p++]=b,r[p++]=d,r[p++]=A,r[p++]=A,r[p++]=d,r[p++]=q;d=i*2-2+m*i*2,b=d+1,A=b+F,q=d+F,r[p++]=b,r[p++]=d,r[p++]=A,r[p++]=A,r[p++]=d,r[p++]=q}if(o.st||o.tangent||o.bitangent){let c=new Float32Array(u*2),S=1/(L-1),w=1/n.height,O=n.height/2,y,a,h=0;for(m=0;m<L;m++){for(y=m*S,a=w*(e[0].y+O),c[h++]=y,c[h++]=a,s=1;s<i;s++)a=w*(e[s].y+O),c[h++]=y,c[h++]=a,c[h++]=y,c[h++]=a;a=w*(e[0].y+O),c[h++]=y,c[h++]=a}for(s=0;s<i;s++)y=0,a=w*(e[s].y+O),c[h++]=y,c[h++]=a;for(s=0;s<i;s++)y=(L-1)*S,a=w*(e[s].y+O),c[h++]=y,c[h++]=a;l.st=new U({componentDatatype:B.FLOAT,componentsPerAttribute:2,values:new Float32Array(c)})}let N=u-i*2;for(m=0;m<E.length;m+=3){let c=E[m]+N,S=E[m+1]+N,w=E[m+2]+N;r[p++]=c,r[p++]=S,r[p++]=w,r[p++]=w+i,r[p++]=S+i,r[p++]=c+i}let P=new z({attributes:l,indices:r,boundingSphere:K.fromVertices(t),primitiveType:Y.TRIANGLES});if(o.normal&&(P=W.computeNormal(P)),o.tangent||o.bitangent){try{P=W.computeTangentAndBitangent(P)}catch{I("polyline-volume-tangent-bitangent","Unable to compute tangents and bitangents for polyline volume geometry")}o.tangent||(P.attributes.tangent=void 0),o.bitangent||(P.attributes.bitangent=void 0),o.st||(P.attributes.st=void 0)}return P}function R(t){t=k(t,k.EMPTY_OBJECT);let e=t.polylinePositions,n=t.shapePositions;if(!_(e))throw new D("options.polylinePositions is required.");if(!_(n))throw new D("options.shapePositions is required.");this._positions=e,this._shape=n,this._ellipsoid=f.clone(k(t.ellipsoid,f.WGS84)),this._cornerType=k(t.cornerType,x.ROUNDED),this._vertexFormat=g.clone(k(t.vertexFormat,g.DEFAULT)),this._granularity=k(t.granularity,J.RADIANS_PER_DEGREE),this._workerName="createPolylineVolumeGeometry";let o=1+e.length*T.packedLength;o+=1+n.length*C.packedLength,this.packedLength=o+f.packedLength+g.packedLength+2}R.pack=function(t,e,n){if(!_(t))throw new D("value is required");if(!_(e))throw new D("array is required");n=k(n,0);let o,l=t._positions,i=l.length;for(e[n++]=i,o=0;o<i;++o,n+=T.packedLength)T.pack(l[o],e,n);let u=t._shape;for(i=u.length,e[n++]=i,o=0;o<i;++o,n+=C.packedLength)C.pack(u[o],e,n);return f.pack(t._ellipsoid,e,n),n+=f.packedLength,g.pack(t._vertexFormat,e,n),n+=g.packedLength,e[n++]=t._cornerType,e[n]=t._granularity,e};var ee=f.clone(f.UNIT_SPHERE),te=new g,v={polylinePositions:void 0,shapePositions:void 0,ellipsoid:ee,vertexFormat:te,cornerType:void 0,granularity:void 0};R.unpack=function(t,e,n){if(!_(t))throw new D("array is required");e=k(e,0);let o,l=t[e++],i=new Array(l);for(o=0;o<l;++o,e+=T.packedLength)i[o]=T.unpack(t,e);l=t[e++];let u=new Array(l);for(o=0;o<l;++o,e+=C.packedLength)u[o]=C.unpack(t,e);let L=f.unpack(t,e,ee);e+=f.packedLength;let E=g.unpack(t,e,te);e+=g.packedLength;let G=t[e++],r=t[e];return _(n)?(n._positions=i,n._shape=u,n._ellipsoid=f.clone(L,n._ellipsoid),n._vertexFormat=g.clone(E,n._vertexFormat),n._cornerType=G,n._granularity=r,n):(v.polylinePositions=i,v.shapePositions=u,v.cornerType=G,v.granularity=r,new R(v))};var ne=new M;R.createGeometry=function(t){let e=t._positions,n=Z(e,T.equalsEpsilon),o=t._shape;if(o=j.removeDuplicatesFromShape(o),n.length<2||o.length<3)return;V.computeWindingOrder2D(o)===$.CLOCKWISE&&o.reverse();let l=M.fromPoints(o,ne),i=j.computePositions(n,o,l,t,!0);return oe(i,o,l,t._vertexFormat)};var H=R;function ie(t,e){return _(e)&&(t=H.unpack(t,e)),t._ellipsoid=f.clone(t._ellipsoid),H.createGeometry(t)}var Re=ie;export{Re as default};