Giter VIP home page Giter VIP logo

three-landscape's Introduction

Three landscape

A react-three-fiber component for rendering high quality 3d landscapes. If you prefer to use vanilla three.js you can also just use the custom material on its own.

features include:

  • hightmap support
  • splatmaps based texture blending
  • texture repetition hiding
  • multi level normal blending for increased detail

todo:

  • tri-planar projection to lessen texture stretching on vertical surfaces
  • use higher quality terrain assets near camera.

Demo:

https://three-landscape.vercel.app/

Installation

npm install three-landscape

Usage

The terrain component extends three.meshStandardMaterial so all the parameters you would normally pass to the standard material can also be passed to the Terrain component.

By default the size of the terrain is equal to 1 world unit per pixel in the hight map.

There are a couple of new parameters including splats, tiles and layers which are the primary way of interacting with the additional terrain specific features of the component.

This example is taken from the examples directory:

<Terrain
  envMapIntensity={0.5}
  metalness={1}
  displacement={`${root}/heightmap.jpg`}
  displacementScale={100}
  displacementBias={-60}
  normalScale={new THREE.Vector2(1.5, 2)}
  normal={`${root}/normalmap-y-hd.jpg`}
  splats={[`${root}/splatmap_00.tga`, `${root}/splatmap_01.tga`]}
  tiles={[
    {
      diffuse: `${root}/Assets/Cliffs_02/Rock_DarkCrackyCliffs_col.png`,
      normal: `${root}/Assets/Cliffs_02/Rock_DarkCrackyCliffs_norm.png`
    },
    {
      diffuse: `${root}/Assets/Rock_04/Rock_sobermanRockWall_col.png`,
      normal: `${root}/Assets/Rock_04/Rock_sobermanRockWall_norm.png`
    },
    {
      diffuse: `${root}/Assets/Mud_03/Ground_WetBumpyMud_col.png`,
      normal: `${root}/Assets/Mud_03/Ground_WetBumpyMud_norm.png`
    },
    {
      diffuse: `${root}/Assets/Grass_020/ground_Grass1_col.png`
    }
  ]}
  layers={[
    {
      diffuse: { tile: 0, repeat: [23.5252656529, 23.5252656529] },
      normal: { tile: 0, repeat: [23.5252656529, 23.5252656529], splat: 1, weight: 0.5 }
    },
    {
      diffuse: { tile: 1, repeat: [21.7732806125, 21.7732806125] },
      normal: { tile: 1, repeat: [256, 256], weight: 0.5 }
    },
    {
      diffuse: { tile: 2, repeat: [256, 256] },
      normal: { tile: 2, repeat: [256, 256] }
    },
    {
      diffuse: { tile: 3, repeat: [256, 256], saturation: 1.1 }
    },
    {
      diffuse: { tile: 3, repeat: [256, 256], saturation: 1.25 }
    },
    {
      diffuse: { tile: 2, repeat: [256, 256] },
      normal: { tile: 2, repeat: [256, 256], weight: 0.5 }
    }
  ]}
/>

Contributing

In lieu of a formal style guide, take care to maintain the existing coding style. Please Lint and test your code before submitting.

License

MIT License does not apply to any of the image files in the examples directory

three-landscape's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.