"use strict";exports.__esModule=!0,exports.default=createTubeGeometry;var _util=require("../../common/util"),_three=require("three");function createTubeGeometry(a,b=64,c=1,e=8,f=!1){function g(f){d=a.getPointAt(f/b,d);const g=k.normals[f],h=k.binormals[f];for(let a=0;a<=e;a++){const b=2*(a/e*Math.PI),f=Math.cos(b),i=-Math.sin(b);n.x=i*g.x+f*h.x,n.y=i*g.y+f*h.y,n.z=i*g.z+f*h.z,n.normalize(),q.push(n.x,n.y,n.z),m.x=d.x+c*n.x,m.y=d.y+c*n.y,m.z=d.z+c*n.z,p.push(m.x,m.y,m.z)}}function h(){for(let f=1;f<=b;f++)for(let g=1;g<=e;g++){const h=(e+1)*(f-1)+(g-1),a=(e+1)*f+(g-1),b=(e+1)*f+g,c=(e+1)*(f-1)+g;s.push(h,a,c),s.push(a,b,c)}}function i(){for(let a=0;a<=b;a++)for(let c=0;c<=e;c++)o.x=a/b,o.y=c/e,r.push(o.x,o.y)}a=a||new _three.QuadraticBezierCurve3(new _three.Vector3(-1,-1,0),new _three.Vector3(-1,1,0),new _three.Vector3(1,1,0));let j=new _three.BufferGeometry;const k=a.computeFrenetFrames(b,f);let l=(0,_util.extend)({type:"TubeGeometry",parameters:{path:a,tubularSegments:b,radius:c,radialSegments:e,closed:f},tangents:k.tangents,normals:k.normals,binormals:k.binormals},j);const m=new _three.Vector3,n=new _three.Vector3,o=new _three.Vector2;let d=new _three.Vector3;const p=[],q=[],r=[],s=[];return function(){for(let a=0;a<b;a++)g(a);g(!1===f?b:0),i(),h()}(),l.setIndex(s),l.setAttribute("position",new _three.Float32BufferAttribute(p,3)),l.setAttribute("normal",new _three.Float32BufferAttribute(q,3)),l.setAttribute("uv",new _three.Float32BufferAttribute(r,2)),l}