Giter Site home page Giter Site logo

voxel.css's Introduction

#voxel.css

JavaScript 3D library

The goal of this project is to provide a lightweight 3D CSS library with very simple implementation.

DemoDocumentation

Usage

Download the minified library and css file and include both in your html.

<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8">
		<title>voxel.css</title>
		<link rel="stylesheet" href="css/voxel.css"></link>
	</head>
	<body>
		<script src="js/voxelcss.js"></script>
	</body>
</html>

This code creates a scene, a savable world, and an editor that allow you to immediately begin building worlds with voxel.css and see how little code is required to make complex 3D voxel games. If you've built anything in the past it auto-loads your previous build instead of creating a new one.

function init(element) {
	var PI          = Math.PI;
	var scene       = new voxelcss.Scene();
	var lightSource = new voxelcss.LightSource(300, 300, 300, 750, 0.3, 1);
	var world       = new voxelcss.World(scene);
	var editor      = new voxelcss.Editor(world);

	scene.rotate(-PI / 8, PI / 4, 0);
	scene.attach(element);
	scene.addLightSource(lightSource);

	editor.enableAutoSave();
	editor.load();

	if (world.getVoxels().length === 0) {
		editor.add(new voxelcss.Voxel(0, 0, 0, 100, {
			mesh: voxelcss.Meshes.grass
		}));
	}
}

init(document.body);

If everything went well you should see this.

Core Concepts

There are 4 important classes. Scene, World, Editor and of course Voxel. The distinctions between a Scene, World, and Editor are important to know if you are to leverage them well. A Scene is simply a camera. It can rotate, pan, zoom, and contain voxels. Meanwhile a World can save the state of any voxels added to it. This is important as voxels that are in a scene but not in a world are not savable. Lastly the Editor creates all the mouse events necessary to allow the user to add and remove blocks from a World with the added option to autosave all changes.

Properties and Classes

Core ClassesInterfaces

Future Features

  • Shadows
  • Firefox back-face culling
  • Mobile touch support

Projects built with voxel.css

Change log

releases

voxel.css's People

Contributors

marcobiedermann avatar bpartridge83 avatar bryanbraun avatar rebrendov avatar johannesfritsch avatar moul avatar prayagverma avatar wesbos avatar

Stargazers

Steven Wood avatar  avatar nuken avatar Stephan Eisfeld avatar Diego Dueñez avatar Givi Kuchukhidze avatar Marco Chan avatar Me avatar mkdirnow avatar  avatar Sergey Sobko avatar Sheldon Ketterer avatar Matt Price avatar zhuyanjun avatar Art A. avatar linjinbo avatar fakbarr avatar  avatar Geeky Gladiator avatar  avatar  avatar  avatar 「Vue.js」 avatar Saman Bemel-Benrud avatar Mark Beznos avatar  avatar RukkaPlus avatar Joseph Hancock avatar QYunChao avatar Benoit Dubois avatar Shi  avatar Gurbinder Singh avatar Eren Birk avatar Sjoerd de Jong avatar  avatar theophoric avatar  avatar ilker avatar Abirul Alam avatar YJP avatar Radoš avatar C4 avatar Ryan Vice avatar Mehul Puri avatar Hunter avatar Abd El Rahman Zeid avatar Bob Wadholm avatar Ali avatar hiiambradkim avatar Ruslan Gilmullin avatar Alan Johnson avatar  avatar Matthew Dangle avatar Vsevolod Tsiliurik avatar Jaron Wanderley avatar Wyatt Walsh avatar Harry Hope avatar Tomoyuki Hisada avatar 简爱 avatar  avatar CoreyMakes avatar Peng avatar Prahalad Belavadi avatar Jamie Sparks avatar Boyne avatar Sogrey avatar  avatar The Sun Didn't Vanish avatar Jordan Richards avatar Roni Serra avatar Victor Nogueira avatar Nick Brady avatar Adrián Guerrero González avatar Gino Fazari avatar Yasin ATEŞ avatar Adriana Toledo Santiago avatar  avatar  avatar  avatar Daniel Salvadori avatar hyeonjang avatar  avatar Meyti avatar Hong Minhee (洪 民憙) avatar Christian Klotz avatar ranjanprj avatar Aleksandr Suchkov avatar George Kuznetsov avatar Tim Sullivan avatar Vinyl Smyk avatar  avatar Maximilian Gärber avatar Andy Edmonds avatar Oluwatosin Olubiyi avatar zhang avatar Walid Doch avatar Δηϊάνειρα avatar Miqotes avatar SengHyun Lee avatar Engineer avatar

Watchers

Stig Kleppe-Jørgensen avatar N Clements avatar German Bauer avatar Bennett Neale avatar Sam Huang avatar Sebastian Schlatow avatar Alberto Llamera avatar Andrew Colclough avatar evandrix avatar Mike Dunlop avatar Matt Ezell avatar Damien Chaillou avatar mayulu avatar  avatar Will Pracht avatar Mathuvathanan Mounasamy avatar André avatar Eduard Grün avatar  avatar imran khawaja avatar James Cloos avatar Frison B Alexander avatar  avatar  avatar Florian Neumann avatar Ken Stowell avatar Mikhail Larchanka avatar  avatar Toms VEILANDS avatar Paul Fedotov avatar Arun K. Subramaniyan avatar MOTOO11 avatar NJB avatar Emmanuel Ulloa Arguello avatar Shane Lister avatar Hunter Larco avatar prometheansacrifice avatar Aflext Yang avatar Shuqian Ying avatar  avatar Carabineiro avatar GS avatar Patrick Witmer avatar Iain J McCallum avatar Artyom Prikhodko avatar Leon Yip avatar Mike Russell avatar Whoami avatar Anvesh Checka avatar Harshit shukla avatar Andrea Bovo avatar Marcin Baraniecki avatar fred avatar  avatar Pradeep Chauhan avatar Stefano Tondi avatar Zhen Zhi Lee avatar 王刚 avatar Sawan Gupta avatar Jason Wohlgemuth avatar Johannes Kromer avatar  avatar Noemí Sánchez del Río avatar  avatar Daniel Mantei avatar Luke Solomon avatar  avatar Fredy Mendez avatar Doug avatar Gary Bunofsky avatar Aditya Chowdhry avatar  avatar Julian Sutter avatar Shrihari Shastry avatar Zulfikar avatar Yuichiro Nakada avatar  avatar Tindo Arsel avatar  avatar Alan Johnson avatar  avatar  avatar  avatar  avatar  avatar Papa Ibrahima Sow avatar  avatar  avatar K0RR avatar  avatar Miqotes avatar Friso avatar

voxel.css's Issues

What should happen when applying opacity less than 1 to a node with descendants?

Hello Huner,

I'd like your opinion:

If we have a node (in a 3D scene), and it has many descendants (a sub tree), what should happen when we apply opacity with a value less than 1 to it?

  1. It, and all of it's children should become transparent, multiplying opacities down the scene graph.
  2. It's content should become transparent but not that of its descendants.
  3. Same as (1), but the whole object should be flattened into a plane.

The reason I want your opinion is because the new specs for CSS 3D (css-transforms) state here that the answer is (3).

To see what I mean, view these two examples in Chrome 53 or higher:

The second example has opacity applied to the node that contains all the sub-nodes which compose the car. The opacity, according to spec, flattens the car into a plane (turns it into paper!).

I'm asking various 3D engine authors for opinions of what the correct or most expected behavior should be.

All the best,
~ Joe

add bower support

It would be great if you could your lib to the bower package repository

Prefix CSS Classes

I suggest prefixing all CSS classes with "voxel-" to avoid any collision.
.scene should be .voxel-scene.

If you agree, I could send you a PR :)

Library Name

Is this library called voxel or voxel.css.
Either way, we should use one of both names.

https://github.com/HunterLarco/voxel.css/tree/master/dist
https://github.com/HunterLarco/voxel.css/tree/master/Server/voxelcss

Which one do you prefer?

voxel.css
voxel.js

or

voxel.css.css
voxel.css.js

or

voxelcss.css
voxelcss.js

My vote does to voxelcss.* because voxel.* might be too generic and could collide with some other libraries. This library is mainly focused on the CSS technique.
Also voxel.css.* looks a bit confusing in my opinion.

Seting up CI

Hello @HunterLarco 😃

preScriptum: voxell just look AWESOME :D

I propose you to set up Continuous Integration if you are open to it.
I see you have existing test, so it will be running them on travis.
The only thing I need is your go, and you telling me how you run your test so I can automate it.

bestRegards 😃

@AdrieanKhisbe

Culling

This is more of a feature request but culling invisible faces would probably massively improve performance

logoworld example source

Hi. I love your library! thank you for putting it out there.

I was wondering if you have the source code for how you built the logo on your landing page using voxel. Trying to do something similar and looking for a starting point.

Thank you!

Add MIT License.

package.json refers to MIT license but now license is found. :)

...
 "license": "MIT",
...

Crash label:bug

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>3D ROOM</title>
  <link rel="stylesheet" href="style.css">
<!--</head>-->
  </head>
<body>
<script src="script.js"></script>
<script>
var scene;
var world;
var color = "#ffeb3b";
function graph(x,y,z) {
    var voxel = new voxelcss.Voxel(x*50, y*50, z*50, 50, {
      mesh: new voxelcss.Mesh(new voxelcss.ColorFace(color))
    });
    world.add(voxel);
    voxel.addEventListener("VoxelClick",function() {alert();});
}
function init(element) {
  var PI          = Math.PI;
  scene       = new voxelcss.Scene();
  var lightSource = new voxelcss.LightSource(300, 300, 300, 750, 0.3, 1);
  world       = new voxelcss.World(scene);
  scene.rotate(-PI / 8, PI / 4, 0);
  scene.attach(element);
  scene.addLightSource(lightSource);
    for(x=0;x<=100;x++) {
        for(z=0;z<=100;z++) {graph(x,0,z);}
        graph(x,100,100);
        graph(x,100,0);
    }
    for(y=0;y<=100;y++) {
        graph(0,y,0);
        graph(100,y,0);
        graph(0,y,100);
        graph(100,y,100);
    }
    for (z=0; z<=100; z++) {
        graph(0,100,z);
        graph(100,100,z);
    }
}
init(document.body); </script>
</body>
</html>

Try this. It crashes the browser.

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.