Code Monkey home page Code Monkey logo

css3d.js's Introduction

CSS3D.js

by Steven Wittens

CSS 3D renderer

CSS 3D renderer for Three.js

This experimental renderer was built for the design of Acko.net. It lets you manage simple CSS 3D objects using Three.js.

Functionality is very limited: only planes and lines are supported (THREE.Line, THREE.PlaneGeometry). In its current form it is nowhere near a replacement for WebGL or Canvas, and browser support is buggy at best.

However, in the right setting, CSS 3D can be a useful and impressive effect, particularly when combined with parallax scrolling. I think it shows that there is a case to be made to integrate 3D more tightly into the DOM, with arbitrary meshes and shaders. In the meantime, this library opens the door for more complicated experimentation and prototyping of 3D Web UI concepts.

I don't intend to maintain or develop this further, so forking is encouraged.

Requires: jQuery

Browser support

Currently, it only works in Chrome and Safari. Firefox doesn't seem to reliably support the necessary cascading of preserve-3d transforms.

Usage

Initialize the renderer like any other Three.js renderer, using:

var renderer = new Acko.CSS3DRenderer({
  perspective: ... // optional
});

By default, the renderer wraps itself in a CSS perspective for the camera. Use perspective to specify a custom DOM element which will receive the camera's CSS perspective instead. You can use this to link the renderer to a page-wide parallax effect. Or, specify 'false' to forego camera perspective and hardcode it yourself.

To nest the CSS 3D renderer, make sure you apply transform-style: preserve-3d as necessary.

The file css3d.css contains useful default styles.

Editor

A simple keyboard operator editor is included in editor.html. The scene is serialized into the textfield at the bottom. Copy/paste this into data.js to save it.

Controls

  • Click+Drag — Orbit camera
  • Enter — New object
  • Space — Clone object
  • Backspace — Delete object
  • Tab / Shift+Tab — Cycle through objects
  • WASD/QE — Move object
  • Shift+WASD/QE — Resize object
  • Ctrl+WASD/QE — Move camera
  • [] — Lower/raise units
  • ZX — Orbit distance
  • T/T/U — Tag/untag/untag all

The scene editor was developed specifically for Acko.net and lacks many features (like custom colors). Colors are hardcoded in serialize.js.

© 2012 Steven Wittens - MIT License.

css3d.js's People

Contributors

unconed avatar mrdoob avatar

Watchers

Gijs Nijholt avatar James Cloos 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.