Files
sdk4.0/static/Cesium/Workers/createCorridorGeometry.js

26 lines
17 KiB
JavaScript
Raw Permalink Normal View History

2025-07-03 13:54:01 +08:00
/**
* @license
* Cesium - https://github.com/CesiumGS/cesium
* Version 1.98
*
* 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.
*/
define(["./arrayRemoveDuplicates-fd3a3f4e","./Transforms-c9e418cb","./Matrix2-cf4c6e69","./ComponentDatatype-9b23164a","./PolylineVolumeGeometryLibrary-6a648b4f","./CorridorGeometryLibrary-2f861952","./defaultValue-50f7432c","./GeometryAttribute-b84ffce6","./GeometryAttributes-8bab1b25","./GeometryOffsetAttribute-490bc2c9","./IndexDatatype-ceed713e","./PolygonPipeline-13f0bfa4","./VertexFormat-fa0c27e8","./combine-8462e002","./RuntimeError-48e1f06d","./WebGLConstants-58abc51a","./EllipsoidTangentPlane-2597ceda","./AxisAlignedBoundingBox-ae9b3d82","./IntersectionTests-d662a125","./Plane-b9f0711b","./PolylinePipeline-98b8bcbb","./EllipsoidGeodesic-759beff8","./EllipsoidRhumbLine-0cc30625"],(function(t,e,r,a,i,o,n,s,l,d,u,c,m,f,y,p,g,h,b,C,A,_,w){"use strict";const v=new r.Cartesian3,T=new r.Cartesian3,G=new r.Cartesian3,E=new r.Cartesian3,V=new r.Cartesian3,x=new r.Cartesian3,L=new r.Cartesian3,P=new r.Cartesian3;function F(t,e){for(let r=0;r<t.length;r++)t[r]=e.scaleToGeodeticSurface(t[r],t[r]);return t}function N(t,e,a,i,n,s){const l=t.normals,d=t.tangents,u=t.bitangents,c=r.Cartesian3.normalize(r.Cartesian3.cross(a,e,L),L);s.normal&&o.CorridorGeometryLibrary.addAttribute(l,e,i,n),s.tangent&&o.CorridorGeometryLibrary.addAttribute(d,c,i,n),s.bitangent&&o.CorridorGeometryLibrary.addAttribute(u,a,i,n)}function D(t,e,i){const d=t.positions,c=t.corners,m=t.endPositions,f=t.lefts,y=t.normals,p=new l.GeometryAttributes;let g,h,b,C=0,A=0,_=0;for(h=0;h<d.length;h+=2)b=d[h].length-3,C+=b,_+=2*b,A+=d[h+1].length-3;for(C+=3,A+=3,h=0;h<c.length;h++){g=c[h];const t=c[h].leftPositions;n.defined(t)?(b=t.length,C+=b,_+=b):(b=c[h].rightPositions.length,A+=b,_+=b)}const w=n.defined(m);let V;w&&(V=m[0].length-3,C+=V,A+=V,V/=3,_+=6*V);const F=C+A,D=new Float64Array(F),M={normals:e.normal?new Float32Array(F):void 0,tangents:e.tangent?new Float32Array(F):void 0,bitangents:e.bitangent?new Float32Array(F):void 0};let O,I,S,R,k,H,z=0,B=F-1,U=v,Y=T;const W=V/2,q=u.IndexDatatype.createTypedArray(F/3,_);let J=0;if(w){H=G,k=E;const t=m[0];for(U=r.Cartesian3.fromArray(y,0,U),Y=r.Cartesian3.fromArray(f,0,Y),h=0;h<W;h++)H=r.Cartesian3.fromArray(t,3*(W-1-h),H),k=r.Cartesian3.fromArray(t,3*(W+h),k),o.CorridorGeometryLibrary.addAttribute(D,k,z),o.CorridorGeometryLibrary.addAttribute(D,H,void 0,B),N(M,U,Y,z,B,e),I=z/3,R=I+1,O=(B-2)/3,S=O-1,q[J++]=O,q[J++]=I,q[J++]=S,q[J++]=S,q[J++]=I,q[J++]=R,z+=3,B-=3}let j,K,Q=0,X=0,Z=d[Q++],$=d[Q++];for(D.set(Z,z),D.set($,B-$.length+1),Y=r.Cartesian3.fromArray(f,X,Y),b=$.length-3,h=0;h<b;h+=3)j=i.geodeticSurfaceNormal(r.Cartesian3.fromArray(Z,h,L),L),K=i.geodeticSurfaceNormal(r.Cartesian3.fromArray($,b-h,P),P),U=r.Cartesian3.normalize(r.Cartesian3.add(j,K,U),U),N(M,U,Y,z,B,e),I=z/3,R=I+1,O=(B-2)/3,S=O-1,q[J++]=O,q[J++]=I,q[J++]=S,q[J++]=S,q[J++]=I,q[J++]=R,z+=3,B-=3;for(j=i.geodeticSurfaceNormal(r.Cartesian3.fromArray(Z,b,L),L),K=i.geodeticSurfaceNormal(r.Cartesian3.fromArray($,b,P),P),U=r.Cartesian3.normalize(r.Cartesian3.add(j,K,U),U),X+=3,h=0;h<c.length;h++){let t;g=c[h];const a=g.leftPositions,s=g.rightPositions;let l,u,m=x,p=G,C=E;if(U=r.Cartesian3.fromArray(y,X,U),n.defined(a)){for(N(M,U,Y,void 0,B,e),B-=3,l=R,u=S,t=0;t<a.length/3;t++)m=r.Cartesian3.fromArray(a,3*t,m),q[J++]=l,q[J++]=u-t-1,q[J++]=u-t,o.CorridorGeometryLibrary.addAttribute(D,m,void 0,B),p=r.Cartesian3.fromArray(D,3*(u-t-1),p),C=r.Cartesian3.fromArray(D,3*l,C),Y=r.Cartesian3.normalize(r.Cartesian3.subtract(p,C,Y),Y),N(M,U,Y,void 0,B,e),B-=3;m=r.Cartesian3.fromArray(D,3*l,m),p=r.Cartesian3.subtract(r.Cartesian3.fromArray(D,3*u,p),m,p),C=r.Cartesian3.subtract(r.Cartesian3.fromArray(D,3*(u-t),C),m,C),Y=r.Cartesian3.normalize(r.Cartesian3.add(p,C,Y),Y),N(M,U,Y,z,void 0,e),z+=3}else{for(N(M,U,Y,z,void 0,e),z+=3,l=S,u=R,t=0;t<s.length/3;t++)m=r.Cartesian3.fromArray(s,3*t,m),q[J++]=l,q[J++]=u+t,q[J++]=u+t+1,o.CorridorGeometryLibrary.addAttribute(D,m,z),p=r.Cartesian3.fromArray(D,3*l,p),C=r.Cartesian3.fromArray(D,3*(u+t),C),Y=r.Cartesian3.normalize(r.Cartesian3.subtract(p,C,Y),Y),N(M,U,Y,z,void 0,e),z+=3;m=r.Cartesian3.fromArray(D,3*l,m),p=r.Cartesian3.subt