Giter Site home page Giter Site logo

kellycode / threex.grass Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jeromeetienne/threex.grass

0.0 0.0 0.0 4.16 MB

three.js game extensions for fast grass. (fork)

Home Page: https://kellycode.github.io/threex.grass/examples/demo.html

License: MIT License

JavaScript 76.89% HTML 23.11%

threex.grass's Introduction

Update 13/2/2023

  1. Update to latest THREE r147 (last revision before forced module use)
  2. Camera controls added for easier looking around
  3. Organization mostly for readability
  4. geometry.merge (no longer available) replaced with group.add (easy peasy)

threex.grass

threex.grass is a three.js extension which provides fast grass tufts. It has tweaked normals for better lighting, and a merged geometry to better performance. It is loosely based on "Rendering Countless Blades of Waving Grass" GPUGem.

Show Don't Tell

How To Install It

You can install it via script tag

<script src='threex.grass.js'></script>

Or you can install with bower, as you wish.

bower install threex.grass

How To Use It

To create a full grass, first you determine the positions of each grass tufts you want and put that in a array. Like this.

var positions	= []
positions.push(new THREE.Vector3(-1,0,0))
positions.push(new THREE.Vector3(+1,0,0))

So you got one tuft on the left at (-1,0,0) and another on the right at (+1,0,0). Now let's create a mesh with a tufts at each of those positions.

var mesh	= new THREEx.createGrassTufts(positions)
scene.add(mesh)

You are done!

References and Credits

TODO

  • make a demo with minecraft walking in it, with daynight cycle and later swarm
  • make a version which use THREE.ParticlesSystem. it is fast and may work well when the grass is far.
    • CON: use gl-pointsize so very limited size on screen
    • CON: particle arent lite. one could set a color per particle to simulate ligthing. if middle of the day, use white. if the night, use grey. something like that
    • PRO: likely faster

threex.grass's People

Contributors

kellycode avatar jeromeetienne 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.