cione-comp-lib
Version:
`$ yarn add cione-comp-lib` 或者 `$ npm i cione-comp-lib -S`
2 lines (1 loc) • 1.24 kB
JavaScript
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var t=require("../Geometry.js"),i=require("../math/BoundingBox.js"),e=t.default.extend({dynamic:!1,widthSegments:40,heightSegments:20,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:Math.PI,radius:1},(function(){this.build()}),{build:function(){var t=this.heightSegments,e=this.widthSegments,s=this.attributes.position,h=this.attributes.texcoord0,n=this.attributes.normal,a=(e+1)*(t+1);s.init(a),h.init(a),n.init(a);var r,o,u,d,g,l,m,b,f,S,c,x=a>65535?Uint32Array:Uint16Array,M=this.indices=new x(e*t*6),p=this.radius,v=this.phiStart,y=this.phiLength,B=this.thetaStart,w=this.thetaLength,L=[],j=[],P=0,q=1/(p=this.radius);for(m=0;m<=t;m++)for(l=0;l<=e;l++)d=l/e,g=m/t,r=-p*Math.cos(v+d*y)*Math.sin(B+g*w),o=p*Math.cos(B+g*w),u=p*Math.sin(v+d*y)*Math.sin(B+g*w),L[0]=r,L[1]=o,L[2]=u,j[0]=d,j[1]=g,s.set(P,L),h.set(P,j),L[0]*=q,L[1]*=q,L[2]*=q,n.set(P,L),P++;var A=e+1,I=0;for(m=0;m<t;m++)for(l=0;l<e;l++)f=m*A+l,b=m*A+l+1,c=(m+1)*A+l+1,S=(m+1)*A+l,M[I++]=b,M[I++]=f,M[I++]=c,M[I++]=f,M[I++]=S,M[I++]=c;this.boundingBox=new i.default,this.boundingBox.max.set(p,p,p),this.boundingBox.min.set(-p,-p,-p)}});exports.default=e;