Giter Site home page Giter Site logo

rubik-js's Introduction

rubik-js

A WebGL Rubik's cube.

See it in action. It requires a WebGL-capable browser.

Features

  • Shuffle
  • Click and drag plane rotation
  • Solve (by replaying moves in reverse)

This was a learning exercise in Three.js, and there are plenty of rough edges. TODO list:

  • Better lighting and materials
  • Support for non-WebGL browsers
  • A general solver algorithm
  • Awareness of puzzle completion, possibly with some celebratory 3D effects
  • Touch support

rubik-js's People

Contributors

joews avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

rubik-js's Issues

Queue is reversed

The queue of moves to make is unfortunatly reversed. This is caused by the following two actions you are performing on the queue:

rubik.js
var pushMove = function(cube, clickVector, axis, direction) {
moveQueue.push({ cube: cube, vector: clickVector, axis: axis, direction: direction });
}

and (in the same file)
var startNextMove = function() {
var nextMove = moveQueue.pop();
...}

The problem here is that moveQueue.push() adds an element to the end of the array but you get the next move by moveQueue.pop() which also returns the last element of the array. Therefore you are performing the latest move added to the queue instead of the first.

This can be easily solved by using moveQueue.unshift() instead of moveQueue.pop()

Outdated dependencies, move to npm / webpack?

I was looking for a suitably licensed rubik cube class based on three.js and found this repo, it's working great, thanks!. I had to do some tweaks on my side:

  • three.js 63 -> 155 (2013 -> 2023)
  • dropped the OrbitControls, jqeury, threex.domevent and threex.domevent.object3d dependencies
  • moved to typescript
  • ability to show a facelet string

The result is here: https://github.com/vmiklos/vmexam/blob/master/js/rubik/rubik.ts

Do you have any interest to take PRs to upstream some of this work? Perhaps a first step would be to switch to webpack / npm instead of bundling these dependencies. That would in itself already make it more obvious what security problems are there with the old dependency versions. And then perhaps updating to a recent three.js + moving to typescript could be also interesting.

If no interest, that's fine, I just wanted to try upstreaming, so it's easier for the next person. :-)

Documentation Issue

When you link to the demo in the readme, there is a 404 error. It looks like you are linking to the previous name of your profile. The following replacement fixes the broken link "See it in action" in your readme:

[See it in action](https://joews.github.io/rubik-js/).

Felt this was too small for a pull request.

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.