import{u as t,c as s,e}from"./index.fbca08c6.js";import{a5 as o,d as n,V as i,q as a,ai as r,r as l,o as u,c as h,w as d,y as m,z as c,a as p,aj as g,O as y}from"./vendor.6afcf1a6.js";const b=t();let f=[];const x=new o;var C=n({data:()=>({tubes:[],dx:-1,dy:-1,x0:-1,y0:-1,size:new i}),mounted(){const t=b.camera.value,s=t.fov*Math.PI/180,e=2*Math.tan(s/2)*Math.abs(t.position.z),o=e*t.aspect;this.size=new i(o,e),this.initTubes(),this.update()},methods:{initTubes(){f=[],this.tubes.splice(0),this.dx=this.size.x/39*4,this.dy=this.size.y/14,this.x0=2*-this.size.x,this.y0=-this.size.y/2;for(let t=0;t<15;t++){const s=[];f[t]=[];for(let e=0;e<40;e++){const o=new a(this.x0+e*this.dx,this.y0+t*this.dy,0);s.push(o),f[t].push(o.clone())}this.tubes.push({key:`tube-${t}`,points:s,radius:.1,tubularSegments:40,radialSegments:8})}},update(){var t;requestAnimationFrame(this.update);const s=new i,e=2e-4*Date.now();let o,n,a,r,l,u,h;for(let i=0;i<15;i++){o=f[i];for(let t=0;t<40;t++)n=this.x0+t*this.dx,r=.25*n,a=this.y0+i*this.dy,l=.25*a,u=.3*x.noise2D(r-e+.3*s.x,l-e+.3*s.y),h=.3*x.noise2D(l+e,r+e),o[t].x=n,o[t].y=a+u,o[t].z=h;this.updateTubeGeometryPoints(null==(t=this.$refs.group.$el.instance.children[i])?void 0:t.geometry,o)}},updateTubeGeometryPoints(t,s){if(!t)return;const e=new r(s),{radialSegments:o,radius:n,tubularSegments:i,closed:l}=t.parameters,u=e.computeFrenetFrames(i,l);t.tangents=u.tangents,t.normals=u.normals,t.binormals=u.binormals,t.parameters.path=e;const h=t.getAttribute("position"),d=t.getAttribute("normal"),m=new a,c=new a;for(let a=0;a<i;a++)p(a);function p(t){e.getPointAt(t/i,c);const s=u.normals[t],a=u.binormals[t];for(let e=0;e<=o;e++){const i=e/o*Math.PI*2,r=Math.sin(i),l=-Math.cos(i);m.x=l*s.x+r*a.x,m.y=l*s.y+r*a.y,m.z=l*s.z+r*a.z,m.normalize();const u=t*(o+1)+e;d.setXYZ(u,m.x,m.y,m.z),h.setXYZ(u,c.x+n*m.x,c.y+n*m.y,c.z+n*m.z)}}p(i),t.attributes.position.needsUpdate=!0,t.attributes.normal.needsUpdate=!0}}});C.render=function(t,s,e,o,n,i){const a=l("catmullRomCurve3"),r=l("tubeBufferGeometry"),g=l("meshStandardMaterial"),y=l("group");return u(),h(y,{ref:"group"},{default:d((()=>[(u(!0),h(m,null,c(t.tubes,((t,s)=>(u(),h("mesh",{key:s},[p(r,{args:["$attached.curve",t.tubularSegments,t.radius,t.radialSegments]},{default:d((()=>[p(a,{args:[t.points],attach:"curve"},null,8,["args"])])),_:2},1032,["args"]),p(g,{roughness:.4,metalness:1},null,8,["roughness"])])))),128))])),_:1},512)};var z=n({components:{DemoTubes:C},data:()=>({light1Color:"#b307b5",light2Color:"#8132aa",light3Color:"#5737d0",light4Color:"#0d25bb"}),mounted(){window.addEventListener("click",this.randomColors)},methods:{randomColors(){this.light1Color=g.random().hex(),this.light2Color=g.random().hex(),this.light3Color=g.random().hex(),this.light4Color=g.random().hex()}}});z.render=function(t,s,e,o,n,i){const a=l("pointLight"),r=l("DemoTubes"),m=l("TroisCanvas");return u(),h(m,{cameraPosition:[0,0,5]},{default:d((()=>[p(a,{color:t.light1Color,position:[-2,-2,2],intensity:.5},null,8,["color","intensity"]),p(a,{color:t.light2Color,position:[-2,2,2],intensity:.5},null,8,["color","intensity"]),p(a,{color:t.light3Color,position:[2,2,2],intensity:.5},null,8,["color","intensity"]),p(a,{color:t.light4Color,position:[2,-2,2],intensity:.5},null,8,["color","intensity"]),p(r)])),_:1})};const v=s(z);e({app:v,OrbitControls:y}),v.mount("#app");
