Newer
Older
smartwell_front_dz / XLJCYJ / mars3d-cesium / Workers / createCoplanarPolygonGeometry.js
/**
 * @license
 * Cesium - https://github.com/CesiumGS/cesium
 * Version 1.120.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-TPDTXXTZ.js";import{a as U}from"./chunk-7LDXOWAG.js";import"./chunk-JA4HQIWI.js";import{a as y}from"./chunk-IYIAJDXR.js";import"./chunk-O3XIRCSZ.js";import{a as I}from"./chunk-7X5355YR.js";import{a as $}from"./chunk-343SJCYH.js";import"./chunk-AWTNTFWT.js";import"./chunk-VMUA7QRT.js";import{a as u}from"./chunk-7QS2ZEBL.js";import"./chunk-HVRCTCKZ.js";import"./chunk-PCAQWIAU.js";import{b as ot}from"./chunk-B7DJSUT3.js";import{a as tt}from"./chunk-W3YQL44J.js";import"./chunk-2YTOGJWB.js";import"./chunk-ZZPAAKFL.js";import"./chunk-A2J5OJ74.js";import{a as J}from"./chunk-VRSMIU2E.js";import{a as X}from"./chunk-WGB3L4DG.js";import{b as W,c as Y,d as z}from"./chunk-VT3S74KG.js";import{d as K}from"./chunk-JYT7LKWQ.js";import{f as Q}from"./chunk-DPXXHKCX.js";import{a as N}from"./chunk-UTQP35IH.js";import{a as i,c as x,d as m,e as P}from"./chunk-S74IVKSO.js";import{a as q}from"./chunk-XQPFZTAL.js";import"./chunk-CYX2VK56.js";import"./chunk-A5LGJSYE.js";import{a as f}from"./chunk-CDFKIAC5.js";import{b as B}from"./chunk-DRUYFASX.js";import{e as g}from"./chunk-A4U73JJE.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),A=e.normal?new Float32Array(f):void 0,w=e.tangent?new Float32Array(f):void 0,T=e.bitangent?new Float32Array(f):void 0,j=e.st?new Float32Array(2*d):void 0,v=0,_=0,F=0,b=0,L=0;for(let i=0;i<d;i++){let t=l[i];if(k[v++]=t.x,k[v++]=t.y,k[v++]=t.z,e.st)if(g(r)&&r.positions.length===d)j[L++]=r.positions[i].x,j[L++]=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);j[L++]=i,j[L++]=r}e.normal&&(A[_++]=s.x,A[_++]=s.y,A[_++]=s.z),e.tangent&&(w[b++]=c.x,w[b++]=c.y,w[b++]=c.z),e.bitangent&&(T[F++]=p.x,T[F++]=p.y,T[F++]=p.z)}let E=new X;return e.position&&(E.position=new z({componentDatatype:N.DOUBLE,componentsPerAttribute:3,values:k})),e.normal&&(E.normal=new z({componentDatatype:N.FLOAT,componentsPerAttribute:3,values:A})),e.tangent&&(E.tangent=new z({componentDatatype:N.FLOAT,componentsPerAttribute:3,values:w})),e.bitangent&&(E.bitangent=new z({componentDatatype:N.FLOAT,componentsPerAttribute:3,values:T})),e.st&&(E.st=new z({componentDatatype:N.FLOAT,componentsPerAttribute:2,values:j})),new Y({attributes:E,indices:m,primitiveType:W.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.default)),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,A=f.polygons,P=function(t){return t},x=a?y.polygonsFromHierarchy(r,!0,P,!1).polygons:void 0;if(0===k.length)return;s=k[0].outerRing;let w=K.fromPoints(s),T=y.computeBoundingRectangle(c,d,s,o,at),j=[];for(let i=0;i<A.length;i++){let t=new I({geometry:wt(A[i],e,T,o,a?x[i]:void 0,d,c,p,l)});j.push(t)}let v=$.combineInstances(j)[0];v.attributes.position.values=new Float64Array(v.attributes.position.values),v.indices=J.createTypedArray(v.attributes.position.values.length/3,v.indices);let _=v.attributes;return e.position||delete _.position,new Y({attributes:_,indices:v.indices,primitiveType:v.primitiveType,boundingSphere:w})};var Z=E;function kt(t,e){return g(e)&&(t=Z.unpack(t,e)),Z.createGeometry(t)}var Xt=kt;export{Xt as default};