cesium
Version:
CesiumJS is a JavaScript library for creating 3D globes and 2D maps in a web browser without a plugin.
27 lines (25 loc) • 7.53 kB
JavaScript
/**
* @license
* Cesium - https://github.com/CesiumGS/cesium
* Version 1.144.0
*
* Copyright 2011-2022 Cesium Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Columbus View (Pat. Pend.)
*
* Portions licensed separately.
* See https://github.com/CesiumGS/cesium/blob/main/LICENSE.md for full licensing details.
*/
import{a as C}from"./chunk-SL3G6WV5.js";import{a as Q}from"./chunk-AEIJDD3C.js";import"./chunk-WNW5RVPR.js";import"./chunk-PTFQE44E.js";import{a as J}from"./chunk-3BERLVP2.js";import"./chunk-HCBOUAOS.js";import"./chunk-LXB5W3RT.js";import{b as K}from"./chunk-L3KCARNY.js";import{a as it}from"./chunk-XBXKBB6E.js";import"./chunk-BMZ3PJJO.js";import"./chunk-Q2AGSIFJ.js";import"./chunk-4XQS6KUO.js";import{a as X}from"./chunk-CVUC3Z4F.js";import{a as et}from"./chunk-WF6KNLYB.js";import{b as I,c as tt,d as z}from"./chunk-VGKISNF5.js";import{c as x}from"./chunk-VPJRLZMB.js";import"./chunk-635BMVFD.js";import"./chunk-Y7Z6CVXH.js";import"./chunk-HHFPYI7Q.js";import{a as q}from"./chunk-SSZI3JCE.js";import"./chunk-LP5YXEIX.js";import"./chunk-AMKKUAL3.js";import{c as P}from"./chunk-WORPNHJT.js";import{a as A,c as $}from"./chunk-SWCW4GSU.js";import{a as Y}from"./chunk-PZM5FOOW.js";import{b as B}from"./chunk-3MNKUQ6L.js";import{f as N}from"./chunk-J4SK6SKL.js";var ot=new A,nt=new A,lt=new A;function ft(t,i){for(let e=0;e<t.length;e++)t[e]=i.scaleToGeodeticSurface(t[e],t[e]);return t}function st(t,i){let e=[],r=t.positions,p=t.corners,m=t.endPositions,H=new et,E,u=0,h=0,o,g=0,d;for(o=0;o<r.length;o+=2)d=r[o].length-3,u+=d,g+=d/3*4,h+=r[o+1].length-3;for(u+=3,h+=3,o=0;o<p.length;o++){let c=p[o].leftPositions;N(c)?(d=c.length,u+=d,g+=d/3*2):(d=p[o].rightPositions.length,h+=d,g+=d/3*2)}let _=N(m),w;_&&(w=m[0].length-3,u+=w,h+=w,w/=3,g+=w*4);let T=u+h,b=new Float64Array(T),n=0,s=T-1,a,y,L,k,S,U,j=w/2,l=X.createTypedArray(T/3,g+4),f=0;if(l[f++]=n/3,l[f++]=(s-2)/3,_){e.push(n/3),U=ot,S=nt;let c=m[0];for(o=0;o<j;o++)U=A.fromArray(c,(j-1-o)*3,U),S=A.fromArray(c,(j+o)*3,S),C.addAttribute(b,S,n),C.addAttribute(b,U,void 0,s),y=n/3,k=y+1,a=(s-2)/3,L=a-1,l[f++]=a,l[f++]=L,l[f++]=y,l[f++]=k,n+=3,s-=3}let V=0,F=r[V++],D=r[V++];for(b.set(F,n),b.set(D,s-D.length+1),d=D.length-3,e.push(n/3,(s-2)/3),o=0;o<d;o+=3)y=n/3,k=y+1,a=(s-2)/3,L=a-1,l[f++]=a,l[f++]=L,l[f++]=y,l[f++]=k,n+=3,s-=3;for(o=0;o<p.length;o++){let c;E=p[o];let G=E.leftPositions,W=E.rightPositions,O,R=lt;if(N(G)){for(s-=3,O=L,e.push(k),c=0;c<G.length/3;c++)R=A.fromArray(G,c*3,R),l[f++]=O-c-1,l[f++]=O-c,C.addAttribute(b,R,void 0,s),s-=3;e.push(O-Math.floor(G.length/6)),i===Q.BEVELED&&e.push((s-2)/3+1),n+=3}else{for(n+=3,O=k,e.push(L),c=0;c<W.length/3;c++)R=A.fromArray(W,c*3,R),l[f++]=O+c,l[f++]=O+c+1,C.addAttribute(b,R,n),n+=3;e.push(O+Math.floor(W.length/6)),i===Q.BEVELED&&e.push(n/3-1),s-=3}for(F=r[V++],D=r[V++],F.splice(0,3),D.splice(D.length-3,3),b.set(F,n),b.set(D,s-D.length+1),c=0;c<D.length;c+=3)k=n/3,y=k-1,L=(s-2)/3,a=L+1,l[f++]=a,l[f++]=L,l[f++]=y,l[f++]=k,n+=3,s-=3;n-=3,s+=3,e.push(n/3,(s-2)/3)}if(_){n+=3,s-=3,U=ot,S=nt;let c=m[1];for(o=0;o<j;o++)U=A.fromArray(c,(w-o-1)*3,U),S=A.fromArray(c,o*3,S),C.addAttribute(b,U,void 0,s),C.addAttribute(b,S,n),k=n/3,y=k-1,L=(s-2)/3,a=L+1,l[f++]=a,l[f++]=L,l[f++]=y,l[f++]=k,n+=3,s-=3;e.push(n/3)}else e.push(n/3,(s-2)/3);return l[f++]=n/3,l[f]=(s-2)/3,H.position=new z({componentDatatype:q.DOUBLE,componentsPerAttribute:3,values:b}),{attributes:H,indices:l,wallIndices:e}}function ct(t){let i=t.ellipsoid,e=C.computePositions(t),r=st(e,t.cornerType),p=r.wallIndices,m=t.height,H=t.extrudedHeight,E=r.attributes,u=r.indices,h=E.position.values,o=h.length,g=new Float64Array(o);g.set(h);let d=new Float64Array(o*2);if(h=K.scaleToGeodeticHeight(h,m,i),g=K.scaleToGeodeticHeight(g,H,i),d.set(h),d.set(g,o),E.position.values=d,o/=3,N(t.offsetAttribute)){let a=new Uint8Array(o*2);if(t.offsetAttribute===J.TOP)a=a.fill(1,0,o);else{let y=t.offsetAttribute===J.NONE?0:1;a=a.fill(y)}E.applyOffset=new z({componentDatatype:q.UNSIGNED_BYTE,componentsPerAttribute:1,values:a})}let _,w=u.length,T=X.createTypedArray(d.length/3,(w+p.length)*2);T.set(u);let b=w;for(_=0;_<w;_+=2){let a=u[_],y=u[_+1];T[b++]=a+o,T[b++]=y+o}let n,s;for(_=0;_<p.length;_++)n=p[_],s=n+o,T[b++]=n,T[b++]=s;return{attributes:E,indices:T}}function M(t){t=t??$.EMPTY_OBJECT;let i=t.positions,e=t.width;B.typeOf.object("options.positions",i),B.typeOf.number("options.width",e);let r=t.height??0,p=t.extrudedHeight??r;this._positions=i,this._ellipsoid=P.clone(t.ellipsoid??P.default),this._width=e,this._height=Math.max(r,p),this._extrudedHeight=Math.min(r,p),this._cornerType=t.cornerType??Q.ROUNDED,this._granularity=t.granularity??Y.RADIANS_PER_DEGREE,this._offsetAttribute=t.offsetAttribute,this._workerName="createCorridorOutlineGeometry",this.packedLength=1+i.length*A.packedLength+P.packedLength+6}M.pack=function(t,i,e){B.typeOf.object("value",t),B.typeOf.object("array",i),e=e??0;let r=t._positions,p=r.length;i[e++]=p;for(let m=0;m<p;++m,e+=A.packedLength)A.pack(r[m],i,e);return P.pack(t._ellipsoid,i,e),e+=P.packedLength,i[e++]=t._width,i[e++]=t._height,i[e++]=t._extrudedHeight,i[e++]=t._cornerType,i[e++]=t._granularity,i[e]=t._offsetAttribute??-1,i};var rt=P.clone(P.UNIT_SPHERE),v={positions:void 0,ellipsoid:rt,width:void 0,height:void 0,extrudedHeight:void 0,cornerType:void 0,granularity:void 0,offsetAttribute:void 0};M.unpack=function(t,i,e){B.typeOf.object("array",t),i=i??0;let r=t[i++],p=new Array(r);for(let d=0;d<r;++d,i+=A.packedLength)p[d]=A.unpack(t,i);let m=P.unpack(t,i,rt);i+=P.packedLength;let H=t[i++],E=t[i++],u=t[i++],h=t[i++],o=t[i++],g=t[i];return N(e)?(e._positions=p,e._ellipsoid=P.clone(m,e._ellipsoid),e._width=H,e._height=E,e._extrudedHeight=u,e._cornerType=h,e._granularity=o,e._offsetAttribute=g===-1?void 0:g,e):(v.positions=p,v.width=H,v.height=E,v.extrudedHeight=u,v.cornerType=h,v.granularity=o,v.offsetAttribute=g===-1?void 0:g,new M(v))};M.createGeometry=function(t){let i=t._positions,e=t._width,r=t._ellipsoid;i=ft(i,r);let p=it(i,A.equalsEpsilon);if(p.length<2||e<=0)return;let m=t._height,H=t._extrudedHeight,E=!Y.equalsEpsilon(m,H,0,Y.EPSILON2),u={ellipsoid:r,positions:p,width:e,cornerType:t._cornerType,granularity:t._granularity,saveAttributes:!1},h;if(E)u.height=m,u.extrudedHeight=H,u.offsetAttribute=t._offsetAttribute,h=ct(u);else{let d=C.computePositions(u);if(h=st(d,u.cornerType),h.attributes.position.values=K.scaleToGeodeticHeight(h.attributes.position.values,m,r),N(t._offsetAttribute)){let _=h.attributes.position.values.length,w=t._offsetAttribute===J.NONE?0:1,T=new Uint8Array(_/3).fill(w);h.attributes.applyOffset=new z({componentDatatype:q.UNSIGNED_BYTE,componentsPerAttribute:1,values:T})}}let o=h.attributes,g=x.fromVertices(o.position.values,void 0,3);return new tt({attributes:o,indices:h.indices,primitiveType:I.LINES,boundingSphere:g,offsetAttribute:t._offsetAttribute})};var Z=M;function ht(t,i){return N(i)&&(t=Z.unpack(t,i)),t._ellipsoid=P.clone(t._ellipsoid),Z.createGeometry(t)}var Ot=ht;export{Ot as default};