Newer
Older
smartwell_front_dz / smartwell / mars3d-cesium / Workers / BoxGeometry-ef98ea8e.js
wangxitong on 11 Sep 2023 8 KB first commit
/**
 * @license
 * Cesium - https://github.com/CesiumGS/cesium
 * Version 1.96.6
 *
 * 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(["exports","./Transforms-66eda18c","./Matrix2-4706dd70","./RuntimeError-a977b8e0","./ComponentDatatype-438cad2a","./defaultValue-028a8a27","./GeometryAttribute-2cdece80","./GeometryAttributes-98e858da","./GeometryOffsetAttribute-116f8293","./VertexFormat-3518f543"],(function(e,t,n,a,r,o,i,m,s,u){"use strict";const y=new n.Cartesian3;function f(e){e=o.defaultValue(e,o.defaultValue.EMPTY_OBJECT);const t=e.minimum,r=e.maximum;if(a.Check.typeOf.object("min",t),a.Check.typeOf.object("max",r),o.defined(e.offsetAttribute)&&e.offsetAttribute===s.GeometryOffsetAttribute.TOP)throw new a.DeveloperError("GeometryOffsetAttribute.TOP is not a supported options.offsetAttribute for this geometry.");const i=o.defaultValue(e.vertexFormat,u.VertexFormat.DEFAULT);this._minimum=n.Cartesian3.clone(t),this._maximum=n.Cartesian3.clone(r),this._vertexFormat=i,this._offsetAttribute=e.offsetAttribute,this._workerName="createBoxGeometry"}f.fromDimensions=function(e){e=o.defaultValue(e,o.defaultValue.EMPTY_OBJECT);const t=e.dimensions;a.Check.typeOf.object("dimensions",t),a.Check.typeOf.number.greaterThanOrEquals("dimensions.x",t.x,0),a.Check.typeOf.number.greaterThanOrEquals("dimensions.y",t.y,0),a.Check.typeOf.number.greaterThanOrEquals("dimensions.z",t.z,0);const r=n.Cartesian3.multiplyByScalar(t,.5,new n.Cartesian3);return new f({minimum:n.Cartesian3.negate(r,new n.Cartesian3),maximum:r,vertexFormat:e.vertexFormat,offsetAttribute:e.offsetAttribute})},f.fromAxisAlignedBoundingBox=function(e){return a.Check.typeOf.object("boundingBox",e),new f({minimum:e.minimum,maximum:e.maximum})},f.packedLength=2*n.Cartesian3.packedLength+u.VertexFormat.packedLength+1,f.pack=function(e,t,r){return a.Check.typeOf.object("value",e),a.Check.defined("array",t),r=o.defaultValue(r,0),n.Cartesian3.pack(e._minimum,t,r),n.Cartesian3.pack(e._maximum,t,r+n.Cartesian3.packedLength),u.VertexFormat.pack(e._vertexFormat,t,r+2*n.Cartesian3.packedLength),t[r+2*n.Cartesian3.packedLength+u.VertexFormat.packedLength]=o.defaultValue(e._offsetAttribute,-1),t};const c=new n.Cartesian3,p=new n.Cartesian3,x=new u.VertexFormat,d={minimum:c,maximum:p,vertexFormat:x,offsetAttribute:void 0};let l;f.unpack=function(e,t,r){a.Check.defined("array",e),t=o.defaultValue(t,0);const i=n.Cartesian3.unpack(e,t,c),m=n.Cartesian3.unpack(e,t+n.Cartesian3.packedLength,p),s=u.VertexFormat.unpack(e,t+2*n.Cartesian3.packedLength,x),y=e[t+2*n.Cartesian3.packedLength+u.VertexFormat.packedLength];return o.defined(r)?(r._minimum=n.Cartesian3.clone(i,r._minimum),r._maximum=n.Cartesian3.clone(m,r._maximum),r._vertexFormat=u.VertexFormat.clone(s,r._vertexFormat),r._offsetAttribute=-1===y?void 0:y,r):(d.offsetAttribute=-1===y?void 0:y,new f(d))},f.createGeometry=function(e){const a=e._minimum,u=e._maximum,f=e._vertexFormat;if(n.Cartesian3.equals(a,u))return;const c=new m.GeometryAttributes;let p,x;if(f.position&&(f.st||f.normal||f.tangent||f.bitangent)){if(f.position&&(x=new Float64Array(72),x[0]=a.x,x[1]=a.y,x[2]=u.z,x[3]=u.x,x[4]=a.y,x[5]=u.z,x[6]=u.x,x[7]=u.y,x[8]=u.z,x[9]=a.x,x[10]=u.y,x[11]=u.z,x[12]=a.x,x[13]=a.y,x[14]=a.z,x[15]=u.x,x[16]=a.y,x[17]=a.z,x[18]=u.x,x[19]=u.y,x[20]=a.z,x[21]=a.x,x[22]=u.y,x[23]=a.z,x[24]=u.x,x[25]=a.y,x[26]=a.z,x[27]=u.x,x[28]=u.y,x[29]=a.z,x[30]=u.x,x[31]=u.y,x[32]=u.z,x[33]=u.x,x[34]=a.y,x[35]=u.z,x[36]=a.x,x[37]=a.y,x[38]=a.z,x[39]=a.x,x[40]=u.y,x[41]=a.z,x[42]=a.x,x[43]=u.y,x[44]=u.z,x[45]=a.x,x[46]=a.y,x[47]=u.z,x[48]=a.x,x[49]=u.y,x[50]=a.z,x[51]=u.x,x[52]=u.y,x[53]=a.z,x[54]=u.x,x[55]=u.y,x[56]=u.z,x[57]=a.x,x[58]=u.y,x[59]=u.z,x[60]=a.x,x[61]=a.y,x[62]=a.z,x[63]=u.x,x[64]=a.y,x[65]=a.z,x[66]=u.x,x[67]=a.y,x[68]=u.z,x[69]=a.x,x[70]=a.y,x[71]=u.z,c.position=new i.GeometryAttribute({componentDatatype:r.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:x})),f.normal){const e=new Float32Array(72);e[0]=0,e[1]=0,e[2]=1,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=1,e[9]=0,e[10]=0,e[11]=1,e[12]=0,e[13]=0,e[14]=-1,e[15]=0,e[16]=0,e[17]=-1,e[18]=0,e[19]=0,e[20]=-1,e[21]=0,e[22]=0,e[23]=-1,e[24]=1,e[25]=0,e[26]=0,e[27]=1,e[28]=0,e[29]=0,e[30]=1,e[31]=0,e[32]=0,e[33]=1,e[34]=0,e[35]=0,e[36]=-1,e[37]=0,e[38]=0,e[39]=-1,e[40]=0,e[41]=0,e[42]=-1,e[43]=0,e[44]=0,e[45]=-1,e[46]=0,e[47]=0,e[48]=0,e[49]=1,e[50]=0,e[51]=0,e[52]=1,e[53]=0,e[54]=0,e[55]=1,e[56]=0,e[57]=0,e[58]=1,e[59]=0,e[60]=0,e[61]=-1,e[62]=0,e[63]=0,e[64]=-1,e[65]=0,e[66]=0,e[67]=-1,e[68]=0,e[69]=0,e[70]=-1,e[71]=0,c.normal=new i.GeometryAttribute({componentDatatype:r.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:e})}if(f.st){const e=new Float32Array(48);e[0]=0,e[1]=0,e[2]=1,e[3]=0,e[4]=1,e[5]=1,e[6]=0,e[7]=1,e[8]=1,e[9]=0,e[10]=0,e[11]=0,e[12]=0,e[13]=1,e[14]=1,e[15]=1,e[16]=0,e[17]=0,e[18]=1,e[19]=0,e[20]=1,e[21]=1,e[22]=0,e[23]=1,e[24]=1,e[25]=0,e[26]=0,e[27]=0,e[28]=0,e[29]=1,e[30]=1,e[31]=1,e[32]=1,e[33]=0,e[34]=0,e[35]=0,e[36]=0,e[37]=1,e[38]=1,e[39]=1,e[40]=0,e[41]=0,e[42]=1,e[43]=0,e[44]=1,e[45]=1,e[46]=0,e[47]=1,c.st=new i.GeometryAttribute({componentDatatype:r.ComponentDatatype.FLOAT,componentsPerAttribute:2,values:e})}if(f.tangent){const e=new Float32Array(72);e[0]=1,e[1]=0,e[2]=0,e[3]=1,e[4]=0,e[5]=0,e[6]=1,e[7]=0,e[8]=0,e[9]=1,e[10]=0,e[11]=0,e[12]=-1,e[13]=0,e[14]=0,e[15]=-1,e[16]=0,e[17]=0,e[18]=-1,e[19]=0,e[20]=0,e[21]=-1,e[22]=0,e[23]=0,e[24]=0,e[25]=1,e[26]=0,e[27]=0,e[28]=1,e[29]=0,e[30]=0,e[31]=1,e[32]=0,e[33]=0,e[34]=1,e[35]=0,e[36]=0,e[37]=-1,e[38]=0,e[39]=0,e[40]=-1,e[41]=0,e[42]=0,e[43]=-1,e[44]=0,e[45]=0,e[46]=-1,e[47]=0,e[48]=-1,e[49]=0,e[50]=0,e[51]=-1,e[52]=0,e[53]=0,e[54]=-1,e[55]=0,e[56]=0,e[57]=-1,e[58]=0,e[59]=0,e[60]=1,e[61]=0,e[62]=0,e[63]=1,e[64]=0,e[65]=0,e[66]=1,e[67]=0,e[68]=0,e[69]=1,e[70]=0,e[71]=0,c.tangent=new i.GeometryAttribute({componentDatatype:r.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:e})}if(f.bitangent){const e=new Float32Array(72);e[0]=0,e[1]=1,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=0,e[7]=1,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=1,e[14]=0,e[15]=0,e[16]=1,e[17]=0,e[18]=0,e[19]=1,e[20]=0,e[21]=0,e[22]=1,e[23]=0,e[24]=0,e[25]=0,e[26]=1,e[27]=0,e[28]=0,e[29]=1,e[30]=0,e[31]=0,e[32]=1,e[33]=0,e[34]=0,e[35]=1,e[36]=0,e[37]=0,e[38]=1,e[39]=0,e[40]=0,e[41]=1,e[42]=0,e[43]=0,e[44]=1,e[45]=0,e[46]=0,e[47]=1,e[48]=0,e[49]=0,e[50]=1,e[51]=0,e[52]=0,e[53]=1,e[54]=0,e[55]=0,e[56]=1,e[57]=0,e[58]=0,e[59]=1,e[60]=0,e[61]=0,e[62]=1,e[63]=0,e[64]=0,e[65]=1,e[66]=0,e[67]=0,e[68]=1,e[69]=0,e[70]=0,e[71]=1,c.bitangent=new i.GeometryAttribute({componentDatatype:r.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:e})}p=new Uint16Array(36),p[0]=0,p[1]=1,p[2]=2,p[3]=0,p[4]=2,p[5]=3,p[6]=6,p[7]=5,p[8]=4,p[9]=7,p[10]=6,p[11]=4,p[12]=8,p[13]=9,p[14]=10,p[15]=8,p[16]=10,p[17]=11,p[18]=14,p[19]=13,p[20]=12,p[21]=15,p[22]=14,p[23]=12,p[24]=18,p[25]=17,p[26]=16,p[27]=19,p[28]=18,p[29]=16,p[30]=20,p[31]=21,p[32]=22,p[33]=20,p[34]=22,p[35]=23}else x=new Float64Array(24),x[0]=a.x,x[1]=a.y,x[2]=a.z,x[3]=u.x,x[4]=a.y,x[5]=a.z,x[6]=u.x,x[7]=u.y,x[8]=a.z,x[9]=a.x,x[10]=u.y,x[11]=a.z,x[12]=a.x,x[13]=a.y,x[14]=u.z,x[15]=u.x,x[16]=a.y,x[17]=u.z,x[18]=u.x,x[19]=u.y,x[20]=u.z,x[21]=a.x,x[22]=u.y,x[23]=u.z,c.position=new i.GeometryAttribute({componentDatatype:r.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:x}),p=new Uint16Array(36),p[0]=4,p[1]=5,p[2]=6,p[3]=4,p[4]=6,p[5]=7,p[6]=1,p[7]=0,p[8]=3,p[9]=1,p[10]=3,p[11]=2,p[12]=1,p[13]=6,p[14]=5,p[15]=1,p[16]=2,p[17]=6,p[18]=2,p[19]=3,p[20]=7,p[21]=2,p[22]=7,p[23]=6,p[24]=3,p[25]=0,p[26]=4,p[27]=3,p[28]=4,p[29]=7,p[30]=0,p[31]=1,p[32]=5,p[33]=0,p[34]=5,p[35]=4;const d=n.Cartesian3.subtract(u,a,y),l=.5*n.Cartesian3.magnitude(d);if(o.defined(e._offsetAttribute)){const t=x.length,n=e._offsetAttribute===s.GeometryOffsetAttribute.NONE?0:1,a=new Uint8Array(t/3).fill(n);c.applyOffset=new i.GeometryAttribute({componentDatatype:r.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:a})}return new i.Geometry({attributes:c,indices:p,primitiveType:i.PrimitiveType.TRIANGLES,boundingSphere:new t.BoundingSphere(n.Cartesian3.ZERO,l),offsetAttribute:e._offsetAttribute})},f.getUnitBox=function(){return o.defined(l)||(l=f.createGeometry(f.fromDimensions({dimensions:new n.Cartesian3(1,1,1),vertexFormat:u.VertexFormat.POSITION_ONLY}))),l},e.BoxGeometry=f}));