26 lines
17 KiB
JavaScript
26 lines
17 KiB
JavaScript
|
/**
|
||
|
* @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(["./defaultValue-50f7432c","./Matrix2-cf4c6e69","./ArcType-24f44850","./BoundingRectangle-af4243d8","./Transforms-c9e418cb","./ComponentDatatype-9b23164a","./EllipsoidGeodesic-759beff8","./EllipsoidTangentPlane-2597ceda","./GeometryAttribute-b84ffce6","./GeometryInstance-a6a77e5a","./GeometryOffsetAttribute-490bc2c9","./GeometryPipeline-9c11a3d1","./IndexDatatype-ceed713e","./PolygonGeometryLibrary-7558e2c7","./PolygonPipeline-13f0bfa4","./VertexFormat-fa0c27e8","./RuntimeError-48e1f06d","./combine-8462e002","./WebGLConstants-58abc51a","./AxisAlignedBoundingBox-ae9b3d82","./IntersectionTests-d662a125","./Plane-b9f0711b","./AttributeCompression-b4dfdf5f","./EncodedCartesian3-0b8c686b","./arrayRemoveDuplicates-fd3a3f4e","./EllipsoidRhumbLine-0cc30625","./GeometryAttributes-8bab1b25"],(function(e,t,o,i,r,n,a,s,l,c,u,p,d,y,m,g,h,f,b,_,P,C,x,w,T,I,A){"use strict";const v=new t.Cartographic,E=new t.Cartographic;function G(e,t,o,i){const r=i.cartesianToCartographic(e,v).height,n=i.cartesianToCartographic(t,E);n.height=r,i.cartographicToCartesian(n,t);const a=i.cartesianToCartographic(o,E);a.height=r-100,i.cartographicToCartesian(a,o)}const O=new i.BoundingRectangle,L=new t.Cartesian3,V=new t.Cartesian3,H=new t.Cartesian3,D=new t.Cartesian3,N=new t.Cartesian3,F=new t.Cartesian3;let R=new t.Cartesian3,M=new t.Cartesian3,S=new t.Cartesian3;const B=new t.Cartesian2,k=new t.Cartesian2,z=new t.Cartesian3,W=new r.Quaternion,Y=new t.Matrix3,U=new t.Matrix3;function j(o){const i=o.vertexFormat,a=o.geometry,s=o.shadowVolume,c=a.attributes.position.values,p=e.defined(a.attributes.st)?a.attributes.st.values:void 0;let d=c.length;const y=o.wall,m=o.top||y,g=o.bottom||y;if(i.st||i.normal||i.tangent||i.bitangent||s){const u=o.boundingRectangle,h=o.tangentPlane,f=o.ellipsoid,b=o.stRotation,_=o.perPositionHeight,P=B;P.x=u.x,P.y=u.y;const C=i.st?new Float32Array(d/3*2):void 0;let x;i.normal&&(x=_&&m&&!y?a.attributes.normal.values:new Float32Array(d));const w=i.tangent?new Float32Array(d):void 0,T=i.bitangent?new Float32Array(d):void 0,I=s?new Float32Array(d):void 0;let A=0,v=0,E=V,O=H,j=D,Q=!0,q=Y,K=U;if(0!==b){let e=r.Quaternion.fromAxisAngle(h._plane.normal,b,W);q=t.Matrix3.fromQuaternion(e,q),e=r.Quaternion.fromAxisAngle(h._plane.normal,-b,W),K=t.Matrix3.fromQuaternion(e,K)}else q=t.Matrix3.clone(t.Matrix3.IDENTITY,q),K=t.Matrix3.clone(t.Matrix3.IDENTITY,K);let Z=0,J=0;m&&g&&(Z=d/2,J=d/3,d/=2);for(let r=0;r<d;r+=3){const a=t.Cartesian3.fromArray(c,r,z);if(i.st&&!e.defined(p)){let e=t.Matrix3.multiplyByVector(q,a,L);e=f.scaleToGeodeticSurface(e,e);const o=h.projectPointOntoPlane(e,k);t.Cartesian2.subtract(o,P,o);const i=n.CesiumMath.clamp(o.x/u.width,0,1),r=n.CesiumMath.clamp(o.y/u.height,0,1);g&&(C[A+J]=i,C[A+1+J]=r),m&&(C[A]=i,C[A+1]=r),A+=2}if(i.normal||i.tangent||i.bitangent||s){const e=v+1,l=v+2;if(y){if(r+3<d){const e=t.Cartesian3.fromArray(c,r+3,N);if(Q){const o=t.Cartesian3.fromArray(c,r+d,F);_&&G(a,e,o,f),t.Cartesian3.subtract(e,a,e),t.Cartesian3.subtract(o,a,o),E=t.Cartesian3.normalize(t.Cartesian3.cross(o,e,E),E),Q=!1}t.Cartesian3.equalsEpsilon(e,a,n.CesiumMath.EPSILON10)&&(Q=!0)}(i.tangent||i.bitangent)&&(j=f.geodeticSurfaceNormal(a,j),i.tangent&&(O=t.Cartesian3.normalize(t.Cartesian3.cross(j,E,O),O)))}else E=f.geodeticSurfaceNormal(a,E),(i.tangent||i.bitangent)&&(_&&(R=t.Cartesian3.fromArray(x,v,R),M=t.Cartesian3.cross(t.Cartesian3.UNIT_Z,R,M),M=t.Cartesian3.normalize(t.Matrix3.multiplyByVector(K,M,M),M),i.bitangent&&(S=t.Cartesian3.normalize(t.Cartesian3.cross(R,M,S),S))),O=t.Cartesian3.cross(t.Cartesian3.UNIT_Z,E,O),O=t.Cartesian3.normalize(t.Matrix3.multiplyByVector(K,O,O),O),i.bitangent&&(j=t.Cartesian3.normalize(t.Cartesian3.cross(E,O,j),j)));i.normal&&(o.wall?(x[v+Z]=E.x,x[e+Z]=E.y,x[l+Z]=E.z):g&&(x[v+Z]=-E.x,x[e+Z]=-E.y,x[l+Z]=-E.z),(m&&!_||y)&&(x[v]=E.x,x[e]=E.y,x[l]=E.z)),s&&(y&&(E=f.geodeticSurfaceNormal(a,E)),I[v+Z]=-E.x,I[e+Z]=-E.y,I[l+Z]=-E.z),i.tangent&&(o.wall?(w[v+Z]=O.x,w[e+Z]=O.y,w[l+Z]=O.z):g&&(w[v+Z]=-O.x,w[e+Z]=-O.y,w[l+Z]=-O.z),m&&(_?(w[v]=M.x,w[e]=M.y,w[l]=M.z):(w[v]=O.x,w[e]=O.y,w[l]=O.z))),i.bitang
|