Newer
Older
smartwell_front_dz / XLJCYJ / mars3d-cesium / Workers / createCoplanarPolygonGeometry.js
wangxitong on 8 Jul 2024 6 KB 达州变更
/**
 * @license
 * Cesium - https://github.com/CesiumGS/cesium
 * Version 1.109.1
 *
 * 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 et}from"./chunk-V24F56N4.js";import{a as U}from"./chunk-2O7ETGTO.js";import"./chunk-HKOQYCKL.js";import{a as y}from"./chunk-3FJ6KZYW.js";import"./chunk-7CAA5V4E.js";import{a as I}from"./chunk-7GLIBSMD.js";import{a as $}from"./chunk-DB2DGJAQ.js";import"./chunk-YRDOGW7W.js";import"./chunk-SMROTTNJ.js";import{a as u}from"./chunk-JEAHRXD5.js";import"./chunk-GTVOTRDF.js";import"./chunk-UGOEDKTL.js";import{b as ot}from"./chunk-ZODPEIAS.js";import{a as tt}from"./chunk-5CQT33QV.js";import"./chunk-YPLRJVJ5.js";import"./chunk-XZQSRYDQ.js";import"./chunk-MPWN7KNI.js";import{a as J}from"./chunk-BBX2BII7.js";import{a as X}from"./chunk-BZJ4WRF6.js";import{b as K,c as Y,d as z}from"./chunk-ESC6A27A.js";import{d as Z,f as Q}from"./chunk-FCJU2DRX.js";import"./chunk-JDODZPYM.js";import{d as x}from"./chunk-Y3I2OBKV.js";import{a as N}from"./chunk-KUWODMWG.js";import{a as i,c as m,d as P}from"./chunk-WADCMYQO.js";import{a as q}from"./chunk-2LQD2HPA.js";import"./chunk-YWFM6JRF.js";import"./chunk-P2U2ARL5.js";import{a as f}from"./chunk-3B6S2GOO.js";import{b as B}from"./chunk-EYEHMX6X.js";import{e as g}from"./chunk-BWKFPVR5.js";var st=new i,at=new et,pt=new x,lt=new x,mt=new i,ft=new i,ut=new i,V=new i,yt=new i,ht=new i,nt=new Q,dt=new P,gt=new P,Pt=new i;function wt(t,e,n,o,r,a,s,c,p){let l=t.positions,u=ot.triangulate(t.positions2D,t.holes);u.length<3&&(u=[0,1,2]);let m=J.createTypedArray(l.length,u.length);m.set(u);let h=dt;if(0!==o){let t=Q.fromAxisAngle(s,o,nt);if(h=P.fromQuaternion(t,h),e.tangent||e.bitangent){t=Q.fromAxisAngle(s,-o,nt);let n=P.fromQuaternion(t,gt);c=i.normalize(P.multiplyByVector(n,c,c),c),e.bitangent&&(p=i.normalize(i.cross(s,c,p),p))}}else h=P.clone(P.IDENTITY,h);let y=lt;e.st&&(y.x=n.x,y.y=n.y);let d=l.length,f=3*d,k=new Float64Array(f),w=e.normal?new Float32Array(f):void 0,A=e.tangent?new Float32Array(f):void 0,j=e.bitangent?new Float32Array(f):void 0,v=e.st?new Float32Array(2*d):void 0,F=0,E=0,T=0,_=0,b=0;for(let i=0;i<d;i++){let t=l[i];if(k[F++]=t.x,k[F++]=t.y,k[F++]=t.z,e.st)if(g(r)&&r.positions.length===d)v[b++]=r.positions[i].x,v[b++]=r.positions[i].y;else{let e=P.multiplyByVector(h,t,st),o=a(e,pt);x.subtract(o,y,o);let i=q.clamp(o.x/n.width,0,1),r=q.clamp(o.y/n.height,0,1);v[b++]=i,v[b++]=r}e.normal&&(w[E++]=s.x,w[E++]=s.y,w[E++]=s.z),e.tangent&&(A[_++]=c.x,A[_++]=c.y,A[_++]=c.z),e.bitangent&&(j[T++]=p.x,j[T++]=p.y,j[T++]=p.z)}let D=new X;return e.position&&(D.position=new z({componentDatatype:N.DOUBLE,componentsPerAttribute:3,values:k})),e.normal&&(D.normal=new z({componentDatatype:N.FLOAT,componentsPerAttribute:3,values:w})),e.tangent&&(D.tangent=new z({componentDatatype:N.FLOAT,componentsPerAttribute:3,values:A})),e.bitangent&&(D.bitangent=new z({componentDatatype:N.FLOAT,componentsPerAttribute:3,values:j})),e.st&&(D.st=new z({componentDatatype:N.FLOAT,componentsPerAttribute:2,values:v})),new Y({attributes:D,indices:m,primitiveType:K.TRIANGLES})}function E(t){t=f(t,f.EMPTY_OBJECT);let e=t.polygonHierarchy,n=t.textureCoordinates;B.defined("options.polygonHierarchy",e);let o=f(t.vertexFormat,u.DEFAULT);this._vertexFormat=u.clone(o),this._polygonHierarchy=e,this._stRotation=f(t.stRotation,0),this._ellipsoid=m.clone(f(t.ellipsoid,m.WGS84)),this._workerName="createCoplanarPolygonGeometry",this._textureCoordinates=n,this.packedLength=y.computeHierarchyPackedLength(e,i)+u.packedLength+m.packedLength+(g(n)?y.computeHierarchyPackedLength(n,x):1)+2}E.fromPositions=function(t){t=f(t,f.EMPTY_OBJECT),B.defined("options.positions",t.positions);let e={polygonHierarchy:{positions:t.positions},vertexFormat:t.vertexFormat,stRotation:t.stRotation,ellipsoid:t.ellipsoid,textureCoordinates:t.textureCoordinates};return new E(e)},E.pack=function(t,e,n){return B.typeOf.object("value",t),B.defined("array",e),n=f(n,0),n=y.packPolygonHierarchy(t._polygonHierarchy,e,n,i),m.pack(t._ellipsoid,e,n),n+=m.packedLength,u.pack(t._vertexFormat,e,n),n+=u.packedLength,e[n++]=t._stRotation,g(t._textureCoordinates)?n=y.packPolygonHierarchy(t._textureCoordinates,e,n,x):e[n++]=-1,e[n++]=t.packedLength,e};var _t=m.clone(m.UNIT_SPHERE),At=new u,bt={polygonHierarchy:{}};E.unpack=function(t,e,n){B.defined("array",t),e=f(e,0);let o=y.unpackPolygonHierarchy(t,e,i);e=o.startingIndex,delete o.startingIndex;let r=m.unpack(t,e,_t);e+=m.packedLength;let a=u.unpack(t,e,At);e+=u.packedLength;let s=t[e++],c=-1===t[e]?void 0:y.unpackPolygonHierarchy(t,e,x);g(c)?(e=c.startingIndex,delete c.startingIndex):e++;let p=t[e++];return g(n)||(n=new E(bt)),n._polygonHierarchy=o,n._ellipsoid=m.clone(r,n._ellipsoid),n._vertexFormat=u.clone(a,n._vertexFormat),n._stRotation=s,n._textureCoordinates=c,n.packedLength=p,n},E.createGeometry=function(t){let e=t._vertexFormat,n=t._polygonHierarchy,o=t._stRotation,r=t._textureCoordinates,a=g(r),s=n.positions;if(s=tt(s,i.equalsEpsilon,!0),s.length<3)return;let c=mt,p=ft,l=ut,u=yt,m=ht;if(!U.computeProjectTo2DArguments(s,V,u,m))return;if(c=i.cross(u,m,c),c=i.normalize(c,c),!i.equalsEpsilon(V,i.ZERO,q.EPSILON6)){let e=t._ellipsoid.geodeticSurfaceNormal(V,Pt);i.dot(c,e)<0&&(c=i.negate(c,c),u=i.negate(u,u))}let h=U.createProjectPointsTo2DFunction(V,u,m),d=U.createProjectPointTo2DFunction(V,u,m);e.tangent&&(p=i.clone(u,p)),e.bitangent&&(l=i.clone(m,l));let f=y.polygonsFromHierarchy(n,a,h,!1),k=f.hierarchy,P=f.polygons,x=function(t){return t},w=a?y.polygonsFromHierarchy(r,!0,x,!1).polygons:void 0;if(0===k.length)return;s=k[0].outerRing;let A=Z.fromPoints(s),j=y.computeBoundingRectangle(c,d,s,o,at),v=[];for(let i=0;i<P.length;i++){let t=new I({geometry:wt(P[i],e,j,o,a?w[i]:void 0,d,c,p,l)});v.push(t)}let F=$.combineInstances(v)[0];F.attributes.position.values=new Float64Array(F.attributes.position.values),F.indices=J.createTypedArray(F.attributes.position.values.length/3,F.indices);let E=F.attributes;return e.position||delete E.position,new Y({attributes:E,indices:F.indices,primitiveType:F.primitiveType,boundingSphere:A})};var W=E;function kt(t,e){return g(e)&&(t=W.unpack(t,e)),W.createGeometry(t)}var Xt=kt;export{Xt as default};