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