← Back to posts

Simple fast animation

Falling balls

balls = RandomReal[{-1,1}, {300,3}]; vels = RandomReal[{-1,1}, {300,3}]; Graphics3D[{ Table[With[{i = i}, { RGBColor[RandomReal[{0,1}, 3]], Sphere[balls[[i]] // Offload, 0.03] } ], {i, Length[balls]}], EventHandler[AnimationFrameListener[balls // Offload], updateFunction] }] (*VB[*)(FrontEndRef["138df528-eb27-45c4-9734-0996e11de8e2"])(*,*)(*"1:eJxTTMoPSmNkYGAoZgESHvk5KRCeEJBwK8rPK3HNS3GtSE0uLUlMykkNVgEKGxpbpKSZGlnopiYZmeuamCab6FqaG5voGlhamqUaGqakWqQaAQB5/BUm"*)(*]VB*)

Update function

updateFunction = Function[Null, vels = Table[ If[Norm[balls[[i]]] < 0.01, -1, 1] vels[[i]] - 0.08 balls[[i]] , {i, Length[balls]}]; balls = Table[balls[[i]] + 0.08 vels[[i]], {i, Length[balls]}]; ];

Kickstart

updateFunction[];