Giter Club home page Giter Club logo

medea.js's Introduction

medea.js

A powerful yet simple WebGL-based 3D engine

medea is a scenegraph-based, lightweight and extremely straightforward 3D engine. Obviously it is written in Javascript.

It is currently in active development, but I try to keep the trunk constantly alive and the API relatively stable, so there is no need to be scared off. Things I focus on:

  • Asynchronous and progressive loading to minimize 'hard' loading times.
  • Data-driven effect framework supporting stuff like automatic dynamic lighting whilst still offering a high degree of flexibility to shader authors.
  • Offline content processing to save as much bandwidth and runtime overhead as possible. For instance Open Asset Import Library (via assimp2json) is used to import geometry from douzens of common (and also not-so-common) 3D model formats.
  • Automatic detail management so medea-based applications can scale to all platforms, including mobile devices. This is clearly the most difficult point on the list, but also the one of which I believe that developers would benefit the most from.

Medea's basic structure is very similar to that of other, non browser-based 3D engines (i.e. Ogre), so anyone with some experience in 3D programming will need little time to get to work with it.

Media

At the time being there's only a rather boring video showing medea's experimental terrain system.

terrain scene

More screenshots will soon be added right here.

Usage

This is effectively the whole code for the terrain in the video above.

medea.Ready("canvas",{dataroot:'../../data'},['camcontroller'],function() {

	// create a viewport to fill the entire <canvas>
	var viewport = medea.CreateViewport();
	viewport.ClearColor([1.0,1.0,1.0]);
 
	var root = medea.RootNode();

	// create a camera node and attach it to both the scenegraph and the viewport.
	var cam = medea.CreateCameraNode("MainCamera");
	root.AddChild(cam);
	viewport.Camera(cam);
	
	// add a first-person-style camera controller (i.e. input handler).
	// camera controllers are so called entities and can be attached to
	// arbitrary nodes, not only cameras.
	var cam_controller = medea.CreateCamController('fps');
	cam.AddEntity(cam_controller);
	cam_controller.Enabled(true);
		
	// add terrain - this is highly asynchronous because a lot of data needs to be loaded
	medea.FetchMods(['terrain'], function() {
		medea.CreateDefaultTerrainDataProviderFromResource('remote:terrain_sample/terrain.json', function(p) {
		
			var ter = medea.CreateTerrainNode(p);
			root.AddChild(ter);
			
			medea.FetchMods('terrainheightpath', function() {
				var terrain_animator = medea.CreateTerrainHeightPathAnimator(ter,15.0);
				cam.AddEntity(terrain_animator);
				cam_controller.TerrainEntity(terrain_animator);
			});
		});
	});
	
	// add skydome
	medea.FetchMods('skydome',function() {
		root.AddChild(medea.CreateSkydomeNode('remote:skydome_sample/midmorning/midmorning.png',0.4));
	});
}

medea.js's People

Contributors

acgessler avatar

Watchers

James Cloos avatar Jimmy Yu 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.