Q: What do programmers do when they have nothing to do? This is a real conversation I had this morning with a male programmer in my department. No shopping, no food, no drama, no girlfriend

But there are some programmers really to code code for fun, idle nothing to do, will write some fun, good-looking code exercise their ability at the same time, let oneself happy, today to share this 3D rotation effect is a foreign programmer little brother leisure time work, looks really very shocking! Let’s share this special effect and source code with you.

3D rotation effects

I can’t upload the video, so I only upload the picture, which is a little unclear. When I open it in the browser, IT is super shocking, with some background music, which is not Hollywood special effects, but also looks like the super evolution in Digimon!

3D rotation effect source code

function spawnParticle(vars){ var p,ls; pt={}; p=Math.PI2Math.random(); ls=Math.sqrt(Math.random()vars.distributionRadius); pt.x=Math.sin(p)ls; pt.y=-vars.vortexHeight/2; pt.vy=vars.initV/20+Math.random()vars.initV; pt.z=Math.cos(p)ls; pt.radius=200+800*Math.random(); pt.color=pt.radius/1000+vars.frameNo/250; vars.points.push(pt); } function frame(vars) { if(vars === undefined){ var vars={}; vars.canvas = document.querySelector(“canvas”); vars.ctx = vars.canvas.getContext(“2d”); vars.canvas.width = document.body.clientWidth; vars.canvas.height = document.body.clientHeight; window.addEventListener(“resize”, function(){ vars.canvas.width = document.body.clientWidth; vars.canvas.height = document.body.clientHeight; vars.cx=vars.canvas.width/2; vars.cy=vars.canvas.height/2; }, true); vars.frameNo=0; vars.camX = 0; vars.camY = 0; vars.camZ = -14; vars.pitch = elevation(vars.camX, vars.camZ, vars.camY) – Math.PI / 2; vars.yaw = 0; vars.cx=vars.canvas.width/2; vars.cy=vars.canvas.height/2; vars.bounding=10; vars.scale=500; Vars. Floor = 26.5; vars.points=[]; vars.initParticles=2000; vars.initV=.01; vars.distributionRadius=800; vars.vortexHeight=25; } vars.frameNo++; requestAnimationFrame(function() { frame(vars); }); process(vars); draw(vars); } frame();

PS: Because the code is too long, so only show part of the JavaScript code, the need for friends can pay attention to the following welfare area to get the complete source code.

Welfare area:

Attention to the public number “tadpole front” reply to “source”, self-help 3D rotation source complete version.

Share I summarize some dry, I myself is a web front-end development engineer for 5 years, resignation is doing online education instructors, to sort out a most suitable for 2019 web front-end study of dry goods, including basic + data + video, all are free, here believe that there are many students want to learn web front-end, add QQ group: 931661106