MCPcopy
hub / github.com/lo-th/Oimo.js / demo

Function demo

examples/demos/donut.js:8–98  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

6var pos = [];
7
8function demo() {
9
10 cam ( 90, 20, 100 );
11
12 world = new OIMO.World({
13 timestep: 1/60,
14 iterations: 8,
15 broadphase: 2, // 1: brute force, 2: sweep & prune, 3: volume tree
16 worldscale: 1,
17 random: true,
18 info:true // display statistique
19 });
20
21
22
23 // basic geometry body
24
25 var i, j, n, x, y, z, s, b;
26 var px, py, pz;
27 var radius = 3;
28 var margin = 0.3;
29 var num = 10;
30 var mx = maxPoint;
31 var rayon = 8;
32 var a = (360/mx) * Math.torad;
33 var spring = [2, 0.3];// soften the joint ex: 100, 0.2
34 var isBall = true;
35
36 for( i = 0; i < num; i++){
37
38
39
40 n = i*mx;
41 py = (60 + (i*10));
42 px = rand(-40, 40);
43 pz = rand(-40, 40);
44
45 isBall = randInt(0, 1);
46
47 donutsGeo[i] = new THREE.Tubular({ start:[px,0,pz], end:[px,-40,pz+40], numSegment:mx }, (mx)*3, radius, 12, true );
48 donuts[i] = new THREE.Mesh( donutsGeo[i], mat.donut );
49 donuts[i].castShadow = true;
50 donuts[i].receiveShadow = true;
51 view.addMesh( donuts[i] );
52
53 pos.push([])
54
55 for( j = 0; j < mx; j++){
56
57 x = (Math.sin(j*a) * rayon) + px;
58 y = py; //+ Math.sin(j*0.5);
59 z = (Math.cos(j*a) * rayon) + pz;
60
61 add({ type:'sphere', size:[radius], pos:[x, y, z], move:1 }, true );
62
63 if(isBall){
64
65 if( j > 0 ) world.add({ type:'jointBall', body1:n+(j-1), body2:n+j, pos1:[-(radius+margin),0, 0], pos2:[(radius+margin),0, 0], collision:true });

Callers

nothing calls this directly

Calls 2

camFunction · 0.50
addFunction · 0.50

Tested by

no test coverage detected