Chapter 11. Simulation
400
81 material:groundMaterial});
82 h=Height/2+2.0;
83 varfixedShape=newCANNON.Box(newCANNON.Vec3(X*2.5,2,h));
84 fixedShape.color=0x00ffff;
85 fixedBody.addShape(fixedShape);
86 fixedBody.position.set((X‐1)*2.5,0,h+0.5);
87 world.addBody(fixedBody);
88 GUI.addVisual(fixedBody);
89 fixedBody=newCANNON.Body({mass:0,
90 material:groundMaterial});
91 fixedShape=newCANNON.Box(newCANNON.Vec3(X*2.5,2,h));
92 fixedShape.color=0x00ffff;
93 fixedBody.addShape(fixedShape);
94 fixedBody.position.set((X‐1)*2.5,(Y‐1)*5,h+0.5);
95 world.addBody(fixedBody);
96 GUI.addVisual(fixedBody);
97 h2=(Z‐1)*5+1;
98 fixedBody=newCANNON.Body({mass:0,
99 material:groundMaterial});
100 fixedShape=newCANNON.Box(newCANNON.Vec3(X*2.5,0.5,h2/2));
101 fixedShape.color=0x00ffff;
102 fixedBody.addShape(fixedShape);
103 fixedBody.position.set((X‐1)*2.5,‐1,2*h+h2/2+0.5);
104 world.addBody(fixedBody);
105 GUI.addVisual(fixedBody);
106 fixedBody=newCANNON.Body({mass:0,
107 material:groundMaterial});
108 fixedShape=newCANNON.Box(newCANNON.Vec3(X*2.5,0.5,h2/2));
109 fixedShape.color=0x00ffff;
110 fixedBody.addShape(fixedShape);
111 fixedBody.position.set((X‐1)*2.5,(Y‐1)*5+1,2*h+h2/2+0.5);
112 world.addBody(fixedBody);
113 GUI.addVisual(fixedBody);
114 }
115
116 functionmakeLoad(x,y,r,m){
117 varh=2;
118 if(!r)r=10;
119 varbShape=newCANNON.Cylinder(r,r,h,16);
120 bShape.color='red';
121 varb=newCANNON.Body({mass:m||Mass});
122 b.addShape(bShape);
123 b.position.set(x,y,Height+4.0+h/2+(Z‐1)*5+1.0+0.5);
124 bodies.push(b);
125 loadings.push(b);
126 }
127
128 functionmakeBox(x,y,z){
129 varbShape
=newCANNON.Box(newCANNON.Vec3(0.5,0.5,0.5));
130 varb=newCANNON.Body({mass:mass});
131 b.addShape(bShape);
S. Bosse, Unified Distributed Sensor and Environmental Information Processing with Multi-Agent Systems
epubli, ISBN 9783746752228 (2018)