You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

28 lines
881 B

import { PlaneGeometry, MeshLambertMaterial, Mesh, TextureLoader, Color } from "three";
class Terrain {
constructor(props: { width: number; height: number; color: Color }) {
const loader = new TextureLoader();
const heightTexture = loader.load("img/textures/leafy-autumn-forest-floor.jpg");
const geometry = new PlaneGeometry(props.width, props.height, 64, 64);
const material = new MeshLambertMaterial({
color: props.color,
flatShading: true,
map: heightTexture,
});
const plane = new Mesh(geometry, material);
plane.position.set(0, 0, 0);
plane.rotation.x -= Math.PI * 0.5;
// Storing our original vertices position on a new attribute
plane.geometry.attributes.position.originalPosition = plane.geometry.attributes.position.array;
plane.tick = () => {};
return plane;
}
}
export { Terrain };