icegl-three-vue-tres/dist/static/tilingCaustics-a86d69fe.js
hawk86104 cc7a5a656a Merge branch 'master' into online
# Conflicts:
#	.fes.js
2023-12-04 19:58:17 +08:00

2 lines
3.4 KiB
JavaScript

var h=Object.defineProperty;var i=Object.getOwnPropertySymbols;var _=Object.prototype.hasOwnProperty,b=Object.prototype.propertyIsEnumerable;var l=(n,t,e)=>t in n?h(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,c=(n,t)=>{for(var e in t||(t={}))_.call(t,e)&&l(n,e,t[e]);if(i)for(var e of i(t))b.call(t,e)&&l(n,e,t[e]);return n};import{Y as u,aL as r,aE as x,a2 as y,w,o as f,c as T,U as a,a7 as v,a8 as m,Z as C,ae as S,s as k,B,a5 as A,I as d,a6 as M,a as p,a9 as P}from"./vendor-76c85ed2.js";const U="// Examples of variables passed from vertex to fragment shader\nvarying vec2 vUv;\n\nvoid main(){\n // To pass variables to the fragment shader, you assign them here in the\n // main function. Traditionally you name the varying with vAttributeName\n vUv=uv;\n \n // This sets the position of the vertex in 3d space. The correct math is\n // provided below to take into account camera and object data.\n gl_Position=projectionMatrix*modelViewMatrix*vec4(position,1.);\n}",E="#define TAU 6.28318530718\n#define MAX_ITER 5\n\nuniform vec2 resolution;\nuniform vec3 backgroundColor;\nuniform vec3 color;\nuniform float speed;\nuniform vec2 flowSpeed;\nuniform float brightness;\nuniform float time;\n\nvarying vec2 vUv;\n\nvoid main(){\n vec2 uv=(vUv.xy+(time*flowSpeed))*resolution;\n \n vec2 p=mod(uv*TAU,TAU)-250.;\n vec2 i=vec2(p);\n \n float c=1.;\n float inten=.005;\n \n for(int n=0;n<MAX_ITER;n++){\n float t=time*speed*(1.-(3.5/float(n+1)));\n i=p+vec2(cos(t-i.x)+sin(t+i.y),sin(t-i.y)+cos(t+i.x));\n c+=1./length(vec2(p.x/(sin(i.x+t)/inten),p.y/(cos(i.y+t)/inten)));\n }\n \n c/=float(MAX_ITER);\n c=1.17-pow(c,brightness);\n \n vec3 rgb=vec3(pow(abs(c),8.));\n \n gl_FragColor=vec4(rgb*color+backgroundColor,length(rgb)+.1);\n}",I=["rotation-x"],R=a("TresPlaneGeometry",{args:[10,10]},null,-1),L=u({__name:"tilingCaustics",props:{speed:{default:.478},backgroundColor:{},color:{default:"#fff"},flowSpeed:{default:{x:.01,y:.01}},brightness:{default:1.5}},setup(n){const t=n,e={uniforms:{resolution:{type:"v2",value:{x:1,y:1}},backgroundColor:{type:"c",value:new r(t.color)},color:{type:"c",value:new r("#fff")},speed:{type:"f",value:t.speed},flowSpeed:{type:"v2",value:t.flowSpeed},brightness:{type:"f",value:t.brightness},time:{type:"f",value:.1}},vertexShader:U,fragmentShader:E,side:x,transparent:!0,depthWrite:!1,depthTest:!0},{onLoop:o}=y();return o(({delta:s})=>{e.uniforms.time.value+=s}),w(()=>t,()=>{e.uniforms.speed.value=t.speed,e.uniforms.brightness.value=t.brightness,e.uniforms.backgroundColor.value=new r(t.color)},{deep:!0}),(s,g)=>(f(),T("TresMesh",{"rotation-x":-Math.PI/2,"position-y":1},[R,a("TresShaderMaterial",v(m(e)),null,16)],8,I))}}),N=a("TresPerspectiveCamera",{position:[10,10,10]},null,-1),V=a("TresAmbientLight",{intensity:1},null,-1),X=a("TresGridHelper",{args:[10,10]},null,-1),z=u({__name:"tilingCaustics",setup(n){const t={clearColor:"#222"},e=C({color:"#fff",speed:.1,brightness:1.5,flowSpeed:{x:.01,y:.01}}),o=new S({title:"参数",expanded:!0});return o.addBinding(e,"color",{label:"颜色"}),o.addBinding(e,"speed",{label:"速度",min:.1,max:1,step:.1}),o.addBinding(e,"brightness",{label:"亮度",min:.1,max:2,step:.1}),o.addBinding(e,"flowSpeed",{label:"流动速度",picker:"inline",expanded:!0,x:{min:.01,step:.02,max:.6,inverted:!0},y:{min:.01,step:.02,max:.6,inverted:!0}}),(s,g)=>(f(),k(d(M),A(t,{"window-size":""}),{default:B(()=>[N,V,p(d(P)),X,p(L,v(m(c({},e))),null,16)]),_:1},16))}});export{z as default};