| 1 | function demo() { |
| 2 | |
| 3 | cam ( 0, 10, 40 ); |
| 4 | |
| 5 | world = new OIMO.World({ |
| 6 | timestep: 1/60, |
| 7 | iterations: 8, |
| 8 | broadphase: 2, // 1: brute force, 2: sweep & prune, 3: volume tree |
| 9 | worldscale: 1, |
| 10 | random: true, |
| 11 | info:true // display statistique |
| 12 | }); |
| 13 | |
| 14 | var ground = world.add({size:[50, 10, 50], pos:[0,-5,0], density:1 }); |
| 15 | |
| 16 | // basic geometry body |
| 17 | |
| 18 | var i = 200, d, h, w, o; |
| 19 | |
| 20 | while( i-- ) { |
| 21 | |
| 22 | w = rand(0.3,1); |
| 23 | h = rand(0.3,4); |
| 24 | d = rand(0.3,1); |
| 25 | |
| 26 | o = { |
| 27 | |
| 28 | move:true, |
| 29 | density:1, |
| 30 | pos : [ |
| 31 | rand(-5,5), |
| 32 | rand(2,10) + ( i*h ), |
| 33 | rand(-5,5), |
| 34 | ], |
| 35 | rot : [ |
| 36 | randInt(0,360), |
| 37 | randInt(0,360), |
| 38 | randInt(0,360), |
| 39 | ] |
| 40 | |
| 41 | }; |
| 42 | |
| 43 | rot = [ |
| 44 | randInt(0,360), |
| 45 | randInt(0,360), |
| 46 | randInt(0,360), |
| 47 | ]; |
| 48 | |
| 49 | switch( randInt(0,2) ){ |
| 50 | |
| 51 | case 0 : o.type = 'sphere'; o.size = [w]; break; |
| 52 | case 1 : o.type = 'box'; o.size = [w,w,d]; break; |
| 53 | case 2 : o.type = 'cylinder'; o.size = [d,h,d]; break; |
| 54 | |
| 55 | } |
| 56 | |
| 57 | // see main.js |
| 58 | add( o ); |
| 59 | |
| 60 | } |