BoxGeometry-59bbebbc.js 7.7 KB

1
  1. define(["exports","./GeometryOffsetAttribute-ed56ff58","./Transforms-98ffa11d","./Cartesian3-7e9cc2ff","./Check-741c5f3c","./ComponentDatatype-aaeec80f","./defaultValue-81eec7ed","./GeometryAttribute-b025f9a8","./GeometryAttributes-32b29525","./VertexFormat-d50a69ba"],(function(t,e,n,a,r,i,o,m,s,u){"use strict";const y=new a.Cartesian3;function x(t){const e=(t=o.defaultValue(t,o.defaultValue.EMPTY_OBJECT)).minimum,n=t.maximum,r=o.defaultValue(t.vertexFormat,u.VertexFormat.DEFAULT);this._minimum=a.Cartesian3.clone(e),this._maximum=a.Cartesian3.clone(n),this._vertexFormat=r,this._offsetAttribute=t.offsetAttribute,this._workerName="createBoxGeometry"}x.fromDimensions=function(t){const e=(t=o.defaultValue(t,o.defaultValue.EMPTY_OBJECT)).dimensions,n=a.Cartesian3.multiplyByScalar(e,.5,new a.Cartesian3);return new x({minimum:a.Cartesian3.negate(n,new a.Cartesian3),maximum:n,vertexFormat:t.vertexFormat,offsetAttribute:t.offsetAttribute})},x.fromAxisAlignedBoundingBox=function(t){return new x({minimum:t.minimum,maximum:t.maximum})},x.packedLength=2*a.Cartesian3.packedLength+u.VertexFormat.packedLength+1,x.pack=function(t,e,n){return n=o.defaultValue(n,0),a.Cartesian3.pack(t._minimum,e,n),a.Cartesian3.pack(t._maximum,e,n+a.Cartesian3.packedLength),u.VertexFormat.pack(t._vertexFormat,e,n+2*a.Cartesian3.packedLength),e[n+2*a.Cartesian3.packedLength+u.VertexFormat.packedLength]=o.defaultValue(t._offsetAttribute,-1),e};const c=new a.Cartesian3,f=new a.Cartesian3,p=new u.VertexFormat,l={minimum:c,maximum:f,vertexFormat:p,offsetAttribute:void 0};let A;x.unpack=function(t,e,n){e=o.defaultValue(e,0);const r=a.Cartesian3.unpack(t,e,c),i=a.Cartesian3.unpack(t,e+a.Cartesian3.packedLength,f),m=u.VertexFormat.unpack(t,e+2*a.Cartesian3.packedLength,p),s=t[e+2*a.Cartesian3.packedLength+u.VertexFormat.packedLength];return o.defined(n)?(n._minimum=a.Cartesian3.clone(r,n._minimum),n._maximum=a.Cartesian3.clone(i,n._maximum),n._vertexFormat=u.VertexFormat.clone(m,n._vertexFormat),n._offsetAttribute=-1===s?void 0:s,n):(l.offsetAttribute=-1===s?void 0:s,new x(l))},x.createGeometry=function(t){const r=t._minimum,u=t._maximum,x=t._vertexFormat;if(a.Cartesian3.equals(r,u))return;const c=new s.GeometryAttributes;let f,p;if(x.position&&(x.st||x.normal||x.tangent||x.bitangent)){if(x.position&&(p=new Float64Array(72),p[0]=r.x,p[1]=r.y,p[2]=u.z,p[3]=u.x,p[4]=r.y,p[5]=u.z,p[6]=u.x,p[7]=u.y,p[8]=u.z,p[9]=r.x,p[10]=u.y,p[11]=u.z,p[12]=r.x,p[13]=r.y,p[14]=r.z,p[15]=u.x,p[16]=r.y,p[17]=r.z,p[18]=u.x,p[19]=u.y,p[20]=r.z,p[21]=r.x,p[22]=u.y,p[23]=r.z,p[24]=u.x,p[25]=r.y,p[26]=r.z,p[27]=u.x,p[28]=u.y,p[29]=r.z,p[30]=u.x,p[31]=u.y,p[32]=u.z,p[33]=u.x,p[34]=r.y,p[35]=u.z,p[36]=r.x,p[37]=r.y,p[38]=r.z,p[39]=r.x,p[40]=u.y,p[41]=r.z,p[42]=r.x,p[43]=u.y,p[44]=u.z,p[45]=r.x,p[46]=r.y,p[47]=u.z,p[48]=r.x,p[49]=u.y,p[50]=r.z,p[51]=u.x,p[52]=u.y,p[53]=r.z,p[54]=u.x,p[55]=u.y,p[56]=u.z,p[57]=r.x,p[58]=u.y,p[59]=u.z,p[60]=r.x,p[61]=r.y,p[62]=r.z,p[63]=u.x,p[64]=r.y,p[65]=r.z,p[66]=u.x,p[67]=r.y,p[68]=u.z,p[69]=r.x,p[70]=r.y,p[71]=u.z,c.position=new m.GeometryAttribute({componentDatatype:i.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:p})),x.normal){const t=new Float32Array(72);t[0]=0,t[1]=0,t[2]=1,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=1,t[9]=0,t[10]=0,t[11]=1,t[12]=0,t[13]=0,t[14]=-1,t[15]=0,t[16]=0,t[17]=-1,t[18]=0,t[19]=0,t[20]=-1,t[21]=0,t[22]=0,t[23]=-1,t[24]=1,t[25]=0,t[26]=0,t[27]=1,t[28]=0,t[29]=0,t[30]=1,t[31]=0,t[32]=0,t[33]=1,t[34]=0,t[35]=0,t[36]=-1,t[37]=0,t[38]=0,t[39]=-1,t[40]=0,t[41]=0,t[42]=-1,t[43]=0,t[44]=0,t[45]=-1,t[46]=0,t[47]=0,t[48]=0,t[49]=1,t[50]=0,t[51]=0,t[52]=1,t[53]=0,t[54]=0,t[55]=1,t[56]=0,t[57]=0,t[58]=1,t[59]=0,t[60]=0,t[61]=-1,t[62]=0,t[63]=0,t[64]=-1,t[65]=0,t[66]=0,t[67]=-1,t[68]=0,t[69]=0,t[70]=-1,t[71]=0,c.normal=new m.GeometryAttribute({componentDatatype:i.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:t})}if(x.st){const t=new Float32Array(48);t[0]=0,t[1]=0,t[2]=1,t[3]=0,t[4]=1,t[5]=1,t[6]=0,t[7]=1,t[8]=1,t[9]=0,t[10]=0,t[11]=0,t[12]=0,t[13]=1,t[14]=1,t[15]=1,t[16]=0,t[17]=0,t[18]=1,t[19]=0,t[20]=1,t[21]=1,t[22]=0,t[23]=1,t[24]=1,t[25]=0,t[26]=0,t[27]=0,t[28]=0,t[29]=1,t[30]=1,t[31]=1,t[32]=1,t[33]=0,t[34]=0,t[35]=0,t[36]=0,t[37]=1,t[38]=1,t[39]=1,t[40]=0,t[41]=0,t[42]=1,t[43]=0,t[44]=1,t[45]=1,t[46]=0,t[47]=1,c.st=new m.GeometryAttribute({componentDatatype:i.ComponentDatatype.FLOAT,componentsPerAttribute:2,values:t})}if(x.tangent){const t=new Float32Array(72);t[0]=1,t[1]=0,t[2]=0,t[3]=1,t[4]=0,t[5]=0,t[6]=1,t[7]=0,t[8]=0,t[9]=1,t[10]=0,t[11]=0,t[12]=-1,t[13]=0,t[14]=0,t[15]=-1,t[16]=0,t[17]=0,t[18]=-1,t[19]=0,t[20]=0,t[21]=-1,t[22]=0,t[23]=0,t[24]=0,t[25]=1,t[26]=0,t[27]=0,t[28]=1,t[29]=0,t[30]=0,t[31]=1,t[32]=0,t[33]=0,t[34]=1,t[35]=0,t[36]=0,t[37]=-1,t[38]=0,t[39]=0,t[40]=-1,t[41]=0,t[42]=0,t[43]=-1,t[44]=0,t[45]=0,t[46]=-1,t[47]=0,t[48]=-1,t[49]=0,t[50]=0,t[51]=-1,t[52]=0,t[53]=0,t[54]=-1,t[55]=0,t[56]=0,t[57]=-1,t[58]=0,t[59]=0,t[60]=1,t[61]=0,t[62]=0,t[63]=1,t[64]=0,t[65]=0,t[66]=1,t[67]=0,t[68]=0,t[69]=1,t[70]=0,t[71]=0,c.tangent=new m.GeometryAttribute({componentDatatype:i.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:t})}if(x.bitangent){const t=new Float32Array(72);t[0]=0,t[1]=1,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=0,t[7]=1,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=1,t[14]=0,t[15]=0,t[16]=1,t[17]=0,t[18]=0,t[19]=1,t[20]=0,t[21]=0,t[22]=1,t[23]=0,t[24]=0,t[25]=0,t[26]=1,t[27]=0,t[28]=0,t[29]=1,t[30]=0,t[31]=0,t[32]=1,t[33]=0,t[34]=0,t[35]=1,t[36]=0,t[37]=0,t[38]=1,t[39]=0,t[40]=0,t[41]=1,t[42]=0,t[43]=0,t[44]=1,t[45]=0,t[46]=0,t[47]=1,t[48]=0,t[49]=0,t[50]=1,t[51]=0,t[52]=0,t[53]=1,t[54]=0,t[55]=0,t[56]=1,t[57]=0,t[58]=0,t[59]=1,t[60]=0,t[61]=0,t[62]=1,t[63]=0,t[64]=0,t[65]=1,t[66]=0,t[67]=0,t[68]=1,t[69]=0,t[70]=0,t[71]=1,c.bitangent=new m.GeometryAttribute({componentDatatype:i.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:t})}f=new Uint16Array(36),f[0]=0,f[1]=1,f[2]=2,f[3]=0,f[4]=2,f[5]=3,f[6]=6,f[7]=5,f[8]=4,f[9]=7,f[10]=6,f[11]=4,f[12]=8,f[13]=9,f[14]=10,f[15]=8,f[16]=10,f[17]=11,f[18]=14,f[19]=13,f[20]=12,f[21]=15,f[22]=14,f[23]=12,f[24]=18,f[25]=17,f[26]=16,f[27]=19,f[28]=18,f[29]=16,f[30]=20,f[31]=21,f[32]=22,f[33]=20,f[34]=22,f[35]=23}else p=new Float64Array(24),p[0]=r.x,p[1]=r.y,p[2]=r.z,p[3]=u.x,p[4]=r.y,p[5]=r.z,p[6]=u.x,p[7]=u.y,p[8]=r.z,p[9]=r.x,p[10]=u.y,p[11]=r.z,p[12]=r.x,p[13]=r.y,p[14]=u.z,p[15]=u.x,p[16]=r.y,p[17]=u.z,p[18]=u.x,p[19]=u.y,p[20]=u.z,p[21]=r.x,p[22]=u.y,p[23]=u.z,c.position=new m.GeometryAttribute({componentDatatype:i.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:p}),f=new Uint16Array(36),f[0]=4,f[1]=5,f[2]=6,f[3]=4,f[4]=6,f[5]=7,f[6]=1,f[7]=0,f[8]=3,f[9]=1,f[10]=3,f[11]=2,f[12]=1,f[13]=6,f[14]=5,f[15]=1,f[16]=2,f[17]=6,f[18]=2,f[19]=3,f[20]=7,f[21]=2,f[22]=7,f[23]=6,f[24]=3,f[25]=0,f[26]=4,f[27]=3,f[28]=4,f[29]=7,f[30]=0,f[31]=1,f[32]=5,f[33]=0,f[34]=5,f[35]=4;const l=a.Cartesian3.subtract(u,r,y),A=.5*a.Cartesian3.magnitude(l);if(o.defined(t._offsetAttribute)){const n=p.length,a=new Uint8Array(n/3),r=t._offsetAttribute===e.GeometryOffsetAttribute.NONE?0:1;e.arrayFill(a,r),c.applyOffset=new m.GeometryAttribute({componentDatatype:i.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:a})}const d=function(t){for(var e=new a.Cartesian3(-1/0,-1/0,-1/0),n=new a.Cartesian3(1/0,1/0,1/0),r=0;r<t.length/3;r++){var i=new a.Cartesian3(t[3*r],t[3*r+1],t[3*r+2]);e.x=Math.max(e.x,i.x),e.y=Math.max(e.y,i.y),e.z=Math.max(e.z,i.z),n.x=Math.min(n.x,i.x),n.y=Math.min(n.y,i.y),n.z=Math.min(n.z,i.z)}return[e,n]}(p);return new m.Geometry({attributes:c,indices:f,primitiveType:m.PrimitiveType.TRIANGLES,boundingSphere:new n.BoundingSphere(a.Cartesian3.ZERO,A),offsetAttribute:t._offsetAttribute,MaxPoint:d[0],MinPoint:d[1]})},x.getUnitBox=function(){return o.defined(A)||(A=x.createGeometry(x.fromDimensions({dimensions:new a.Cartesian3(1,1,1),vertexFormat:u.VertexFormat.POSITION_ONLY}))),A},t.BoxGeometry=x}));