MCPcopy
hub / github.com/piqnt/planck.js / createBody

Function createBody

example/RayCast.ts:194–218  ·  view source on GitHub ↗
(index: number)

Source from the content-addressed store, hash-verified

192shapes[5] = new Edge({ x: -1.0, y: 0.0 }, { x: 1.0, y: 0.0 });
193
194function createBody(index: number) {
195 if (bodies.length > MAX_BODIES) {
196 world.destroyBody(bodies.shift()!);
197 }
198
199 const body = world.createBody({
200 type: "static",
201 position: {
202 x: Math.random() * 20 - 10,
203 y: Math.random() * 20,
204 },
205 angle: Math.random() * 2 * Math.PI - Math.PI,
206 userData: index,
207 angularDamping: index === 4 ? 0.02 : 0,
208 });
209
210 const shape = shapes[index % shapes.length];
211
212 body.createFixture({
213 shape: shape,
214 friction: 0.3,
215 });
216
217 bodies.push(body);
218}
219
220function destroyBody() {
221 const body = bodies.shift();

Callers 1

RayCast.tsFile · 0.70

Calls 4

destroyBodyMethod · 0.80
createBodyMethod · 0.80
randomMethod · 0.80
createFixtureMethod · 0.80

Tested by

no test coverage detected