Skip to content

MeerKatDev/terrain-drawer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

terrain-drawer

A js toolkit to draw maps from textures to be used with Three.js.

Example of usage:

  var basic_schema = { // this is the format for the map
            zones: [
                new MAP.Zone('water', [
                    new MAP.Rectangle(200,200,512,400),
                    new MAP.Rectangle(700,0,1024,314)
                ]),
                new MAP.Zone('grass', [
                    new MAP.Rectangle(200,0,700,200),
                    new MAP.Rectangle(200,400,700,628)
                ]),
                new MAP.Zone('earth', [
                    new MAP.Rectangle( 0,0,200,628),
                    new MAP.Rectangle(512,200,700,428),
                    new MAP.Rectangle(512,314,1024,628)
                ])
            ],
            materials: {
                'grass': new THREE.MeshLambertMaterial({ map: THREE.ImageUtils.loadTexture('textures/tex32-grass.jpg') }),
                'earth': new THREE.MeshLambertMaterial({ map: THREE.ImageUtils.loadTexture('textures/tex32-earth.jpg') }),
                'water': new THREE.MeshLambertMaterial({ map: THREE.ImageUtils.loadTexture('textures/tex32-water.jpg') })
            }
        };

        MAP.drawMap({
            scene: scene, // THREE.Scene
            width: 1024, // ..of the map
            height: 628, // ..of the map
            tile_size: 32, // 16 or 32 preferably
            schema: basic_schema,
            default_terrain: 'water'
        });

terrain.js is the version in CommonJS as a module for Require.js

Dependencies: Three.js r58

component of the Magellano rts project

About

A js engine to manually draw textures on a mesh of Three.js

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published