Balance, interrupted
Install
npm install -g @lmctl-ai/lmctl
lmvideo 0.1.38 is released. Source examples are pinned to public commit aab2677.
Gravity reorganizes the pyramid into a loose arrangement of blocks. Motion is replayed through a smooth periodic phase to form the loop.
Run this example
lmctl autorun https://raw.githubusercontent.com/lmctl-ai/lmvideo/aab2677a4b6264ae6afae8ad64a1d7c1dcd3a052/examples/physics/pyramid-collapse.lms
Source
# Pyramid collapse: one impact, a readable mid-collapse frame.
mkdir("build/physics");
program=_lmcode_ cli="lmvideo" install="github:lmctl-ai/lmvideo@v0.1.38";
let w=physics_world(0.008333333,88).gravity(0.0,-9.81,0.0).planar(true);let m=physics_material(0.55,0.2);
w.box(10.0,0.4,5.0,0.0,-0.2,0.0,0.0,physics_material(0.8,0.1));
for(row in range(0,4)){for(col in range(0,4-row)){w.box(0.72,0.72,0.72,-1.3+float(col)*0.9+float(row)*0.45,0.45+float(row)*0.78,0.0,1.0,m);}}
w.body(1).impulse(1.8,0.0,0.0);let take=w.bake(180,1);
video.size(512,384);video.fps(24);video.frames(96);video.output("build/physics/pyramid-collapse.mp4");video.begin();let s=scene3d().background("#171827").ambient(0.22);let c=camera3d().look_at(6.0,4.0,9.0,0.0,1.2,0.0).perspective(42.0,0.1,35.0);
for(f in range(0,video.count())){video.frame();let q=sin(3.1415926535*float(f)/96.0);let t=q*q;s.clear().camera(c).shadows(256,0.0004,0.001,1).directional_light(-3.0,5.0,4.0,"#ffe9d0",1.4);s.add(mesh_box(10.0,0.4,5.0),"#cc9e74").position(0.0,-0.2,0.0);for(i in range(0,10)){let n=s.add(mesh_box(0.72,0.72,0.72),"#ef8f8f");take.pose(t,i+1).sync(n);}let im=s.render_image(512,384,2);canvas.clear("#101827");canvas.image(im,0.0,0.0);canvas.text("time-replayed physics",16.0,28.0,font(15.0),paint().color("#fff1d6"));if(f==48){im.save("build/physics/pyramid-collapse.png");}}
video.end();
end _lmcode_
r=run_lmcode(program);assert(r.ok,(r.ok ? "" : r.message));