Skip to content

Commit

Permalink
Just example simplification (forEach -> map)
Browse files Browse the repository at this point in the history
  • Loading branch information
kungfooman committed Sep 2, 2024
1 parent 62bcd08 commit 6f077b6
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions examples/src/examples/physics/vehicle.example.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,12 @@ assetListLoader.load(() => {
app.root.addChild(ground);

// Create 4 wheels for our vehicle
/**
* @todo use .map ...
* @type {pc.Entity[]}
*/
const wheels = [];
[
const wheels = [
{ name: 'Front Left Wheel', pos: new pc.Vec3(0.8, 0.4, 1.2), front: true },
{ name: 'Front Right Wheel', pos: new pc.Vec3(-0.8, 0.4, 1.2), front: true },
{ name: 'Back Left Wheel', pos: new pc.Vec3(0.8, 0.4, -1.2), front: false },
{ name: 'Back Right Wheel', pos: new pc.Vec3(-0.8, 0.4, -1.2), front: false }
].forEach(function (wheelDef) {
].map(function (wheelDef) {
// Create a wheel
const wheel = new pc.Entity(wheelDef.name);
wheel.addComponent('script');
Expand All @@ -110,7 +105,7 @@ assetListLoader.load(() => {
}
});
wheel.setLocalPosition(wheelDef.pos);
wheels.push(wheel);
return wheel;
});

// Create a physical vehicle
Expand Down

0 comments on commit 6f077b6

Please sign in to comment.