Skip to content

kunukn/cube-two

Repository files navigation

Cube Two

Pocket Cube - Rubiks Cube 2x2x2 on web platform

Browser support

Chrome logo Opera logo Safari logo Edge logo
50+ ✅ 40+ ✅ 9+ ✅ 12+ ✅

Demo

http://codepen.io/kunukn/pen/EgzJdR/

demo

Bugs

  • Safari - transform-origin in z axis seems buggy, this has been avoided by not using it.
  • Firefox - glitchy cube display, it has 3D order issue
  • Edge - vmin and 3d doesn't work properly.

Getting started

npm install

npm start

start a browser and go to http://localhost:3456/

Configuration

    var imgPath = 'http://your-cdn-url/image.svg';

    var cubetwo = new window.CubeTwo({
    
        cubeComponent: document.getElementById('cubetwo-component-1'), /* required */
        
        isTapEnabled: true, /* default: true */
        
        isRotateAnimationEnabled: true, /* default: true */
        
        borderOnTheCube: true, /* default: true */
        
        backgroundBlendModeOnTheCube: 'multiply', 
        
        /* e.g. screen, difference, normal, default: multiply */
        
        backfaceVisibilityHiddenOnTheCube: false, /* default: false */
        
        transition: 'transform cubic-bezier(0.4, 0.0, 0.2, 1) 190ms', /* optional */
        
        backgroundImages: { /* optional */
            u: imgPath,
            d: imgPath,
            f: imgPath,
            b: imgPath,
            r: imgPath,
            l: imgPath,
        },
        
        backgroundColors: { /* optional */
            u: 'rgba(255, 255, 255, .9)',
            d: 'rgba(255, 213, 0, .9)',
            f: 'rgba(0, 158, 96, .9)',
            b: 'rgba(0, 81, 186, .9)',
            r: 'rgba(196, 30, 58, .9)',
            l: 'rgba(255, 88, 0, .9)',
            backface: 'transparent',
        },
        
        cubeSize: { /* optional */
            value: 25,
            unit: 'vmin',
        }
    });

Edge support

To support Edge browser you must set a specific cube size, e.g..

var cubetwo = new window.CubeTwo({
        cubeComponent: document.getElementById('cubetwo-component-1'),        
        
        cubeSize: {
            value: 80,
            unit: 'px',
        }
});

About

Rubiks Cube 2x2 on web platform

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published