An open API service indexing awesome lists of open source software.

https://github.com/kunukn/cube-two

Rubiks Cube 2x2 on web platform
https://github.com/kunukn/cube-two

Last synced: 6 months ago
JSON representation

Rubiks Cube 2x2 on web platform

Awesome Lists containing this project

README

        

# Cube Two

## Pocket Cube - Rubiks Cube 2x2x2 on web platform

## Demo

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

![demo](/demo/pocket-cube.gif?raw=true)

## Browser support

| Chrome logo | Opera logo | Safari logo |Firefox logo |Edge logo | IE logo |
|:---:|:---:|:---:|:---:|:---:|:---:|
| 50+ ✅ | 40+ ✅ | 9+ ✅ | 40+ ✅ | 12+ ✅ | ⛔ |

## Getting started
```
You need nodejs

npm install

npm start

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

## Configuration
```javascript
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',
}
});

/* optional callbacks */
cubetwo.addCallbackForEvent('init', function(eventname, payload){});
cubetwo.addCallbackForEvent('statechange', function(eventname, payload){});
cubetwo.addCallbackForEvent('beforerotate', function(eventname, payload){});
cubetwo.addCallbackForEvent('afterrotate', function(eventname, payload){});
cubetwo.addCallbackForEvent('issolved', function(eventname, payload){});

/* required */
cubetwo.init();
```

## Edge browser support

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

```javascript
var cubetwo = new window.CubeTwo({
cubeComponent: document.getElementById('cubetwo-component-1'),

cubeSize: {
value: 80,
unit: 'px',
}
});
```

## 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.