Browse Source

totally remove code to make terrain bob up and down

kb/add-usage-guide
Trent Larson 1 year ago
parent
commit
02ae78de7b
  1. 25
      src/components/World/components/objects/terrain.js

25
src/components/World/components/objects/terrain.js

@ -36,31 +36,6 @@ export default function createTerrain(props) {
// eslint-disable-next-line @typescript-eslint/no-empty-function
plane.tick = () => {};
/**
* This makes the terrain bob up and down.
*
let frame = 0;
plane.tick = () => {
frame += 0.01;
// destructuring of the random values, the original position and the current vertex position
const { array, originalPosition, randomValues } =
plane.geometry.attributes.position;
// Animation for loop
// In our vertex array, we have 3 coordinates: x, y and z. We are
// only going to animate on ONE coordinate: the z coordinate.
// This means we have to omit the x and y coords, hence the i+=3 in our loop.
// Also, to access that y coordinate on each vertex, we have to add 2 to our
// current i each time.
for (let i = 0; i < array.length; i += 3) {
// Accessing the z coord
array[i + 2] =
// Try switching this numbers up, or using sine instead of cosine, see how the animation changes
originalPosition[i + 2] + Math.cos(frame + randomValues[i + 2]) * 0.002;
}
plane.geometry.attributes.position.needsUpdate = true;
};
**/
return plane;
}

Loading…
Cancel
Save